File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def url_for(options = {})
28
28
path = options . delete ( :script_name ) . to_s . chomp ( "/" )
29
29
path << options . delete ( :path ) . to_s
30
30
31
- params = options [ :params ] || { }
31
+ params = options [ :params ] . is_a? ( Hash ) ? options [ :params ] : { }
32
32
params . reject! { |_ , v | v . to_param . nil? }
33
33
34
34
result = build_host_url ( options )
Original file line number Diff line number Diff line change @@ -799,6 +799,14 @@ def url_for(options = {})
799
799
end
800
800
end
801
801
802
+ test "url_for options[:params]" do
803
+ assert_equal 'http://www.example.com?params=' , url_for ( :params => '' )
804
+ assert_equal 'http://www.example.com?params=1' , url_for ( :params => 1 )
805
+ assert_equal 'http://www.example.com' , url_for
806
+ assert_equal 'http://www.example.com' , url_for ( :params => { } )
807
+ assert_equal 'http://www.example.com?name=tumayun' , url_for ( :params => { :name => 'tumayun' } )
808
+ end
809
+
802
810
protected
803
811
804
812
def stub_request ( env = { } )
You can’t perform that action at this time.
0 commit comments