spec/adapter_spec.rb in carrierwave-base64-2.5.0 vs spec/adapter_spec.rb in carrierwave-base64-2.5.1
- old
+ new
@@ -4,11 +4,11 @@
subject do
User.mount_base64_uploader(
:image, uploader, file_name: ->(u) { u.username }
)
- User.new
+ User.new(username: 'batman')
end
let(:mongoid_model) do
MongoidModel.mount_base64_uploader(:image, uploader)
MongoidModel.new
@@ -63,9 +63,28 @@
it 'does not call will_change mongoid models' do
expect do
mongoid_model.image = 'test.jpg'
end.not_to raise_error
+ end
+
+ context 'with additional instances of the mounting class' do
+ let(:another_subject) do
+ another_subject = User.new(username: 'robin')
+ another_subject.image = File.read(
+ file_path('fixtures', 'base64_image.fixture')
+ ).strip
+ another_subject
+ end
+
+ it 'should invoke the file_name proc upon each upload' do
+ subject.save!
+ another_subject.save!
+ another_subject.reload
+ expect(
+ another_subject.image.current_path
+ ).to eq file_path('../uploads', 'robin.jpeg')
+ end
end
end
context 'stored uploads exist for the field' do
before :each do