From 4ee3eee2390e7a5ae16540531d049ba6d379f950 Mon Sep 17 00:00:00 2001 From: Dawid Fatyga Date: Thu, 11 Nov 2010 13:39:03 +0100 Subject: [PATCH] Added failing test for path globbing with format [#1939 state:open] --- actionpack/test/dispatch/routing_test.rb | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 0ac8c24..0f2bdeb 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -468,7 +468,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest match '/countries/:country/(*other)', :to => redirect{ |params, req| params[:other] ? "/countries/all/#{params[:other]}" : '/countries/all' } - match '/:locale/*file.:format', :to => 'files#show', :file => /path\/to\/existing\/file/ + match '/:locale/*file.:format', + :to => 'files#show', + :file => /path\/to\/existing\/file/, + :defaults => { :format => "html" }, + :as => "file" end end @@ -2170,6 +2174,22 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + def test_route_globbing_with_optional_format + with_test_routes do + get '/en/path/to/existing/file.xml' + assert_equal 'files#show', @response.body + assert_equal true, @request.format.xml? + assert_equal 'path/to/existing/file', @request.params[:file] + assert_equal '/en/path/to/existing/file.xml', file_path(:locale => "en", :file => 'path/to/existing/file', :format => "xml") + + get '/fr/path/to/existing/file' + assert_equal 'files#show', @response.body + assert_equal true, @request.format.html? + assert_equal 'path/to/existing/file', @request.params[:file] + assert_equal '/fr/path/to/existing/file', file_path(:locale => "fr", :file => 'path/to/existing/file') + end + end + private def with_test_routes yield -- 1.7.1