Skip to content

Commit

Permalink
Fix rubocop issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vipulnsward committed Aug 25, 2024
1 parent 5ab4236 commit 8fb079c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
before do
allow(Rails).to receive(:cache).and_return(double(read: nil, write: nil))
allow(Uploadcare::Rails).to receive(:configuration).and_return(
OpenStruct.new(
double(
store_files_async: false,
delete_files_async: false,
do_not_store: false,
Expand Down Expand Up @@ -79,29 +79,29 @@

context 'when the file group is present' do
it 'stores the file group synchronously if not configured for async storage' do
Uploadcare::Rails.configuration.store_files_async = false
allow(Uploadcare::Rails.configuration).to receive(:store_files_async).and_return(false)
expect(Uploadcare::GroupApi).to receive(:store_group).with(group_id)
model.send("uploadcare_store_#{attribute}!")
end

it 'performs the store job asynchronously if configured' do
Uploadcare::Rails.configuration.store_files_async = true
allow(Uploadcare::Rails.configuration).to receive(:store_files_async).and_return(true)
expect(Uploadcare::Rails::StoreGroupJob).to receive(:perform_later).with(group_id)
model.send("uploadcare_store_#{attribute}!")
end
end

context 'when do_not_store configuration is true' do
it 'does not define the after_save callback' do
Uploadcare::Rails.configuration.do_not_store = true
allow(Uploadcare::Rails.configuration).to receive(:do_not_store).and_return(true)
expect(TestModel).not_to receive(:after_save)
TestModel.mount_uploadcare_file_group(:attribute)
end
end

context 'when do_not_store configuration is false' do
it 'defines the after_save callback' do
Uploadcare::Rails.configuration.do_not_store = false
allow(Uploadcare::Rails.configuration).to receive(:do_not_store).and_return(false)
expect(TestModel).to receive(:set_callback).with(:save, :after, :uploadcare_store_cdn_url!)
TestModel.mount_uploadcare_file_group(attribute)
end
Expand Down
14 changes: 7 additions & 7 deletions spec/uploadcare/rails/mongoid/mount_uploadcare_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
before do
allow(Rails).to receive(:cache).and_return(double(read: nil, write: nil))
allow(Uploadcare::Rails).to receive(:configuration).and_return(
OpenStruct.new(
double(
store_files_async: false,
delete_files_async: false,
do_not_store: false,
Expand Down Expand Up @@ -69,7 +69,7 @@

context 'when store_files_async configuration is true' do
before do
Uploadcare::Rails.configuration.store_files_async = true
allow(Uploadcare::Rails.configuration).to receive(:store_files_async).and_return(true)
end

it 'should enqueue StoreFileJob when calling uploadcare_store_cdn_url!' do
Expand All @@ -80,7 +80,7 @@

context 'when store_files_async configuration is false' do
before do
Uploadcare::Rails.configuration.store_files_async = false
allow(Uploadcare::Rails.configuration).to receive(:store_files_async).and_return(false)
end

it 'should call Uploadcare::FileApi.store_file when calling uploadcare_store_cdn_url!' do
Expand All @@ -91,7 +91,7 @@

context 'when delete_files_async configuration is true' do
before do
Uploadcare::Rails.configuration.delete_files_async = true
allow(Uploadcare::Rails.configuration).to receive(:delete_files_async).and_return(true)
end

it 'should enqueue DeleteFileJob when calling uploadcare_delete_cdn_url!' do
Expand All @@ -102,7 +102,7 @@

context 'when delete_files_async configuration is false' do
before do
Uploadcare::Rails.configuration.delete_files_async = false
allow(Uploadcare::Rails.configuration).to receive(:delete_files_async).and_return(false)
end

it 'should call Uploadcare::FileApi.delete_file when calling uploadcare_delete_cdn_url!' do
Expand All @@ -113,7 +113,7 @@

context 'when do_not_store configuration is false' do
before do
Uploadcare::Rails.configuration.do_not_store = false
allow(Uploadcare::Rails.configuration).to receive(:do_not_store).and_return(false)
end

it 'should set callback for saving to call uploadcare_store_cdn_url! if cdn_url attribute changed' do
Expand All @@ -125,7 +125,7 @@

context 'when delete_files_after_destroy configuration is true' do
before do
Uploadcare::Rails.configuration.delete_files_after_destroy = true
allow(Uploadcare::Rails.configuration).to receive(:delete_files_after_destroy).and_return(true)
end

it 'should set callback for destroying to call uploadcare_delete_cdn_url!' do
Expand Down

0 comments on commit 8fb079c

Please sign in to comment.