summaryrefslogtreecommitdiff
path: root/spec/finders/packages/maven
diff options
context:
space:
mode:
Diffstat (limited to 'spec/finders/packages/maven')
-rw-r--r--spec/finders/packages/maven/package_finder_spec.rb57
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