Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Convert style name to symbol for the interpolator
Browse files Browse the repository at this point in the history
Fixes #745
  • Loading branch information
sikachu committed Feb 17, 2012
1 parent 7045e29 commit 9ad074a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/paperclip/interpolations.rb
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions test/interpolations_test.rb
Expand Up @@ -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"}})

This comment has been minimized.

Copy link
@mike-burns

mike-burns Feb 24, 2012

Member

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
Expand Down

0 comments on commit 9ad074a

Please sign in to comment.