diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-01-30 12:21:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-30 12:21:43 -0500 |
commit | ede6673f9b8ea9567e300a6bd68ba14f48651c08 (patch) | |
tree | 4391c4099912c1526ce6c70e83973c319bccb7b6 | |
parent | de2bca4e8513d59c1a4f131e6fc6386231db1f82 (diff) | |
parent | 6e49cc77ab3d16c06e12f93158eaf3e507d4120e (diff) | |
download | rails-ede6673f9b8ea9567e300a6bd68ba14f48651c08.tar.gz rails-ede6673f9b8ea9567e300a6bd68ba14f48651c08.tar.bz2 rails-ede6673f9b8ea9567e300a6bd68ba14f48651c08.zip |
Merge pull request #27787 from y-yagi/show_correct_class_name_in_migration_error
show correct class name in migration inherited directly error
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/migration/compatibility_test.rb | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 339332a60d..40f6226315 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -525,7 +525,7 @@ module ActiveRecord 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 diff --git a/activerecord/test/cases/migration/compatibility_test.rb b/activerecord/test/cases/migration/compatibility_test.rb index e5a7412bc3..9296f3da90 100644 --- a/activerecord/test/cases/migration/compatibility_test.rb +++ b/activerecord/test/cases/migration/compatibility_test.rb @@ -103,9 +103,10 @@ module ActiveRecord 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 |