summaryrefslogtreecommitdiff
path: root/spec/finders
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
commit8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch)
tree544930fb309b30317ae9797a9683768705d664c4 /spec/finders
parent4b1de649d0168371549608993deac953eb692019 (diff)
downloadgitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/finders')
-rw-r--r--spec/finders/alert_management/alerts_finder_spec.rb34
-rw-r--r--spec/finders/ci/daily_build_group_report_results_finder_spec.rb87
-rw-r--r--spec/finders/ci/pipeline_schedules_finder_spec.rb2
-rw-r--r--spec/finders/ci/pipelines_finder_spec.rb17
-rw-r--r--spec/finders/ci/pipelines_for_merge_request_finder_spec.rb18
-rw-r--r--spec/finders/feature_flags_finder_spec.rb12
-rw-r--r--spec/finders/fork_projects_finder_spec.rb2
-rw-r--r--spec/finders/group_descendants_finder_spec.rb6
-rw-r--r--spec/finders/group_members_finder_spec.rb44
-rw-r--r--spec/finders/issues_finder_spec.rb4
-rw-r--r--spec/finders/members_finder_spec.rb4
-rw-r--r--spec/finders/merge_requests_finder_spec.rb118
-rw-r--r--spec/finders/releases/evidence_pipeline_finder_spec.rb44
13 files changed, 304 insertions, 88 deletions
diff --git a/spec/finders/alert_management/alerts_finder_spec.rb b/spec/finders/alert_management/alerts_finder_spec.rb
index e74f3ac68ed..87a5da38dd1 100644
--- a/spec/finders/alert_management/alerts_finder_spec.rb
+++ b/spec/finders/alert_management/alerts_finder_spec.rb
@@ -8,6 +8,8 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
let_it_be(:resolved_alert) { create(:alert_management_alert, :all_fields, :resolved, project: project, ended_at: 1.year.ago, events: 2, severity: :high) }
let_it_be(:ignored_alert) { create(:alert_management_alert, :all_fields, :ignored, project: project, events: 1, severity: :critical) }
let_it_be(:triggered_alert) { create(:alert_management_alert, :all_fields) }
+ let_it_be(:threat_monitroing_alert) { create(:alert_management_alert, domain: 'threat_monitoring') }
+
let(:params) { {} }
describe '#execute' do
@@ -22,6 +24,26 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
project.add_developer(current_user)
end
+ context 'domain' do
+ context 'domain is threat management' do
+ let(:params) { { domain: 'threat_management' } }
+
+ it { is_expected.to contain_exactly(resolved_alert, ignored_alert) }
+ end
+
+ context 'domain is unknown' do
+ let(:params) { { domain: 'unkown' } }
+
+ it { is_expected.to contain_exactly(resolved_alert, ignored_alert) }
+ end
+
+ context 'domain is missing' do
+ let(:params) { {} }
+
+ it { is_expected.to contain_exactly(resolved_alert, ignored_alert) }
+ end
+ end
+
context 'empty params' do
it { is_expected.to contain_exactly(resolved_alert, ignored_alert) }
end
@@ -233,12 +255,6 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
it { is_expected.to be_empty }
end
-
- context 'empty search' do
- let(:params) { { search: ' ' } }
-
- it { is_expected.not_to include(alert) }
- end
end
context 'assignee username given' do
@@ -257,12 +273,6 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
it { is_expected.to be_empty }
end
-
- context 'with empty assignee_username' do
- let(:username) { ' ' }
-
- it { is_expected.not_to include(alert) }
- end
end
end
end
diff --git a/spec/finders/ci/daily_build_group_report_results_finder_spec.rb b/spec/finders/ci/daily_build_group_report_results_finder_spec.rb
index c0434b5f371..28a732fda82 100644
--- a/spec/finders/ci/daily_build_group_report_results_finder_spec.rb
+++ b/spec/finders/ci/daily_build_group_report_results_finder_spec.rb
@@ -4,57 +4,77 @@ require 'spec_helper'
RSpec.describe Ci::DailyBuildGroupReportResultsFinder do
describe '#execute' do
- let(:project) { create(:project, :private) }
- let(:ref_path) { 'refs/heads/master' }
+ let_it_be(:project) { create(:project, :private) }
+ let_it_be(:current_user) { project.owner }
+ let_it_be(:ref_path) { 'refs/heads/master' }
let(:limit) { nil }
+ let_it_be(:default_branch) { false }
- let!(:rspec_coverage_1) { create_daily_coverage('rspec', 79.0, '2020-03-09') }
- let!(:karma_coverage_1) { create_daily_coverage('karma', 89.0, '2020-03-09') }
- let!(:rspec_coverage_2) { create_daily_coverage('rspec', 95.0, '2020-03-10') }
- let!(:karma_coverage_2) { create_daily_coverage('karma', 92.0, '2020-03-10') }
- let!(:rspec_coverage_3) { create_daily_coverage('rspec', 97.0, '2020-03-11') }
- let!(:karma_coverage_3) { create_daily_coverage('karma', 99.0, '2020-03-11') }
+ let_it_be(:rspec_coverage_1) { create_daily_coverage('rspec', 79.0, '2020-03-09') }
+ let_it_be(:karma_coverage_1) { create_daily_coverage('karma', 89.0, '2020-03-09') }
+ let_it_be(:rspec_coverage_2) { create_daily_coverage('rspec', 95.0, '2020-03-10') }
+ let_it_be(:karma_coverage_2) { create_daily_coverage('karma', 92.0, '2020-03-10') }
+ let_it_be(:rspec_coverage_3) { create_daily_coverage('rspec', 97.0, '2020-03-11') }
+ let_it_be(:karma_coverage_3) { create_daily_coverage('karma', 99.0, '2020-03-11') }
- subject do
- described_class.new(
+ let(:attributes) do
+ {
current_user: current_user,
project: project,
ref_path: ref_path,
start_date: '2020-03-09',
end_date: '2020-03-10',
limit: limit
- ).execute
+ }
end
- context 'when current user is allowed to read build report results' do
- let(:current_user) { project.owner }
+ subject(:coverages) do
+ described_class.new(**attributes).execute
+ end
+
+ context 'when ref_path is present' do
+ context 'when current user is allowed to read build report results' do
+ it 'returns all matching results within the given date range' do
+ expect(coverages).to match_array([
+ karma_coverage_2,
+ rspec_coverage_2,
+ karma_coverage_1,
+ rspec_coverage_1
+ ])
+ end
+
+ context 'and limit is specified' do
+ let(:limit) { 2 }
- it 'returns all matching results within the given date range' do
- expect(subject).to match_array([
- karma_coverage_2,
- rspec_coverage_2,
- karma_coverage_1,
- rspec_coverage_1
- ])
+ it 'returns limited number of matching results within the given date range' do
+ expect(coverages).to match_array([
+ karma_coverage_2,
+ rspec_coverage_2
+ ])
+ end
+ end
end
- context 'and limit is specified' do
- let(:limit) { 2 }
+ context 'when current user is not allowed to read build report results' do
+ let(:current_user) { create(:user) }
- it 'returns limited number of matching results within the given date range' do
- expect(subject).to match_array([
- karma_coverage_2,
- rspec_coverage_2
- ])
+ it 'returns an empty result' do
+ expect(coverages).to be_empty
end
end
end
- context 'when current user is not allowed to read build report results' do
- let(:current_user) { create(:user) }
+ context 'when ref_path is not present' do
+ let(:ref_path) { nil }
- it 'returns an empty result' do
- expect(subject).to be_empty
+ context 'when coverages exist for the default branch' do
+ let(:default_branch) { true }
+
+ it 'returns coverage for the default branch' do
+ rspec_coverage_4 = create_daily_coverage('rspec', 66.0, '2020-03-10')
+
+ expect(coverages).to contain_exactly(rspec_coverage_4)
+ end
end
end
end
@@ -65,10 +85,11 @@ RSpec.describe Ci::DailyBuildGroupReportResultsFinder do
create(
:ci_daily_build_group_report_result,
project: project,
- ref_path: ref_path,
+ ref_path: ref_path || 'feature-branch',
group_name: group_name,
data: { 'coverage' => coverage },
- date: date
+ date: date,
+ default_branch: default_branch
)
end
end
diff --git a/spec/finders/ci/pipeline_schedules_finder_spec.rb b/spec/finders/ci/pipeline_schedules_finder_spec.rb
index 57842bbecd7..535c684289e 100644
--- a/spec/finders/ci/pipeline_schedules_finder_spec.rb
+++ b/spec/finders/ci/pipeline_schedules_finder_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Ci::PipelineSchedulesFinder do
let!(:active_schedule) { create(:ci_pipeline_schedule, project: project) }
let!(:inactive_schedule) { create(:ci_pipeline_schedule, :inactive, project: project) }
- subject { described_class.new(project).execute(params) }
+ subject { described_class.new(project).execute(**params) }
describe "#execute" do
context 'when the scope is nil' do
diff --git a/spec/finders/ci/pipelines_finder_spec.rb b/spec/finders/ci/pipelines_finder_spec.rb
index a2a714689ba..16561aa65b6 100644
--- a/spec/finders/ci/pipelines_finder_spec.rb
+++ b/spec/finders/ci/pipelines_finder_spec.rb
@@ -72,7 +72,7 @@ RSpec.describe Ci::PipelinesFinder do
create(:ci_sources_pipeline, pipeline: child_pipeline, source_pipeline: parent_pipeline)
end
- it 'filters out child pipelines and show only the parents' do
+ it 'filters out child pipelines and shows only the parents by default' do
is_expected.to eq([parent_pipeline])
end
end
@@ -195,6 +195,21 @@ RSpec.describe Ci::PipelinesFinder do
end
end
+ context 'when iids filter is specified' do
+ let(:params) { { iids: [pipeline1.iid, pipeline3.iid] } }
+ let!(:pipeline1) { create(:ci_pipeline, project: project) }
+ let!(:pipeline2) { create(:ci_pipeline, project: project) }
+ let!(:pipeline3) { create(:ci_pipeline, project: project, source: :parent_pipeline) }
+
+ it 'returns matches pipelines' do
+ is_expected.to match_array([pipeline1, pipeline3])
+ end
+
+ it 'does not fitler out child pipelines' do
+ is_expected.to include(pipeline3)
+ end
+ end
+
context 'when sha is specified' do
let!(:pipeline) { create(:ci_pipeline, project: project, sha: '97de212e80737a608d939f648d959671fb0a0142') }
diff --git a/spec/finders/ci/pipelines_for_merge_request_finder_spec.rb b/spec/finders/ci/pipelines_for_merge_request_finder_spec.rb
index 65f6dc0ba74..64b3c46e122 100644
--- a/spec/finders/ci/pipelines_for_merge_request_finder_spec.rb
+++ b/spec/finders/ci/pipelines_for_merge_request_finder_spec.rb
@@ -225,6 +225,24 @@ RSpec.describe Ci::PipelinesForMergeRequestFinder do
branch_pipeline_2,
branch_pipeline])
end
+
+ context 'when ci_pipelines_for_merge_request_finder_new_cte feature flag is disabled' do
+ before do
+ stub_feature_flags(ci_pipelines_for_merge_request_finder_new_cte: false)
+ end
+
+ it 'returns only related merge request pipelines' do
+ expect(subject.all)
+ .to eq([detached_merge_request_pipeline,
+ branch_pipeline_2,
+ branch_pipeline])
+
+ expect(described_class.new(merge_request_2, nil).all)
+ .to eq([detached_merge_request_pipeline_2,
+ branch_pipeline_2,
+ branch_pipeline])
+ end
+ end
end
context 'when detached merge request pipeline is run on head ref of the merge request' do
diff --git a/spec/finders/feature_flags_finder_spec.rb b/spec/finders/feature_flags_finder_spec.rb
index 870447a1286..8744a186212 100644
--- a/spec/finders/feature_flags_finder_spec.rb
+++ b/spec/finders/feature_flags_finder_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe FeatureFlagsFinder do
end
describe '#execute' do
- subject { finder.execute(args) }
+ subject { finder.execute(**args) }
let!(:feature_flag_1) { create(:operations_feature_flag, name: 'flag-a', project: project) }
let!(:feature_flag_2) { create(:operations_feature_flag, name: 'flag-b', project: project) }
@@ -80,15 +80,5 @@ RSpec.describe FeatureFlagsFinder do
is_expected.to eq([feature_flag_1, feature_flag_2, feature_flag_3])
end
end
-
- context 'when new version flags are disabled' do
- let!(:feature_flag_3) { create(:operations_feature_flag, :new_version_flag, name: 'flag-c', project: project) }
-
- it 'returns only legacy flags' do
- stub_feature_flags(feature_flags_new_version: false)
-
- is_expected.to eq([feature_flag_1, feature_flag_2])
- end
- end
end
end
diff --git a/spec/finders/fork_projects_finder_spec.rb b/spec/finders/fork_projects_finder_spec.rb
index 9e58378b953..2b2e4c0d618 100644
--- a/spec/finders/fork_projects_finder_spec.rb
+++ b/spec/finders/fork_projects_finder_spec.rb
@@ -14,8 +14,6 @@ RSpec.describe ForkProjectsFinder do
let(:private_fork_member) { create(:user) }
before do
- stub_feature_flags(object_pools: source_project)
-
private_fork.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
private_fork.add_developer(private_fork_member)
diff --git a/spec/finders/group_descendants_finder_spec.rb b/spec/finders/group_descendants_finder_spec.rb
index b66d0ffce87..3c3bb13a629 100644
--- a/spec/finders/group_descendants_finder_spec.rb
+++ b/spec/finders/group_descendants_finder_spec.rb
@@ -77,9 +77,9 @@ RSpec.describe GroupDescendantsFinder do
end
end
- it 'sorts elements by latest created as default' do
- project1 = create(:project, namespace: group, created_at: 1.hour.ago)
- project2 = create(:project, namespace: group)
+ it 'sorts elements by name as default' do
+ project1 = create(:project, namespace: group, name: 'z')
+ project2 = create(:project, namespace: group, name: 'a')
expect(subject.execute).to eq([project2, project1])
end
diff --git a/spec/finders/group_members_finder_spec.rb b/spec/finders/group_members_finder_spec.rb
index 67e7de5921a..a87a05d4408 100644
--- a/spec/finders/group_members_finder_spec.rb
+++ b/spec/finders/group_members_finder_spec.rb
@@ -129,4 +129,48 @@ RSpec.describe GroupMembersFinder, '#execute' do
expect(result.to_a).not_to include(member_with_2fa)
expect(result.to_a).to match_array([member1, member2])
end
+
+ it 'returns direct members with two-factor auth if requested by owner' do
+ group.add_owner(user1)
+ group.add_maintainer(user2)
+ nested_group.add_maintainer(user3)
+ member_with_2fa = nested_group.add_maintainer(user5)
+
+ result = described_class.new(nested_group, user1, params: { two_factor: 'enabled' }).execute(include_relations: [:direct])
+
+ expect(result.to_a).to match_array([member_with_2fa])
+ end
+
+ it 'returns inherited members with two-factor auth if requested by owner' do
+ group.add_owner(user1)
+ member_with_2fa = group.add_maintainer(user5)
+ nested_group.add_maintainer(user2)
+ nested_group.add_maintainer(user3)
+
+ result = described_class.new(nested_group, user1, params: { two_factor: 'enabled' }).execute(include_relations: [:inherited])
+
+ expect(result.to_a).to match_array([member_with_2fa])
+ end
+
+ it 'returns direct members without two-factor auth if requested by owner' do
+ group.add_owner(user1)
+ group.add_maintainer(user2)
+ member3 = nested_group.add_maintainer(user3)
+ nested_group.add_maintainer(user5)
+
+ result = described_class.new(nested_group, user1, params: { two_factor: 'disabled' }).execute(include_relations: [:direct])
+
+ expect(result.to_a).to match_array([member3])
+ end
+
+ it 'returns inherited members without two-factor auth if requested by owner' do
+ member1 = group.add_owner(user1)
+ group.add_maintainer(user5)
+ nested_group.add_maintainer(user2)
+ nested_group.add_maintainer(user3)
+
+ result = described_class.new(nested_group, user1, params: { two_factor: 'disabled' }).execute(include_relations: [:inherited])
+
+ expect(result.to_a).to match_array([member1])
+ end
end
diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb
index 3c3bf1a8870..0def3412aa7 100644
--- a/spec/finders/issues_finder_spec.rb
+++ b/spec/finders/issues_finder_spec.rb
@@ -472,10 +472,6 @@ RSpec.describe IssuesFinder do
it 'returns issues with title and description match for search term' do
expect(issues).to contain_exactly(issue1, issue2)
end
-
- it 'uses optimizer hints' do
- expect(issues.to_sql).to match(/BitmapScan/)
- end
end
context 'filtering by issue term in title' do
diff --git a/spec/finders/members_finder_spec.rb b/spec/finders/members_finder_spec.rb
index 3530858e2de..d25e1b9ca4b 100644
--- a/spec/finders/members_finder_spec.rb
+++ b/spec/finders/members_finder_spec.rb
@@ -160,8 +160,8 @@ RSpec.describe MembersFinder, '#execute' do
expect(result).to eq([member3, member2, member1])
end
- context 'when include_invited_groups_members == true' do
- subject { described_class.new(project, user2).execute(include_relations: [:inherited, :direct, :invited_groups_members]) }
+ context 'when :invited_groups is passed' do
+ subject { described_class.new(project, user2).execute(include_relations: [:inherited, :direct, :invited_groups]) }
let_it_be(:linked_group) { create(:group, :public) }
let_it_be(:nested_linked_group) { create(:group, parent: linked_group) }
diff --git a/spec/finders/merge_requests_finder_spec.rb b/spec/finders/merge_requests_finder_spec.rb
index 68958e37001..7b59b581b1c 100644
--- a/spec/finders/merge_requests_finder_spec.rb
+++ b/spec/finders/merge_requests_finder_spec.rb
@@ -333,6 +333,8 @@ RSpec.describe MergeRequestsFinder do
end
context 'assignee filtering' do
+ let_it_be(:user3) { create(:user) }
+
let(:issuables) { described_class.new(user, params).execute }
it_behaves_like 'assignee ID filter' do
@@ -351,7 +353,6 @@ RSpec.describe MergeRequestsFinder do
merge_request3.assignees = [user2, user3]
end
- let_it_be(:user3) { create(:user) }
let(:params) { { assignee_username: [user2.username, user3.username] } }
let(:expected_issuables) { [merge_request3] }
end
@@ -366,38 +367,95 @@ RSpec.describe MergeRequestsFinder do
end
it_behaves_like 'no assignee filter' do
- let_it_be(:user3) { create(:user) }
let(:expected_issuables) { [merge_request4, merge_request5] }
end
it_behaves_like 'any assignee filter' do
let(:expected_issuables) { [merge_request1, merge_request2, merge_request3] }
end
+ end
- context 'filtering by group milestone' do
- let(:group_milestone) { create(:milestone, group: group) }
+ context 'reviewer filtering' do
+ subject { described_class.new(user, params).execute }
- before do
- merge_request1.update!(milestone: group_milestone)
- merge_request2.update!(milestone: group_milestone)
- end
+ context 'by reviewer_id' do
+ let(:params) { { reviewer_id: user2.id } }
+ let(:expected_mr) { [merge_request1, merge_request2] }
- it 'returns merge requests assigned to that group milestone' do
- params = { milestone_title: group_milestone.title }
+ it { is_expected.to contain_exactly(*expected_mr) }
+ end
- merge_requests = described_class.new(user, params).execute
+ context 'by NOT reviewer_id' do
+ let(:params) { { not: { reviewer_id: user2.id } } }
+ let(:expected_mr) { [merge_request3, merge_request4, merge_request5] }
- expect(merge_requests).to contain_exactly(merge_request1, merge_request2)
- end
+ it { is_expected.to contain_exactly(*expected_mr) }
+ end
- context 'using NOT' do
- let(:params) { { not: { milestone_title: group_milestone.title } } }
+ context 'by reviewer_username' do
+ let(:params) { { reviewer_username: user2.username } }
+ let(:expected_mr) { [merge_request1, merge_request2] }
- it 'returns MRs not assigned to that group milestone' do
- merge_requests = described_class.new(user, params).execute
+ it { is_expected.to contain_exactly(*expected_mr) }
+ end
- expect(merge_requests).to contain_exactly(merge_request3, merge_request4, merge_request5)
- end
+ context 'by NOT reviewer_username' do
+ let(:params) { { not: { reviewer_username: user2.username } } }
+ let(:expected_mr) { [merge_request3, merge_request4, merge_request5] }
+
+ it { is_expected.to contain_exactly(*expected_mr) }
+ end
+
+ context 'by reviewer_id=None' do
+ let(:params) { { reviewer_id: 'None' } }
+ let(:expected_mr) { [merge_request4, merge_request5] }
+
+ it { is_expected.to contain_exactly(*expected_mr) }
+ end
+
+ context 'by reviewer_id=Any' do
+ let(:params) { { reviewer_id: 'Any' } }
+ let(:expected_mr) { [merge_request1, merge_request2, merge_request3] }
+
+ it { is_expected.to contain_exactly(*expected_mr) }
+ end
+
+ context 'by reviewer_id with unknown user' do
+ let(:params) { { reviewer_id: 99999 } }
+
+ it { is_expected.to be_empty }
+ end
+
+ context 'by NOT reviewer_id with unknown user' do
+ let(:params) { { not: { reviewer_id: 99999 } } }
+
+ it { is_expected.to be_empty }
+ end
+ end
+
+ context 'filtering by group milestone' do
+ let(:group_milestone) { create(:milestone, group: group) }
+
+ before do
+ merge_request1.update!(milestone: group_milestone)
+ merge_request2.update!(milestone: group_milestone)
+ end
+
+ it 'returns merge requests assigned to that group milestone' do
+ params = { milestone_title: group_milestone.title }
+
+ merge_requests = described_class.new(user, params).execute
+
+ expect(merge_requests).to contain_exactly(merge_request1, merge_request2)
+ end
+
+ context 'using NOT' do
+ let(:params) { { not: { milestone_title: group_milestone.title } } }
+
+ it 'returns MRs not assigned to that group milestone' do
+ merge_requests = described_class.new(user, params).execute
+
+ expect(merge_requests).to contain_exactly(merge_request3, merge_request4, merge_request5)
end
end
end
@@ -563,6 +621,28 @@ RSpec.describe MergeRequestsFinder do
expect(mrs).to eq([mr2])
end
end
+
+ it 'does not raise any exception with complex filters' do
+ # available filters from MergeRequest dashboard UI
+ params = {
+ project_id: project1.id,
+ scope: 'authored',
+ state: 'opened',
+ author_username: user.username,
+ assignee_username: user.username,
+ reviewer_username: user.username,
+ approver_usernames: [user.username],
+ approved_by_usernames: [user.username],
+ milestone_title: 'none',
+ release_tag: 'none',
+ label_names: 'none',
+ my_reaction_emoji: 'none',
+ draft: 'no'
+ }
+
+ merge_requests = described_class.new(user, params).execute
+ expect { merge_requests.load }.not_to raise_error
+ end
end
describe '#row_count', :request_store do
diff --git a/spec/finders/releases/evidence_pipeline_finder_spec.rb b/spec/finders/releases/evidence_pipeline_finder_spec.rb
new file mode 100644
index 00000000000..8c435f7b0b6
--- /dev/null
+++ b/spec/finders/releases/evidence_pipeline_finder_spec.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Releases::EvidencePipelineFinder, '#execute' do
+ let(:params) { {} }
+ let(:project) { create(:project, :repository) }
+ let(:tag_name) { project.repository.tag_names.first }
+ let(:sha) { project.repository.find_tag(tag_name).dereferenced_target.sha }
+ let!(:pipeline) { create(:ci_empty_pipeline, sha: sha, project: project) }
+
+ subject { described_class.new(project, params).execute }
+
+ context 'when the tag is passed' do
+ let(:params) { { tag: tag_name } }
+
+ it 'returns the evidence pipeline' do
+ expect(subject).to eq(pipeline)
+ end
+ end
+
+ context 'when the ref is passed' do
+ let(:params) { { ref: sha } }
+
+ it 'returns the evidence pipeline' do
+ expect(subject).to eq(pipeline)
+ end
+ end
+
+ context 'empty params' do
+ it 'returns nil' do
+ expect(subject).to be_nil
+ end
+ end
+
+ # TODO: remove this with the release creation moved to it's own form https://gitlab.com/gitlab-org/gitlab/-/issues/214245
+ context 'params[:evidence_pipeline] is present' do
+ let(:params) { { evidence_pipeline: pipeline } }
+
+ it 'returns the passed evidence pipeline' do
+ expect(subject).to eq(pipeline)
+ end
+ end
+end