gitlab-org--gitlab-foss/spec/initializers/direct_upload_support_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

114 lines
2.7 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-05-09 11:27:38 -04:00
require 'spec_helper'
RSpec.describe 'Direct upload support' do
2018-05-09 11:27:38 -04:00
subject do
load Rails.root.join('config/initializers/direct_upload_support.rb')
end
where(:config_name) do
%w(artifacts lfs uploads)
2018-05-09 11:27:38 -04:00
end
with_them do
let(:connection) do
{ provider: provider }
end
let(:object_store) do
{
enabled: enabled,
direct_upload: direct_upload,
connection: connection
}
end
before do
2018-06-04 08:06:07 -04:00
allow(Gitlab.config).to receive_messages(to_settings(config_name => {
object_store: object_store
}))
2018-05-09 11:27:38 -04:00
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 AWS' do
let(:provider) { 'AWS' }
it 'succeeds' do
expect { subject }.not_to raise_error
end
end
context 'when provider is Google' do
let(:provider) { 'Google' }
it 'succeeds' do
expect { subject }.not_to raise_error
end
end
context 'when provider is AzureRM' do
let(:provider) { 'AzureRM' }
it 'succeeds' do
expect { subject }.not_to raise_error
end
end
2018-05-09 11:27:38 -04:00
context 'when connection is empty' do
let(:connection) { nil }
it 'raises an error' do
expect { subject }.to raise_error "No provider configured for '#{config_name}'. Only Google, AWS, and AzureRM are supported."
2018-05-09 11:27:38 -04:00
end
end
context 'when other provider is used' do
let(:provider) { 'Rackspace' }
it 'raises an error' do
expect { subject }.to raise_error /Object storage provider '#{provider}' is not supported when 'direct_upload' is used for '#{config_name}'/
end
end
context 'when connection is omitted' do
let(:object_store) do
{
enabled: enabled,
direct_upload: direct_upload
}
end
it 'raises an error' do
expect { subject }.to raise_error /the 'connection' section is missing/
2018-05-09 11:27:38 -04:00
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) { 'Rackspace' }
it 'succeeds' do
expect { subject }.not_to raise_error
end
end
end
end