Changeset 5671
- Timestamp:
- 12/04/06 00:12:00 (2 years ago)
- Files:
-
- branches/1-2-pre-release/actionpack/lib/action_controller/routing.rb (modified) (1 diff)
- branches/1-2-pre-release/actionpack/test/controller/routing_test.rb (modified) (4 diffs)
- branches/1-2-pre-release/railties/CHANGELOG (modified) (1 diff)
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/routing.rb (modified) (1 diff)
- trunk/actionpack/test/controller/routing_test.rb (modified) (4 diffs)
- trunk/railties/configs/routes.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1-2-pre-release/actionpack/lib/action_controller/routing.rb
r5608 r5671 979 979 @set.add_named_route(name, path, options) 980 980 end 981 982 # Added deprecation notice for anyone who already added a named route called "root". 983 # It'll be used as a shortcut for map.connect '' in Rails 2.0. 984 def root(*args, &proc) 985 super unless args.length >= 1 && proc.nil? 986 @set.add_named_route("root", *args) 987 end 988 deprecate :root => "(as the the label for a named route) will become a shortcut for map.connect '', so find another name" 981 989 982 990 def method_missing(route_name, *args, &proc) branches/1-2-pre-release/actionpack/test/controller/routing_test.rb
r5608 r5671 377 377 def test_named_url_with_no_action_specified 378 378 rs.draw do |map| 379 map. root'', :controller => 'content'379 map.home '', :controller => 'content' 380 380 map.connect ':controller/:action/:id' 381 381 end … … 385 385 386 386 x = setup_for_named_route.new 387 assert_equal({:controller => 'content', :action => 'index', :use_route => : root, :only_path => false},388 x.send(: root_url))387 assert_equal({:controller => 'content', :action => 'index', :use_route => :home, :only_path => false}, 388 x.send(:home_url)) 389 389 end 390 390 … … 392 392 [{:controller => 'content', :action => 'index'}, {:controller => 'content'}].each do |hash| 393 393 rs.draw do |map| 394 map. root'', hash394 map.home '', hash 395 395 map.connect ':controller/:action/:id' 396 396 end … … 1583 1583 end 1584 1584 1585 def test_deprecation_warning_for_root_route 1586 Object.const_set(:PeopleController, Class.new) 1587 1588 set.draw do |map| 1589 assert_deprecated do 1590 map.root('', :controller => "people") 1591 end 1592 end 1593 ensure 1594 Object.send(:remove_const, :PeopleController) 1595 end 1596 1585 1597 def test_generate_with_default_action 1586 1598 set.draw do |map| branches/1-2-pre-release/railties/CHANGELOG
r5652 r5671 1 1 *SVN* 2 3 * Deprecated the name route "root" as it'll be used as a shortcut for map.connect '' in Rails 2.0 [DHH] 2 4 3 5 * Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [DHH] trunk/actionpack/CHANGELOG
r5664 r5671 1 1 *SVN* 2 3 * Added map.root as an alias for map.connect '' [DHH] 2 4 3 5 * Added Request#format to return the format used for the request as a mime type. If no format is specified, the first Request#accepts type is used. This means you can stop using respond_to for anything else than responses [DHH]. Examples: trunk/actionpack/lib/action_controller/routing.rb
r5607 r5671 974 974 def connect(path, options = {}) 975 975 @set.add_route(path, options) 976 end 977 978 # Creates a named route called "root" for matching the root level request. 979 def root(options = {}) 980 named_route("root", '', options) 976 981 end 977 982 trunk/actionpack/test/controller/routing_test.rb
r5607 r5671 377 377 def test_named_url_with_no_action_specified 378 378 rs.draw do |map| 379 map. root'', :controller => 'content'379 map.home '', :controller => 'content' 380 380 map.connect ':controller/:action/:id' 381 381 end … … 385 385 386 386 x = setup_for_named_route.new 387 assert_equal({:controller => 'content', :action => 'index', :use_route => : root, :only_path => false},388 x.send(: root_url))387 assert_equal({:controller => 'content', :action => 'index', :use_route => :home, :only_path => false}, 388 x.send(:home_url)) 389 389 end 390 390 … … 392 392 [{:controller => 'content', :action => 'index'}, {:controller => 'content'}].each do |hash| 393 393 rs.draw do |map| 394 map. root'', hash394 map.home '', hash 395 395 map.connect ':controller/:action/:id' 396 396 end … … 1593 1593 end 1594 1594 1595 def test_root_map 1596 Object.const_set(:PeopleController, Class.new) 1597 1598 set.draw { |map| map.root :controller => "people" } 1599 1600 request.path = "" 1601 request.method = :get 1602 assert_nothing_raised { set.recognize(request) } 1603 assert_equal("people", request.path_parameters[:controller]) 1604 assert_equal("index", request.path_parameters[:action]) 1605 ensure 1606 Object.send(:remove_const, :PeopleController) 1607 end 1608 1595 1609 def test_generate_finds_best_fit 1596 1610 set.draw do |map| trunk/railties/configs/routes.rb
r5148 r5671 9 9 # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' 10 10 # This route can be invoked with purchase_url(:id => product.id) 11 12 # Sample resource route (maps HTTP verbs to controller actions automatically): 13 # map.resources :products 11 14 12 # You can have the root of your site routed by hooking up '' 15 # Sample resource route with options: 16 # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get } 17 18 # You can have the root of your site routed with map.root 13 19 # -- just remember to delete public/index.html. 14 # map. connect '',:controller => "welcome"20 # map.root :controller => "welcome" 15 21 16 # Allow downloading Web Service WSDL as a file with an extension 17 # instead of a file named 'wsdl' 22 # Allow downloading Web Service WSDL as a file with an extension instead of a file named 'wsdl' 18 23 map.connect ':controller/service.wsdl', :action => 'wsdl' 19 24 20 25 # Install the default route as the lowest priority. 21 map.connect ':controller/:action/:id.:format'22 26 map.connect ':controller/:action/:id' 23 27 end