aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-12-03 07:55:34 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-12-03 07:55:34 +0900
commit5358f2b67bd6fb12d708527a4a70dcab65513c5e (patch)
tree9f4628c62c569cbcd247e565d19bc212a9bfc9e8 /activerecord/test
parent33a3f7123bc4cc49b99b01a40bbfd463b2e73f76 (diff)
downloadrails-5358f2b67bd6fb12d708527a4a70dcab65513c5e.tar.gz
rails-5358f2b67bd6fb12d708527a4a70dcab65513c5e.tar.bz2
rails-5358f2b67bd6fb12d708527a4a70dcab65513c5e.zip
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
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/migration/change_schema_test.rb13
-rw-r--r--activerecord/test/cases/migration/compatibility_test.rb2
2 files changed, 8 insertions, 7 deletions
diff --git a/activerecord/test/cases/migration/change_schema_test.rb b/activerecord/test/cases/migration/change_schema_test.rb
index 7b0644e9c0..43aac5da75 100644
--- a/activerecord/test/cases/migration/change_schema_test.rb
+++ b/activerecord/test/cases/migration/change_schema_test.rb
@@ -264,19 +264,18 @@ module ActiveRecord
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
diff --git a/activerecord/test/cases/migration/compatibility_test.rb b/activerecord/test/cases/migration/compatibility_test.rb
index f1defe1a8a..e6ca252369 100644
--- a/activerecord/test/cases/migration/compatibility_test.rb
+++ b/activerecord/test/cases/migration/compatibility_test.rb
@@ -141,6 +141,8 @@ module ActiveRecord
Testing.create!
ActiveRecord::Migrator.new(:up, [migration]).migrate
assert_equal ["foobar"], Testing.all.map(&:foo)
+ ensure
+ ActiveRecord::Base.clear_cache!
end
end
end