aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb2
-rw-r--r--actionpack/test/dispatch/request_test.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb
index 9a7e8a5a9c..7183939934 100644
--- a/actionpack/lib/action_dispatch/http/url.rb
+++ b/actionpack/lib/action_dispatch/http/url.rb
@@ -28,7 +28,7 @@ module ActionDispatch
path = options.delete(:script_name).to_s.chomp("/")
path << options.delete(:path).to_s
- params = options[:params] || {}
+ params = options[:params].is_a?(Hash) ? options[:params] : {}
params.reject! { |_,v| v.to_param.nil? }
result = build_host_url(options)
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index 2bc145c1cc..08d1c6fe73 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -799,6 +799,14 @@ class RequestTest < ActiveSupport::TestCase
end
end
+ test "url_for options[:params]" do
+ assert_equal 'http://www.example.com?params=', url_for(:params => '')
+ assert_equal 'http://www.example.com?params=1', url_for(:params => 1)
+ assert_equal 'http://www.example.com', url_for
+ assert_equal 'http://www.example.com', url_for(:params => {})
+ assert_equal 'http://www.example.com?name=tumayun', url_for(:params => { :name => 'tumayun' })
+ end
+
protected
def stub_request(env = {})