diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2011-06-01 12:47:19 -0700 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2011-06-01 12:47:19 -0700 |
commit | 04593742c4bcb4d7dd107b6fd1234a4f42c23a10 (patch) | |
tree | 9a9f099dc56d1022adc511daebc2418004323ad1 | |
parent | 63665f6c9fbc19ca9163dc3811ffbe41311ca7e0 (diff) | |
parent | 8a0ffa7c9521c6c8d4298422ae1504d9d839987e (diff) | |
download | rails-04593742c4bcb4d7dd107b6fd1234a4f42c23a10.tar.gz rails-04593742c4bcb4d7dd107b6fd1234a4f42c23a10.tar.bz2 rails-04593742c4bcb4d7dd107b6fd1234a4f42c23a10.zip |
Merge pull request #1447 from dmathieu/empty_route
Fix creating an empty route on 1.8. Closes #1210
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 4 | ||||
-rw-r--r-- | actionpack/test/controller/integration_test.rb | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 3999bd0a5e..ec76d1da1e 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -1423,7 +1423,9 @@ module ActionDispatch end def action_path(name, path = nil) #:nodoc: - path || @scope[:path_names][name.to_sym] || name.to_s + # Ruby 1.8 can't transform empty strings to symbols + name = name.to_sym if name.is_a?(String) && !name.empty? + path || @scope[:path_names][name] || name.to_s end def prefix_name_for_action(as, action) #:nodoc: diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 01dc2f2091..23709e44e2 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -492,6 +492,8 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest end routes.draw do + match '', :to => 'application_integration_test/test#index', :as => :empty_string + match 'foo', :to => 'application_integration_test/test#index', :as => :foo match 'bar', :to => 'application_integration_test/test#index', :as => :bar end @@ -501,11 +503,15 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest end test "includes route helpers" do + assert_equal '/', empty_string_path assert_equal '/foo', foo_path assert_equal '/bar', bar_path end test "route helpers after controller access" do + get '/' + assert_equal '/', empty_string_path + get '/foo' assert_equal '/foo', foo_path |