debian-mirror-gitlab/spec/serializers/codequality_reports_comparer_serializer_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.2 KiB
Ruby
Raw Permalink Normal View History

2021-02-22 17:27:13 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe CodequalityReportsComparerSerializer do
let(:project) { double(:project) }
let(:serializer) { described_class.new(project: project).represent(comparer) }
let(:comparer) { Gitlab::Ci::Reports::CodequalityReportsComparer.new(base_report, head_report) }
let(:base_report) { Gitlab::Ci::Reports::CodequalityReports.new }
let(:head_report) { Gitlab::Ci::Reports::CodequalityReports.new }
2021-03-11 19:13:27 +05:30
let(:degradation_1) { build(:codequality_degradation_1) }
let(:degradation_2) { build(:codequality_degradation_2) }
2021-02-22 17:27:13 +05:30
describe '#to_json' do
subject { serializer.as_json }
context 'when base report has error and head has a different error' do
before do
base_report.add_degradation(degradation_1)
head_report.add_degradation(degradation_2)
end
it 'matches the schema' do
expect(subject).to match_schema('entities/codequality_reports_comparer')
end
end
context 'when base report has no error and head has errors' do
before do
head_report.add_degradation(degradation_1)
end
it 'matches the schema' do
expect(subject).to match_schema('entities/codequality_reports_comparer')
end
end
end
end