Commit 9ad074a0 by Prem Sichanugrist

Convert style name to symbol for the interpolator

Fixes #745
parent 7045e297
......@@ -93,7 +93,7 @@ module Paperclip
# If the style has a format defined, it will return the format instead
# of the actual extension.
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(/^\.+/, "")
end
......
......@@ -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
attachment = mock
attachment.expects(:original_filename).never
attachment.expects(:styles).returns({:style => {:format => "png"}})
assert_equal "png", Paperclip::Interpolations.extension(attachment, :style)
attachment.expects(:styles).twice.returns({:style => {:format => "png"}})
[:style, 'style'].each do |style|
assert_equal "png", Paperclip::Interpolations.extension(attachment, style)
end
end
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