From f94600bdaf7d73971ad9a53148b0844c2efb901d Mon Sep 17 00:00:00 2001 From: Michael Raidel Date: Fri, 13 Jun 2008 16:14:07 +0200 Subject: ActiveRecord::Migrator#run records version-state after migrating. [#369 state:resolved] --- activerecord/test/cases/migration_test.rb | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 2cac7f04ab..fe7fa7ba03 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -825,6 +825,21 @@ if ActiveRecord::Base.connection.supports_migrations? assert !Reminder.table_exists? end + def test_migrator_double_up + assert_equal(0, ActiveRecord::Migrator.current_version) + ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 1) + assert_nothing_raised { ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 1) } + assert_equal(1, ActiveRecord::Migrator.current_version) + end + + def test_migrator_double_down + assert_equal(0, ActiveRecord::Migrator.current_version) + ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 1) + ActiveRecord::Migrator.run(:down, MIGRATIONS_ROOT + "/valid", 1) + assert_nothing_raised { ActiveRecord::Migrator.run(:down, MIGRATIONS_ROOT + "/valid", 1) } + assert_equal(0, ActiveRecord::Migrator.current_version) + end + def test_finds_migrations migrations = ActiveRecord::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").migrations [['1', 'people_have_last_names'], @@ -914,16 +929,6 @@ if ActiveRecord::Base.connection.supports_migrations? ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") assert_equal(0, ActiveRecord::Migrator.current_version) end - - def test_migrator_run - assert_equal(0, ActiveRecord::Migrator.current_version) - ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 3) - assert_equal(0, ActiveRecord::Migrator.current_version) - - assert_equal(0, ActiveRecord::Migrator.current_version) - ActiveRecord::Migrator.run(:down, MIGRATIONS_ROOT + "/valid", 3) - assert_equal(0, ActiveRecord::Migrator.current_version) - end def test_schema_migrations_table_name ActiveRecord::Base.table_name_prefix = "prefix_" -- cgit v1.2.3