From fdb61f02c54bda0ad5ff6d0259209113202b9307 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 16 Apr 2009 16:48:07 -0500 Subject: Added ActiveRecord::Base#touch to update the updated_at/on attributes with the current time [DHH] --- activerecord/test/cases/timestamp_test.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 activerecord/test/cases/timestamp_test.rb (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb new file mode 100644 index 0000000000..e5f8fb9c1d --- /dev/null +++ b/activerecord/test/cases/timestamp_test.rb @@ -0,0 +1,30 @@ +require 'cases/helper' +require 'models/developer' + +class TimestampTest < ActiveRecord::TestCase + fixtures :developers + + def setup + @developer = Developer.first + @previously_updated_at = @developer.updated_at + end + + def test_saving_a_changed_record_updates_its_timestamp + @developer.name = "Jack Bauer" + @developer.save! + + assert @previously_updated_at != @developer.updated_at + end + + def test_saving_a_unchanged_record_doesnt_update_its_timestamp + @developer.save! + + assert @previously_updated_at == @developer.updated_at + end + + def test_touching_a_record_updates_its_timestamp + @developer.touch + + assert @previously_updated_at != @developer.updated_at + end +end \ No newline at end of file -- cgit v1.2.3