diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/finders | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/ci/auth_job_finder_spec.rb | 30 | ||||
-rw-r--r-- | spec/finders/ci/runners_finder_spec.rb | 58 | ||||
-rw-r--r-- | spec/finders/concerns/packages/finder_helper_spec.rb | 82 | ||||
-rw-r--r-- | spec/finders/deployments_finder_spec.rb | 24 | ||||
-rw-r--r-- | spec/finders/feature_flags_finder_spec.rb | 8 | ||||
-rw-r--r-- | spec/finders/issues_finder_spec.rb | 10 | ||||
-rw-r--r-- | spec/finders/packages/helm/package_files_finder_spec.rb | 47 | ||||
-rw-r--r-- | spec/finders/packages/maven/package_finder_spec.rb | 136 | ||||
-rw-r--r-- | spec/finders/packages/pypi/package_finder_spec.rb | 10 | ||||
-rw-r--r-- | spec/finders/pending_todos_finder_spec.rb | 28 | ||||
-rw-r--r-- | spec/finders/projects/serverless/functions_finder_spec.rb | 2 | ||||
-rw-r--r-- | spec/finders/projects_finder_spec.rb | 35 | ||||
-rw-r--r-- | spec/finders/security/security_jobs_finder_spec.rb | 6 |
13 files changed, 272 insertions, 204 deletions
diff --git a/spec/finders/ci/auth_job_finder_spec.rb b/spec/finders/ci/auth_job_finder_spec.rb index 6cd58f5cd01..78827c9ddee 100644 --- a/spec/finders/ci/auth_job_finder_spec.rb +++ b/spec/finders/ci/auth_job_finder_spec.rb @@ -2,7 +2,8 @@ require 'spec_helper' RSpec.describe Ci::AuthJobFinder do - let_it_be(:job, reload: true) { create(:ci_build, status: :running) } + let_it_be(:user, reload: true) { create(:user) } + let_it_be(:job, reload: true) { create(:ci_build, status: :running, user: user) } let(:token) { job.token } @@ -55,10 +56,31 @@ RSpec.describe Ci::AuthJobFinder do describe '#execute' do subject(:execute) { finder.execute } - before do - job.success! + context 'when job is not running' do + before do + job.success! + end + + it { is_expected.to be_nil } end - it { is_expected.to be_nil } + context 'when job is running', :request_store do + it 'sets ci_job_token_scope on the job user', :aggregate_failures do + expect(subject).to eq(job) + expect(subject.user).to be_from_ci_job_token + expect(subject.user.ci_job_token_scope.source_project).to eq(job.project) + end + + context 'when feature flag ci_scoped_job_token is disabled' do + before do + stub_feature_flags(ci_scoped_job_token: false) + end + + it 'does not set ci_job_token_scope on the job user' do + expect(subject).to eq(job) + expect(subject.user).not_to be_from_ci_job_token + end + end + end end end diff --git a/spec/finders/ci/runners_finder_spec.rb b/spec/finders/ci/runners_finder_spec.rb index 4df026f2f5f..250a85dde30 100644 --- a/spec/finders/ci/runners_finder_spec.rb +++ b/spec/finders/ci/runners_finder_spec.rb @@ -51,23 +51,55 @@ RSpec.describe Ci::RunnersFinder do end context 'sort' do + let_it_be(:runner1) { create :ci_runner, created_at: '2018-07-12 07:00', contacted_at: 1.minute.ago } + let_it_be(:runner2) { create :ci_runner, created_at: '2018-07-12 08:00', contacted_at: 3.minutes.ago } + let_it_be(:runner3) { create :ci_runner, created_at: '2018-07-12 09:00', contacted_at: 2.minutes.ago } + + subject do + described_class.new(current_user: admin, params: params).execute + end + + shared_examples 'sorts by created_at descending' do + it 'sorts by created_at descending' do + is_expected.to eq [runner3, runner2, runner1] + end + end + context 'without sort param' do - it 'sorts by created_at' do - runner1 = create :ci_runner, created_at: '2018-07-12 07:00' - runner2 = create :ci_runner, created_at: '2018-07-12 08:00' - runner3 = create :ci_runner, created_at: '2018-07-12 09:00' + let(:params) { {} } + + it_behaves_like 'sorts by created_at descending' + end + + %w(created_date created_at_desc).each do |sort| + context "with sort param equal to #{sort}" do + let(:params) { { sort: sort } } + + it_behaves_like 'sorts by created_at descending' + end + end + + context 'with sort param equal to created_at_asc' do + let(:params) { { sort: 'created_at_asc' } } + + it 'sorts by created_at ascending' do + is_expected.to eq [runner1, runner2, runner3] + end + end + + context 'with sort param equal to contacted_asc' do + let(:params) { { sort: 'contacted_asc' } } - expect(described_class.new(current_user: admin, params: {}).execute).to eq [runner3, runner2, runner1] + it 'sorts by contacted_at ascending' do + is_expected.to eq [runner2, runner3, runner1] end end - context 'with sort param' do - it 'sorts by specified attribute' do - runner1 = create :ci_runner, contacted_at: 1.minute.ago - runner2 = create :ci_runner, contacted_at: 3.minutes.ago - runner3 = create :ci_runner, contacted_at: 2.minutes.ago + context 'with sort param equal to contacted_desc' do + let(:params) { { sort: 'contacted_desc' } } - expect(described_class.new(current_user: admin, params: { sort: 'contacted_asc' }).execute).to eq [runner2, runner3, runner1] + it 'sorts by contacted_at descending' do + is_expected.to eq [runner1, runner3, runner2] end end end @@ -246,8 +278,8 @@ RSpec.describe Ci::RunnersFinder do subject { described_class.new(current_user: user, group: group, params: params).sort_key } context 'no params' do - it 'returns created_date' do - expect(subject).to eq('created_date') + it 'returns created_at_desc' do + expect(subject).to eq('created_at_desc') end end diff --git a/spec/finders/concerns/packages/finder_helper_spec.rb b/spec/finders/concerns/packages/finder_helper_spec.rb index bad4c482bc6..e8648d131ff 100644 --- a/spec/finders/concerns/packages/finder_helper_spec.rb +++ b/spec/finders/concerns/packages/finder_helper_spec.rb @@ -113,41 +113,22 @@ RSpec.describe ::Packages::FinderHelper do let_it_be(:user) { create(:deploy_token, :group, read_package_registry: true) } let_it_be(:group_deploy_token) { create(:group_deploy_token, deploy_token: user, group: group) } - shared_examples 'handling all conditions' do - where(:group_visibility, :subgroup_visibility, :project2_visibility, :shared_example_name) do - 'PUBLIC' | 'PUBLIC' | 'PUBLIC' | 'returning both packages' - 'PUBLIC' | 'PUBLIC' | 'PRIVATE' | 'returning both packages' - 'PUBLIC' | 'PRIVATE' | 'PRIVATE' | 'returning both packages' - 'PRIVATE' | 'PRIVATE' | 'PRIVATE' | 'returning both packages' - end - - with_them do - before do - project2.update!(visibility_level: Gitlab::VisibilityLevel.const_get(project2_visibility, false)) - subgroup.update!(visibility_level: Gitlab::VisibilityLevel.const_get(subgroup_visibility, false)) - project1.update!(visibility_level: Gitlab::VisibilityLevel.const_get(group_visibility, false)) - group.update!(visibility_level: Gitlab::VisibilityLevel.const_get(group_visibility, false)) - end - - it_behaves_like params[:shared_example_name] - end - end - - context 'with packages_finder_helper_deploy_token enabled' do - before do - expect(group).not_to receive(:all_projects) - end - - it_behaves_like 'handling all conditions' + where(:group_visibility, :subgroup_visibility, :project2_visibility, :shared_example_name) do + 'PUBLIC' | 'PUBLIC' | 'PUBLIC' | 'returning both packages' + 'PUBLIC' | 'PUBLIC' | 'PRIVATE' | 'returning both packages' + 'PUBLIC' | 'PRIVATE' | 'PRIVATE' | 'returning both packages' + 'PRIVATE' | 'PRIVATE' | 'PRIVATE' | 'returning both packages' end - context 'with packages_finder_helper_deploy_token disabled' do + with_them do before do - stub_feature_flags(packages_finder_helper_deploy_token: false) - expect(group).to receive(:all_projects).and_call_original + project2.update!(visibility_level: Gitlab::VisibilityLevel.const_get(project2_visibility, false)) + subgroup.update!(visibility_level: Gitlab::VisibilityLevel.const_get(subgroup_visibility, false)) + project1.update!(visibility_level: Gitlab::VisibilityLevel.const_get(group_visibility, false)) + group.update!(visibility_level: Gitlab::VisibilityLevel.const_get(group_visibility, false)) end - it_behaves_like 'handling all conditions' + it_behaves_like params[:shared_example_name] end end end @@ -236,41 +217,22 @@ RSpec.describe ::Packages::FinderHelper do let_it_be(:user) { create(:deploy_token, :group, read_package_registry: true) } let_it_be(:group_deploy_token) { create(:group_deploy_token, deploy_token: user, group: group) } - shared_examples 'handling all conditions' do - where(:group_visibility, :subgroup_visibility, :project2_visibility, :shared_example_name) do - 'PUBLIC' | 'PUBLIC' | 'PUBLIC' | 'returning both projects' - 'PUBLIC' | 'PUBLIC' | 'PRIVATE' | 'returning both projects' - 'PUBLIC' | 'PRIVATE' | 'PRIVATE' | 'returning both projects' - 'PRIVATE' | 'PRIVATE' | 'PRIVATE' | 'returning both projects' - end - - with_them do - before do - project2.update!(visibility_level: Gitlab::VisibilityLevel.const_get(project2_visibility, false)) - subgroup.update!(visibility_level: Gitlab::VisibilityLevel.const_get(subgroup_visibility, false)) - project1.update!(visibility_level: Gitlab::VisibilityLevel.const_get(group_visibility, false)) - group.update!(visibility_level: Gitlab::VisibilityLevel.const_get(group_visibility, false)) - end - - it_behaves_like params[:shared_example_name] - end - end - - context 'with packages_finder_helper_deploy_token enabled' do - before do - expect(group).not_to receive(:all_projects) - end - - it_behaves_like 'handling all conditions' + where(:group_visibility, :subgroup_visibility, :project2_visibility, :shared_example_name) do + 'PUBLIC' | 'PUBLIC' | 'PUBLIC' | 'returning both projects' + 'PUBLIC' | 'PUBLIC' | 'PRIVATE' | 'returning both projects' + 'PUBLIC' | 'PRIVATE' | 'PRIVATE' | 'returning both projects' + 'PRIVATE' | 'PRIVATE' | 'PRIVATE' | 'returning both projects' end - context 'with packages_finder_helper_deploy_token disabled' do + with_them do before do - stub_feature_flags(packages_finder_helper_deploy_token: false) - expect(group).to receive(:all_projects).and_call_original + project2.update!(visibility_level: Gitlab::VisibilityLevel.const_get(project2_visibility, false)) + subgroup.update!(visibility_level: Gitlab::VisibilityLevel.const_get(subgroup_visibility, false)) + project1.update!(visibility_level: Gitlab::VisibilityLevel.const_get(group_visibility, false)) + group.update!(visibility_level: Gitlab::VisibilityLevel.const_get(group_visibility, false)) end - it_behaves_like 'handling all conditions' + it_behaves_like params[:shared_example_name] end end end diff --git a/spec/finders/deployments_finder_spec.rb b/spec/finders/deployments_finder_spec.rb index b294f1117f5..bd03b254f40 100644 --- a/spec/finders/deployments_finder_spec.rb +++ b/spec/finders/deployments_finder_spec.rb @@ -81,16 +81,6 @@ RSpec.describe DeploymentsFinder do it 'returns deployments with matched updated_at' do is_expected.to match_array([deployment_2, deployment_1]) end - - context 'when deployments_finder_implicitly_enforce_ordering_for_updated_at_filter feature flag is disabled' do - before do - stub_feature_flags(deployments_finder_implicitly_enforce_ordering_for_updated_at_filter: false) - end - - it 'returns deployments with matched updated_at' do - is_expected.to match_array([deployment_1, deployment_2]) - end - end end context 'when the environment name is specified' do @@ -244,20 +234,6 @@ RSpec.describe DeploymentsFinder do expect(subject.order_values.first.to_sql).to eq(Deployment.arel_table[:updated_at].asc.to_sql) expect(subject.order_values.second.to_sql).to eq(Deployment.arel_table[:id].asc.to_sql) end - - context 'when deployments_finder_implicitly_enforce_ordering_for_updated_at_filter feature flag is disabled' do - before do - stub_feature_flags(deployments_finder_implicitly_enforce_ordering_for_updated_at_filter: false) - end - - it 'sorts by only one column' do - expect(subject.order_values.size).to eq(1) - end - - it 'sorts by `id`' do - expect(subject.order_values.first.to_sql).to eq(Deployment.arel_table[:id].asc.to_sql) - end - end end context 'when filtering by finished time' do diff --git a/spec/finders/feature_flags_finder_spec.rb b/spec/finders/feature_flags_finder_spec.rb index 8744a186212..4faa6a62a1f 100644 --- a/spec/finders/feature_flags_finder_spec.rb +++ b/spec/finders/feature_flags_finder_spec.rb @@ -73,11 +73,11 @@ RSpec.describe FeatureFlagsFinder do end end - context 'when new version flags are enabled' do - let!(:feature_flag_3) { create(:operations_feature_flag, :new_version_flag, name: 'flag-c', project: project) } + context 'with a legacy flag' do + let!(:feature_flag_3) { create(:operations_feature_flag, :legacy_flag, name: 'flag-c', project: project) } - it 'returns new and legacy flags' do - is_expected.to eq([feature_flag_1, feature_flag_2, feature_flag_3]) + it 'returns new flags' do + is_expected.to eq([feature_flag_1, feature_flag_2]) end end end diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index 27466ab563f..1c8c2af8e03 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -49,6 +49,11 @@ RSpec.describe IssuesFinder do let(:expected_issuables) { [issue3, issue4] } end + it_behaves_like 'assignee OR filter' do + let(:params) { { or: { assignee_id: [user.id, user2.id] } } } + let(:expected_issuables) { [issue1, issue2, issue3, issue5] } + end + context 'when assignee_id does not exist' do it_behaves_like 'assignee NOT ID filter' do let(:params) { { not: { assignee_id: -100 } } } @@ -79,6 +84,11 @@ RSpec.describe IssuesFinder do let(:expected_issuables) { [issue3, issue4] } end + it_behaves_like 'assignee OR filter' do + let(:params) { { or: { assignee_username: [user2.username, user3.username] } } } + let(:expected_issuables) { [issue2, issue3] } + end + context 'when assignee_username does not exist' do it_behaves_like 'assignee NOT username filter' do before do diff --git a/spec/finders/packages/helm/package_files_finder_spec.rb b/spec/finders/packages/helm/package_files_finder_spec.rb new file mode 100644 index 00000000000..2b84fd2b2d2 --- /dev/null +++ b/spec/finders/packages/helm/package_files_finder_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Packages::Helm::PackageFilesFinder do + let_it_be(:project1) { create(:project) } + let_it_be(:project2) { create(:project) } + let_it_be(:helm_package) { create(:helm_package, project: project1) } + let_it_be(:helm_package_file) { helm_package.package_files.first } + let_it_be(:debian_package) { create(:debian_package, project: project1) } + + describe '#execute' do + let(:project) { project1 } + let(:channel) { 'stable' } + let(:params) { {} } + + subject { described_class.new(project, channel, params).execute } + + context 'with empty params' do + it { is_expected.to match_array([helm_package_file]) } + end + + context 'with another project' do + let(:project) { project2 } + + it { is_expected.to match_array([]) } + end + + context 'with another channel' do + let(:channel) { 'staging' } + + it { is_expected.to match_array([]) } + end + + context 'with file_name' do + let(:params) { { file_name: helm_package_file.file_name } } + + it { is_expected.to match_array([helm_package_file]) } + end + + context 'with another file_name' do + let(:params) { { file_name: 'foobar.tgz' } } + + it { is_expected.to match_array([]) } + end + end +end diff --git a/spec/finders/packages/maven/package_finder_spec.rb b/spec/finders/packages/maven/package_finder_spec.rb index 13c603f1ec4..38fc3b7cce4 100644 --- a/spec/finders/packages/maven/package_finder_spec.rb +++ b/spec/finders/packages/maven/package_finder_spec.rb @@ -17,107 +17,89 @@ RSpec.describe ::Packages::Maven::PackageFinder do group.add_developer(user) end - shared_examples 'Packages::Maven::PackageFinder examples' do - describe '#execute!' do - subject { finder.execute! } + describe '#execute!' do + subject { finder.execute! } - shared_examples 'handling valid and invalid paths' do - context 'with a valid path' do - let(:param_path) { package.maven_metadatum.path } + shared_examples 'handling valid and invalid paths' do + context 'with a valid path' do + let(:param_path) { package.maven_metadatum.path } - it { is_expected.to eq(package) } - end - - context 'with an invalid path' do - let(:param_path) { 'com/example/my-app/1.0-SNAPSHOT' } - - it 'raises an error' do - expect { subject }.to raise_error(ActiveRecord::RecordNotFound) - end - end - - context 'with an uninstallable package' do - let(:param_path) { package.maven_metadatum.path } - - before do - package.update_column(:status, 1) - end - - it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) } - end + it { is_expected.to eq(package) } end - context 'within the project' do - let(:project_or_group) { project } + context 'with an invalid path' do + let(:param_path) { 'com/example/my-app/1.0-SNAPSHOT' } - it_behaves_like 'handling valid and invalid paths' - end - - context 'within a group' do - let(:project_or_group) { group } - - it_behaves_like 'handling valid and invalid paths' - end - - context 'across all projects' do it 'raises an error' do expect { subject }.to raise_error(ActiveRecord::RecordNotFound) end end - context 'versionless maven-metadata.xml package' do - let_it_be(:sub_group1) { create(:group, parent: group) } - let_it_be(:sub_group2) { create(:group, parent: group) } - let_it_be(:project1) { create(:project, group: sub_group1) } - let_it_be(:project2) { create(:project, group: sub_group2) } - let_it_be(:project3) { create(:project, group: sub_group1) } - let_it_be(:package_name) { 'foo' } - let_it_be(:package1) { create(:maven_package, project: project1, name: package_name, version: nil) } - let_it_be(:package2) { create(:maven_package, project: project2, name: package_name, version: nil) } - let_it_be(:package3) { create(:maven_package, project: project3, name: package_name, version: nil) } - - let(:project_or_group) { group } - let(:param_path) { package_name } + context 'with an uninstallable package' do + let(:param_path) { package.maven_metadatum.path } before do - sub_group1.add_developer(user) - sub_group2.add_developer(user) - # the package with the most recently published file should be returned - create(:package_file, :xml, package: package2) - end - - context 'without order by package file' do - it { is_expected.to eq(package3) } + package.update_column(:status, 1) end - context 'with order by package file' do - let(:param_order_by_package_file) { true } - - it { is_expected.to eq(package2) } - end + it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) } end end - end - context 'when the maven_metadata_by_path_with_optimization_fence feature flag is off' do - before do - stub_feature_flags(maven_metadata_by_path_with_optimization_fence: false) + context 'within the project' do + let(:project_or_group) { project } + + it_behaves_like 'handling valid and invalid paths' end - it_behaves_like 'Packages::Maven::PackageFinder examples' - end + context 'within a group' do + let(:project_or_group) { group } - context 'when the maven_metadata_by_path_with_optimization_fence feature flag is on' do - before do - stub_feature_flags(maven_metadata_by_path_with_optimization_fence: true) + it_behaves_like 'handling valid and invalid paths' end - it_behaves_like 'Packages::Maven::PackageFinder examples' + context 'across all projects' do + it 'raises an error' do + expect { subject }.to raise_error(ActiveRecord::RecordNotFound) + end + end - it 'uses CTE in the query' do - sql = described_class.new(user, group, path: package.maven_metadatum.path).send(:packages).to_sql + context 'versionless maven-metadata.xml package' do + let_it_be(:sub_group1) { create(:group, parent: group) } + let_it_be(:sub_group2) { create(:group, parent: group) } + let_it_be(:project1) { create(:project, group: sub_group1) } + let_it_be(:project2) { create(:project, group: sub_group2) } + let_it_be(:project3) { create(:project, group: sub_group1) } + let_it_be(:package_name) { 'foo' } + let_it_be(:package1) { create(:maven_package, project: project1, name: package_name, version: nil) } + let_it_be(:package2) { create(:maven_package, project: project2, name: package_name, version: nil) } + let_it_be(:package3) { create(:maven_package, project: project3, name: package_name, version: nil) } + + let(:project_or_group) { group } + let(:param_path) { package_name } + + before do + sub_group1.add_developer(user) + sub_group2.add_developer(user) + # the package with the most recently published file should be returned + create(:package_file, :xml, package: package2) + end - expect(sql).to include('WITH "maven_metadata_by_path" AS') + context 'without order by package file' do + it { is_expected.to eq(package3) } + end + + context 'with order by package file' do + let(:param_order_by_package_file) { true } + + it { is_expected.to eq(package2) } + end end end + + it 'uses CTE in the query' do + sql = described_class.new(user, group, path: package.maven_metadatum.path).send(:packages).to_sql + + expect(sql).to include('WITH "maven_metadata_by_path" AS') + end end diff --git a/spec/finders/packages/pypi/package_finder_spec.rb b/spec/finders/packages/pypi/package_finder_spec.rb index 7d9eb8a5cd1..f065bd21f6d 100644 --- a/spec/finders/packages/pypi/package_finder_spec.rb +++ b/spec/finders/packages/pypi/package_finder_spec.rb @@ -31,15 +31,7 @@ RSpec.describe Packages::Pypi::PackageFinder do context 'within a group' do let(:scope) { group } - it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) } - - context 'user with access' do - before do - project.add_developer(user) - end - - it { is_expected.to eq(package2) } - end + it { is_expected.to eq(package2) } end end end diff --git a/spec/finders/pending_todos_finder_spec.rb b/spec/finders/pending_todos_finder_spec.rb index b17915f0d59..f317d8b1633 100644 --- a/spec/finders/pending_todos_finder_spec.rb +++ b/spec/finders/pending_todos_finder_spec.rb @@ -3,8 +3,11 @@ require 'spec_helper' RSpec.describe PendingTodosFinder do - let(:user) { create(:user) } - let(:user2) { create(:user) } + let_it_be(:user) { create(:user) } + let_it_be(:user2) { create(:user) } + let_it_be(:issue) { create(:issue) } + let_it_be(:note) { create(:note) } + let(:users) { [user, user2] } describe '#execute' do @@ -30,20 +33,16 @@ RSpec.describe PendingTodosFinder do end it 'supports retrieving of todos for a specific todo target' do - issue = create(:issue) - note = create(:note) todo = create(:todo, :pending, user: user, target: issue) create(:todo, :pending, user: user, target: note) - todos = described_class.new(users, target_id: issue.id).execute + todos = described_class.new(users, target_id: issue.id, target_type: 'Issue').execute expect(todos).to eq([todo]) end it 'supports retrieving of todos for a specific target type' do - issue = create(:issue) - note = create(:note) todo = create(:todo, :pending, user: user, target: issue) create(:todo, :pending, user: user, target: note) @@ -61,5 +60,20 @@ RSpec.describe PendingTodosFinder do expect(todos).to eq([todo]) end + + it 'supports retrieving of todos for specific discussion' do + first_discussion_note = create(:discussion_note_on_issue, noteable: issue, project: issue.project) + note_2 = create(:note, discussion_id: first_discussion_note.discussion_id) + note_3 = create(:note, discussion_id: first_discussion_note.discussion_id) + todo1 = create(:todo, :pending, target: issue, note: note_2, user: note_2.author) + todo2 = create(:todo, :pending, target: issue, note: note_3, user: note_3.author) + create(:todo, :pending, note: note, user: user) + discussion = Discussion.lazy_find(first_discussion_note.discussion_id) + users = [note_2.author, note_3.author, user] + + todos = described_class.new(users, discussion: discussion).execute + + expect(todos).to contain_exactly(todo1, todo2) + end end end diff --git a/spec/finders/projects/serverless/functions_finder_spec.rb b/spec/finders/projects/serverless/functions_finder_spec.rb index 3d3e4183d4e..9b58da2e398 100644 --- a/spec/finders/projects/serverless/functions_finder_spec.rb +++ b/spec/finders/projects/serverless/functions_finder_spec.rb @@ -165,7 +165,7 @@ RSpec.describe Projects::Serverless::FunctionsFinder do context 'has prometheus' do let(:prometheus_adapter) { double('prometheus_adapter', can_query?: true) } let!(:knative) { create(:clusters_applications_knative, :installed, cluster: cluster) } - let!(:prometheus) { create(:clusters_applications_prometheus, :installed, cluster: cluster) } + let!(:prometheus) { create(:clusters_integrations_prometheus, cluster: cluster) } let(:finder) { described_class.new(project) } before do diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb index 364e5de4ece..b8b5e2c3bb7 100644 --- a/spec/finders/projects_finder_spec.rb +++ b/spec/finders/projects_finder_spec.rb @@ -137,9 +137,9 @@ RSpec.describe ProjectsFinder do end end - describe 'filter by tags' do + describe 'filter by tags (deprecated)' do before do - public_project.tag_list = 'foo' + public_project.topic_list = 'foo' public_project.save! end @@ -148,6 +148,37 @@ RSpec.describe ProjectsFinder do it { is_expected.to eq([public_project]) } end + describe 'filter by topics' do + before do + public_project.topic_list = 'foo, bar' + public_project.save! + end + + context 'single topic' do + let(:params) { { topic: 'foo' } } + + it { is_expected.to eq([public_project]) } + end + + context 'multiple topics' do + let(:params) { { topic: 'bar, foo' } } + + it { is_expected.to eq([public_project]) } + end + + context 'one topic matches, other one does not' do + let(:params) { { topic: 'foo, xyz' } } + + it { is_expected.to eq([]) } + end + + context 'no matching topic' do + let(:params) { { topic: 'xyz' } } + + it { is_expected.to eq([]) } + end + end + describe 'filter by personal' do let!(:personal_project) { create(:project, namespace: user.namespace) } let(:params) { { personal: true } } diff --git a/spec/finders/security/security_jobs_finder_spec.rb b/spec/finders/security/security_jobs_finder_spec.rb index fa8253b96b5..3023c42341b 100644 --- a/spec/finders/security/security_jobs_finder_spec.rb +++ b/spec/finders/security/security_jobs_finder_spec.rb @@ -28,19 +28,19 @@ RSpec.describe Security::SecurityJobsFinder do end end - context 'with combination of security jobs and license management jobs' do + context 'with combination of security jobs and license scanning jobs' do let!(:sast_build) { create(:ci_build, :sast, pipeline: pipeline) } let!(:container_scanning_build) { create(:ci_build, :container_scanning, pipeline: pipeline) } let!(:dast_build) { create(:ci_build, :dast, pipeline: pipeline) } let!(:secret_detection_build) { create(:ci_build, :secret_detection, pipeline: pipeline) } - let!(:license_management_build) { create(:ci_build, :license_management, pipeline: pipeline) } + let!(:license_scanning_build) { create(:ci_build, :license_scanning, pipeline: pipeline) } it 'returns only the security jobs' do is_expected.to include(sast_build) is_expected.to include(container_scanning_build) is_expected.to include(dast_build) is_expected.to include(secret_detection_build) - is_expected.not_to include(license_management_build) + is_expected.not_to include(license_scanning_build) end end end |