Commit 65fb9268 by Jon Yurek

Fixed extension interpolation bug when relying on default_style

parent 93073d5f
...@@ -108,7 +108,7 @@ module Paperclip ...@@ -108,7 +108,7 @@ module Paperclip
# file is stored in the filesystem the path refers to the path of the file # file is stored in the filesystem the path refers to the path of the file
# on disk. If the file is stored in S3, the path is the "key" part of the # on disk. If the file is stored in S3, the path is the "key" part of the
# URL, and the :bucket option refers to the S3 bucket. # URL, and the :bucket option refers to the S3 bucket.
def path style = nil #:nodoc: def path style = default_style
original_filename.nil? ? nil : interpolate(@path, style) original_filename.nil? ? nil : interpolate(@path, style)
end end
......
...@@ -114,6 +114,20 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -114,6 +114,20 @@ class AttachmentTest < Test::Unit::TestCase
end end
end end
context "An attachment with a default style and an extension interpolation" do
setup do
@attachment = attachment :path => ":basename.:extension",
:styles => { :default => ["100x100", :png] },
:default_style => :default
@file = StringIO.new("...")
@file.expects(:original_filename).returns("file.jpg")
end
should "return the right extension for the path" do
@attachment.assign(@file)
assert_equal "file.png", @attachment.path
end
end
context "An attachment with :convert_options" do context "An attachment with :convert_options" do
setup do setup do
rebuild_model :styles => { rebuild_model :styles => {
......
...@@ -91,7 +91,7 @@ class FakeModel ...@@ -91,7 +91,7 @@ class FakeModel
@errors ||= [] @errors ||= []
end end
def run_callbacks def run_callbacks name, *args
end end
end end
......
...@@ -39,7 +39,7 @@ class InterpolationsTest < Test::Unit::TestCase ...@@ -39,7 +39,7 @@ class InterpolationsTest < Test::Unit::TestCase
assert_equal "jpg", Paperclip::Interpolations.extension(attachment, :style) assert_equal "jpg", Paperclip::Interpolations.extension(attachment, :style)
end end
should "return the extension of the file as the format is defined in the style" do should "return the extension of the file as the format if defined in the style" do
attachment = mock attachment = mock
attachment.expects(:original_filename).never attachment.expects(:original_filename).never
attachment.expects(:styles).returns({:style => {:format => "png"}}) attachment.expects(:styles).returns({:style => {:format => "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