1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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*

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"]))