spec/adapter_spec.rb in carrierwave-base64-2.10.0 vs spec/adapter_spec.rb in carrierwave-base64-2.11.0
- old
+ new
@@ -38,13 +38,11 @@
end
end
context 'models with file_name options for the uploader' do
subject do
- User.mount_base64_uploader(
- :image, uploader, file_name: ->(u) { u.username }
- )
+ User.mount_base64_uploader(:image, uploader, file_name: :username.to_proc)
User.new(username: 'batman')
end
it 'mounts the uploader on the image field' do
expect(subject.image).to be_an_instance_of(uploader)
@@ -61,13 +59,11 @@
end
context 'when file_name is a proc' do
it 'does NOT issue a deprecation warning' do
expect do
- User.mount_base64_uploader(
- :image, uploader, file_name: ->(u) { u.username }
- )
+ User.mount_base64_uploader(:image, uploader, file_name: :username.to_proc)
end.not_to warn('Deprecation')
end
end
context 'normal file uploads' do
@@ -144,9 +140,15 @@
expect(File.exist?(subject.image.file.file)).to be_truthy
end
it 'removes files when remove_* is set to true' do
subject.remove_image = true
+ subject.save!
+ expect(subject.image.file).to be_nil
+ end
+
+ it 'removes files when setting the attribute to nil' do
+ subject.image = nil
subject.save!
expect(subject.image.file).to be_nil
end
end
end