diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-28 21:04:40 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-28 21:04:40 -0700 |
commit | 3d4ede2959e04b4d6e4c932947ea99758b6d73cd (patch) | |
tree | 19941da2bc7f03250e5a2f99480041686f9bf309 | |
parent | 8795ac52978464805f4759f2769bafca1c02c9ff (diff) | |
parent | b89553cf41e3376d46f43dafcaed99df3f7721d3 (diff) | |
download | rails-3d4ede2959e04b4d6e4c932947ea99758b6d73cd.tar.gz rails-3d4ede2959e04b4d6e4c932947ea99758b6d73cd.tar.bz2 rails-3d4ede2959e04b4d6e4c932947ea99758b6d73cd.zip |
Merge pull request #6527 from frodsan/add_test_to_delete_by_fixnum_or_string
Add tests to delete by fixnum or string id with has many through associations
-rw-r--r-- | activerecord/test/cases/associations/join_model_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb index c2f8f1ca8c..783b83631c 100644 --- a/activerecord/test/cases/associations/join_model_test.rb +++ b/activerecord/test/cases/associations/join_model_test.rb @@ -581,6 +581,26 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:thinking).tags.delete(Object.new) } end + def test_deleting_by_fixnum_id_from_has_many_through + post = posts(:thinking) + + assert_difference 'post.tags.count', -1 do + assert_equal 1, post.tags.delete(1).size + end + + assert_equal 0, post.tags.size + end + + def test_deleting_by_string_id_from_has_many_through + post = posts(:thinking) + + assert_difference 'post.tags.count', -1 do + assert_equal 1, post.tags.delete('1').size + end + + assert_equal 0, post.tags.size + end + def test_has_many_through_sum_uses_calculations assert_nothing_raised { authors(:david).comments.sum(:post_id) } end |