mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
plugin new generator should generate config/routes.rb file for full engines
This commit is contained in:
parent
0aef847927
commit
d75ff73a72
3 changed files with 8 additions and 3 deletions
|
@ -44,7 +44,7 @@ module Rails
|
||||||
end
|
end
|
||||||
|
|
||||||
def config
|
def config
|
||||||
template "config/routes.rb" if mountable?
|
template "config/routes.rb" if full?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test
|
def test
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
<% if mountable? -%>
|
||||||
<%= camelized %>::Engine.routes.draw do
|
<%= camelized %>::Engine.routes.draw do
|
||||||
|
<% else -%>
|
||||||
|
Rails.application.routes.draw do
|
||||||
|
<% end -%>
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,8 +38,9 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
|
||||||
assert_file "things-43/lib/things-43.rb", /module Things43/
|
assert_file "things-43/lib/things-43.rb", /module Things43/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generating_test_files
|
def test_generating_without_options
|
||||||
run_generator
|
run_generator
|
||||||
|
assert_no_file "config/routes.rb"
|
||||||
assert_file "test/test_helper.rb"
|
assert_file "test/test_helper.rb"
|
||||||
assert_file "test/bukkits_test.rb", /assert_kind_of Module, Bukkits/
|
assert_file "test/bukkits_test.rb", /assert_kind_of Module, Bukkits/
|
||||||
end
|
end
|
||||||
|
@ -151,6 +152,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
|
||||||
|
|
||||||
def test_creating_engine_in_full_mode
|
def test_creating_engine_in_full_mode
|
||||||
run_generator [destination_root, "--full"]
|
run_generator [destination_root, "--full"]
|
||||||
|
assert_file "config/routes.rb", /Rails.application.routes.draw do/
|
||||||
assert_file "lib/bukkits/engine.rb", /module Bukkits\n class Engine < Rails::Engine\n end\nend/
|
assert_file "lib/bukkits/engine.rb", /module Bukkits\n class Engine < Rails::Engine\n end\nend/
|
||||||
assert_file "lib/bukkits.rb", /require "bukkits\/engine"/
|
assert_file "lib/bukkits.rb", /require "bukkits\/engine"/
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue