aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration_test.rb
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-04-20 11:14:00 -0400
committerJosé Valim <jose.valim@gmail.com>2010-04-29 13:41:35 +0200
commitf4d174b211effd4cd510c1578bdc391852f4d375 (patch)
treec2da99f8836314c0175eb7a8b75c898384e9207a /activerecord/test/cases/migration_test.rb
parent68c96fad55fb13164e339426d7f1cbc88d4ccc8b (diff)
downloadrails-f4d174b211effd4cd510c1578bdc391852f4d375.tar.gz
rails-f4d174b211effd4cd510c1578bdc391852f4d375.tar.bz2
rails-f4d174b211effd4cd510c1578bdc391852f4d375.zip
making rake:migrate VERSION=0 a noop called in succession. [#2137 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/cases/migration_test.rb')
-rw-r--r--activerecord/test/cases/migration_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 7a26ee072d..a3d1ceaa1f 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -1136,6 +1136,25 @@ if ActiveRecord::Base.connection.supports_migrations?
load(MIGRATIONS_ROOT + "/valid/1_people_have_last_names.rb")
end
+ def test_target_version_zero_should_run_only_once
+ # migrate up to 1
+ ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 1)
+
+ # migrate down to 0
+ ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 0)
+
+ # now unload the migrations that have been defined
+ PeopleHaveLastNames.unloadable
+ ActiveSupport::Dependencies.remove_unloadable_constants!
+
+ # migrate down to 0 again
+ ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 0)
+
+ assert !defined? PeopleHaveLastNames
+ ensure
+ load(MIGRATIONS_ROOT + "/valid/1_people_have_last_names.rb")
+ end
+
def test_migrator_db_has_no_schema_migrations_table
# Oracle adapter raises error if semicolon is present as last character
if current_adapter?(:OracleAdapter)