2021-03-11 19:13:27 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
RSpec.describe Ci::CodequalityMrDiffEntity, feature_category: :code_quality do
|
2021-03-11 19:13:27 +05:30
|
|
|
let(:entity) { described_class.new(mr_diff_report) }
|
2021-06-08 01:23:25 +05:30
|
|
|
let(:mr_diff_report) { Gitlab::Ci::Reports::CodequalityMrDiff.new(codequality_report.all_degradations) }
|
2021-03-11 19:13:27 +05:30
|
|
|
let(:codequality_report) { Gitlab::Ci::Reports::CodequalityReports.new }
|
2021-06-08 01:23:25 +05:30
|
|
|
let(:major) { build(:codequality_degradation, :major) }
|
|
|
|
let(:minor) { build(:codequality_degradation, :minor) }
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
describe '#as_json' do
|
|
|
|
subject(:report) { entity.as_json }
|
|
|
|
|
|
|
|
context 'when quality report has degradations' do
|
|
|
|
before do
|
2021-06-08 01:23:25 +05:30
|
|
|
codequality_report.add_degradation(major)
|
|
|
|
codequality_report.add_degradation(minor)
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains correct codequality mr diff report', :aggregate_failures do
|
|
|
|
expect(report[:files].keys).to eq(["file_a.rb"])
|
|
|
|
expect(report[:files]["file_a.rb"].first).to include(:line, :description, :severity)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|