Decorate empty collections
This commit is contained in:
parent
7efeaa492b
commit
597fbdf0c8
|
@ -10,7 +10,7 @@ module Draper
|
|||
end
|
||||
|
||||
def call
|
||||
return undecorated if undecorated.nil? || undecorated == []
|
||||
return undecorated if undecorated.nil?
|
||||
decorate
|
||||
end
|
||||
|
||||
|
|
|
@ -22,10 +22,11 @@ describe Draper::DecoratedAssociation do
|
|||
end
|
||||
|
||||
context "when the association is empty" do
|
||||
it "doesn't decorate the collection" do
|
||||
it "returns an empty collection decorator" do
|
||||
source.stub(:similar_products).and_return([])
|
||||
subject.should_not be_a Draper::CollectionDecorator
|
||||
subject.should be_a Draper::CollectionDecorator
|
||||
subject.should be_empty
|
||||
subject.first.should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -44,10 +45,11 @@ describe Draper::DecoratedAssociation do
|
|||
end
|
||||
|
||||
context "when the association is empty" do
|
||||
it "doesn't decorate the collection" do
|
||||
it "returns an empty collection decorator" do
|
||||
source.stub(:poro_similar_products).and_return([])
|
||||
subject.should_not be_a Draper::CollectionDecorator
|
||||
subject.should be_a Draper::CollectionDecorator
|
||||
subject.should be_empty
|
||||
subject.first.should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue