diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-16 13:15:38 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-16 13:15:38 -0300 |
commit | 4dc6b64c542f82270958976335e468d70246265c (patch) | |
tree | a37fbdb9912eb5195a836f0dfa66e5d307f66069 /activerecord/test/cases/migration | |
parent | 92de6d4c359e970cf282fe6742633b8be06b998a (diff) | |
parent | 8de5f7e8a86292c83f0c202061dcea1d78e4ba09 (diff) | |
download | rails-4dc6b64c542f82270958976335e468d70246265c.tar.gz rails-4dc6b64c542f82270958976335e468d70246265c.tar.bz2 rails-4dc6b64c542f82270958976335e468d70246265c.zip |
Merge pull request #13963 from lucas-clemente/pending_migrations
Skip migration check if adapter doesn't support it
Diffstat (limited to 'activerecord/test/cases/migration')
-rw-r--r-- | activerecord/test/cases/migration/pending_migrations_test.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/pending_migrations_test.rb b/activerecord/test/cases/migration/pending_migrations_test.rb new file mode 100644 index 0000000000..eff000e1a4 --- /dev/null +++ b/activerecord/test/cases/migration/pending_migrations_test.rb @@ -0,0 +1,50 @@ +require 'cases/helper' +require "minitest/mock" + +module ActiveRecord + class Migration + class PendingMigrationsTest < ActiveRecord::TestCase + def setup + super + @connection = MiniTest::Mock.new + @app = MiniTest::Mock.new + @pending = CheckPending.new(@app, @connection) + @pending.instance_variable_set :@last_check, -1 # Force checking + end + + def teardown + super + assert @connection.verify + assert @app.verify + 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 |