Commit 7ccefc24 by Jon Yurek

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

parent 4f9ffb85
......@@ -63,7 +63,10 @@ module Paperclip
# 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
......
......@@ -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)
......
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