summaryrefslogtreecommitdiff
path: root/spec/initializers
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-04-03 18:47:33 +0200
committerKamil Trzciński <ayufan@ayufan.eu>2018-04-05 15:01:14 +0200
commit678620cce67cc283b19b75137f747f9415aaf942 (patch)
tree650b53c790087b88ce40f79c7c66cef6994c25b4 /spec/initializers
parent9b1677b2deeec1faf0dd1d60a2b0c47e80b58433 (diff)
downloadgitlab-ce-678620cce67cc283b19b75137f747f9415aaf942.tar.gz
Add `direct_upload` setting for artifactsdirect-upload-of-artifacts
Diffstat (limited to 'spec/initializers')
-rw-r--r--spec/initializers/artifacts_direct_upload_support_spec.rb71
1 files changed, 71 insertions, 0 deletions
diff --git a/spec/initializers/artifacts_direct_upload_support_spec.rb b/spec/initializers/artifacts_direct_upload_support_spec.rb
new file mode 100644
index 00000000000..bfb71da3388
--- /dev/null
+++ b/spec/initializers/artifacts_direct_upload_support_spec.rb
@@ -0,0 +1,71 @@
+require 'spec_helper'
+
+describe 'Artifacts direct upload support' do
+ subject do
+ load Rails.root.join('config/initializers/artifacts_direct_upload_support.rb')
+ end
+
+ let(:connection) do
+ { provider: provider }
+ end
+
+ before do
+ stub_artifacts_setting(
+ object_store: {
+ enabled: enabled,
+ direct_upload: direct_upload,
+ connection: connection
+ })
+ end
+
+ context 'when object storage is enabled' do
+ let(:enabled) { true }
+
+ context 'when direct upload is enabled' do
+ let(:direct_upload) { true }
+
+ context 'when provider is Google' do
+ let(:provider) { 'Google' }
+
+ it 'succeeds' do
+ expect { subject }.not_to raise_error
+ end
+ end
+
+ context 'when connection is empty' do
+ let(:connection) { nil }
+
+ it 'raises an error' do
+ expect { subject }.to raise_error /object storage provider when 'direct_upload' of artifacts is used/
+ end
+ end
+
+ context 'when other provider is used' do
+ let(:provider) { 'AWS' }
+
+ it 'raises an error' do
+ expect { subject }.to raise_error /object storage provider when 'direct_upload' of artifacts is used/
+ end
+ end
+ end
+
+ context 'when direct upload is disabled' do
+ let(:direct_upload) { false }
+ let(:provider) { 'AWS' }
+
+ it 'succeeds' do
+ expect { subject }.not_to raise_error
+ end
+ end
+ end
+
+ context 'when object storage is disabled' do
+ let(:enabled) { false }
+ let(:direct_upload) { false }
+ let(:provider) { 'AWS' }
+
+ it 'succeeds' do
+ expect { subject }.not_to raise_error
+ end
+ end
+end