Skip to content
This repository
Browse code

expand migration paths before requiring them. [#4240 state:resolved]

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
commit ed21f0c50270139ddb6993acfdaea4586ffd09a3 1 parent bc48d39
Aaron Patterson tenderlove authored wycats committed
2  activerecord/lib/active_record/migration.rb
@@ -374,7 +374,7 @@ def migration
374 374 end
375 375
376 376 def load_migration
377   - require(filename)
  377 + require(File.expand_path(filename))
378 378 name.constantize
379 379 end
380 380
13 activerecord/test/cases/migration_test.rb
@@ -1104,6 +1104,19 @@ def test_finds_pending_migrations
1104 1104 assert_equal migrations[0].name, 'InnocentJointable'
1105 1105 end
1106 1106
  1107 + def test_relative_migrations
  1108 + $".delete_if do |fname|
  1109 + fname == (MIGRATIONS_ROOT + "/valid/1_people_have_last_names.rb")
  1110 + end
  1111 + Object.send(:remove_const, :PeopleHaveLastNames)
  1112 +
  1113 + Dir.chdir(MIGRATIONS_ROOT) do
  1114 + ActiveRecord::Migrator.up("valid/", 1)
  1115 + end
  1116 +
  1117 + assert defined?(PeopleHaveLastNames)
  1118 + end
  1119 +
1107 1120 def test_only_loads_pending_migrations
1108 1121 # migrate up to 1
1109 1122 ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1)

0 comments on commit ed21f0c

Please sign in to comment.
Something went wrong with that request. Please try again.