diff --git a/lib/draper/decoratable.rb b/lib/draper/decoratable.rb index 3707134a..4876ddaa 100644 --- a/lib/draper/decoratable.rb +++ b/lib/draper/decoratable.rb @@ -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. diff --git a/spec/draper/decoratable_spec.rb b/spec/draper/decoratable_spec.rb index df3e033a..2566e0c9 100644 --- a/spec/draper/decoratable_spec.rb +++ b/spec/draper/decoratable_spec.rb @@ -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) diff --git a/spec/generators/decorator/decorator_generator_spec.rb b/spec/generators/decorator/decorator_generator_spec.rb index daf7f29b..271063fb 100644 --- a/spec/generators/decorator/decorator_generator_spec.rb +++ b/spec/generators/decorator/decorator_generator_spec.rb @@ -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") }