mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Merge pull request #470 from haines/sti
Support STI in Decoratable.decorate
This commit is contained in:
commit
7802d97446
3 changed files with 4 additions and 4 deletions
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -6,7 +6,7 @@ describe Rails::Generators::DecoratorGenerator do
|
|||
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") }
|
||||
|
|
Loading…
Add table
Reference in a new issue