Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-02-27 16:09:33 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2018-02-28 23:28:26 +0300
commita22f6fa6e50bb31921415b01fd345d6802581390 (patch)
tree4e617f85dd0500b1c0bb004f9a4ed3e2000df818 /spec/uploaders/object_storage_spec.rb
parentb4dc556c2f40f2e8e4d71c5dd8d1747974f8147f (diff)
Merge branch 'fix/sm/atomic-migration' into 'master'
Fix migrate! method (Minimal fix with ExclusiveLock to prevent race conditions) Closes #4928 and #4980 See merge request gitlab-org/gitlab-ee!4624
Diffstat (limited to 'spec/uploaders/object_storage_spec.rb')
-rw-r--r--spec/uploaders/object_storage_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb
index e01ad9af1dc..64b59acb286 100644
--- a/spec/uploaders/object_storage_spec.rb
+++ b/spec/uploaders/object_storage_spec.rb
@@ -128,6 +128,33 @@ describe ObjectStorage do
expect(uploader.object_store).to eq(uploader.upload.store)
end
end
+
+ describe '#migrate!' do
+ let(:new_store) { ObjectStorage::Store::REMOTE }
+
+ before do
+ stub_uploads_object_storage(uploader: AvatarUploader)
+ end
+
+ subject { uploader.migrate!(new_store) }
+
+ it 'persist @object_store to the recorded upload' do
+ subject
+
+ expect(uploader.upload.store).to eq(new_store)
+ end
+
+ describe 'fails' do
+ it 'is handled gracefully' do
+ store = uploader.object_store
+ expect_any_instance_of(Upload).to receive(:save!).and_raise("An error")
+
+ expect { subject }.to raise_error("An error")
+ expect(uploader.exists?).to be_truthy
+ expect(uploader.upload.store).to eq(store)
+ end
+ end
+ end
end
# this means the model holds an <mounted_as>_store attribute directly