From 2aaeac9a0a0165eb2cdd8ea00f25990cc6cc1a6e Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Tue, 31 May 2011 20:56:07 -0400 Subject: Isolated PostgreSQL test into PostgreSQL folder --- .../cases/adapters/postgresql/timestamp_test.rb | 29 ++++++++++++++++++++++ activerecord/test/cases/timestamp_test.rb | 20 --------------- 2 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 activerecord/test/cases/adapters/postgresql/timestamp_test.rb diff --git a/activerecord/test/cases/adapters/postgresql/timestamp_test.rb b/activerecord/test/cases/adapters/postgresql/timestamp_test.rb new file mode 100644 index 0000000000..d3f48f5d77 --- /dev/null +++ b/activerecord/test/cases/adapters/postgresql/timestamp_test.rb @@ -0,0 +1,29 @@ +require 'cases/helper' + +class TimestampTest < ActiveRecord::TestCase + 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 +end diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index 7505b94187..ceb1452afd 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -14,26 +14,6 @@ class TimestampTest < ActiveRecord::TestCase @previously_updated_at = @developer.updated_at end - if current_adapter?(:PostgreSQLAdapter) - def test_load_infinity_and_beyond - 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 - 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 - end - def test_saving_a_changed_record_updates_its_timestamp @developer.name = "Jack Bauer" @developer.save! -- cgit v1.2.3