Commit dca87ec5 by Jonathan Lim Committed by Jon Yurek

Allow #original_filename= to receive nil argument

parent ad23a0f8
...@@ -20,6 +20,7 @@ module Paperclip ...@@ -20,6 +20,7 @@ module Paperclip
end end
def original_filename=(new_filename) def original_filename=(new_filename)
return unless new_filename
@original_filename = new_filename.gsub(OS_RESTRICTED_CHARACTERS, "_") @original_filename = new_filename.gsub(OS_RESTRICTED_CHARACTERS, "_")
end end
......
...@@ -67,4 +67,11 @@ describe Paperclip::AbstractAdapter do ...@@ -67,4 +67,11 @@ describe Paperclip::AbstractAdapter do
@adapter.original_filename = "file.png" @adapter.original_filename = "file.png"
expect(@adapter.send(:destination).path).to end_with(".png") expect(@adapter.send(:destination).path).to end_with(".png")
end end
context "#original_filename=" do
it "should not fail with a nil original filename" do
adapter = TestAdapter.new
expect{ adapter.original_filename = nil }.not_to raise_error
end
end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment