aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-10 09:25:33 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-10 15:05:02 -0300
commit2e000743801359c37e80cb2cc68ef5c4721ef780 (patch)
tree6123e5980b18e0beab423c16a370c0a24cf04f06 /activerecord/test
parentae2383d90a9646e36c8b5d92801fba284ea62ec0 (diff)
downloadrails-2e000743801359c37e80cb2cc68ef5c4721ef780.tar.gz
rails-2e000743801359c37e80cb2cc68ef5c4721ef780.tar.bz2
rails-2e000743801359c37e80cb2cc68ef5c4721ef780.zip
Merge pull request #7286 from kennyj/fix_7191
Fix #7191. Remove unnecessary transaction when assigning has_one associations. Conflicts: activerecord/test/cases/associations/has_one_associations_test.rb
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index 3ce87df126..08831a42ba 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -472,4 +472,17 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
assert_equal car.id, bulb.attributes_after_initialize['car_id']
end
+
+ def test_has_one_transaction
+ company = companies(:first_firm)
+ account = Account.find(1)
+
+ company.account # force loading
+ assert_no_queries { company.account = account }
+
+ company.account = nil
+ assert_no_queries { company.account = nil }
+ account = Account.find(2)
+ assert_queries { company.account = account }
+ end
end