diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-03 11:55:34 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-03 11:55:34 -0300 |
commit | 0691810bca0d9e79abb9b9943b618159920b687c (patch) | |
tree | 628368cbccd3c1e2c8c67281f34a948e30018534 /activerecord/test/cases/adapters/postgresql | |
parent | be543efe64fc19625fb56d5d2e38191c064c7636 (diff) | |
parent | 81b718728e5884ace2a965f8896dc5979aeb7284 (diff) | |
download | rails-0691810bca0d9e79abb9b9943b618159920b687c.tar.gz rails-0691810bca0d9e79abb9b9943b618159920b687c.tar.bz2 rails-0691810bca0d9e79abb9b9943b618159920b687c.zip |
Merge pull request #16036 from sgrif/sg-datetime-infinity
Do not rely on the column type when quoting infinity
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/infinity_test.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/infinity_test.rb b/activerecord/test/cases/adapters/postgresql/infinity_test.rb new file mode 100644 index 0000000000..22e8873333 --- /dev/null +++ b/activerecord/test/cases/adapters/postgresql/infinity_test.rb @@ -0,0 +1,44 @@ +require "cases/helper" + +class PostgresqlInfinityTest < ActiveRecord::TestCase + class PostgresqlInfinity < ActiveRecord::Base + end + + setup do + @connection = ActiveRecord::Base.connection + @connection.create_table(:postgresql_infinities) do |t| + t.float :float + t.datetime :datetime + end + end + + teardown do + @connection.execute("DROP TABLE IF EXISTS postgresql_infinities") + end + + test "type casting infinity on a float column" do + record = PostgresqlInfinity.create!(float: Float::INFINITY) + record.reload + assert_equal Float::INFINITY, record.float + end + + test "update_all with infinity on a float column" do + record = PostgresqlInfinity.create! + PostgresqlInfinity.update_all(float: Float::INFINITY) + record.reload + assert_equal Float::INFINITY, record.float + end + + test "type casting infinity on a datetime column" do + record = PostgresqlInfinity.create!(datetime: Float::INFINITY) + record.reload + assert_equal Float::INFINITY, record.datetime + end + + test "update_all with infinity on a datetime column" do + record = PostgresqlInfinity.create! + PostgresqlInfinity.update_all(datetime: Float::INFINITY) + record.reload + assert_equal Float::INFINITY, record.datetime + end +end |