From 03cbd9672cfc142842c95aae0fb27b8eb27e6990 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 9 Mar 2011 14:44:25 +0000 Subject: Filter params that return nil for to_param and allow through false values --- actionpack/test/controller/url_for_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index 1c28da33bd..3f3d6dcc2f 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -311,6 +311,14 @@ module AbstractController assert_equal("/c/a", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'action' => 'a', 'only_path' => true))) end + def test_url_params_with_nil_to_param_are_not_in_url + assert_equal("/c/a", W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :id => Struct.new(:to_param).new(nil))) + end + + def test_false_url_params_are_included_in_query + assert_equal("/c/a?show=false", W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :show => false)) + end + private def extract_params(url) url.split('?', 2).last.split('&').sort -- cgit v1.2.3