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:
Rafael França 2021-03-29 22:27:34 -04:00 committed by GitHub
commit 6675f6b785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -20,6 +20,8 @@ module Rails
end
def invoke!
return super if pretend?
invoked_file = super
File.exist?(@destination) ? invoked_file : relative_existing_migration
end

View File

@ -55,6 +55,8 @@ class CreateMigrationTest < Rails::Generators::TestCase
def test_invoke_pretended
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
end