Skip to content

Commit 311ea94

Browse files
Jakub Kuźmajosevalim
Jakub Kuźma
authored andcommitted
added failing touch propagation test
Signed-off-by: José Valim <[email protected]>
1 parent 3b44b52 commit 311ea94

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

activerecord/test/cases/timestamp_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,21 @@ def test_saving_a_record_with_a_belongs_to_that_specifies_touching_a_specific_at
8282
ensure
8383
Pet.belongs_to :owner, :touch => true
8484
end
85+
86+
def test_touching_a_record_touches_parent_record_and_grandparent_record
87+
Toy.belongs_to :pet, :touch => true
88+
Pet.belongs_to :owner, :touch => true
89+
90+
toy = Toy.first
91+
pet = toy.pet
92+
owner = pet.owner
93+
94+
previously_owner_updated_at = owner.updated_at
95+
96+
toy.touch
97+
98+
assert_not_equal previously_owner_updated_at, owner.updated_at
99+
ensure
100+
Toy.belongs_to :pet
101+
end
85102
end

activerecord/test/schema/schema.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ def create_table(*args, &block)
398398
create_table :pets, :primary_key => :pet_id ,:force => true do |t|
399399
t.string :name
400400
t.integer :owner_id, :integer
401+
t.timestamps
401402
end
402403

403404
create_table :pirates, :force => true do |t|
@@ -530,6 +531,7 @@ def create_table(*args, &block)
530531
create_table :toys, :primary_key => :toy_id ,:force => true do |t|
531532
t.string :name
532533
t.integer :pet_id, :integer
534+
t.timestamps
533535
end
534536

535537
create_table :traffic_lights, :force => true do |t|

0 commit comments

Comments
 (0)