diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-13 11:49:39 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-13 13:04:44 -0700 |
commit | ce1a1b47be2abc42062c24954108550d8a431e1b (patch) | |
tree | b310560bdf232911aa638462ff1ac2a513e70d0c /activerecord/test/cases | |
parent | b1ceffd7b224c397d8ba5344b9c1438dd62f8325 (diff) | |
download | rails-ce1a1b47be2abc42062c24954108550d8a431e1b.tar.gz rails-ce1a1b47be2abc42062c24954108550d8a431e1b.tar.bz2 rails-ce1a1b47be2abc42062c24954108550d8a431e1b.zip |
supporting infinity and -infinity for timestamps in PG. fixes #544
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/timestamp_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index ceb1452afd..22d4cac422 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -14,6 +14,32 @@ class TimestampTest < ActiveRecord::TestCase @previously_updated_at = @developer.updated_at end + def test_load_infinity_and_beyond + unless current_adapter?(:PostgreSQLAdapter) + return skip("only tested on postgresql") + end + + d = Developer.find_by_sql("select 'infinity'::timestamp as updated_at") + assert d.first.updated_at.infinite?, 'timestamp should be infinite' + + d = Developer.find_by_sql("select '-infinity'::timestamp as updated_at") + time = d.first.updated_at + assert time.infinite?, 'timestamp should be infinite' + assert_operator time, :<, 0 + end + + def test_save_infinity_and_beyond + unless current_adapter?(:PostgreSQLAdapter) + return skip("only tested on postgresql") + end + + d = Developer.create!(:name => 'aaron', :updated_at => 1.0 / 0.0) + assert_equal(1.0 / 0.0, d.updated_at) + + d = Developer.create!(:name => 'aaron', :updated_at => -1.0 / 0.0) + assert_equal(-1.0 / 0.0, d.updated_at) + end + def test_saving_a_changed_record_updates_its_timestamp @developer.name = "Jack Bauer" @developer.save! |