aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-07-09 14:11:51 -0400
committerJosé Valim <jose.valim@gmail.com>2010-07-13 07:03:42 +0200
commit1d45ea081493cd4eca95cd75cce7be7b8d9cb07c (patch)
treeebf901a60827701e5e09c45d8d0cd24a4f69967d /activerecord/test/cases
parent2aed63eb526b5493df63151e2bf451d55114c49a (diff)
downloadrails-1d45ea081493cd4eca95cd75cce7be7b8d9cb07c.tar.gz
rails-1d45ea081493cd4eca95cd75cce7be7b8d9cb07c.tar.bz2
rails-1d45ea081493cd4eca95cd75cce7be7b8d9cb07c.zip
with this fix touch method - does not call validations - doest not call callbacks - updates updated_at/on along with attribute if attribute is provided - marks udpated_at/on and attribute as NOT changed
[#2520 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/timestamp_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb
index 549c4af6b1..f765540808 100644
--- a/activerecord/test/cases/timestamp_test.rb
+++ b/activerecord/test/cases/timestamp_test.rb
@@ -25,16 +25,26 @@ class TimestampTest < ActiveRecord::TestCase
end
def test_touching_a_record_updates_its_timestamp
+ previous_salary = @developer.salary
+ @developer.salary = previous_salary + 10000
@developer.touch
assert_not_equal @previously_updated_at, @developer.updated_at
+ assert_equal previous_salary + 10000, @developer.salary
+ assert @developer.salary_changed?, 'developer salary should have changed'
+ assert @developer.changed?, 'developer should be marked as changed'
+ @developer.reload
+ assert_equal previous_salary, @developer.salary
end
def test_touching_a_different_attribute
previously_created_at = @developer.created_at
@developer.touch(:created_at)
+ assert !@developer.created_at_changed? , 'created_at should not be changed'
+ assert !@developer.changed?, 'record should not be changed'
assert_not_equal previously_created_at, @developer.created_at
+ assert_not_equal @previously_updated_at, @developer.updated_at
end
def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at