Use major + minor AR versions in 'Directly inheriting' error message
This commit is contained in:
parent
f250208dd4
commit
80f204b78c
|
@ -556,10 +556,12 @@ module ActiveRecord
|
|||
def self.inherited(subclass) #:nodoc:
|
||||
super
|
||||
if subclass.superclass == Migration
|
||||
major = ActiveRecord::VERSION::MAJOR
|
||||
minor = ActiveRecord::VERSION::MINOR
|
||||
raise StandardError, "Directly inheriting from ActiveRecord::Migration is not supported. " \
|
||||
"Please specify the Rails release the migration was written for:\n" \
|
||||
"Please specify the Active Record release the migration was written for:\n" \
|
||||
"\n" \
|
||||
" class #{subclass} < ActiveRecord::Migration[4.2]"
|
||||
" class #{subclass} < ActiveRecord::Migration[#{major}.#{minor}]"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ module ActiveRecord
|
|||
e = assert_raises(StandardError) do
|
||||
class_eval("class LegacyMigration < ActiveRecord::Migration; end")
|
||||
end
|
||||
assert_match(/LegacyMigration < ActiveRecord::Migration\[4\.2\]/, e.message)
|
||||
assert_match(/LegacyMigration < ActiveRecord::Migration\[\d\.\d\]/, e.message)
|
||||
end
|
||||
|
||||
def test_legacy_migrations_not_raise_exception_on_reverting_transaction
|
||||
|
|
Loading…
Reference in New Issue