aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/associations_test.rb
diff options
context:
space:
mode:
authorFlorian Weber <csshsh@gmail.com>2005-11-23 21:03:25 +0000
committerFlorian Weber <csshsh@gmail.com>2005-11-23 21:03:25 +0000
commitc66ac2102be2d7a53872c7bb96939f616275010e (patch)
tree039951a6c2afcc30d5ebafd665d0d4df5d20993f /activerecord/test/associations_test.rb
parent202e4208c4d26f05ea856dbd57f4843ee3a7db29 (diff)
downloadrails-c66ac2102be2d7a53872c7bb96939f616275010e.tar.gz
rails-c66ac2102be2d7a53872c7bb96939f616275010e.tar.bz2
rails-c66ac2102be2d7a53872c7bb96939f616275010e.zip
Fixed bug where using update_attribute after pushing a record to a habtm association of the object caused duplicate rows in the join table. #2888
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_test.rb')
-rwxr-xr-xactiverecord/test/associations_test.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index ef2872e13c..df53118040 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -1397,5 +1397,14 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
assert developer.special_projects.include?(special_project)
assert !developer.special_projects.include?(other_project)
end
-
+
+ def test_update_attributes_after_push_without_duplicate_join_table_rows
+ developer = Developer.new("name" => "Kano")
+ project = SpecialProject.create("name" => "Special Project")
+ assert developer.save
+ developer.projects << project
+ developer.update_attribute("name", "Bruza")
+ assert_equal "1", developer.connection.select_one("SELECT count(*) FROM developers_projects WHERE
+ project_id = #{project.id} AND developer_id = #{developer.id}")["count(*)"]
+ end
end