mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
fix creating an empty route on 1.8. Closes #1210
This commit is contained in:
parent
1ff4bfc147
commit
8a0ffa7c95
2 changed files with 9 additions and 1 deletions
|
@ -1423,7 +1423,9 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
def action_path(name, path = nil) #:nodoc:
|
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
|
end
|
||||||
|
|
||||||
def prefix_name_for_action(as, action) #:nodoc:
|
def prefix_name_for_action(as, action) #:nodoc:
|
||||||
|
|
|
@ -492,6 +492,8 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
routes.draw do
|
routes.draw do
|
||||||
|
match '', :to => 'application_integration_test/test#index', :as => :empty_string
|
||||||
|
|
||||||
match 'foo', :to => 'application_integration_test/test#index', :as => :foo
|
match 'foo', :to => 'application_integration_test/test#index', :as => :foo
|
||||||
match 'bar', :to => 'application_integration_test/test#index', :as => :bar
|
match 'bar', :to => 'application_integration_test/test#index', :as => :bar
|
||||||
end
|
end
|
||||||
|
@ -501,11 +503,15 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
test "includes route helpers" do
|
test "includes route helpers" do
|
||||||
|
assert_equal '/', empty_string_path
|
||||||
assert_equal '/foo', foo_path
|
assert_equal '/foo', foo_path
|
||||||
assert_equal '/bar', bar_path
|
assert_equal '/bar', bar_path
|
||||||
end
|
end
|
||||||
|
|
||||||
test "route helpers after controller access" do
|
test "route helpers after controller access" do
|
||||||
|
get '/'
|
||||||
|
assert_equal '/', empty_string_path
|
||||||
|
|
||||||
get '/foo'
|
get '/foo'
|
||||||
assert_equal '/foo', foo_path
|
assert_equal '/foo', foo_path
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue