Skip to content

Commit

Permalink
Merge pull request #470 from haines/sti
Browse files Browse the repository at this point in the history
Support STI in Decoratable.decorate
  • Loading branch information
steveklabnik committed Feb 12, 2013
2 parents 11bb59b + b156635 commit 7802d97
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 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
2 changes: 1 addition & 1 deletion spec/generators/decorator/decorator_generator_spec.rb
Expand Up @@ -6,7 +6,7 @@
destination File.expand_path("../tmp", __FILE__)

before { prepare_destination }
#after(:all) { FileUtils.rm_rf destination_root }
after(:all) { FileUtils.rm_rf destination_root }

describe "the generated decorator" do
subject { file("app/decorators/your_model_decorator.rb") }
Expand Down

0 comments on commit 7802d97

Please sign in to comment.