From f59f897d25d2cf96b29d28360789ad3ce9f0fbc1 Mon Sep 17 00:00:00 2001 From: Ross Kaffenberger Date: Mon, 19 Mar 2012 15:56:42 -0400 Subject: [PATCH] Deprecation warning for counter_caching? --- app/models/impressionist/impressionable.rb | 5 +++++ test_app/spec/models/counter_caching_spec.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/models/impressionist/impressionable.rb b/app/models/impressionist/impressionable.rb index 6143538..5e7508f 100644 --- a/app/models/impressionist/impressionable.rb +++ b/app/models/impressionist/impressionable.rb @@ -17,6 +17,11 @@ module Impressionist def impressionist_counter_caching? impressionist_counter_cache_options.present? end + + def counter_caching? + ::ActiveSupport::Deprecation.warn("#counter_caching? is deprecated; please use #impressionist_counter_caching? instead") + impressionist_counter_caching? + end end def impressionable? diff --git a/test_app/spec/models/counter_caching_spec.rb b/test_app/spec/models/counter_caching_spec.rb index ac7b615..486a90b 100644 --- a/test_app/spec/models/counter_caching_spec.rb +++ b/test_app/spec/models/counter_caching_spec.rb @@ -18,6 +18,19 @@ describe Impression do end end + describe "self#counter_caching?" do + it "should know when counter caching is enabled" do + ActiveSupport::Deprecation.should_receive(:warn) + Widget.should be_counter_caching + end + + it "should know when counter caching is enabled" do + ActiveSupport::Deprecation.should_receive(:warn) + Article.should_not be_counter_caching + end + + end + describe "#update_impressionist_counter_cache" do it "should update the counter cache column to reflect the correct number of impressions" do lambda {