aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorNik Wakelin <nik@codetocustomer.com>2008-08-02 17:44:02 +1200
committerMichael Koziarski <michael@koziarski.com>2008-08-06 12:46:52 +0200
commit080974784582e1e289c2948227b446bc56d404a1 (patch)
tree99f7a9679a1dadddfda338db67ef311bafdb902c /activerecord/test/cases
parent29a06f10e8600bbda333c30bf294e7896f35b8d5 (diff)
downloadrails-080974784582e1e289c2948227b446bc56d404a1.tar.gz
rails-080974784582e1e289c2948227b446bc56d404a1.tar.bz2
rails-080974784582e1e289c2948227b446bc56d404a1.zip
Added MigrationProxy to defer loading of Migration classes until they are actually required by the migrator
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#747 state:resolved]
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/migration_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 7ecf755ef8..920f719995 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -922,6 +922,26 @@ if ActiveRecord::Base.connection.supports_migrations?
migrations[0].name == 'innocent_jointable'
end
+ def test_only_loads_pending_migrations
+ # migrate up to 1
+ ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1)
+
+ # now unload the migrations that have been defined
+ PeopleHaveLastNames.unloadable
+ ActiveSupport::Dependencies.remove_unloadable_constants!
+
+ ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", nil)
+
+ assert !defined? PeopleHaveLastNames
+
+ %w(WeNeedReminders, InnocentJointable).each do |migration|
+ assert defined? migration
+ end
+
+ ensure
+ load(MIGRATIONS_ROOT + "/valid/1_people_have_last_names.rb")
+ end
+
def test_migrator_interleaved_migrations
ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/interleaved/pass_1")