Commit 9ad074a0 by Prem Sichanugrist

Convert style name to symbol for the interpolator

Fixes #745
parent 7045e297
...@@ -93,7 +93,7 @@ module Paperclip ...@@ -93,7 +93,7 @@ module Paperclip
# If the style has a format defined, it will return the format instead # If the style has a format defined, it will return the format instead
# of the actual extension. # of the actual extension.
def extension attachment, style_name def extension attachment, style_name
((style = attachment.styles[style_name]) && style[:format]) || ((style = attachment.styles[style_name.to_sym]) && style[:format]) ||
File.extname(attachment.original_filename).gsub(/^\.+/, "") File.extname(attachment.original_filename).gsub(/^\.+/, "")
end end
......
...@@ -46,8 +46,11 @@ class InterpolationsTest < Test::Unit::TestCase ...@@ -46,8 +46,11 @@ class InterpolationsTest < Test::Unit::TestCase
should "return the extension of the file as the format if 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).twice.returns({:style => {:format => "png"}})
assert_equal "png", Paperclip::Interpolations.extension(attachment, :style)
[:style, 'style'].each do |style|
assert_equal "png", Paperclip::Interpolations.extension(attachment, style)
end
end end
should "return the extension of the file based on the content type" do should "return the extension of the file based on the content type" do
......
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