1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

test, use columns_hash[] in place of columns.find {}.

This commit is contained in:
Yves Senn 2014-05-12 17:52:40 +02:00
parent 096be96db8
commit a214bb71b2
8 changed files with 12 additions and 12 deletions

View file

@ -16,7 +16,7 @@ class PostgresqlArrayTest < ActiveRecord::TestCase
t.integer 'ratings', array: true
end
end
@column = PgArray.columns.find { |c| c.name == 'tags' }
@column = PgArray.columns_hash['tags']
end
teardown do
@ -64,7 +64,7 @@ class PostgresqlArrayTest < ActiveRecord::TestCase
@connection.change_column :pg_arrays, :snippets, :text, array: true, default: []
PgArray.reset_column_information
column = PgArray.columns.find { |c| c.name == 'snippets' }
column = PgArray.columns_hash['snippets']
assert_equal :text, column.type
assert_equal [], column.default

View file

@ -19,7 +19,7 @@ class PostgresqlByteaTest < ActiveRecord::TestCase
end
end
end
@column = ByteaDataType.columns.find { |c| c.name == 'payload' }
@column = ByteaDataType.columns_hash['payload']
assert(@column.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLColumn))
end

View file

@ -50,7 +50,7 @@ if ActiveRecord::Base.connection.supports_extensions?
t.citext 'username'
end
Citext.reset_column_information
column = Citext.columns.find { |c| c.name == 'username' }
column = Citext.columns_hash['username']
assert_equal :citext, column.type
raise ActiveRecord::Rollback # reset the schema change

View file

@ -138,7 +138,7 @@ class PostgresqlDataTypeTest < ActiveRecord::TestCase
end
def test_money_type_cast
column = PostgresqlMoney.columns.find { |c| c.name == 'wealth' }
column = PostgresqlMoney.columns_hash['wealth']
assert_equal(12345678.12, column.type_cast("$12,345,678.12"))
assert_equal(12345678.12, column.type_cast("$12.345.678,12"))
assert_equal(-1.15, column.type_cast("-$1.15"))

View file

@ -28,7 +28,7 @@ class PostgresqlHstoreTest < ActiveRecord::TestCase
t.hstore 'settings'
end
end
@column = Hstore.columns.find { |c| c.name == 'tags' }
@column = Hstore.columns_hash['tags']
end
teardown do
@ -78,7 +78,7 @@ class PostgresqlHstoreTest < ActiveRecord::TestCase
t.hstore 'users', default: ''
end
Hstore.reset_column_information
column = Hstore.columns.find { |c| c.name == 'users' }
column = Hstore.columns_hash['users']
assert_equal :hstore, column.type
raise ActiveRecord::Rollback # reset the schema change

View file

@ -23,7 +23,7 @@ class PostgresqlJSONTest < ActiveRecord::TestCase
rescue ActiveRecord::StatementInvalid
skip "do not test on PG without json"
end
@column = JsonDataType.columns.find { |c| c.name == 'payload' }
@column = JsonDataType.columns_hash['payload']
end
teardown do
@ -57,7 +57,7 @@ class PostgresqlJSONTest < ActiveRecord::TestCase
t.json 'users', default: '{}'
end
JsonDataType.reset_column_information
column = JsonDataType.columns.find { |c| c.name == 'users' }
column = JsonDataType.columns_hash['users']
assert_equal :json, column.type
raise ActiveRecord::Rollback # reset the schema change

View file

@ -43,13 +43,13 @@ class PostgresqlUUIDTest < ActiveRecord::TestCase
def test_change_column_default
@connection.add_column :uuid_data_type, :thingy, :uuid, null: false, default: "uuid_generate_v1()"
UUIDType.reset_column_information
column = UUIDType.columns.find { |c| c.name == 'thingy' }
column = UUIDType.columns_hash['thingy']
assert_equal "uuid_generate_v1()", column.default_function
@connection.change_column :uuid_data_type, :thingy, :uuid, null: false, default: "uuid_generate_v4()"
UUIDType.reset_column_information
column = UUIDType.columns.find { |c| c.name == 'thingy' }
column = UUIDType.columns_hash['thingy']
assert_equal "uuid_generate_v4()", column.default_function
ensure
UUIDType.reset_column_information

View file

@ -20,7 +20,7 @@ class PostgresqlXMLTest < ActiveRecord::TestCase
rescue ActiveRecord::StatementInvalid
skip "do not test on PG without xml"
end
@column = XmlDataType.columns.find { |c| c.name == 'payload' }
@column = XmlDataType.columns_hash['payload']
end
teardown do