Skip to content

Commit

Permalink
Fixed a bug where #class scanning would error on the Interpolations m…
Browse files Browse the repository at this point in the history
…odule
  • Loading branch information
Jon Yurek committed Aug 21, 2009
1 parent 4f9ffb8 commit 7ccefc2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/paperclip/interpolations.rb
Expand Up @@ -63,7 +63,10 @@ def rails_env attachment, style

# Returns the underscored, pluralized version of the class name.
# e.g. "users" for the User class.
def class attachment, style
# NOTE: The arguments need to be optional, because some tools fetch
# all class names. Calling #class will return the expected class.
def class attachment = nil, style = nil
return super() if attachment.nil? && style.nil?
attachment.instance.class.to_s.underscore.pluralize
end

Expand Down
4 changes: 4 additions & 0 deletions test/interpolations_test.rb
Expand Up @@ -19,6 +19,10 @@ class InterpolationsTest < Test::Unit::TestCase
assert_equal RAILS_ENV, Paperclip::Interpolations.rails_env(:attachment, :style)
end

should "return the class of the Interpolations module when called with no params" do
assert_equal Module, Paperclip::Interpolations.class
end

should "return the class of the instance" do
attachment = mock
attachment.expects(:instance).returns(attachment)
Expand Down

0 comments on commit 7ccefc2

Please sign in to comment.