File tree 2 files changed +11
-5
lines changed
2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,11 @@ def decorator
59
59
attr_reader :decorator_class , :source
60
60
61
61
def source_decorator
62
- -> ( source , options ) { source . decorate ( options ) }
62
+ if collection?
63
+ -> ( source , options ) { source . decorator_class . decorate_collection ( source , options . reverse_merge ( with : nil ) ) }
64
+ else
65
+ -> ( source , options ) { source . decorate ( options ) }
66
+ end
63
67
end
64
68
65
69
def decorator_method ( klass )
Original file line number Diff line number Diff line change @@ -213,13 +213,15 @@ module Draper
213
213
214
214
context "when decorator_class is unspecified" do
215
215
context "and the source is decoratable" do
216
- it "returns the source's #decorate method " do
216
+ it "returns the .decorate_collection method from the source's decorator " do
217
217
source = [ ]
218
- options = { foo : "bar" }
218
+ decorator_class = Class . new ( Decorator )
219
+ source . stub decorator_class : decorator_class
220
+ source . stub decorate : nil
219
221
worker = Factory ::Worker . new ( nil , source )
220
222
221
- source . should_receive ( :decorate ) . with ( options ) . and_return ( :decorated )
222
- expect ( worker . decorator . call ( source , options ) ) . to be :decorated
223
+ decorator_class . should_receive ( :decorate_collection ) . with ( source , foo : "bar" , with : nil ) . and_return ( :decorated )
224
+ expect ( worker . decorator . call ( source , foo : "bar" ) ) . to be :decorated
223
225
end
224
226
end
225
227
You can’t perform that action at this time.
0 commit comments