Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 3d4ede2959e04b4d6e4c932947ea99758b6d73cd 2 parents 8795ac5 + b89553c
@carlosantoniodasilva carlosantoniodasilva authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 activerecord/test/cases/associations/join_model_test.rb
View
20 activerecord/test/cases/associations/join_model_test.rb
@@ -581,6 +581,26 @@ def test_deleting_junk_from_has_many_through_should_raise_type_mismatch
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
Please sign in to comment.
Something went wrong with that request. Please try again.