diff options
author | Carlhuda <carlhuda@engineyard.com> | 2009-12-23 19:18:11 -0800 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2009-12-23 19:18:11 -0800 |
commit | 84f1137ef87ff3c8e7cff5e8363d1f116b23fcae (patch) | |
tree | d6fe70688d13cbb24302175d348a997ed955ad51 /actionpack | |
parent | c4d6d50a46a0fe53f75aadc306212b5437e22ed8 (diff) | |
parent | 7a6f73e79b850e05d8d9639310159679ef872fb7 (diff) | |
download | rails-84f1137ef87ff3c8e7cff5e8363d1f116b23fcae.tar.gz rails-84f1137ef87ff3c8e7cff5e8363d1f116b23fcae.tar.bz2 rails-84f1137ef87ff3c8e7cff5e8363d1f116b23fcae.zip |
Merge remote branch 'origin/master'
Conflicts:
railties/lib/rails/application.rb
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 2 | ||||
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 6 |
3 files changed, 9 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 46163706c3..40e30bca6f 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -35,13 +35,15 @@ module ActionDispatch end def root(options = {}) + raise "Can't rename root to #{options[:as].inspect}: root is always named 'root'" if options.include?(:as) match '/', options.merge(:as => :root) end def match(*args) if args.one? && args.first.is_a?(Hash) - path = args.first.keys.first - options = { :to => args.first.values.first } + options = args.first + path = options.keys.first + options[:to] = options.delete(path) else path = args.first options = args.extract_options! diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index a4dc5e0956..498ad3268c 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -273,7 +273,7 @@ module ActionDispatch # TODO: Move this into Railties if defined?(Rails.application) # Find namespaces in controllers/ directory - Rails.application.configuration.controller_paths.each do |load_path| + Rails.application.config.controller_paths.each do |load_path| load_path = File.expand_path(load_path) Dir["#{load_path}/**/*_controller.rb"].collect do |path| namespaces << File.dirname(path).sub(/#{load_path}\/?/, '') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 1c7822358d..7ca85a4201 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -22,7 +22,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest delete 'logout', :to => :destroy, :as => :logout end - match 'account/logout' => redirect("/logout") + match 'account/logout' => redirect("/logout"), :as => :logout_redirect match 'account/login', :to => redirect("/login") match 'account/modulo/:name', :to => redirect("/%{name}s") @@ -109,7 +109,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest scope ':access_token', :constraints => { :access_token => /\w{5,5}/ } do resources :rooms end - + root :to => 'projects#index' end end @@ -153,6 +153,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest def test_logout_redirect_without_to with_test_routes do + assert_equal '/account/logout', logout_redirect_path get '/account/logout' assert_equal 301, @response.status assert_equal 'http://www.example.com/logout', @response.headers['Location'] @@ -462,6 +463,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest def test_root with_test_routes do + assert_equal '/', root_path get '/' assert_equal 'projects#index', @response.body end |