mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Should test LegacyPrimaryKeyTest
to both V5_0
and V4_2
This commit is contained in:
parent
2f88ead952
commit
3be123ba26
1 changed files with 34 additions and 15 deletions
|
@ -71,9 +71,6 @@ module ActiveRecord
|
||||||
|
|
||||||
assert_not connection.index_exists?(:more_testings, :foo_id)
|
assert_not connection.index_exists?(:more_testings, :foo_id)
|
||||||
assert_not connection.index_exists?(:more_testings, :bar_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
|
ensure
|
||||||
connection.drop_table :more_testings rescue nil
|
connection.drop_table :more_testings rescue nil
|
||||||
end
|
end
|
||||||
|
@ -133,11 +130,9 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
module LegacyPrimaryKeyTestCases
|
||||||
include SchemaDumpingHelper
|
include SchemaDumpingHelper
|
||||||
|
|
||||||
self.use_transactional_tests = false
|
|
||||||
|
|
||||||
class LegacyPrimaryKey < ActiveRecord::Base
|
class LegacyPrimaryKey < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -155,7 +150,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_legacy_primary_key_should_be_auto_incremented
|
def test_legacy_primary_key_should_be_auto_incremented
|
||||||
@migration = Class.new(ActiveRecord::Migration[5.0]) {
|
@migration = Class.new(migration_class) {
|
||||||
def change
|
def change
|
||||||
create_table :legacy_primary_keys do |t|
|
create_table :legacy_primary_keys do |t|
|
||||||
t.references :legacy_ref
|
t.references :legacy_ref
|
||||||
|
@ -185,7 +180,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
||||||
def test_legacy_integer_primary_key_should_not_be_auto_incremented
|
def test_legacy_integer_primary_key_should_not_be_auto_incremented
|
||||||
skip if current_adapter?(:SQLite3Adapter)
|
skip if current_adapter?(:SQLite3Adapter)
|
||||||
|
|
||||||
@migration = Class.new(ActiveRecord::Migration[5.0]) {
|
@migration = Class.new(migration_class) {
|
||||||
def change
|
def change
|
||||||
create_table :legacy_primary_keys, id: :integer do |t|
|
create_table :legacy_primary_keys, id: :integer do |t|
|
||||||
end
|
end
|
||||||
|
@ -204,7 +199,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
||||||
|
|
||||||
if current_adapter?(:Mysql2Adapter, :PostgreSQLAdapter)
|
if current_adapter?(:Mysql2Adapter, :PostgreSQLAdapter)
|
||||||
def test_legacy_primary_key_in_create_table_should_be_integer
|
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
|
def change
|
||||||
create_table :legacy_primary_keys, id: false do |t|
|
create_table :legacy_primary_keys, id: false do |t|
|
||||||
t.primary_key :id
|
t.primary_key :id
|
||||||
|
@ -219,7 +214,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_legacy_primary_key_in_change_table_should_be_integer
|
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
|
def change
|
||||||
create_table :legacy_primary_keys, id: false do |t|
|
create_table :legacy_primary_keys, id: false do |t|
|
||||||
t.integer :dummy
|
t.integer :dummy
|
||||||
|
@ -237,7 +232,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_column_with_legacy_primary_key_should_be_integer
|
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
|
def change
|
||||||
create_table :legacy_primary_keys, id: false do |t|
|
create_table :legacy_primary_keys, id: false do |t|
|
||||||
t.integer :dummy
|
t.integer :dummy
|
||||||
|
@ -254,7 +249,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_legacy_join_table_foreign_keys_should_be_integer
|
def test_legacy_join_table_foreign_keys_should_be_integer
|
||||||
@migration = Class.new(ActiveRecord::Migration[5.0]) {
|
@migration = Class.new(migration_class) {
|
||||||
def change
|
def change
|
||||||
create_join_table :apples, :bananas do |t|
|
create_join_table :apples, :bananas do |t|
|
||||||
end
|
end
|
||||||
|
@ -269,7 +264,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_legacy_join_table_column_options_should_be_overwritten
|
def test_legacy_join_table_column_options_should_be_overwritten
|
||||||
@migration = Class.new(ActiveRecord::Migration[5.0]) {
|
@migration = Class.new(migration_class) {
|
||||||
def change
|
def change
|
||||||
create_join_table :apples, :bananas, column_options: { type: :bigint } do |t|
|
create_join_table :apples, :bananas, column_options: { type: :bigint } do |t|
|
||||||
end
|
end
|
||||||
|
@ -285,7 +280,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
||||||
|
|
||||||
if current_adapter?(:Mysql2Adapter)
|
if current_adapter?(:Mysql2Adapter)
|
||||||
def test_legacy_bigint_primary_key_should_be_auto_incremented
|
def test_legacy_bigint_primary_key_should_be_auto_incremented
|
||||||
@migration = Class.new(ActiveRecord::Migration[5.0]) {
|
@migration = Class.new(migration_class) {
|
||||||
def change
|
def change
|
||||||
create_table :legacy_primary_keys, id: :bigint
|
create_table :legacy_primary_keys, id: :bigint
|
||||||
end
|
end
|
||||||
|
@ -302,7 +297,7 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
def test_legacy_bigint_primary_key_should_not_be_auto_incremented
|
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
|
def change
|
||||||
create_table :legacy_primary_keys, id: :bigint do |t|
|
create_table :legacy_primary_keys, id: :bigint do |t|
|
||||||
end
|
end
|
||||||
|
@ -320,3 +315,27 @@ class LegacyPrimaryKeyTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
|
Loading…
Reference in a new issue