aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/timestamp_test.rb
diff options
context:
space:
mode:
authortnp <tnp@cruzio.com>2010-09-24 10:35:35 -0700
committerJosé Valim <jose.valim@gmail.com>2010-09-24 20:42:38 +0200
commit55b6fa9370dbdac23b0df2bbcb70b2e2d604b410 (patch)
tree8183e0695cb21f3df8cc701bc0049463712e2ede /activerecord/test/cases/timestamp_test.rb
parent8d30193b08bd2321a7a78a1f481bd5e4d4d45557 (diff)
downloadrails-55b6fa9370dbdac23b0df2bbcb70b2e2d604b410.tar.gz
rails-55b6fa9370dbdac23b0df2bbcb70b2e2d604b410.tar.bz2
rails-55b6fa9370dbdac23b0df2bbcb70b2e2d604b410.zip
restore behavior of touch for models without :updated_xx [#5439 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/cases/timestamp_test.rb')
-rw-r--r--activerecord/test/cases/timestamp_test.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb
index db7accfc40..eb93761fb2 100644
--- a/activerecord/test/cases/timestamp_test.rb
+++ b/activerecord/test/cases/timestamp_test.rb
@@ -4,14 +4,14 @@ require 'models/owner'
require 'models/pet'
require 'models/toy'
require 'models/car'
+require 'models/task'
class TimestampTest < ActiveRecord::TestCase
- fixtures :developers, :owners, :pets, :toys, :cars
+ fixtures :developers, :owners, :pets, :toys, :cars, :tasks
def setup
@developer = Developer.first
@previously_updated_at = @developer.updated_at
- @car = Car.first
end
def test_saving_a_changed_record_updates_its_timestamp
@@ -50,7 +50,7 @@ class TimestampTest < ActiveRecord::TestCase
Developer.record_timestamps = true
end
- def test_touching_a_different_attribute
+ def test_touching_an_attribute_updates_timestamp
previously_created_at = @developer.created_at
@developer.touch(:created_at)
@@ -60,8 +60,16 @@ class TimestampTest < ActiveRecord::TestCase
assert_not_equal @previously_updated_at, @developer.updated_at
end
- def test_touch_a_record_without_timestamps
- assert_nothing_raised { @car.touch }
+ def test_touching_an_attribute_updates_it
+ task = Task.first
+ previous_value = task.ending
+ task.touch(:ending)
+ assert_not_equal previous_value, task.ending
+ assert_in_delta Time.now, task.ending, 1
+ end
+
+ def test_touching_a_record_without_timestamps_is_unexceptional
+ assert_nothing_raised { Car.first.touch }
end
def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at