-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CarrierWave file retrieval after store
- Loading branch information
David Liu
authored
Apr 5, 2022
1 parent
ddde239
commit a55748c
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
require 'cloudinary' | ||
|
||
module CarrierWave | ||
module Storage | ||
class Abstract | ||
def initialize(uploader) | ||
@uploader = uploader | ||
end | ||
|
||
attr_accessor :uploader | ||
end | ||
end | ||
class SanitizedFile; end | ||
end | ||
|
||
RSpec.describe Cloudinary::CarrierWave do | ||
describe '#store!' do | ||
let(:column) { 'example_field' } | ||
let(:identifier) { 'identifier' } | ||
let(:model) { double(:model, _mounter: mount) } | ||
let(:mount) { double(:mount, serialization_column: column) } | ||
let(:uploader) { spy(:uploader, model: model, mounted_as: :example).tap { |u| u.extend(Cloudinary::CarrierWave) } } | ||
|
||
subject { uploader.store! } | ||
|
||
it 'triggers `#retrieve_from_store!` after `#store!` executed to populate @file and @identifier' do | ||
expect(model).to receive(:attribute).with(column).and_return(identifier) | ||
expect(uploader).to receive(:retrieve_from_store!).with(identifier) | ||
|
||
subject | ||
end | ||
end | ||
end |