2012-01-11 14:48:14 -05:00
|
|
|
require "cases/helper"
|
|
|
|
|
|
|
|
module ActiveRecord
|
|
|
|
class Migration
|
|
|
|
class LoggerTest < ActiveRecord::TestCase
|
2012-01-17 12:18:40 -05:00
|
|
|
# mysql can't roll back ddl changes
|
|
|
|
self.use_transactional_fixtures = false
|
|
|
|
|
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
|
2012-01-11 15:01:04 -05:00
|
|
|
def migrate direction
|
|
|
|
# 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
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
super
|
|
|
|
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
|
2012-01-12 18:37:06 -05: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
|