diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2016-12-19 09:20:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-19 09:20:03 -0500 |
commit | 6e6b00f3423f0e79fb0078dada1096da54bb06a8 (patch) | |
tree | dd80f4dde6691744c2b9d7a62d4c816da5772ca1 /railties | |
parent | 79b6a259168caa573e0c96fc0c115c13ab17537d (diff) | |
parent | fa69b2c03582f5817572050a4373e365d9071b5d (diff) | |
download | rails-6e6b00f3423f0e79fb0078dada1096da54bb06a8.tar.gz rails-6e6b00f3423f0e79fb0078dada1096da54bb06a8.tar.bz2 rails-6e6b00f3423f0e79fb0078dada1096da54bb06a8.zip |
Merge pull request #27388 from maclover7/jm-argv
`ARGV.shift` before calling Rails generators
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/commands/generate/generate_command.rb | 2 | ||||
-rw-r--r-- | railties/test/application/generators_test.rb | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/railties/lib/rails/commands/generate/generate_command.rb b/railties/lib/rails/commands/generate/generate_command.rb index 59b2febc43..aa8dab71b0 100644 --- a/railties/lib/rails/commands/generate/generate_command.rb +++ b/railties/lib/rails/commands/generate/generate_command.rb @@ -14,6 +14,8 @@ module Rails require_application_and_environment! load_generators + ARGV.shift + Rails::Generators.invoke generator, args, behavior: :invoke, destination_root: Rails::Command.root end end diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index 0153f94504..d75577c5f6 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -169,5 +169,20 @@ module ApplicationTests assert File.exist?(File.join(rails_root, "app/views/notifier_mailer/foo.text.erb")) assert File.exist?(File.join(rails_root, "app/views/notifier_mailer/foo.html.erb")) end + + test "ARGV is mutated as expected" do + require "#{app_path}/config/environment" + Rails::Command.const_set("APP_PATH", "rails/all") + + FileUtils.cd(rails_root) do + ARGV = ["mailer", "notifier", "foo"] + Rails::Command.const_set("ARGV", ARGV) + Rails::Command.invoke :generate, ARGV + + assert_equal ["notifier", "foo"], ARGV + end + + Rails::Command.send(:remove_const, "APP_PATH") + end end end |