Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolated PostgreSQL test into PostgreSQL folder #1439

Merged
merged 1 commit into from Jun 1, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions 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
20 changes: 0 additions & 20 deletions activerecord/test/cases/timestamp_test.rb
Expand Up @@ -14,26 +14,6 @@ def setup
@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!
Expand Down