From a2f26b971bf61263582604ad7e1af14b9566949e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 18 Jun 2005 05:28:59 +0000 Subject: Fixed that adding a record to a has_and_belongs_to collection would always save it -- now it only saves if its a new record #1203 [Alisdair McDiarmid] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1453 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/associations_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'activerecord/test/associations_test.rb') diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index 02212a862b..214b582f56 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -823,6 +823,22 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase assert_equal 2, action_controller.developers(true).size end + def test_adding_from_the_project_fixed_timestamp + jamis = Developer.find(2) + action_controller = Project.find(2) + action_controller.developers.reload + assert_equal 1, jamis.projects.size + assert_equal 1, action_controller.developers.size + updated_at = jamis.updated_at + + action_controller.developers << jamis + + assert_equal updated_at, jamis.updated_at + assert_equal 2, jamis.projects(true).size + assert_equal 2, action_controller.developers.size + assert_equal 2, action_controller.developers(true).size + end + def test_adding_multiple aredridel = Developer.new("name" => "Aredridel") aredridel.save -- cgit v1.2.3