mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove meaningless ActiveRecord::MigrationContext.new(old_path)
in ensure block
`ActiveRecord::MigrationContext.new` just create an instance, doesn't have any side-effect.
This commit is contained in:
parent
7931951ccd
commit
18a1c750cc
2 changed files with 0 additions and 16 deletions
|
@ -87,7 +87,6 @@ class MigrationTest < ActiveRecord::TestCase
|
|||
|
||||
def test_migrator_versions
|
||||
migrations_path = MIGRATIONS_ROOT + "/valid"
|
||||
old_path = ActiveRecord::Migrator.migrations_paths
|
||||
migrator = ActiveRecord::MigrationContext.new(migrations_path)
|
||||
|
||||
migrator.up
|
||||
|
@ -100,24 +99,18 @@ class MigrationTest < ActiveRecord::TestCase
|
|||
|
||||
ActiveRecord::SchemaMigration.create!(version: 3)
|
||||
assert_equal true, migrator.needs_migration?
|
||||
ensure
|
||||
ActiveRecord::MigrationContext.new(old_path)
|
||||
end
|
||||
|
||||
def test_migration_detection_without_schema_migration_table
|
||||
ActiveRecord::Base.connection.drop_table "schema_migrations", if_exists: true
|
||||
|
||||
migrations_path = MIGRATIONS_ROOT + "/valid"
|
||||
old_path = ActiveRecord::Migrator.migrations_paths
|
||||
migrator = ActiveRecord::MigrationContext.new(migrations_path)
|
||||
|
||||
assert_equal true, migrator.needs_migration?
|
||||
ensure
|
||||
ActiveRecord::MigrationContext.new(old_path)
|
||||
end
|
||||
|
||||
def test_any_migrations
|
||||
old_path = ActiveRecord::Migrator.migrations_paths
|
||||
migrator = ActiveRecord::MigrationContext.new(MIGRATIONS_ROOT + "/valid")
|
||||
|
||||
assert_predicate migrator, :any_migrations?
|
||||
|
@ -125,8 +118,6 @@ class MigrationTest < ActiveRecord::TestCase
|
|||
migrator_empty = ActiveRecord::MigrationContext.new(MIGRATIONS_ROOT + "/empty")
|
||||
|
||||
assert_not_predicate migrator_empty, :any_migrations?
|
||||
ensure
|
||||
ActiveRecord::MigrationContext.new(old_path)
|
||||
end
|
||||
|
||||
def test_migration_version
|
||||
|
@ -393,7 +384,6 @@ class MigrationTest < ActiveRecord::TestCase
|
|||
def test_internal_metadata_stores_environment
|
||||
current_env = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
|
||||
migrations_path = MIGRATIONS_ROOT + "/valid"
|
||||
old_path = ActiveRecord::Migrator.migrations_paths
|
||||
migrator = ActiveRecord::MigrationContext.new(migrations_path)
|
||||
|
||||
migrator.up
|
||||
|
@ -410,7 +400,6 @@ class MigrationTest < ActiveRecord::TestCase
|
|||
migrator.up
|
||||
assert_equal new_env, ActiveRecord::InternalMetadata[:environment]
|
||||
ensure
|
||||
migrator = ActiveRecord::MigrationContext.new(old_path)
|
||||
ENV["RAILS_ENV"] = original_rails_env
|
||||
ENV["RACK_ENV"] = original_rack_env
|
||||
migrator.up
|
||||
|
@ -422,16 +411,12 @@ class MigrationTest < ActiveRecord::TestCase
|
|||
|
||||
current_env = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
|
||||
migrations_path = MIGRATIONS_ROOT + "/valid"
|
||||
old_path = ActiveRecord::Migrator.migrations_paths
|
||||
|
||||
current_env = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
|
||||
migrator = ActiveRecord::MigrationContext.new(migrations_path)
|
||||
migrator.up
|
||||
assert_equal current_env, ActiveRecord::InternalMetadata[:environment]
|
||||
assert_equal "bar", ActiveRecord::InternalMetadata[:foo]
|
||||
ensure
|
||||
migrator = ActiveRecord::MigrationContext.new(old_path)
|
||||
migrator.up
|
||||
end
|
||||
|
||||
def test_proper_table_name_on_migration
|
||||
|
|
|
@ -100,7 +100,6 @@ class MigratorTest < ActiveRecord::TestCase
|
|||
def test_finds_migrations_in_subdirectories
|
||||
migrations = ActiveRecord::MigrationContext.new(MIGRATIONS_ROOT + "/valid_with_subdirectories").migrations
|
||||
|
||||
|
||||
[[1, "ValidPeopleHaveLastNames"], [2, "WeNeedReminders"], [3, "InnocentJointable"]].each_with_index do |pair, i|
|
||||
assert_equal migrations[i].version, pair.first
|
||||
assert_equal migrations[i].name, pair.last
|
||||
|
|
Loading…
Reference in a new issue