Permalink
Browse files

Merge pull request #735 from xtreme-tanzeeb-khalili/remove-column-bugfix

Fix bug in #remove_#{column} when filename is set explicitly
  • Loading branch information...
2 parents 7747e9e + 0df712c commit d91ad986f3a8579e62290be3e6974c5c070b1791 @bensie bensie committed May 5, 2012
Showing with 19 additions and 5 deletions.
  1. +5 −5 lib/carrierwave/mount.rb
  2. +14 −0 spec/orm/activerecord_spec.rb
View
@@ -296,11 +296,11 @@ def initialize(record, column, options={})
end
def write_identifier
- if remove?
- record.write_uploader(serialization_column, '')
- elsif not uploader.identifier.blank?
- record.write_uploader(serialization_column, uploader.identifier)
- end
+ return if record.frozen? || uploader.identifier.blank?
+
+ value = remove? ? '' : uploader.identifier
+
+ record.write_uploader(serialization_column, value)
end
def identifier
@@ -419,6 +419,20 @@ def download! file
describe '#destroy' do
+ it "should not raise an error with a custom filename" do
+ @uploader.class_eval do
+ def filename
+ "page.jpeg"
+ end
+ end
+
+ @event.image = stub_file('test.jpeg')
+ @event.save.should be_true
+ expect {
+ @event.destroy
+ }.to_not raise_error
+ end
+
it "should do nothing when no file has been assigned" do
@event.save.should be_true
@event.destroy

0 comments on commit d91ad98

Please sign in to comment.