From 75df4c11650a148f6672ce6407b624b840ec7b50 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sun, 29 Apr 2012 23:12:42 +0100 Subject: Restore interpolation of path option in redirect routes --- actionpack/test/dispatch/routing_test.rb | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'actionpack/test/dispatch/routing_test.rb') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index ce5cc16ace..4b8d308043 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -63,8 +63,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get 'secure', :to => redirect("/secure/login") get 'mobile', :to => redirect(:subdomain => 'mobile') + get 'documentation', :to => redirect(:domain => 'example-documentation.com', :path => '') + get 'new_documentation', :to => redirect(:path => '/documentation/new') get 'super_new_documentation', :to => redirect(:host => 'super-docs.com') + get 'stores/:name', :to => redirect(:subdomain => 'stores', :path => '/%{name}') + get 'stores/:name(*rest)', :to => redirect(:subdomain => 'stores', :path => '/%{name}%{rest}') + get 'youtube_favorites/:youtube_id/:name', :to => redirect(YoutubeFavoritesRedirector) constraints(lambda { |req| true }) do @@ -693,11 +698,31 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest verify_redirect 'http://mobile.example.com/mobile' end + def test_redirect_hash_with_domain_and_path + get '/documentation' + verify_redirect 'http://www.example-documentation.com' + end + + def test_redirect_hash_with_path + get '/new_documentation' + verify_redirect 'http://www.example.com/documentation/new' + end + def test_redirect_hash_with_host get '/super_new_documentation?section=top' verify_redirect 'http://super-docs.com/super_new_documentation?section=top' end + def test_redirect_hash_path_substitution + get '/stores/iernest' + verify_redirect 'http://stores.example.com/iernest' + end + + def test_redirect_hash_path_substitution_with_catch_all + get '/stores/iernest/products' + verify_redirect 'http://stores.example.com/iernest/products' + end + def test_redirect_class get '/youtube_favorites/oHg5SJYRHA0/rick-rolld' verify_redirect 'http://www.youtube.com/watch?v=oHg5SJYRHA0' @@ -2459,17 +2484,23 @@ class TestRedirectInterpolation < ActionDispatch::IntegrationTest ok = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, []] } get "/foo/:id" => redirect("/foo/bar/%{id}") + get "/bar/:id" => redirect(:path => "/foo/bar/%{id}") get "/foo/bar/:id" => ok end end def app; Routes end - test "redirect escapes interpolated parameters" do + test "redirect escapes interpolated parameters with redirect proc" do get "/foo/1%3E" verify_redirect "http://www.example.com/foo/bar/1%3E" end + test "redirect escapes interpolated parameters with option proc" do + get "/bar/1%3E" + verify_redirect "http://www.example.com/foo/bar/1%3E" + end + private def verify_redirect(url, status=301) assert_equal status, @response.status -- cgit v1.2.3