Commit 6459f2c0 by Jon Yurek

Refactoring of previous commit

parent 9a3f9f8b
......@@ -51,8 +51,8 @@ module Paperclip
end
def definitions_for(klass)
klass.ancestors.each_with_object({}) do |k, obj|
obj.merge! @attachments[k]
klass.ancestors.each_with_object({}) do |ancestor, inherited_definitions|
inherited_definitions.merge! @attachments[ancestor]
end
end
end
......
......@@ -64,15 +64,12 @@ class AttachmentRegistryTest < Test::Unit::TestCase
end
should "produce defintions for subclasses" do
expected_definitions = {
avatar: { yo: 'greeting' }
}
foo = Class.new
bar = Class.new(foo)
Paperclip::AttachmentRegistry.register(foo, :avatar, { yo: 'greeting' })
expected_definitions = { avatar: { yo: 'greeting' } }
Foo = Class.new
Bar = Class.new(Foo)
Paperclip::AttachmentRegistry.register(Foo, :avatar, expected_definitions[:avatar])
definitions = Paperclip::AttachmentRegistry.definitions_for(bar)
definitions = Paperclip::AttachmentRegistry.definitions_for(Bar)
assert_equal expected_definitions, definitions
end
......
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