diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-10-04 17:37:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-04 17:37:04 -0400 |
commit | de9a56b66af928a09f85daf15ffb1c2023a7c1b8 (patch) | |
tree | f3ec18064c3b14d3b8448b3a35e0e69550bac67c /activerecord | |
parent | 4d6feef79248a63c4cefde3f9ceb2242925e8d8d (diff) | |
parent | 26fe640c9ae644b280b1d01a0d162422995647d6 (diff) | |
download | rails-de9a56b66af928a09f85daf15ffb1c2023a7c1b8.tar.gz rails-de9a56b66af928a09f85daf15ffb1c2023a7c1b8.tar.bz2 rails-de9a56b66af928a09f85daf15ffb1c2023a7c1b8.zip |
Merge pull request #24571 from raimo/patch-1
Print the proper ::Float::INFINITY value when used as a default value
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 14 | ||||
-rw-r--r-- | activerecord/test/cases/type/date_time_test.rb | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index 57b1bc889a..8b604ba930 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -423,6 +423,13 @@ class SchemaDumperDefaultsTest < ActiveRecord::TestCase t.datetime :datetime_with_default, default: "2014-06-05 07:17:04" t.time :time_with_default, default: "07:17:04" end + + if current_adapter?(:PostgreSQLAdapter) + @connection.create_table :infinity_defaults, force: true do |t| + t.float :float_with_inf_default, default: Float::INFINITY + t.float :float_with_nan_default, default: Float::NAN + end + end end teardown do @@ -438,4 +445,11 @@ class SchemaDumperDefaultsTest < ActiveRecord::TestCase assert_match %r{t\.datetime\s+"datetime_with_default",\s+default: '2014-06-05 07:17:04'}, output assert_match %r{t\.time\s+"time_with_default",\s+default: '2000-01-01 07:17:04'}, output end + + def test_schema_dump_with_float_column_infinity_default + skip unless current_adapter?(:PostgreSQLAdapter) + output = dump_table_schema('infinity_defaults') + assert_match %r{t\.float\s+"float_with_inf_default",\s+default: ::Float::INFINITY}, output + assert_match %r{t\.float\s+"float_with_nan_default",\s+default: ::Float::NAN}, output + end end diff --git a/activerecord/test/cases/type/date_time_test.rb b/activerecord/test/cases/type/date_time_test.rb index bc4900e1c2..6848619ece 100644 --- a/activerecord/test/cases/type/date_time_test.rb +++ b/activerecord/test/cases/type/date_time_test.rb @@ -3,7 +3,7 @@ require "models/task" module ActiveRecord module Type - class IntegerTest < ActiveRecord::TestCase + class DateTimeTest < ActiveRecord::TestCase def test_datetime_seconds_precision_applied_to_timestamp skip "This test is invalid if subsecond precision isn't supported" unless subsecond_precision_supported? p = Task.create!(starting: ::Time.now) |