Permalink
Browse files

Allow running `rails plugin new` command inside rails application

  • Loading branch information...
1 parent 4da6d95 commit b0665345f85e4b7f3b3367ee36fa205e7ff78d12 @drogus drogus committed with josevalim Nov 15, 2010
Showing with 17 additions and 6 deletions.
  1. +11 −6 railties/lib/rails/commands.rb
  2. +6 −0 railties/test/application/generators_test.rb
@@ -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
@@ -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)

0 comments on commit b066534

Please sign in to comment.