From 597fbdf0c80583f5ea6df9f7350fefeaa0cca989 Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Tue, 11 Dec 2012 19:49:39 +0000 Subject: [PATCH] Decorate empty collections --- lib/draper/decorated_association.rb | 2 +- spec/draper/decorated_association_spec.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/draper/decorated_association.rb b/lib/draper/decorated_association.rb index 4bede83..f1771fa 100644 --- a/lib/draper/decorated_association.rb +++ b/lib/draper/decorated_association.rb @@ -10,7 +10,7 @@ module Draper end def call - return undecorated if undecorated.nil? || undecorated == [] + return undecorated if undecorated.nil? decorate end diff --git a/spec/draper/decorated_association_spec.rb b/spec/draper/decorated_association_spec.rb index f48a8af..46471e2 100644 --- a/spec/draper/decorated_association_spec.rb +++ b/spec/draper/decorated_association_spec.rb @@ -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