aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration_test.rb
diff options
context:
space:
mode:
authorJeremy McNevin <jeremy.mcnevin@novu.com>2014-07-30 14:10:28 -0500
committerJeremy McNevin <jeremy.mcnevin@novu.com>2014-08-13 11:01:42 -0500
commit838e18321118ee3ec6669217e5ea0216f79c969a (patch)
tree894e8e98e16edb3ad1a43de20416dc8daad9d04a /activerecord/test/cases/migration_test.rb
parente9ce987a9a6fdad436b5511874963e8485b66f84 (diff)
downloadrails-838e18321118ee3ec6669217e5ea0216f79c969a.tar.gz
rails-838e18321118ee3ec6669217e5ea0216f79c969a.tar.bz2
rails-838e18321118ee3ec6669217e5ea0216f79c969a.zip
Correctly determine if migration is needed.
This method would assume that if last migration in the migrations directory matched the current schema version, that the database was up to date, but this does not account for new migrations with older timestamps that may be pending.
Diffstat (limited to 'activerecord/test/cases/migration_test.rb')
-rw-r--r--activerecord/test/cases/migration_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index ef3f073472..8176e82f10 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -81,6 +81,21 @@ class MigrationTest < ActiveRecord::TestCase
assert_equal 0, ActiveRecord::Migrator.current_version
assert_equal 3, ActiveRecord::Migrator.last_version
assert_equal true, ActiveRecord::Migrator.needs_migration?
+
+ ActiveRecord::SchemaMigration.create!(:version => ActiveRecord::Migrator.last_version)
+ assert_equal true, ActiveRecord::Migrator.needs_migration?
+ ensure
+ ActiveRecord::Migrator.migrations_paths = old_path
+ end
+
+ def test_migration_detection_without_schema_migration_table
+ ActiveRecord::Base.connection.drop_table :schema_migrations
+
+ migrations_path = MIGRATIONS_ROOT + "/valid"
+ old_path = ActiveRecord::Migrator.migrations_paths
+ ActiveRecord::Migrator.migrations_paths = migrations_path
+
+ assert_equal true, ActiveRecord::Migrator.needs_migration?
ensure
ActiveRecord::Migrator.migrations_paths = old_path
end