Skip to content
Browse files

Use 'count' to get item count because it performs SELECT COUNT(*) ins…

…tead of instantiating objects and then counting them.
  • Loading branch information...
1 parent 3ae996c commit 91a90162a1f984f22e82a1d473b75d34d4178dc2 @ugisozols ugisozols committed Jul 12, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 spec/models/refinery/news/item_spec.rb
View
6 spec/models/refinery/news/item_spec.rb
@@ -16,7 +16,7 @@ module News
5.times { Factory(:news_item, :publish_date => publish_date) }
5.times { Factory(:news_item, :publish_date => future_date) }
- Refinery::News::Item.by_archive(archive_range).length.should == 5
+ Refinery::News::Item.by_archive(archive_range).count.should == 5
end
end
@@ -84,12 +84,12 @@ module News
5.times { Factory(:news_item, :publish_date => Time.now + 1.hour) }
Refinery::News::Item.latest.count.should == 5
7.times { Factory(:news_item) }
- Refinery::News::Item.latest.length.should == 10
+ Refinery::News::Item.latest.count.should == 10
end
it "returns latest n news items" do
4.times { Factory(:news_item) }
- Refinery::News::Item.latest(3).length.should == 3
+ Refinery::News::Item.latest(3).count.should == 3
end
end

0 comments on commit 91a9016

Please sign in to comment.
Something went wrong with that request. Please try again.