From 837231a8295be63aa3dcbf867b457b2a7aa27386 Mon Sep 17 00:00:00 2001 From: kennyj Date: Mon, 6 Feb 2012 01:07:49 +0900 Subject: Fix url_for method's behavior when it is called with :controller option which starts with "/" from multiple nested controller. Closes #3864 --- actionpack/test/dispatch/routing_test.rb | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index b9c0189303..1216193075 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -2562,3 +2562,36 @@ class TestUnicodePaths < ActionDispatch::IntegrationTest assert_equal "200", @response.code end end + +class TestMultipleNestedController < ActionDispatch::IntegrationTest + module ::Foo + module Bar + class BazController < ActionController::Base + def index + render :inline => "<%= url_for :controller => '/pooh', :action => 'index' %>" + end + end + end + end + + Routes = ActionDispatch::Routing::RouteSet.new.tap do |app| + app.draw do + namespace :foo do + namespace :bar do + match "baz" => "baz#index" + end + end + match "pooh" => "pooh#index" + end + end + + include Routes.url_helpers + def app; Routes end + + test "controller option which starts with '/' from multiple nested controller" do + get "/foo/bar/baz" + assert_equal "/pooh", @response.body + end + +end + -- cgit v1.2.3