提交 5358f2b6 编写于 作者: R Ryuta Kamizono

Fix `test_add_column_with_timestamp_type` failure

This test failed due to dirty schema cache. It is needed to call
`clear_cache!` when using same named table with different definition.

https://travis-ci.org/rails/rails/jobs/310627767#L769-L772
上级 33a3f712
......@@ -264,19 +264,18 @@ def test_add_column_with_timestamp_type
t.column :foo, :timestamp
end
klass = Class.new(ActiveRecord::Base)
klass.table_name = "testings"
column = connection.columns(:testings).find { |c| c.name == "foo" }
assert_equal :datetime, klass.columns_hash["foo"].type
assert_equal :datetime, column.type
if current_adapter?(:PostgreSQLAdapter)
assert_equal "timestamp without time zone", klass.columns_hash["foo"].sql_type
assert_equal "timestamp without time zone", column.sql_type
elsif current_adapter?(:Mysql2Adapter)
assert_equal "timestamp", klass.columns_hash["foo"].sql_type
assert_equal "timestamp", column.sql_type
elsif current_adapter?(:OracleAdapter)
assert_equal "TIMESTAMP(6)", klass.columns_hash["foo"].sql_type
assert_equal "TIMESTAMP(6)", column.sql_type
else
assert_equal klass.connection.type_to_sql("datetime"), klass.columns_hash["foo"].sql_type
assert_equal klass.connection.type_to_sql("datetime"), column.sql_type
end
end
......
......@@ -141,6 +141,8 @@ def migrate(x)
Testing.create!
ActiveRecord::Migrator.new(:up, [migration]).migrate
assert_equal ["foobar"], Testing.all.map(&:foo)
ensure
ActiveRecord::Base.clear_cache!
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册