aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/timestamp_test.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-08-12 14:23:14 -0600
committerSean Griffin <sean@thoughtbot.com>2014-08-12 14:40:11 -0600
commitea3ba34506c72d636096245016b5ef9cfe27c566 (patch)
treedd7f1c1ca5d3afafa56f914556dfe7acc7d6c414 /activerecord/test/cases/adapters/postgresql/timestamp_test.rb
parent82e28492e7c581cdeea904464a18eb11118f4ac0 (diff)
downloadrails-ea3ba34506c72d636096245016b5ef9cfe27c566.tar.gz
rails-ea3ba34506c72d636096245016b5ef9cfe27c566.tar.bz2
rails-ea3ba34506c72d636096245016b5ef9cfe27c566.zip
Change the default `null` value for timestamps
As per discussion, this changes the model generators to specify `null: false` for timestamp columns. A warning is now emitted if `timestamps` is called without a `null` option specified, so we can safely change the behavior when no option is specified in Rails 5.
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/timestamp_test.rb')
-rw-r--r--activerecord/test/cases/adapters/postgresql/timestamp_test.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/timestamp_test.rb b/activerecord/test/cases/adapters/postgresql/timestamp_test.rb
index 3614b29190..eb32c4d2c2 100644
--- a/activerecord/test/cases/adapters/postgresql/timestamp_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/timestamp_test.rb
@@ -87,7 +87,7 @@ class TimestampTest < ActiveRecord::TestCase
def test_timestamps_helper_with_custom_precision
ActiveRecord::Base.connection.create_table(:foos) do |t|
- t.timestamps :precision => 4
+ t.timestamps :null => true, :precision => 4
end
assert_equal 4, activerecord_column_option('foos', 'created_at', 'precision')
assert_equal 4, activerecord_column_option('foos', 'updated_at', 'precision')
@@ -95,7 +95,7 @@ class TimestampTest < ActiveRecord::TestCase
def test_passing_precision_to_timestamp_does_not_set_limit
ActiveRecord::Base.connection.create_table(:foos) do |t|
- t.timestamps :precision => 4
+ t.timestamps :null => true, :precision => 4
end
assert_nil activerecord_column_option("foos", "created_at", "limit")
assert_nil activerecord_column_option("foos", "updated_at", "limit")
@@ -104,14 +104,14 @@ class TimestampTest < ActiveRecord::TestCase
def test_invalid_timestamp_precision_raises_error
assert_raises ActiveRecord::ActiveRecordError do
ActiveRecord::Base.connection.create_table(:foos) do |t|
- t.timestamps :precision => 7
+ t.timestamps :null => true, :precision => 7
end
end
end
def test_postgres_agrees_with_activerecord_about_precision
ActiveRecord::Base.connection.create_table(:foos) do |t|
- t.timestamps :precision => 4
+ t.timestamps :null => true, :precision => 4
end
assert_equal '4', pg_datetime_precision('foos', 'created_at')
assert_equal '4', pg_datetime_precision('foos', 'updated_at')