Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added failing touch propagation test

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 311ea94f73c95be87f9a474da122719eebee3f98 1 parent 3b44b52
@qoobaa qoobaa authored josevalim committed
View
17 activerecord/test/cases/timestamp_test.rb
@@ -82,4 +82,21 @@ def test_saving_a_record_with_a_belongs_to_that_specifies_touching_a_specific_at
ensure
Pet.belongs_to :owner, :touch => true
end
+
+ def test_touching_a_record_touches_parent_record_and_grandparent_record
+ Toy.belongs_to :pet, :touch => true
+ Pet.belongs_to :owner, :touch => true
+
+ toy = Toy.first
+ pet = toy.pet
+ owner = pet.owner
+
+ previously_owner_updated_at = owner.updated_at
+
+ toy.touch
+
+ assert_not_equal previously_owner_updated_at, owner.updated_at
+ ensure
+ Toy.belongs_to :pet
+ end
end
View
2  activerecord/test/schema/schema.rb
@@ -398,6 +398,7 @@ def create_table(*args, &block)
create_table :pets, :primary_key => :pet_id ,:force => true do |t|
t.string :name
t.integer :owner_id, :integer
+ t.timestamps
end
create_table :pirates, :force => true do |t|
@@ -530,6 +531,7 @@ def create_table(*args, &block)
create_table :toys, :primary_key => :toy_id ,:force => true do |t|
t.string :name
t.integer :pet_id, :integer
+ t.timestamps
end
create_table :traffic_lights, :force => true do |t|
Please sign in to comment.
Something went wrong with that request. Please try again.