Merge pull request #8139 from senny/8121_engine_generator_rakefile_without_test_unit

Add app Rake tasks when -T and --dummy-path is passed to `plugin new`
This commit is contained in:
Carlos Antonio da Silva 2012-11-08 04:15:38 -08:00
commit 9abec81622
4 changed files with 18 additions and 3 deletions

View File

@ -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 File

@ -225,7 +225,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
@ -279,6 +279,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

View File

@ -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 File

@ -66,6 +66,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"]))