From b769119b9feeb9e83837d0310cfc92613173311c Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 11 Apr 2010 04:39:25 -0300 Subject: [PATCH] Make namespace work with options[:to] [#4351 state:committed] --- actionpack/lib/action_dispatch/routing/mapper.rb | 6 +++++- actionpack/test/dispatch/routing_test.rb | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 7035e36..433b977 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -58,7 +58,11 @@ module ActionDispatch path = normalize_path(path) if using_match_shorthand?(path, options) - options[:to] ||= path[1..-1].sub(%r{/([^/]*)$}, '#\1') + if @scope[:module] && options[:to] + options[:to] = "#{@scope[:module]}/#{options[:to]}" + else + options[:to] ||= path[1..-1].sub(%r{/([^/]*)$}, '#\1') + end options[:as] ||= path[1..-1].gsub("/", "_") end diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index d38c48b..46c4c0c 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -856,7 +856,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal '/account/description', account_description_path get '/account/description' - assert_equal 'account#description', @response.body + assert_equal 'account/account#description', @response.body end end @@ -864,7 +864,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest with_test_routes do assert_equal '/account', account_root_path get '/account' - assert_equal 'account#index', @response.body + assert_equal 'account/account#index', @response.body end end -- 1.7.0