From 1dad1b6c6de53910c110d79800bd2c6ebc7f2c10 Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Sat, 25 Sep 2010 19:17:58 -0400 Subject: [PATCH] Update docs around belongs_to with :touch => true to match what code actually does, test case to ensure documented behavior doesn't change. --- activerecord/lib/active_record/associations.rb | 2 +- activerecord/test/cases/timestamp_test.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletions(-) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 3a32581..2654088 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1022,7 +1022,7 @@ module ActiveRecord # If true, always save the associated object or destroy it if marked for destruction, when saving the parent object. Off by default. # [:touch] # If true, the associated object will be touched (the updated_at/on attributes set to now) when this record is either saved or - # destroyed. If you specify a symbol, that attribute will be updated with the current time instead of the updated_at/on attribute. + # destroyed. If you specify a symbol, that attribute will be updated with the current time in addition to the updated_at/on attribute. # # Option examples: # belongs_to :firm, :foreign_key => "client_of" diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index 24b237a..9705c22 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -72,4 +72,18 @@ class TimestampTest < ActiveRecord::TestCase ensure Pet.belongs_to :owner, :touch => true end + + def test_saving_a_record_with_a_belongs_to_that_specifies_touching_a_specific_attribute_the_parent_should_still_update_the_parent_updated_at + Pet.belongs_to :owner, :touch => :happy_at + + pet = Pet.first + owner = pet.owner + previously_owner_updated_at = owner.updated_at + + pet.destroy + + assert previously_owner_updated_at != pet.owner.updated_at + ensure + Pet.belongs_to :owner, :touch => true + end end \ No newline at end of file -- 1.6.4.2