diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-05-13 23:48:36 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-13 23:48:36 +0900 |
commit | 3b2ba908bad6962be8b1b0c368a97721dc864eb4 (patch) | |
tree | ed378d749fa4a075f5e380b1b05a82ffe4697fb8 /activerecord/test/cases/associations | |
parent | 9854efd5ac6a05555cc73b21c98c37252eaef0a6 (diff) | |
parent | dcb825902d79d0f6baba956f7c6ec5767611353e (diff) | |
download | rails-3b2ba908bad6962be8b1b0c368a97721dc864eb4.tar.gz rails-3b2ba908bad6962be8b1b0c368a97721dc864eb4.tar.bz2 rails-3b2ba908bad6962be8b1b0c368a97721dc864eb4.zip |
Merge pull request #36271 from kamipo/dont_track_implicit_touch_mutation
Don't track implicit `touch` mutation
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 32285f269a..9869657961 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -2711,18 +2711,22 @@ class HasManyAssociationsTest < ActiveRecord::TestCase bulb = Bulb.create! tyre = Tyre.create! - car = Car.create! do |c| + car = Car.create!(name: "honda") do |c| c.bulbs << bulb c.tyres << tyre end + assert_equal [nil, "honda"], car.saved_change_to_name + assert_equal 1, car.bulbs.count assert_equal 1, car.tyres.count end test "associations replace in memory when records have the same id" do bulb = Bulb.create! - car = Car.create!(bulbs: [bulb]) + car = Car.create!(name: "honda", bulbs: [bulb]) + + assert_equal [nil, "honda"], car.saved_change_to_name new_bulb = Bulb.find(bulb.id) new_bulb.name = "foo" @@ -2733,7 +2737,9 @@ class HasManyAssociationsTest < ActiveRecord::TestCase test "in memory replacement executes no queries" do bulb = Bulb.create! - car = Car.create!(bulbs: [bulb]) + car = Car.create!(name: "honda", bulbs: [bulb]) + + assert_equal [nil, "honda"], car.saved_change_to_name new_bulb = Bulb.find(bulb.id) @@ -2765,7 +2771,9 @@ class HasManyAssociationsTest < ActiveRecord::TestCase test "in memory replacements sets inverse instance" do bulb = Bulb.create! - car = Car.create!(bulbs: [bulb]) + car = Car.create!(name: "honda", bulbs: [bulb]) + + assert_equal [nil, "honda"], car.saved_change_to_name new_bulb = Bulb.find(bulb.id) car.bulbs = [new_bulb] @@ -2785,7 +2793,9 @@ class HasManyAssociationsTest < ActiveRecord::TestCase test "in memory replacement maintains order" do first_bulb = Bulb.create! second_bulb = Bulb.create! - car = Car.create!(bulbs: [first_bulb, second_bulb]) + car = Car.create!(name: "honda", bulbs: [first_bulb, second_bulb]) + + assert_equal [nil, "honda"], car.saved_change_to_name same_bulb = Bulb.find(first_bulb.id) car.bulbs = [second_bulb, same_bulb] |