2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2012-01-11 14:48:14 -05:00
|
|
|
require "cases/helper"
|
|
|
|
|
|
|
|
module ActiveRecord
|
|
|
|
class Migration
|
|
|
|
class LoggerTest < ActiveRecord::TestCase
|
2014-06-14 07:41:08 -04:00
|
|
|
# MySQL can't roll back ddl changes
|
2015-03-10 22:21:19 -04:00
|
|
|
self.use_transactional_tests = false
|
2012-01-17 12:18:40 -05:00
|
|
|
|
2012-12-06 19:17:11 -05:00
|
|
|
Migration = Struct.new(:name, :version) do
|
2013-03-01 05:39:39 -05:00
|
|
|
def disable_ddl_transaction; false end
|
2016-08-06 14:20:22 -04:00
|
|
|
def migrate(direction)
|
2012-01-11 15:01:04 -05:00
|
|
|
# do nothing
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-17 12:18:40 -05:00
|
|
|
def setup
|
2012-01-13 19:09:47 -05:00
|
|
|
super
|
|
|
|
ActiveRecord::SchemaMigration.create_table
|
|
|
|
ActiveRecord::SchemaMigration.delete_all
|
|
|
|
end
|
|
|
|
|
2014-03-14 00:35:58 -04:00
|
|
|
teardown do
|
2012-01-13 19:09:47 -05:00
|
|
|
ActiveRecord::SchemaMigration.drop_table
|
|
|
|
end
|
|
|
|
|
2012-01-11 14:48:14 -05:00
|
|
|
def test_migration_should_be_run_without_logger
|
|
|
|
previous_logger = ActiveRecord::Base.logger
|
|
|
|
ActiveRecord::Base.logger = nil
|
2016-08-06 12:26:20 -04:00
|
|
|
migrations = [Migration.new("a", 1), Migration.new("b", 2), Migration.new("c", 3)]
|
2012-01-11 15:01:04 -05:00
|
|
|
ActiveRecord::Migrator.new(:up, migrations).migrate
|
2012-01-11 14:48:14 -05:00
|
|
|
ensure
|
|
|
|
ActiveRecord::Base.logger = previous_logger
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|