From fc61bca31d899f359671d4b58bceb8b9d6555aa7 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Tue, 25 Feb 2014 14:57:23 +0100 Subject: Avoid namespacing routes inside engines Since #11544, invoking the controller generator, any generated route is namespaced according to the class_path method. Since a mountable plugin is namespaced, creating a controller inside would generate a namespaced route based on the engine's name. The controller generator now relies on regular_class_path which does not contain the class hierarchy but the given path. Fixes #14079. --- railties/test/generators/plugin_generator_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'railties/test/generators/plugin_generator_test.rb') diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index 932cd75bcb..b2fc3a2a4f 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -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) -- cgit v1.2.3