Skip to content

Commit

Permalink
Support STI in Decoratable.decorate
Browse files Browse the repository at this point in the history
Closes #468
  • Loading branch information
haines committed Feb 12, 2013
1 parent cbe62c0 commit b156635
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/draper/decoratable.rb
Expand Up @@ -52,7 +52,7 @@ module ClassMethods
# @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.
Expand Down
4 changes: 2 additions & 2 deletions spec/draper/decoratable_spec.rb
Expand Up @@ -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)
Expand Down

0 comments on commit b156635

Please sign in to comment.