From e69058c15389b7f88771a95c1637b2f306d0c02f Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Thu, 15 Nov 2012 18:45:37 +0100 Subject: =?UTF-8?q?backport=20#8139,=20`plugin=20new`=20adds=20dummy=20app?= =?UTF-8?q?=20tasks=20when=20necessary.=20=E2=80=A6=20The=20`plugin=20new`?= =?UTF-8?q?=20generator=20always=20adds=20the=20dummy=20app=20rake=20tasks?= =?UTF-8?q?,=20when=20a=20dummy=20app=20was=20created.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #8224 Conflicts: railties/CHANGELOG.md --- railties/CHANGELOG.md | 5 +++++ .../lib/rails/generators/rails/plugin_new/plugin_new_generator.rb | 6 +++++- railties/lib/rails/generators/rails/plugin_new/templates/Rakefile | 2 +- railties/test/generators/plugin_new_generator_test.rb | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 32a3cf3129..0096e4f8f8 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,5 +1,10 @@ ## Rails 3.2.9 (Nov 12, 2012) ## +* Add dummy app Rake tasks when --skip-test-unit and --dummy-path is passed to the plugin generator. [Backport #8139] + Fix #8121 + + *Yves Senn* + * Update supported ruby versions error message in ruby_version_check.rb *Lihan Li* ## Rails 3.2.8 (Aug 9, 2012) ## diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb index 918fa5bd3b..6c53d8bebb 100644 --- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +++ b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb @@ -204,7 +204,7 @@ task :default => :test end def create_test_dummy_files - return if options[:skip_test_unit] && options[:dummy_path] == 'test/dummy' + return unless with_dummy_app? create_dummy_app end @@ -242,6 +242,10 @@ task :default => :test options[:mountable] end + def with_dummy_app? + options[:skip_test_unit].blank? || options[:dummy_path] != 'test/dummy' + end + def self.banner "rails plugin new #{self.arguments.map(&:usage).join(' ')} [options]" end diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile index 564fda3c49..9b3b8cc03f 100755 --- a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile +++ b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile @@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_files.include('lib/**/*.rb') end -<% if full? && !options[:skip_active_record] && !options[:skip_test_unit] -%> +<% if full? && !options[:skip_active_record] && with_dummy_app? -%> APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__) load 'rails/tasks/engine.rake' <% end %> diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index dcf4f95194..a33c6b096c 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -65,6 +65,12 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_no_match(/APP_RAKEFILE/, File.read(File.join(destination_root, "Rakefile"))) end + def test_generating_adds_dummy_app_rake_tasks_without_unit_test_files + run_generator [destination_root, "-T", "--mountable", '--dummy-path', 'my_dummy_app'] + + assert_match(/APP_RAKEFILE/, File.read(File.join(destination_root, "Rakefile"))) + end + def test_ensure_that_plugin_options_are_not_passed_to_app_generator FileUtils.cd(Rails.root) assert_no_match(/It works from file!.*It works_from_file/, run_generator([destination_root, "-m", "lib/template.rb"])) -- cgit v1.2.3