diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-11-30 02:42:43 -0800 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-11-30 02:42:43 -0800 |
commit | 61ad8d5c32422c523293428d25277be1759b597c (patch) | |
tree | febfdcc97db26bbfc5cef3cc887957b5c4eb89ab /activerecord/test | |
parent | 31c20a244b7e9a284d45d7aaa56f6e5277810418 (diff) | |
parent | 35fd2d401938df1afc595de9b87dadd4421f44a5 (diff) | |
download | rails-61ad8d5c32422c523293428d25277be1759b597c.tar.gz rails-61ad8d5c32422c523293428d25277be1759b597c.tar.bz2 rails-61ad8d5c32422c523293428d25277be1759b597c.zip |
Merge pull request #13107 from chancancode/has_one_counter_cache_should_raise
Raise `ArgumentError` when `has_one` is used with `counter_cache`
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_one_associations_test.rb | 8 | ||||
-rw-r--r-- | activerecord/test/cases/associations/has_one_through_associations_test.rb | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index 1f78c73f71..5a41461edf 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -549,4 +549,12 @@ class HasOneAssociationsTest < ActiveRecord::TestCase assert_not_nil author.post assert_equal author.post, post end + + def test_has_one_relationship_cannot_have_a_counter_cache + assert_raise(ArgumentError) do + Class.new(ActiveRecord::Base) do + has_one :thing, counter_cache: true + end + end + end end diff --git a/activerecord/test/cases/associations/has_one_through_associations_test.rb b/activerecord/test/cases/associations/has_one_through_associations_test.rb index f2723f2e18..a2725441b3 100644 --- a/activerecord/test/cases/associations/has_one_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb @@ -315,4 +315,12 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase def test_has_one_through_with_custom_select_on_join_model_default_scope assert_equal clubs(:boring_club), members(:groucho).selected_club end + + def test_has_one_through_relationship_cannot_have_a_counter_cache + assert_raise(ArgumentError) do + Class.new(ActiveRecord::Base) do + has_one :thing, through: :other_thing, counter_cache: true + end + end + end end |