Optimize impressionist_count query via arel count with distinct option

This commit is contained in:
Ross Kaffenberger committed 2012-03-19 18:27:41 -04:00
1 parent 594889a3db
commit fcfacdfdc9
2 files changed
+2 -5

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ describe Impression do
describe "#update_counter_cache" do
it "should update the counter cache column to reflect the correct number of impressions" do
lambda {
Impression.create(:impressionable_type => @widget.class.name, :impressionable_id => @widget.id)
@widget.impressions.create(:request_hash => 'abcd1234')
@widget.reload
}.should change(@widget, :impressions_count).from(0).to(1)
end