aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-10-18 08:38:30 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-10-18 08:38:30 +0900
commit3be123ba26cad461a80d7d680819e71c1388a241 (patch)
tree5a9eaf3484892f99737539ffd7de79be65ad9a12 /activerecord
parent2f88ead95265d0a05e1a269754c5c08c885c353c (diff)
downloadrails-3be123ba26cad461a80d7d680819e71c1388a241.tar.gz
rails-3be123ba26cad461a80d7d680819e71c1388a241.tar.bz2
rails-3be123ba26cad461a80d7d680819e71c1388a241.zip
Should test `LegacyPrimaryKeyTest` to both `V5_0` and `V4_2`
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/migration/compatibility_test.rb49
1 files changed, 34 insertions, 15 deletions
diff --git a/activerecord/test/cases/migration/compatibility_test.rb b/activerecord/test/cases/migration/compatibility_test.rb
index b50d68d6df..2fef2f796e 100644
--- a/activerecord/test/cases/migration/compatibility_test.rb
+++ b/activerecord/test/cases/migration/compatibility_test.rb
@@ -71,9 +71,6 @@ module ActiveRecord
assert_not connection.index_exists?(:more_testings, :foo_id)
assert_not connection.index_exists?(:more_testings, :bar_id)
-
- legacy_ref = connection.columns(:more_testings).find { |c| c.name == "foo_id" }
- assert_not legacy_ref.bigint?
ensure
connection.drop_table :more_testings rescue nil
end
@@ -133,11 +130,9 @@ module ActiveRecord
end
end
-class LegacyPrimaryKeyTest < ActiveRecord::TestCase
+module LegacyPrimaryKeyTestCases
include SchemaDumpingHelper
- self.use_transactional_tests = false
-
class LegacyPrimaryKey < ActiveRecord::Base
end
@@ -155,7 +150,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
end
def test_legacy_primary_key_should_be_auto_incremented
- @migration = Class.new(ActiveRecord::Migration[5.0]) {
+ @migration = Class.new(migration_class) {
def change
create_table :legacy_primary_keys do |t|
t.references :legacy_ref
@@ -185,7 +180,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
def test_legacy_integer_primary_key_should_not_be_auto_incremented
skip if current_adapter?(:SQLite3Adapter)
- @migration = Class.new(ActiveRecord::Migration[5.0]) {
+ @migration = Class.new(migration_class) {
def change
create_table :legacy_primary_keys, id: :integer do |t|
end
@@ -204,7 +199,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
if current_adapter?(:Mysql2Adapter, :PostgreSQLAdapter)
def test_legacy_primary_key_in_create_table_should_be_integer
- @migration = Class.new(ActiveRecord::Migration[5.0]) {
+ @migration = Class.new(migration_class) {
def change
create_table :legacy_primary_keys, id: false do |t|
t.primary_key :id
@@ -219,7 +214,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
end
def test_legacy_primary_key_in_change_table_should_be_integer
- @migration = Class.new(ActiveRecord::Migration[5.0]) {
+ @migration = Class.new(migration_class) {
def change
create_table :legacy_primary_keys, id: false do |t|
t.integer :dummy
@@ -237,7 +232,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
end
def test_add_column_with_legacy_primary_key_should_be_integer
- @migration = Class.new(ActiveRecord::Migration[5.0]) {
+ @migration = Class.new(migration_class) {
def change
create_table :legacy_primary_keys, id: false do |t|
t.integer :dummy
@@ -254,7 +249,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
end
def test_legacy_join_table_foreign_keys_should_be_integer
- @migration = Class.new(ActiveRecord::Migration[5.0]) {
+ @migration = Class.new(migration_class) {
def change
create_join_table :apples, :bananas do |t|
end
@@ -269,7 +264,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
end
def test_legacy_join_table_column_options_should_be_overwritten
- @migration = Class.new(ActiveRecord::Migration[5.0]) {
+ @migration = Class.new(migration_class) {
def change
create_join_table :apples, :bananas, column_options: { type: :bigint } do |t|
end
@@ -285,7 +280,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
if current_adapter?(:Mysql2Adapter)
def test_legacy_bigint_primary_key_should_be_auto_incremented
- @migration = Class.new(ActiveRecord::Migration[5.0]) {
+ @migration = Class.new(migration_class) {
def change
create_table :legacy_primary_keys, id: :bigint
end
@@ -302,7 +297,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
end
else
def test_legacy_bigint_primary_key_should_not_be_auto_incremented
- @migration = Class.new(ActiveRecord::Migration[5.0]) {
+ @migration = Class.new(migration_class) {
def change
create_table :legacy_primary_keys, id: :bigint do |t|
end
@@ -320,3 +315,27 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
end
end
end
+
+module LegacyPrimaryKeyTest
+ class V5_0 < ActiveRecord::TestCase
+ include LegacyPrimaryKeyTestCases
+
+ self.use_transactional_tests = false
+
+ private
+ def migration_class
+ ActiveRecord::Migration[5.0]
+ end
+ end
+
+ class V4_2 < ActiveRecord::TestCase
+ include LegacyPrimaryKeyTestCases
+
+ self.use_transactional_tests = false
+
+ private
+ def migration_class
+ ActiveRecord::Migration[4.2]
+ end
+ end
+end