Sha256: 8d9530330ac877048fec27ae659d711747f5d0e100dd1f31f6068cf5d56da1af

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 KB

Contents

require 'cases/helper'

module ActiveRecord
  class Migration
    class PendingMigrationsTest < ActiveRecord::TestCase
      def setup
        super
        @connection = Minitest::Mock.new
        @app = Minitest::Mock.new
        conn = @connection
        @pending = Class.new(CheckPending) {
          define_method(:connection) { conn }
        }.new(@app)
        @pending.instance_variable_set :@last_check, -1 # Force checking
      end

      def teardown
        assert @connection.verify
        assert @app.verify
        super
      end

      def test_errors_if_pending
        @connection.expect :supports_migrations?, true

        ActiveRecord::Migrator.stub :needs_migration?, true do
          assert_raise ActiveRecord::PendingMigrationError do
            @pending.call(nil)
          end
        end
      end

      def test_checks_if_supported
        @connection.expect :supports_migrations?, true
        @app.expect :call, nil, [:foo]

        ActiveRecord::Migrator.stub :needs_migration?, false do
          @pending.call(:foo)
        end
      end

      def test_doesnt_check_if_unsupported
        @connection.expect :supports_migrations?, false
        @app.expect :call, nil, [:foo]

        ActiveRecord::Migrator.stub :needs_migration?, true do
          @pending.call(:foo)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ibm_db-5.2.0-x86-mingw32 test/cases/migration/pending_migrations_test.rb
ibm_db-5.1.0-x86-mingw32 test/cases/migration/pending_migrations_test.rb
ibm_db-5.0.5-x86-mingw32 test/cases/migration/pending_migrations_test.rb
ibm_db-5.0.4-x86-mingw32 test/cases/migration/pending_migrations_test.rb
ibm_db-5.0.3-x86-mingw32 test/cases/migration/pending_migrations_test.rb
ibm_db-5.0.2-x86-mingw32 test/cases/migration/pending_migrations_test.rb