From 275e839b8dfa3cf2bdedf1b31302dec20ac96a46 Mon Sep 17 00:00:00 2001 From: J Smith Date: Wed, 21 Apr 2010 21:37:51 -0400 Subject: Ensure that url_for uses symbolized keys in the controller. [#4391] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionpack/test/controller/url_for_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionpack/test/controller/url_for_test.rb') diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index fc7773dffe..501f928e05 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -257,6 +257,16 @@ module AbstractController assert_equal second_class.default_url_options[:host], second_host end + def test_with_stringified_keys + assert_equal("/c/a", W.new.url_for('controller' => 'c', 'action' => 'a', 'only_path' => true)) + assert_equal("/c", W.new.url_for('controller' => 'c', 'only_path' => true)) + end + + def test_with_hash_with_indifferent_access + assert_equal("/c/a", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'action' => 'a', 'only_path' => true))) + assert_equal("/c", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'only_path' => true))) + end + private def extract_params(url) url.split('?', 2).last.split('&').sort -- cgit v1.2.3 From 920df0a4758d003dc284c13e439e0b9f60a6e6f0 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 22 Apr 2010 12:33:54 -0300 Subject: Make ActionDispatch url_for use HWIA symbolize_keys Signed-off-by: Jeremy Kemper --- actionpack/test/controller/url_for_test.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'actionpack/test/controller/url_for_test.rb') diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index 501f928e05..907acf9573 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -258,13 +258,17 @@ module AbstractController end def test_with_stringified_keys - assert_equal("/c/a", W.new.url_for('controller' => 'c', 'action' => 'a', 'only_path' => true)) assert_equal("/c", W.new.url_for('controller' => 'c', 'only_path' => true)) + assert_equal("/c/a", W.new.url_for('controller' => 'c', 'action' => 'a', 'only_path' => true)) end def test_with_hash_with_indifferent_access - assert_equal("/c/a", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'action' => 'a', 'only_path' => true))) + W.default_url_options[:controller] = 'd' + W.default_url_options[:only_path] = false assert_equal("/c", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'only_path' => true))) + + W.default_url_options[:action] = 'b' + assert_equal("/c/a", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'action' => 'a', 'only_path' => true))) end private @@ -273,4 +277,4 @@ module AbstractController end end end -end \ No newline at end of file +end -- cgit v1.2.3