Support STI in Decoratable.decorate

Closes #468
This commit is contained in:
Andrew Haines 2013-02-12 08:45:55 +00:00
parent cbe62c03e4
commit b156635b1e
2 changed files with 3 additions and 3 deletions

View File

@ -52,7 +52,7 @@ module Draper
# @param [Hash] options
# see {Decorator.decorate_collection}.
def decorate(options = {})
decorator_class.decorate_collection(self.scoped, options)
decorator_class.decorate_collection(scoped, options.reverse_merge(with: nil))
end
# Infers the decorator class to be used by {Decoratable#decorate} (e.g.

View File

@ -112,12 +112,12 @@ module Draper
scoped = [Product.new]
Product.stub scoped: scoped
Product.decorator_class.should_receive(:decorate_collection).with(scoped, {}).and_return(:decorated_collection)
Product.decorator_class.should_receive(:decorate_collection).with(scoped, with: nil).and_return(:decorated_collection)
expect(Product.decorate).to be :decorated_collection
end
it "accepts options" do
options = {context: {some: "context"}}
options = {with: ProductDecorator, context: {some: "context"}}
Product.stub scoped: []
Product.decorator_class.should_receive(:decorate_collection).with([], options)