diff options
author | Mehmet Emin İNAÇ <mehmetemininac@gmail.com> | 2015-04-14 22:50:36 +0300 |
---|---|---|
committer | Mehmet Emin İNAÇ <mehmetemininac@gmail.com> | 2016-02-13 17:21:25 +0200 |
commit | 9991f14fced25dac3699b473a05cc7a196f9220e (patch) | |
tree | daace2e77f5c88e29f7e8fda85cc9cbd4b6fdcb6 /activerecord/test/cases/associations | |
parent | 7ee2002008eb7bd4546f556670f5332f06901a0d (diff) | |
download | rails-9991f14fced25dac3699b473a05cc7a196f9220e.tar.gz rails-9991f14fced25dac3699b473a05cc7a196f9220e.tar.bz2 rails-9991f14fced25dac3699b473a05cc7a196f9220e.zip |
Fix for has_and_belongs_to_many & has_many_through associations while partial_writes is false
This will fix #19663
Also with this fix, active record does not fire unnecassary update queries while partial_writes is true
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index 5c4586da19..cab9dff6ca 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -982,4 +982,17 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase Project.first.developers_required_by_default.create!(name: "Sean", salary: 50000) end end + + def test_has_and_belongs_to_many_while_partial_writes_false + begin + original_partial_writes = ActiveRecord::Base.partial_writes + ActiveRecord::Base.partial_writes = false + developer = Developer.new(name: "Mehmet Emin İNAÇ") + developer.projects << Project.new(name: "Bounty") + + assert developer.save + ensure + ActiveRecord::Base.partial_writes = original_partial_writes + end + end end |