From cbe62c03e45afb3249a87e16a76466ffd2f1a81b Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Tue, 12 Feb 2013 08:44:14 +0000 Subject: [PATCH 1/2] Uncomment accidentally-commented line :blush: --- spec/generators/decorator/decorator_generator_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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") } From b156635b1e40af0168d3a90a206da486108b9d49 Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Tue, 12 Feb 2013 08:45:55 +0000 Subject: [PATCH 2/2] Support STI in Decoratable.decorate Closes #468 --- lib/draper/decoratable.rb | 2 +- spec/draper/decoratable_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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)