Permalink
Browse files

Merge pull request #14195 from robin850/issue-14079

Avoid namespacing routes inside engines
  • Loading branch information...
2 parents a7b059e + fc61bca commit b0767afac5390cb885c8274e78d5b7fa8bf7e157 @guilleiguaran guilleiguaran committed Mar 1, 2014
View
@@ -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 @@ def add_routes
# 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 @@ def test_skipping_gemfile_entry
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)

0 comments on commit b0767af

Please sign in to comment.