diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-08-14 12:11:44 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-08-14 12:11:44 +0200 |
commit | 76b587880ed411cd7d4168954ffa673eadcb1073 (patch) | |
tree | 922ec203a3c9179bfe3a30293aefff0850d55898 /activerecord/test | |
parent | 76ea9f9714ff08cfffec16fc3672480a9f46f5d9 (diff) | |
parent | b892d20c610af78a94ba6c9488092ef76845242a (diff) | |
download | rails-76b587880ed411cd7d4168954ffa673eadcb1073.tar.gz rails-76b587880ed411cd7d4168954ffa673eadcb1073.tar.bz2 rails-76b587880ed411cd7d4168954ffa673eadcb1073.zip |
Merge pull request #8813 from greyblake/dont_write_timestamps_if_they_are_not_attributes
Write timestamps only if there are timestamps columns
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/timestamp_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index 0472246f71..abf6becc17 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -1,4 +1,5 @@ require 'cases/helper' +require 'support/ddl_helper' require 'models/developer' require 'models/owner' require 'models/pet' @@ -424,3 +425,21 @@ class TimestampTest < ActiveRecord::TestCase assert_equal [:created_at, :updated_at], toy.send(:all_timestamp_attributes_in_model) end end + +class TimestampsWithoutTransactionTest < ActiveRecord::TestCase + include DdlHelper + self.use_transactional_fixtures = false + + class TimestampAttributePost < ActiveRecord::Base + attr_accessor :created_at, :updated_at + end + + def test_do_not_write_timestamps_on_save_if_they_are_not_attributes + with_example_table ActiveRecord::Base.connection, "timestamp_attribute_posts", "id integer primary key" do + post = TimestampAttributePost.new(id: 1) + post.save! # should not try to assign and persist created_at, updated_at + assert_nil post.created_at + assert_nil post.updated_at + end + end +end |