aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/timestamp_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-09 17:25:20 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-09 17:27:32 -0300
commitdddbccb25a709e1897326e2a25d37da83bbfd717 (patch)
tree6244e959061c596914dc8505468e48b296e63c40 /activerecord/test/cases/timestamp_test.rb
parent9664661f7b8e916ab2cf3fee1b2d2d2f0b26ceeb (diff)
downloadrails-dddbccb25a709e1897326e2a25d37da83bbfd717.tar.gz
rails-dddbccb25a709e1897326e2a25d37da83bbfd717.tar.bz2
rails-dddbccb25a709e1897326e2a25d37da83bbfd717.zip
Timestamp values should be present on callbacks
This reverts commit dd3ea17191e316aeebddaa7b176f6cfeee7a6365 and add a regression test. Fixes #15418
Diffstat (limited to 'activerecord/test/cases/timestamp_test.rb')
-rw-r--r--activerecord/test/cases/timestamp_test.rb31
1 files changed, 13 insertions, 18 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb
index 77ab427be0..0472246f71 100644
--- a/activerecord/test/cases/timestamp_test.rb
+++ b/activerecord/test/cases/timestamp_test.rb
@@ -71,24 +71,6 @@ class TimestampTest < ActiveRecord::TestCase
assert_equal @previously_updated_at, @developer.updated_at
end
- def test_saving_when_callback_sets_record_timestamps_to_false_doesnt_update_its_timestamp
- klass = Class.new(Developer) do
- before_update :cancel_record_timestamps
- def cancel_record_timestamps
- self.record_timestamps = false
- return true
- end
- end
-
- developer = klass.first
- previously_updated_at = developer.updated_at
-
- developer.name = "New Name"
- developer.save!
-
- assert_equal previously_updated_at, developer.updated_at
- end
-
def test_touching_an_attribute_updates_timestamp
previously_created_at = @developer.created_at
@developer.touch(:created_at)
@@ -399,6 +381,19 @@ class TimestampTest < ActiveRecord::TestCase
assert_not_equal time, pet.updated_at
end
+ def test_timestamp_column_values_are_present_in_the_callbacks
+ klass = Class.new(ActiveRecord::Base) do
+ self.table_name = 'people'
+
+ before_create do
+ self.born_at = self.created_at
+ end
+ end
+
+ person = klass.create first_name: 'David'
+ assert_not_equal person.born_at, nil
+ end
+
def test_timestamp_attributes_for_create
toy = Toy.first
assert_equal [:created_at, :created_on], toy.send(:timestamp_attributes_for_create)