Commit c18e8f58 authored by James Edwards-Jones's avatar James Edwards-Jones

ObjectStoreUploader#migrate! uses with_callbacks to trigger verify_license!

parent d0744566
...@@ -106,6 +106,7 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base ...@@ -106,6 +106,7 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
# change storage # change storage
self.object_store = new_store self.object_store = new_store
with_callbacks(:store, file) do
storage.store!(file).tap do |new_file| storage.store!(file).tap do |new_file|
# since we change storage store the new storage # since we change storage store the new storage
# in case of failure delete new file # in case of failure delete new file
...@@ -120,6 +121,7 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base ...@@ -120,6 +121,7 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
old_file.delete old_file.delete
end end
end end
end
def schedule_migration_to_object_storage(new_file) def schedule_migration_to_object_storage(new_file)
if self.class.object_store_enabled? && licensed? && file_storage? if self.class.object_store_enabled? && licensed? && file_storage?
......
...@@ -184,6 +184,16 @@ describe ObjectStoreUploader do ...@@ -184,6 +184,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