提交 ede6673f 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #27787 from y-yagi/show_correct_class_name_in_migration_error

show correct class name in migration inherited directly error
......@@ -525,7 +525,7 @@ def self.inherited(subclass) # :nodoc:
raise StandardError, "Directly inheriting from ActiveRecord::Migration is not supported. " \
"Please specify the Rails release the migration was written for:\n" \
"\n" \
" class #{self.class.name} < ActiveRecord::Migration[4.2]"
" class #{subclass} < ActiveRecord::Migration[4.2]"
end
end
......
......@@ -103,9 +103,10 @@ def migrate(x)
end
def test_legacy_migrations_raises_exception_when_inherited
assert_raises(StandardError) do
Class.new(ActiveRecord::Migration)
e = assert_raises(StandardError) do
class_eval("class LegacyMigration < ActiveRecord::Migration; end")
end
assert_match(/LegacyMigration < ActiveRecord::Migration\[4\.2\]/, e.message)
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册