Commit a1d03756 by Mark Van Holstyn

Make sure paths with multiple .'s work properly

parent 1fcf1d7e
......@@ -137,7 +137,7 @@ module Paperclip
attachment.instance.class.name.underscore.pluralize
end,
:basename => lambda do |attachment,style|
attachment.original_filename.gsub(/\.(.*?)$/, "")
attachment.original_filename.gsub(File.extname(attachment.original_filename), "")
end,
:extension => lambda do |attachment,style|
((style = attachment.styles[style]) && style.last) ||
......
......@@ -111,6 +111,15 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal "/tests/blah/missing.png", @attachment.url(:blah)
end
should "return the proper path when filename has a single .'s" do
assert_equal "./test/../tmp/tests/dummies/original/41/5k.png", @attachment.path
end
should "return the proper path when filename has multiple .'s" do
@instance.stubs(:[]).with(:test_file_name).returns("5k.old.png")
assert_equal "./test/../tmp/tests/dummies/original/41/5k.old.png", @attachment.path
end
context "when expecting three styles" do
setup do
styles = {:styles => { :large => ["400x400", :png],
......
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