Merge pull request #14195 from robin850/issue-14079
Avoid namespacing routes inside engines
This commit is contained in:
commit
b0767afac5
|
@ -1 +1,10 @@
|
|||
* Avoid namespacing routes inside engines.
|
||||
|
||||
Mountable engines are namespaced by default so the generated routes
|
||||
were too while they should not.
|
||||
|
||||
Fixes #14079.
|
||||
|
||||
*Yves Senn*, *Carlos Antonio da Silva*, *Robin Dupret*
|
||||
|
||||
Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/railties/CHANGELOG.md) for previous changes.
|
||||
|
|
|
@ -27,11 +27,11 @@ module Rails
|
|||
# end
|
||||
# end
|
||||
def generate_routing_code(action)
|
||||
depth = class_path.length
|
||||
depth = regular_class_path.length
|
||||
# Create 'namespace' ladder
|
||||
# namespace :foo do
|
||||
# namespace :bar do
|
||||
namespace_ladder = class_path.each_with_index.map do |ns, i|
|
||||
namespace_ladder = regular_class_path.each_with_index.map do |ns, i|
|
||||
indent("namespace :#{ns} do\n", i * 2)
|
||||
end.join
|
||||
|
||||
|
|
|
@ -355,6 +355,18 @@ class PluginGeneratorTest < Rails::Generators::TestCase
|
|||
FileUtils.rm gemfile_path
|
||||
end
|
||||
|
||||
def test_generating_controller_inside_mountable_engine
|
||||
run_generator [destination_root, "--mountable"]
|
||||
|
||||
capture(:stdout) do
|
||||
`#{destination_root}/bin/rails g controller admin/dashboard foo`
|
||||
end
|
||||
|
||||
assert_file "config/routes.rb" do |contents|
|
||||
assert_match(/namespace :admin/, contents)
|
||||
assert_no_match(/namespace :bukkit/, contents)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def action(*args, &block)
|
||||
|
|
Loading…
Reference in New Issue