GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of rails/rails
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/Manfred/rails.git
Allow use of :path_prefix and :name_prefix outside of namespaced routes. 
[#1188 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
tomstuart (author)
Wed Oct 08 01:31:00 -0700 2008
lifo (committer)
Wed Oct 08 06:56:52 -0700 2008
commit  e28ad77bba0574241e6eb64dfd0c1291b221effe
tree    7027fbe4cf1715ffdf816a6c78c0aed1c579b9cd
parent  aec391621b6af7af1e0ba61c993bbdd88624eac3
...
60
61
62
63
 
64
65
66
67
68
69
70
71
...
60
61
62
 
63
64
65
66
 
 
67
68
69
0
@@ -60,12 +60,10 @@ module ActionController
0
       # segments are passed alongside in order to distinguish between default values
0
       # and requirements.
0
       def divide_route_options(segments, options)
0
- options = options.dup
0
+ options = options.except(:path_prefix, :name_prefix)
0
 
0
         if options[:namespace]
0
           options[:controller] = "#{options.delete(:namespace).sub(/\/$/, '')}/#{options[:controller]}"
0
- options.delete(:path_prefix)
0
- options.delete(:name_prefix)
0
         end
0
 
0
         requirements = (options.delete(:requirements) || {}).dup
...
924
925
926
 
 
 
 
 
 
 
 
 
 
 
 
 
 
927
928
929
...
2147
2148
2149
 
 
 
 
 
 
 
2150
2151
2152
...
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
...
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
0
@@ -924,6 +924,20 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do
0
 
0
     end
0
 
0
+ def test_named_route_with_name_prefix
0
+ rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :name_prefix => 'my_'
0
+ x = setup_for_named_route
0
+ assert_equal("http://named.route.test/page",
0
+ x.send(:my_page_url))
0
+ end
0
+
0
+ def test_named_route_with_path_prefix
0
+ rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :path_prefix => 'my'
0
+ x = setup_for_named_route
0
+ assert_equal("http://named.route.test/my/page",
0
+ x.send(:page_url))
0
+ end
0
+
0
     def test_named_route_with_nested_controller
0
       rs.add_named_route :users, 'admin/user', :controller => 'admin/user', :action => 'index'
0
       x = setup_for_named_route
0
@@ -2147,6 +2161,13 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do
0
       assert_equal [:x], set.extra_keys(args)
0
     end
0
 
0
+ def test_generate_with_path_prefix
0
+ set.draw { |map| map.connect ':controller/:action/:id', :path_prefix => 'my' }
0
+
0
+ args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" }
0
+ assert_equal "/my/foo/bar/7?x=y", set.generate(args)
0
+ end
0
+
0
     def test_named_routes_are_never_relative_to_modules
0
       set.draw do |map|
0
         map.connect "/connection/manage/:action", :controller => 'connection/manage'

Comments

    No one has commented yet.