Commit f484e8b5 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-fog-mocking-ee' into 'master'

Fix Fog mocking (EE)

Closes gitlab-ce#47300

See merge request gitlab-org/gitlab-ee!5977
parents 9b50c990 d6ef4c67
require 'spec_helper' require 'spec_helper'
describe 'Fog::Storage::GoogleXML::File' do describe 'Fog::Storage::GoogleXML::File', :fog_requests do
let(:storage) do let(:storage) do
Fog.mock! Fog.mock!
Fog::Storage.new({ Fog::Storage.new(
google_storage_access_key_id: "asdf", google_storage_access_key_id: "asdf",
google_storage_secret_access_key: "asdf", google_storage_secret_access_key: "asdf",
provider: "Google" provider: "Google"
}) )
end end
let(:file) do let(:file) do
......
...@@ -274,16 +274,13 @@ describe Backup::Manager do ...@@ -274,16 +274,13 @@ describe Backup::Manager do
} }
) )
# the Fog mock only knows about directories we create explicitly
Fog.mock! Fog.mock!
# the Fog mock only knows about directories we create explicitly
connection = ::Fog::Storage.new(Gitlab.config.backup.upload.connection.symbolize_keys) connection = ::Fog::Storage.new(Gitlab.config.backup.upload.connection.symbolize_keys)
connection.directories.create(key: Gitlab.config.backup.upload.remote_directory) connection.directories.create(key: Gitlab.config.backup.upload.remote_directory)
end end
after do
Fog.unmock!
end
context 'target path' do context 'target path' do
it 'uses the tar filename by default' do it 'uses the tar filename by default' do
expect_any_instance_of(Fog::Collection).to receive(:create) expect_any_instance_of(Fog::Collection).to receive(:create)
......
...@@ -152,6 +152,10 @@ RSpec.configure do |config| ...@@ -152,6 +152,10 @@ RSpec.configure do |config|
RequestStore.clear! RequestStore.clear!
end end
config.after(:example) do
Fog.unmock! if Fog.mock?
end
config.before(:example, :mailer) do config.before(:example, :mailer) do
reset_delivered_emails! reset_delivered_emails!
end end
......
...@@ -369,13 +369,6 @@ describe ObjectStorage do ...@@ -369,13 +369,6 @@ describe ObjectStorage do
describe '.workhorse_authorize' do describe '.workhorse_authorize' do
subject { uploader_class.workhorse_authorize } subject { uploader_class.workhorse_authorize }
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 shared_examples 'uses local storage' do
it "returns temporary path" do it "returns temporary path" do
is_expected.to have_key(:TempPath) is_expected.to have_key(:TempPath)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment