aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/counter_cache_test.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-03-15 11:22:01 +0100
committerYves Senn <yves.senn@gmail.com>2013-03-15 11:22:01 +0100
commitb601399b72ab56cc01368f02615af99f45d14f02 (patch)
treebe99d39ad7a99fd103f9625e2429111b1f8c2e1b /activerecord/test/cases/counter_cache_test.rb
parentddb9040b433b00aa0206442aa718eee12bceb517 (diff)
downloadrails-b601399b72ab56cc01368f02615af99f45d14f02.tar.gz
rails-b601399b72ab56cc01368f02615af99f45d14f02.tar.bz2
rails-b601399b72ab56cc01368f02615af99f45d14f02.zip
`#reset_counters` verifies counter names.
Closes #9724. Raise an `ArgumentError` when the name of the counter does not match an association name.
Diffstat (limited to 'activerecord/test/cases/counter_cache_test.rb')
-rw-r--r--activerecord/test/cases/counter_cache_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/counter_cache_test.rb b/activerecord/test/cases/counter_cache_test.rb
index fc46a249c8..7de2ceae88 100644
--- a/activerecord/test/cases/counter_cache_test.rb
+++ b/activerecord/test/cases/counter_cache_test.rb
@@ -131,4 +131,11 @@ class CounterCacheTest < ActiveRecord::TestCase
Subscriber.reset_counters(subscriber.id, 'books')
end
end
+
+ test "the passed symbol needs to be an association name" do
+ e = assert_raises(ArgumentError) do
+ Topic.reset_counters(@topic.id, :replies_count)
+ end
+ assert_equal "'Topic' has no association called 'replies_count'", e.message
+ end
end