summaryrefslogtreecommitdiff
path: root/spec/models/dependency_proxy/manifest_spec.rb
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/models/dependency_proxy/manifest_spec.rb
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/models/dependency_proxy/manifest_spec.rb')
-rw-r--r--spec/models/dependency_proxy/manifest_spec.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/models/dependency_proxy/manifest_spec.rb b/spec/models/dependency_proxy/manifest_spec.rb
new file mode 100644
index 00000000000..aa2e73356dd
--- /dev/null
+++ b/spec/models/dependency_proxy/manifest_spec.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+require 'spec_helper'
+
+RSpec.describe DependencyProxy::Manifest, type: :model do
+ describe 'relationships' do
+ it { is_expected.to belong_to(:group) }
+ end
+
+ describe 'validations' do
+ it { is_expected.to validate_presence_of(:group) }
+ it { is_expected.to validate_presence_of(:file) }
+ it { is_expected.to validate_presence_of(:file_name) }
+ it { is_expected.to validate_presence_of(:digest) }
+ end
+
+ describe 'file is being stored' do
+ subject { create(:dependency_proxy_manifest) }
+
+ context 'when existing object has local store' do
+ it_behaves_like 'mounted file in local store'
+ end
+
+ context 'when direct upload is enabled' do
+ before do
+ stub_dependency_proxy_object_storage(direct_upload: true)
+ end
+
+ it_behaves_like 'mounted file in object store'
+ end
+ end
+
+ describe '.find_or_initialize_by_file_name' do
+ subject { DependencyProxy::Manifest.find_or_initialize_by_file_name(file_name) }
+
+ context 'no manifest exists' do
+ let_it_be(:file_name) { 'foo' }
+
+ it 'initializes a manifest' do
+ expect(DependencyProxy::Manifest).to receive(:new).with(file_name: file_name)
+
+ subject
+ end
+ end
+
+ context 'manifest exists' do
+ let_it_be(:dependency_proxy_manifest) { create(:dependency_proxy_manifest) }
+ let_it_be(:file_name) { dependency_proxy_manifest.file_name }
+
+ it { is_expected.to eq(dependency_proxy_manifest) }
+ end
+ end
+end