Permalink
Browse files

Convert style name to symbol for the interpolator

Fixes #745
  • Loading branch information...
1 parent 7045e29 commit 9ad074a053075a3815f507c796e2597990dbdff6 @sikachu sikachu committed Feb 17, 2012
Showing with 6 additions and 3 deletions.
  1. +1 −1 lib/paperclip/interpolations.rb
  2. +5 −2 test/interpolations_test.rb
@@ -93,7 +93,7 @@ def basename attachment, style_name
# 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"}})
@mike-burns

mike-burns Feb 24, 2012

Owner

Do we need to use a mock instead of a stub here?

+
+ [: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

0 comments on commit 9ad074a

Please sign in to comment.