diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/finders/packages/maven | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/finders/packages/maven')
-rw-r--r-- | spec/finders/packages/maven/package_finder_spec.rb | 77 |
1 files changed, 23 insertions, 54 deletions
diff --git a/spec/finders/packages/maven/package_finder_spec.rb b/spec/finders/packages/maven/package_finder_spec.rb index ca144292501..13c603f1ec4 100644 --- a/spec/finders/packages/maven/package_finder_spec.rb +++ b/spec/finders/packages/maven/package_finder_spec.rb @@ -6,13 +6,12 @@ RSpec.describe ::Packages::Maven::PackageFinder do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, namespace: group) } - let_it_be(:package) { create(:maven_package, project: project) } + let_it_be_with_refind(:package) { create(:maven_package, project: project) } let(:param_path) { nil } - let(:param_project) { nil } - let(:param_group) { nil } + let(:project_or_group) { nil } let(:param_order_by_package_file) { false } - let(:finder) { described_class.new(param_path, user, project: param_project, group: param_group, order_by_package_file: param_order_by_package_file) } + let(:finder) { described_class.new(user, project_or_group, path: param_path, order_by_package_file: param_order_by_package_file) } before do group.add_developer(user) @@ -36,34 +35,28 @@ RSpec.describe ::Packages::Maven::PackageFinder 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 end context 'within the project' do - let(:param_project) { project } + let(:project_or_group) { project } it_behaves_like 'handling valid and invalid paths' end context 'within a group' do - let(:param_group) { group } - - context 'with maven_packages_group_level_improvements enabled' do - before do - stub_feature_flags(maven_packages_group_level_improvements: true) - expect(finder).to receive(:packages_visible_to_user).with(user, within_group: group).and_call_original - end - - it_behaves_like 'handling valid and invalid paths' - end - - context 'with maven_packages_group_level_improvements disabled' do - before do - stub_feature_flags(maven_packages_group_level_improvements: false) - expect(finder).not_to receive(:packages_visible_to_user) - end + let(:project_or_group) { group } - it_behaves_like 'handling valid and invalid paths' - end + it_behaves_like 'handling valid and invalid paths' end context 'across all projects' do @@ -83,7 +76,7 @@ RSpec.describe ::Packages::Maven::PackageFinder do 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(:param_group) { group } + let(:project_or_group) { group } let(:param_path) { package_name } before do @@ -93,38 +86,14 @@ RSpec.describe ::Packages::Maven::PackageFinder do create(:package_file, :xml, package: package2) end - context 'with maven_packages_group_level_improvements enabled' do - before do - stub_feature_flags(maven_packages_group_level_improvements: true) - expect(finder).not_to receive(:versionless_package?) - end - - 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 + context 'without order by package file' do + it { is_expected.to eq(package3) } end - context 'with maven_packages_group_level_improvements disabled' do - before do - stub_feature_flags(maven_packages_group_level_improvements: false) - expect(finder).to receive(:versionless_package?).and_call_original - end + context 'with order by package file' do + let(:param_order_by_package_file) { true } - context 'without order by package file' do - it { is_expected.to eq(package2) } - end - - context 'with order by package file' do - let(:param_order_by_package_file) { true } - - it { is_expected.to eq(package2) } - end + it { is_expected.to eq(package2) } end end end @@ -146,7 +115,7 @@ RSpec.describe ::Packages::Maven::PackageFinder do it_behaves_like 'Packages::Maven::PackageFinder examples' it 'uses CTE in the query' do - sql = described_class.new('some_path', user, group: group).send(:packages_with_path).to_sql + 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 |