mirror of https://github.com/rails/rails
Merge pull request #41255 from euxx/fix-create-migration-generator-with-pretend-option
Fix create migration generator with `--pretend` option
This commit is contained in:
commit
6675f6b785
|
@ -20,6 +20,8 @@ module Rails
|
||||||
end
|
end
|
||||||
|
|
||||||
def invoke!
|
def invoke!
|
||||||
|
return super if pretend?
|
||||||
|
|
||||||
invoked_file = super
|
invoked_file = super
|
||||||
File.exist?(@destination) ? invoked_file : relative_existing_migration
|
File.exist?(@destination) ? invoked_file : relative_existing_migration
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,6 +55,8 @@ class CreateMigrationTest < Rails::Generators::TestCase
|
||||||
def test_invoke_pretended
|
def test_invoke_pretended
|
||||||
create_migration(default_destination_path, {}, { pretend: true })
|
create_migration(default_destination_path, {}, { pretend: true })
|
||||||
|
|
||||||
|
stdout = invoke!
|
||||||
|
assert_match(/create db\/migrate\/1_create_articles\.rb\n/, stdout)
|
||||||
assert_no_file @migration.destination
|
assert_no_file @migration.destination
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue