Commit 6db62b76 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'mo-add-accessibility-report-service' into 'master'

Add AccessibilityReportsService class

See merge request gitlab-org/gitlab!31144
parents 44a92d70 7dc27993
# frozen_string_literal: true
module Ci
class CompareAccessibilityReportsService < CompareReportsBaseService
def comparer_class
Gitlab::Ci::Reports::AccessibilityReportsComparer
end
def serializer_class
AccessibilityReportsComparerSerializer
end
def get_report(pipeline)
pipeline&.accessibility_reports
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Ci::CompareAccessibilityReportsService do
let(:service) { described_class.new(project) }
let(:project) { create(:project, :repository) }
describe '#execute' do
subject { service.execute(base_pipeline, head_pipeline) }
context 'when head pipeline has accessibility reports' do
let(:base_pipeline) { nil }
let(:head_pipeline) { create(:ci_pipeline, :with_accessibility_reports, project: project) }
it 'returns status and data' do
expect(subject[:status]).to eq(:parsed)
expect(subject[:data]).to match_schema('entities/accessibility_reports_comparer')
end
end
context 'when base and head pipelines have accessibility reports' do
let(:base_pipeline) { create(:ci_pipeline, :with_accessibility_reports, project: project) }
let(:head_pipeline) { create(:ci_pipeline, :with_accessibility_reports, project: project) }
it 'returns status and data' do
expect(subject[:status]).to eq(:parsed)
expect(subject[:data]).to match_schema('entities/accessibility_reports_comparer')
end
end
end
describe '#latest?' do
subject { service.latest?(base_pipeline, head_pipeline, data) }
let!(:base_pipeline) { nil }
let!(:head_pipeline) { create(:ci_pipeline, :with_accessibility_reports, project: project) }
let!(:key) { service.send(:key, base_pipeline, head_pipeline) }
context 'when cache key is latest' do
let(:data) { { key: key } }
it { is_expected.to be_truthy }
end
context 'when cache key is outdated' do
before do
head_pipeline.update_column(:updated_at, 10.minutes.ago)
end
let(:data) { { key: key } }
it { is_expected.to be_falsy }
end
context 'when cache key is empty' do
let(:data) { { key: nil } }
it { is_expected.to be_falsy }
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment