File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -82,4 +82,21 @@ def test_saving_a_record_with_a_belongs_to_that_specifies_touching_a_specific_at
82
82
ensure
83
83
Pet . belongs_to :owner , :touch => true
84
84
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
85
102
end
Original file line number Diff line number Diff line change @@ -398,6 +398,7 @@ def create_table(*args, &block)
398
398
create_table :pets , :primary_key => :pet_id , :force => true do |t |
399
399
t . string :name
400
400
t . integer :owner_id , :integer
401
+ t . timestamps
401
402
end
402
403
403
404
create_table :pirates , :force => true do |t |
@@ -530,6 +531,7 @@ def create_table(*args, &block)
530
531
create_table :toys , :primary_key => :toy_id , :force => true do |t |
531
532
t . string :name
532
533
t . integer :pet_id , :integer
534
+ t . timestamps
533
535
end
534
536
535
537
create_table :traffic_lights , :force => true do |t |
You can’t perform that action at this time.
0 commit comments