aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJakub Kuźma <qoobaa@gmail.com>2010-08-02 11:07:43 +0200
committerJosé Valim <jose.valim@gmail.com>2010-08-02 15:56:49 +0200
commit311ea94f73c95be87f9a474da122719eebee3f98 (patch)
treeb67e6becc0c08a56956cca8521e1e3bf07e4e056 /activerecord
parent3b44b52fb0f09e437645d12d2feb6b6d37a804ee (diff)
downloadrails-311ea94f73c95be87f9a474da122719eebee3f98.tar.gz
rails-311ea94f73c95be87f9a474da122719eebee3f98.tar.bz2
rails-311ea94f73c95be87f9a474da122719eebee3f98.zip
added failing touch propagation test
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/timestamp_test.rb17
-rw-r--r--activerecord/test/schema/schema.rb2
2 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb
index f765540808..e3d12f6214 100644
--- a/activerecord/test/cases/timestamp_test.rb
+++ b/activerecord/test/cases/timestamp_test.rb
@@ -82,4 +82,21 @@ class TimestampTest < ActiveRecord::TestCase
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
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index f3fd37cd61..a0e620c2ef 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -398,6 +398,7 @@ ActiveRecord::Schema.define do
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 @@ ActiveRecord::Schema.define do
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|