Fix Fog mocking

This commit is contained in:
Kamil Trzciński 2018-06-05 16:17:04 +02:00
parent 3201988b4d
commit 53d1c87c86
5 changed files with 16 additions and 18 deletions

View File

@ -1,13 +1,13 @@
require 'spec_helper'
describe 'Fog::Storage::GoogleXML::File' do
describe 'Fog::Storage::GoogleXML::File', :fog_requests do
let(:storage) do
Fog.mock!
Fog::Storage.new({
google_storage_access_key_id: "asdf",
google_storage_secret_access_key: "asdf",
provider: "Google"
})
Fog::Storage.new(
google_storage_access_key_id: "asdf",
google_storage_secret_access_key: "asdf",
provider: "Google"
)
end
let(:file) do

View File

@ -274,16 +274,13 @@ describe Backup::Manager do
}
)
# the Fog mock only knows about directories we create explicitly
Fog.mock!
# the Fog mock only knows about directories we create explicitly
connection = ::Fog::Storage.new(Gitlab.config.backup.upload.connection.symbolize_keys)
connection.directories.create(key: Gitlab.config.backup.upload.remote_directory)
end
after do
Fog.unmock!
end
context 'target path' do
it 'uses the tar filename by default' do
expect_any_instance_of(Fog::Collection).to receive(:create)

View File

@ -17,6 +17,10 @@ describe ObjectStorage::DirectUpload do
let(:direct_upload) { described_class.new(credentials, bucket_name, object_name, has_length: has_length, maximum_size: maximum_size) }
before do
Fog.unmock!
end
describe '#has_length' do
context 'is known' do
let(:has_length) { true }

View File

@ -133,6 +133,10 @@ RSpec.configure do |config|
RequestStore.clear!
end
config.after(:example) do
Fog.unmock! if Fog.mock?
end
config.before(:example, :mailer) do
reset_delivered_emails!
end

View File

@ -360,13 +360,6 @@ describe ObjectStorage do
subject { uploader_class.workhorse_authorize(has_length: has_length, maximum_size: maximum_size) }
before do
# ensure that we use regular Fog libraries
# other tests might call `Fog.mock!` and
# it will make tests to fail
Fog.unmock!
end
shared_examples 'uses local storage' do
it "returns temporary path" do
is_expected.to have_key(:TempPath)