Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

`plugin new` adds dummy app tasks when necessary.

Closes #8121

The `plugin new` generator always adds the dummy app rake tasks,
when a dummy app was created.
  • Loading branch information...
commit 1785bf7d6727c8c9d847eaa741ad41a9b750cd28 1 parent c148823
@senny senny authored senny committed
View
7 railties/CHANGELOG.md
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Add dummy app Rake tasks when --skip-test-unit and --dummy-path is passed to the plugin generator.
+ Fix #8121
+
+ *Yves Senn*
+
* Ensure that RAILS_ENV is set when accessing Rails.env *Steve Klabnik*
* Don't eager-load app/assets and app/views *Elia Schito*
@@ -9,7 +14,7 @@
* New test locations `test/models`, `test/helpers`, `test/controllers`, and
`test/mailers`. Corresponding rake tasks added as well. *Mike Moore*
-* Set a different cache per environment for assets pipeline
+* Set a different cache per environment for assets pipeline
through `config.assets.cache`.
*Guillermo Iguaran*
View
6 railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
@@ -225,7 +225,7 @@ def create_test_files
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
@@ -279,6 +279,10 @@ def mountable?
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
View
2  railties/lib/rails/generators/rails/plugin_new/templates/Rakefile
@@ -14,7 +14,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 %>
View
6 railties/test/generators/plugin_new_generator_test.rb
@@ -66,6 +66,12 @@ def test_generating_test_files_in_full_mode_without_unit_test_files
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"]))
Please sign in to comment.
Something went wrong with that request. Please try again.