Skip to content

Commit

Permalink
Dropped the idea of automatically routing :format for the vanilla rou…
Browse files Browse the repository at this point in the history
…tes -- that will be a treat for map.resources. Deprecated the name route root as it'll be used as a shortcut for map.connect '' in Rails 2.0 (Rails 1.2). Added map.root as an alias for map.connect '' (Rails 2.0)

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5671 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Dec 4, 2006
1 parent 2a08c45 commit ffb17e8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
8 changes: 8 additions & 0 deletions actionpack/lib/action_controller/routing.rb
Expand Up @@ -979,6 +979,14 @@ def named_route(name, path, options = {})
@set.add_named_route(name, path, options)
end

# Added deprecation notice for anyone who already added a named route called "root".
# It'll be used as a shortcut for map.connect '' in Rails 2.0.
def root(*args, &proc)
super unless args.length >= 1 && proc.nil?
@set.add_named_route("root", *args)
end
deprecate :root => "(as the the label for a named route) will become a shortcut for map.connect '', so find another name"

def method_missing(route_name, *args, &proc)
super unless args.length >= 1 && proc.nil?
@set.add_named_route(route_name, *args)
Expand Down
20 changes: 16 additions & 4 deletions actionpack/test/controller/routing_test.rb
Expand Up @@ -376,22 +376,22 @@ def test_url_with_no_action_specified

def test_named_url_with_no_action_specified
rs.draw do |map|
map.root '', :controller => 'content'
map.home '', :controller => 'content'
map.connect ':controller/:action/:id'
end

assert_equal '/', rs.generate(:controller => 'content', :action => 'index')
assert_equal '/', rs.generate(:controller => 'content')

x = setup_for_named_route.new
assert_equal({:controller => 'content', :action => 'index', :use_route => :root, :only_path => false},
x.send(:root_url))
assert_equal({:controller => 'content', :action => 'index', :use_route => :home, :only_path => false},
x.send(:home_url))
end

def test_url_generated_when_forgetting_action
[{:controller => 'content', :action => 'index'}, {:controller => 'content'}].each do |hash|
rs.draw do |map|
map.root '', hash
map.home '', hash
map.connect ':controller/:action/:id'
end
assert_equal '/', rs.generate({:action => nil}, {:controller => 'content', :action => 'hello'})
Expand Down Expand Up @@ -1582,6 +1582,18 @@ def test_recognize_with_conditions_and_format
Object.send(:remove_const, :PeopleController)
end

def test_deprecation_warning_for_root_route
Object.const_set(:PeopleController, Class.new)

set.draw do |map|
assert_deprecated do
map.root('', :controller => "people")
end
end
ensure
Object.send(:remove_const, :PeopleController)
end

def test_generate_with_default_action
set.draw do |map|
map.connect "/people", :controller => "people"
Expand Down
2 changes: 2 additions & 0 deletions railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Deprecated the name route "root" as it'll be used as a shortcut for map.connect '' in Rails 2.0 [DHH]

* Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [DHH]

* Update initializer to load Rails::VERSION as soon as possible. Closes #6698. [Nicholas Seckar]
Expand Down

0 comments on commit ffb17e8

Please sign in to comment.