Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a bug where #class scanning would error on the Interpolations m…

…odule
  • Loading branch information...
commit 7ccefc249ec4b611beaa3cd4d595f786508cdd59 1 parent 4f9ffb8
@jyurek jyurek authored
Showing with 8 additions and 1 deletion.
  1. +4 −1 lib/paperclip/interpolations.rb
  2. +4 −0 test/interpolations_test.rb
View
5 lib/paperclip/interpolations.rb
@@ -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
View
4 test/interpolations_test.rb
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.