aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/associations/join_model_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/associations/join_model_test.rb')
-rw-r--r--activerecord/test/associations/join_model_test.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/activerecord/test/associations/join_model_test.rb b/activerecord/test/associations/join_model_test.rb
index 6b67b15664..0e146f74c4 100644
--- a/activerecord/test/associations/join_model_test.rb
+++ b/activerecord/test/associations/join_model_test.rb
@@ -9,10 +9,12 @@ require 'fixtures/category'
require 'fixtures/categorization'
require 'fixtures/vertex'
require 'fixtures/edge'
+require 'fixtures/book'
+require 'fixtures/citation'
class AssociationsJoinModelTest < Test::Unit::TestCase
self.use_transactional_fixtures = false
- fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites, :vertices, :items
+ fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites, :vertices, :items, :books
def test_has_many
assert authors(:david).categories.include?(categories(:general))
@@ -476,6 +478,20 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
assert_equal tags, posts(:thinking).tags.push(tags(:general))
end
+ def test_delete_associate_when_deleting_from_has_many_through_with_nonstandard_id
+ count = books(:awdr).references.count
+ references_before = books(:awdr).references
+ book = Book.create!(:name => 'Getting Real')
+ book_awdr = books(:awdr)
+ book_awdr.references << book
+ assert_equal(count + 1, book_awdr.references(true).size)
+
+ assert_nothing_raised { book_awdr.references.delete(book) }
+ assert_equal(count, book_awdr.references.size)
+ assert_equal(count, book_awdr.references(true).size)
+ assert_equal(references_before.sort, book_awdr.references.sort)
+ end
+
def test_delete_associate_when_deleting_from_has_many_through
count = posts(:thinking).tags.count
tags_before = posts(:thinking).tags