aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-06-25 12:16:43 +0100
committerJeremy Kemper <jeremy@bitsweat.net>2010-06-25 10:12:11 -0700
commit3d8200318aab7458e019e2e434901cccc2532979 (patch)
tree839939792ceb92be9391a23fdeefc4e97fae5b8c /actionpack/test/dispatch/routing_test.rb
parent0883b2b0c3dbe85a473a83cce6d1f733e0b74cb6 (diff)
downloadrails-3d8200318aab7458e019e2e434901cccc2532979.tar.gz
rails-3d8200318aab7458e019e2e434901cccc2532979.tar.bz2
rails-3d8200318aab7458e019e2e434901cccc2532979.zip
Add failing test case for parameters with periods
[#2536 state:resolved] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 8f43b5f934..915c51a020 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -213,6 +213,9 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "profile" => "customers#profile", :as => :profile, :on => :member
post "preview" => "customers#preview", :as => :preview, :on => :new
end
+ scope(':version', :version => /.+/) do
+ resources :users, :id => /.+?/, :format => /json|xml/
+ end
end
match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp
@@ -1421,6 +1424,30 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_non_greedy_regexp
+ with_test_routes do
+ get '/api/1.0/users'
+ assert_equal 'api/users#index', @response.body
+ assert_equal '/api/1.0/users', api_users_path(:version => '1.0')
+
+ get '/api/1.0/users.json'
+ assert_equal 'api/users#index', @response.body
+ assert_equal true, @request.format.json?
+ assert_equal '/api/1.0/users.json', api_users_path(:version => '1.0', :format => :json)
+
+ get '/api/1.0/users/first.last'
+ assert_equal 'api/users#show', @response.body
+ assert_equal 'first.last', @request.params[:id]
+ assert_equal '/api/1.0/users/first.last', api_user_path(:version => '1.0', :id => 'first.last')
+
+ get '/api/1.0/users/first.last.xml'
+ assert_equal 'api/users#show', @response.body
+ assert_equal 'first.last', @request.params[:id]
+ assert_equal true, @request.format.xml?
+ assert_equal '/api/1.0/users/first.last.xml', api_user_path(:version => '1.0', :id => 'first.last', :format => :xml)
+ end
+ end
+
private
def with_test_routes
yield