Skip to content
This repository
tree: 0c692f4d12
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 40 lines (33 sloc) 1.074 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
require "cases/helper"

module ActiveRecord
  class Migration
    class LoggerTest < ActiveRecord::TestCase
      # mysql can't roll back ddl changes
      self.use_transactional_fixtures = false

      Migration = Struct.new(:name, :version, :filename, :fingerprint) do
        def migrate direction
          # do nothing
        end
        def filename; "anon.rb"; end
        def fingerprint; "123456789012345678901234567890ab"; end
      end

      def setup
        super
        ActiveRecord::SchemaMigration.create_table
        ActiveRecord::SchemaMigration.delete_all
      end

      def teardown
        super
        ActiveRecord::SchemaMigration.drop_table
      end

      def test_migration_should_be_run_without_logger
        previous_logger = ActiveRecord::Base.logger
        ActiveRecord::Base.logger = nil
        migrations = [Migration.new('a', 1), Migration.new('b', 2), Migration.new('c', 3)]
        ActiveRecord::Migrator.new(:up, migrations).migrate
      ensure
        ActiveRecord::Base.logger = previous_logger
      end
    end
  end
end

Something went wrong with that request. Please try again.