diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/finders/packages/maven | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/finders/packages/maven')
-rw-r--r-- | spec/finders/packages/maven/package_finder_spec.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/finders/packages/maven/package_finder_spec.rb b/spec/finders/packages/maven/package_finder_spec.rb new file mode 100644 index 00000000000..239e8c10f52 --- /dev/null +++ b/spec/finders/packages/maven/package_finder_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe ::Packages::Maven::PackageFinder do + let(:user) { create(:user) } + let(:group) { create(:group) } + let(:project) { create(:project, namespace: group) } + let(:package) { create(:maven_package, project: project) } + + before do + group.add_developer(user) + end + + describe '#execute!' do + context 'within the project' do + it 'returns a package' do + finder = described_class.new(package.maven_metadatum.path, user, project: project) + + expect(finder.execute!).to eq(package) + end + + it 'raises an error' do + finder = described_class.new('com/example/my-app/1.0-SNAPSHOT', user, project: project) + + expect { finder.execute! }.to raise_error(ActiveRecord::RecordNotFound) + end + end + + context 'across all projects' do + it 'returns a package' do + finder = described_class.new(package.maven_metadatum.path, user) + + expect(finder.execute!).to eq(package) + end + + it 'raises an error' do + finder = described_class.new('com/example/my-app/1.0-SNAPSHOT', user) + + expect { finder.execute! }.to raise_error(ActiveRecord::RecordNotFound) + end + end + + context 'within a group' do + it 'returns a package' do + finder = described_class.new(package.maven_metadatum.path, user, group: group) + + expect(finder.execute!).to eq(package) + end + + it 'raises an error' do + finder = described_class.new('com/example/my-app/1.0-SNAPSHOT', user, group: group) + + expect { finder.execute! }.to raise_error(ActiveRecord::RecordNotFound) + end + end + end +end |