Skip to content

Commit

Permalink
expand migration paths before requiring them. [#4240 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information
tenderlove authored and wycats committed Mar 24, 2010
1 parent bc48d39 commit ed21f0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/migration.rb
Expand Up @@ -374,7 +374,7 @@ def migration
end

def load_migration
require(filename)
require(File.expand_path(filename))
name.constantize
end

Expand Down
13 changes: 13 additions & 0 deletions activerecord/test/cases/migration_test.rb
Expand Up @@ -1104,6 +1104,19 @@ def test_finds_pending_migrations
assert_equal migrations[0].name, 'InnocentJointable'
end

def test_relative_migrations
$".delete_if do |fname|
fname == (MIGRATIONS_ROOT + "/valid/1_people_have_last_names.rb")
end
Object.send(:remove_const, :PeopleHaveLastNames)

Dir.chdir(MIGRATIONS_ROOT) do
ActiveRecord::Migrator.up("valid/", 1)
end

assert defined?(PeopleHaveLastNames)
end

def test_only_loads_pending_migrations
# migrate up to 1
ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1)
Expand Down

0 comments on commit ed21f0c

Please sign in to comment.