Commit ec72abf5 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'jej/object-storage-uploader-migrate-with-license-callback' into 'master'

ObjectStoreUploader#migrate! uses with_callbacks to trigger verify_license!

Closes #3370

See merge request !2863
parent 965dc286
...@@ -94,18 +94,20 @@ class ObjectStoreUploader < GitlabUploader ...@@ -94,18 +94,20 @@ class ObjectStoreUploader < GitlabUploader
# change storage # change storage
self.object_store = new_store self.object_store = new_store
storage.store!(file).tap do |new_file| with_callbacks(:store, file) do
# since we change storage store the new storage storage.store!(file).tap do |new_file|
# in case of failure delete new file # since we change storage store the new storage
begin # in case of failure delete new file
subject.save! begin
rescue => e subject.save!
new_file.delete rescue => e
self.object_store = old_store new_file.delete
raise e self.object_store = old_store
raise e
end
old_file.delete
end end
old_file.delete
end end
end end
......
...@@ -111,6 +111,16 @@ describe ObjectStoreUploader do ...@@ -111,6 +111,16 @@ describe ObjectStoreUploader do
end end
end end
context 'when storage is unlicensed' do
before do
stub_artifacts_object_storage(licensed: false)
end
it "raises an error" do
expect { subject }.to raise_error(/Object Storage feature is missing/)
end
end
context 'when credentials are set' do context 'when credentials are set' do
before do before do
stub_artifacts_object_storage stub_artifacts_object_storage
......
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