Commit 566e3e7f authored by nmilojevic1's avatar nmilojevic1

Fix disable upload object storage

- Fix specs for import export task
- Replace File.exists with File.exist
parent ce1893e3
......@@ -27,10 +27,8 @@ module Gitlab
end
def disable_upload_object_storage
overwrite_uploads_setting('background_upload', false) do
overwrite_uploads_setting('direct_upload', false) do
yield
end
overwrite_uploads_setting('enabled', false) do
yield
end
end
......
......@@ -30,7 +30,7 @@ describe Gitlab::ImportExport::Project::ExportTask do
around do |example|
example.run
ensure
File.delete(file_path) if File.exists?(file_path)
File.delete(file_path) if File.exist?(file_path)
end
include_context 'rake task object storage shared context'
......
......@@ -6,15 +6,12 @@ RSpec.shared_context 'rake task object storage shared context' do
end
around do |example|
old_direct_upload_setting = Settings.uploads.object_store['direct_upload']
old_background_upload_setting = Settings.uploads.object_store['background_upload']
old_object_store_setting = Settings.uploads.object_store['enabled']
Settings.uploads.object_store['direct_upload'] = true
Settings.uploads.object_store['background_upload'] = true
Settings.uploads.object_store['enabled'] = true
example.run
Settings.uploads.object_store['direct_upload'] = old_direct_upload_setting
Settings.uploads.object_store['background_upload'] = old_background_upload_setting
Settings.uploads.object_store['enabled'] = old_object_store_setting
end
end
......@@ -4,18 +4,15 @@ RSpec.shared_examples 'rake task with disabled object_storage' do |service_class
it 'disables direct & background upload only for service call' do
expect_next_instance_of(service_class) do |service|
expect(service).to receive(:execute).and_wrap_original do |m|
expect(Settings.uploads.object_store['background_upload']).to eq(false)
expect(Settings.uploads.object_store['direct_upload']).to eq(false)
expect(Settings.uploads.object_store['enabled']).to eq(false)
m.call
end
end
expect(rake_task).to receive(method).and_wrap_original do |m, *args|
expect(Settings.uploads.object_store['background_upload']).to eq(true)
expect(Settings.uploads.object_store['direct_upload']).to eq(true)
expect(Settings.uploads.object_store).not_to receive(:[]=).with('backgroud_upload', false)
expect(Settings.uploads.object_store).not_to receive(:[]=).with('direct_upload', false)
expect(Settings.uploads.object_store['enabled']).to eq(true)
expect(Settings.uploads.object_store).not_to receive(:[]=).with('enabled', false)
m.call(*args)
end
......
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