From 8bb2dfbb7367e08e18f70bb3045aa2db220af3fd Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 21 Apr 2010 11:56:07 -0300 Subject: [PATCH] url_for now works with HashWithIndifferentAccess ht jay [#4391 state:committed] --- actionpack/test/template/url_helper_test.rb | 10 ++++++++++ .../active_support/hash_with_indifferent_access.rb | 4 ++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 4474949..314ed91 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -421,6 +421,11 @@ class UrlHelperControllerTest < ActionController::TestCase 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 @@ -439,6 +444,11 @@ class UrlHelperControllerTest < ActionController::TestCase 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', diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 8241b69..651acfe 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -115,6 +115,10 @@ module ActiveSupport def symbolize_keys!; self end def to_options!; self end + def symbolize_keys + to_hash.symbolize_keys + end + # Convert to a Hash with String keys. def to_hash Hash.new(default).merge!(self) -- 1.7.0