From 5b89fd07b28bcd342f874ab08a03efd864db1340 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 11 Apr 2010 04:39:25 -0300 Subject: Make namespace work with options[:to] [#4351 state:committed] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionpack/lib/action_dispatch/routing/mapper.rb | 8 ++++++++ actionpack/test/dispatch/routing_test.rb | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 7035e360ec..3e15caee2d 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -55,6 +55,14 @@ module ActionDispatch path = args.first end + if @scope[:module] && options[:to] + if options[:to].to_s.include?("#") + options[:to] = "#{@scope[:module]}/#{options[:to]}" + elsif @scope[:controller].nil? + options[:to] = "#{@scope[:module]}##{options[:to]}" + end + end + path = normalize_path(path) if using_match_shorthand?(path, options) diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index d38c48bfd4..411a28d8ee 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -140,7 +140,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest namespace :account do match 'shorthand' - match 'description', :to => "account#description", :as => "description" + match 'description', :to => "description", :as => "description" resource :subscription, :credit, :credit_card root :to => "account#index" @@ -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 -- cgit v1.2.3