Skip to content

Commit

Permalink
url_for now works with HashWithIndifferentAccess ht jay [#4391 state:…
Browse files Browse the repository at this point in the history
…committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
spastorino authored and jeremy committed Apr 22, 2010
1 parent 726b5d7 commit 5c9c30a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/url_helper.rb
Expand Up @@ -102,7 +102,7 @@ def url_for(options = {})
escape = true
options
when Hash
options = { :only_path => options[:host].nil? }.update(options.symbolize_keys)
options = { :only_path => options[:host].nil? }.update(options.to_hash.symbolize_keys)
escape = options.key?(:escape) ? options.delete(:escape) : false
super
when :back
Expand Down
10 changes: 10 additions & 0 deletions actionpack/test/template/url_helper_test.rb
Expand Up @@ -421,6 +421,11 @@ def show_url_for
render :inline => "<%= url_for :controller => 'url_helper_controller_test/url_helper', :action => 'show_url_for' %>"
end

def show_overriden_url_for
params = { :controller => 'c', :action => 'a' }
render :inline => "<%= url_for params.merge(:controller => 'url_helper_controller_test/url_helper', :action => 'show_url_for') %>"
end

def show_named_route
render :inline => "<%= show_named_route_#{params[:kind]} %>"
end
Expand All @@ -439,6 +444,11 @@ def test_url_for_shows_only_path
assert_equal '/url_helper_controller_test/url_helper/show_url_for', @response.body
end

def test_overriden_url_for_shows_only_path
get :show_overriden_url_for
assert_equal '/url_helper_controller_test/url_helper/show_url_for', @response.body
end

def test_named_route_url_shows_host_and_path
get :show_named_route, :kind => 'url'
assert_equal 'http://test.host/url_helper_controller_test/url_helper/show_named_route',
Expand Down

0 comments on commit 5c9c30a

Please sign in to comment.