Permalink
Browse files

Add failing test case for parameters with periods

[#2536 state:resolved]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 0883b2b commit 3d8200318aab7458e019e2e434901cccc2532979 @pixeltrix pixeltrix committed with jeremy Jun 25, 2010
Showing with 27 additions and 0 deletions.
  1. +27 −0 actionpack/test/dispatch/routing_test.rb
@@ -213,6 +213,9 @@ def self.matches?(request)
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 @@ def test_shallow_nested_routes_ignore_module
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

0 comments on commit 3d82003

Please sign in to comment.