1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Duplicate possible frozen string from route

Ruby 1.9 freezes Hash string keys by default so where a route is
defined like this:

  get 'search' => 'search'

then the Mapper will derive the action from the key. This blows up
later when the action is added to the parameters hash and the
encoding is forced.

Closes #3429
This commit is contained in:
Andrew White 2013-01-21 17:05:49 +00:00
parent 4e32722594
commit c4106d0c08
2 changed files with 12 additions and 2 deletions

View file

@ -1403,9 +1403,10 @@ module ActionDispatch
def add_route(action, options) # :nodoc:
path = path_for_action(action, options.delete(:path))
action = action.to_s.dup
if action.to_s =~ /^[\w\/]+$/
options[:action] ||= action unless action.to_s.include?("/")
if action =~ /^[\w\/]+$/
options[:action] ||= action unless action.include?("/")
else
action = nil
end

View file

@ -2678,6 +2678,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal '0c0c0b68-d24b-11e1-a861-001ff3fffe6f', @request.params[:download]
end
def test_action_from_path_is_not_frozen
draw do
get 'search' => 'search'
end
get '/search'
assert !@request.params[:action].frozen?
end
private
def draw(&block)