aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-28 22:31:41 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-28 22:31:41 -0500
commitb89553cf41e3376d46f43dafcaed99df3f7721d3 (patch)
tree19941da2bc7f03250e5a2f99480041686f9bf309 /activerecord
parent8795ac52978464805f4759f2769bafca1c02c9ff (diff)
downloadrails-b89553cf41e3376d46f43dafcaed99df3f7721d3.tar.gz
rails-b89553cf41e3376d46f43dafcaed99df3f7721d3.tar.bz2
rails-b89553cf41e3376d46f43dafcaed99df3f7721d3.zip
Add tests to delete by fixnum or string id with has many through associations
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/associations/join_model_test.rb20
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