diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-10 12:09:38 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-10 12:09:38 +0300 |
commit | b6e10aaed70a798a57a40987b3aafcbb5b2a1f78 (patch) | |
tree | 91272a06b09f5bc31252f7fc02ac96b92e81bcf6 /spec/models | |
parent | a4f3904124120f62c8be87142de87a0ed2b7f352 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/build_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 74 |
2 files changed, 75 insertions, 1 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 63a626d4c8e..4ad7ce70a44 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1860,7 +1860,7 @@ RSpec.describe Ci::Build do subject { build.artifacts_file_for_type(file_type) } it 'queries artifacts for type' do - expect(build).to receive_message_chain(:job_artifacts, :find_by).with(file_type: Ci::JobArtifact.file_types[file_type]) + expect(build).to receive_message_chain(:job_artifacts, :find_by).with(file_type: [Ci::JobArtifact.file_types[file_type]]) subject end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 9ead3d531d5..ebe2cd2ac03 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -2054,6 +2054,50 @@ RSpec.describe MergeRequest, factory_default: :keep do end end + describe '#has_sast_reports?' do + subject { merge_request.has_sast_reports? } + + let(:project) { create(:project, :repository) } + + before do + stub_licensed_features(sast: true) + end + + context 'when head pipeline has sast reports' do + let(:merge_request) { create(:merge_request, :with_sast_reports, source_project: project) } + + it { is_expected.to be_truthy } + end + + context 'when head pipeline does not have sast reports' do + let(:merge_request) { create(:merge_request, source_project: project) } + + it { is_expected.to be_falsey } + end + end + + describe '#has_secret_detection_reports?' do + subject { merge_request.has_secret_detection_reports? } + + let(:project) { create(:project, :repository) } + + before do + stub_licensed_features(secret_detection: true) + end + + context 'when head pipeline has secret detection reports' do + let(:merge_request) { create(:merge_request, :with_secret_detection_reports, source_project: project) } + + it { is_expected.to be_truthy } + end + + context 'when head pipeline does not have secrets detection reports' do + let(:merge_request) { create(:merge_request, source_project: project) } + + it { is_expected.to be_falsey } + end + end + describe '#calculate_reactive_cache' do let(:merge_request) { create(:merge_request) } @@ -4587,4 +4631,34 @@ RSpec.describe MergeRequest, factory_default: :keep do .from(nil).to(ref) end end + + describe '#enabled_reports' do + let(:project) { create(:project, :repository) } + + where(:report_type, :with_reports, :feature) do + :sast | :with_sast_reports | :sast + :secret_detection | :with_secret_detection_reports | :secret_detection + end + + with_them do + subject { merge_request.enabled_reports[report_type] } + + before do + stub_feature_flags(drop_license_management_artifact: false) + stub_licensed_features({ feature => true }) + end + + context "when head pipeline has reports" do + let(:merge_request) { create(:merge_request, with_reports, source_project: project) } + + it { is_expected.to be_truthy } + end + + context "when head pipeline does not have reports" do + let(:merge_request) { create(:merge_request, source_project: project) } + + it { is_expected.to be_falsy } + end + end + end end |