Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow running `rails plugin new` command inside rails application

  • Loading branch information...
commit b0665345f85e4b7f3b3367ee36fa205e7ff78d12 1 parent 4da6d95
Piotr Sarnacki drogus authored josevalim committed
17 railties/lib/rails/commands.rb
View
@@ -12,14 +12,19 @@
case command
when 'generate', 'destroy', 'plugin'
- require APP_PATH
- Rails.application.require_environment!
+ if command == "plugin" && ARGV.first == "new"
+ require "rails/commands/plugin_new"
+ else
+ require APP_PATH
+ Rails.application.require_environment!
- if defined?(ENGINE_PATH)
- engine = Rails.application.railties.engines.find { |r| r.root.to_s == ENGINE_PATH }
- Rails.application = engine
+ if defined?(ENGINE_PATH)
+ engine = Rails.application.railties.engines.find { |r| r.root.to_s == ENGINE_PATH }
+ Rails.application = engine
+ end
+
+ require "rails/commands/#{command}"
end
- require "rails/commands/#{command}"
when 'benchmarker', 'profiler'
require APP_PATH
6 railties/test/application/generators_test.rb
View
@@ -25,6 +25,12 @@ def with_bare_config
yield app_const.config
end
+ test "allow running plugin new generator inside Rails app directory" do
+ FileUtils.cd rails_root
+ `./script/rails plugin new vendor/plugins/bukkits`
+ assert File.exist?(File.join(rails_root, "vendor/plugins/bukkits/test/dummy/config/application.rb"))
+ end
+
test "generators default values" do
with_bare_config do |c|
assert_equal(true, c.generators.colorize_logging)
Please sign in to comment.
Something went wrong with that request. Please try again.