Skip to content
Snippets Groups Projects
Commit b52aefb5 authored by 🤖 GitLab Bot 🤖's avatar 🤖 GitLab Bot 🤖
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 4fc46d75
No related branches found
No related tags found
No related merge requests found
......@@ -2,18 +2,31 @@
require 'spec_helper'
RSpec.describe CodequalityDegradationEntity do
RSpec.describe CodequalityDegradationEntity, feature_category: :code_quality do
let(:entity) { described_class.new(codequality_degradation) }
describe '#as_json' do
subject { entity.as_json }
context 'when sast_reports_in_inline_diff is disabled' do
before do
stub_feature_flags(sast_reports_in_inline_diff: false)
end
let(:codequality_degradation) { build(:codequality_degradation_1) }
it 'does not contain fingerprint' do
expect(subject[:fingerprint]).to be_nil
end
end
context 'when codequality contains an error' do
context 'when line is included in location' do
let(:codequality_degradation) { build(:codequality_degradation_2) }
it 'contains correct codequality degradation details', :aggregate_failures do
expect(subject[:description]).to eq("Method `new_array` has 12 arguments (exceeds 4 allowed). Consider refactoring.")
expect(subject[:fingerprint]).to eq("f3bdc1e8c102ba5fbd9e7f6cda51c95e")
expect(subject[:severity]).to eq("major")
expect(subject[:file_path]).to eq("file_a.rb")
expect(subject[:line]).to eq(10)
......@@ -27,6 +40,7 @@
it 'contains correct codequality degradation details', :aggregate_failures do
expect(subject[:description]).to eq("Avoid parameter lists longer than 5 parameters. [12/5]")
expect(subject[:fingerprint]).to eq("ab5f8b935886b942d621399f5a2ca16e")
expect(subject[:severity]).to eq("minor")
expect(subject[:file_path]).to eq("file_b.rb")
expect(subject[:line]).to eq(10)
......@@ -44,6 +58,7 @@
it 'lowercases severity', :aggregate_failures do
expect(subject[:description]).to eq("Avoid parameter lists longer than 5 parameters. [12/5]")
expect(subject[:fingerprint]).to eq("ab5f8b935886b942d621399f5a2ca16e")
expect(subject[:severity]).to eq("minor")
expect(subject[:file_path]).to eq("file_b.rb")
expect(subject[:line]).to eq(10)
......
......@@ -2,8 +2,8 @@
require 'spec_helper'
RSpec.describe CodequalityReportsComparerSerializer do
let(:project) { double(:project) }
RSpec.describe CodequalityReportsComparerSerializer, feature_category: :code_quality do
let(:project) { build_stubbed(: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 }
......
......@@ -28,6 +28,14 @@
expect(subject.note).to eq "marked this issue as related to #{noteable_ref.to_reference(project)}"
end
end
context 'with work items' do
let_it_be(:noteable) { create(:work_item, :task, project: project) }
it 'sets the note text with the correct work item type' do
expect(subject.note).to eq "marked this task as related to #{noteable_ref.to_reference(project)}"
end
end
end
describe '#unrelate_issuable' do
......
......@@ -115,11 +115,16 @@ def record
private
def record_auto_explain?(connection)
ENV['CI'] \
&& ENV['CI_MERGE_REQUEST_LABELS']&.include?('pipeline:record-queries') \
&& ENV['CI_JOB_NAME_SLUG'] != 'db-migrate-non-superuser' \
&& connection.database_version.to_s[0..1].to_i >= 14 \
&& connection.select_one('SHOW is_superuser')['is_superuser'] == 'on'
return false unless ENV['CI']
return false if ENV['CI_JOB_NAME_SLUG'] == 'db-migrate-non-superuser'
return false if connection.database_version.to_s[0..1].to_i < 14
return false if connection.select_one('SHOW is_superuser')['is_superuser'] != 'on'
# This condition matches the pipeline rules for if-merge-request-labels-record-queries
return true if ENV['CI_MERGE_REQUEST_LABELS']&.include?('pipeline:record-queries')
# This condition matches the pipeline rules for if-default-branch-refs
ENV['CI_COMMIT_REF_NAME'] == ENV['CI_DEFAULT_BRANCH'] && !ENV['CI_MERGE_REQUEST_IID']
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment