Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Wrap table creation in a transaction.

This will make the tests pass when the intrange datatype is not present
  • Loading branch information...
commit aefcd342c4c447f471e285ff666fa1ced7f11754 1 parent c7d7e7f
@rafaelfranca rafaelfranca authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 activerecord/test/cases/adapters/postgresql/intrange_test.rb
View
14 activerecord/test/cases/adapters/postgresql/intrange_test.rb
@@ -12,9 +12,11 @@ class IntRangeDataType < ActiveRecord::Base
def setup
@connection = ActiveRecord::Base.connection
begin
- @connection.create_table('intrange_data_type') do |t|
- t.intrange 'int_range', :default => (1..10)
- t.intrange 'long_int_range', :limit => 8, :default => (1..100)
+ @connection.transaction do
+ @connection.create_table('intrange_data_type') do |t|
+ t.intrange 'int_range', :default => (1..10)
+ t.intrange 'long_int_range', :limit => 8, :default => (1..100)
+ end
end
rescue ActiveRecord::StatementInvalid
return skip "do not test on PG without ranges"
@@ -56,7 +58,7 @@ def test_type_cast_long_intrange
assert_equal((1..100), @long_int_range_column.default)
assert_equal("int8range", @long_int_range_column.sql_type)
end
-
+
def test_rewrite
@connection.execute "insert into intrange_data_type (int_range) VALUES ('(1, 6)')"
x = IntRangeDataType.first
@@ -75,7 +77,7 @@ def test_empty_range
x = IntRangeDataType.first
assert_equal((nil..nil), x.int_range)
end
-
+
def test_rewrite_to_nil
@connection.execute %q|insert into intrange_data_type (int_range) VALUES('(1, 4]')|
x = IntRangeDataType.first
@@ -101,4 +103,4 @@ def test_save_invalid_data
IntRangeDataType.create!(int_range: "empty1")
end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.