debian-mirror-gitlab/spec/support/shared_examples/models/with_uploads_shared_examples.rb

24 lines
757 B
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
require 'spec_helper'
2019-01-03 12:48:30 +05:30
shared_examples_for 'model with mounted uploader' do |supports_fileuploads|
2018-11-08 19:23:39 +05:30
describe '.destroy' do
before do
stub_uploads_object_storage(uploader_class)
model_object.public_send(upload_attribute).migrate!(ObjectStorage::Store::REMOTE)
end
2019-01-03 12:48:30 +05:30
it 'deletes remote uploads' do
expect_any_instance_of(CarrierWave::Storage::Fog::File).to receive(:delete).and_call_original
2018-11-08 19:23:39 +05:30
2019-01-03 12:48:30 +05:30
expect { model_object.destroy }.to change { Upload.count }.by(-1)
2018-11-08 19:23:39 +05:30
end
2019-01-03 12:48:30 +05:30
it 'deletes any FileUploader uploads which are not mounted', skip: !supports_fileuploads do
create(:upload, uploader: FileUploader, model: model_object)
2018-11-08 19:23:39 +05:30
2019-01-03 12:48:30 +05:30
expect { model_object.destroy }.to change { Upload.count }.by(-2)
2018-11-08 19:23:39 +05:30
end
end
end