Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #6160 from carlosantoniodasilva/resource-route-can…

…onical-action

Force given path to http methods in mapper to skip canonical action checking
  • Loading branch information...
commit 9ce057d8ccc799eb4844494e3c6ee553969a66d3 2 parents 3f46e7a + d03aa10
@tenderlove tenderlove authored
View
5 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -535,7 +535,8 @@ def delete(*args, &block)
private
def map_method(method, args, &block)
options = args.extract_options!
- options[:via] = method
+ options[:via] = method
+ options[:path] ||= args.first if args.first.is_a?(String)
match(*args, options, &block)
self
end
@@ -1509,7 +1510,7 @@ def path_for_action(action, path) #:nodoc:
prefix = shallow_scoping? ?
"#{@scope[:shallow_path]}/#{parent_resource.path}/:id" : @scope[:path]
- path = if canonical_action?(action, path.blank?)
+ if canonical_action?(action, path.blank?)
prefix.to_s
else
"#{prefix}/#{action_path(action, path)}"
View
4 actionpack/test/controller/routing_test.rb
@@ -1405,7 +1405,7 @@ def test_route_constraints_with_supported_options_must_not_error
end
end
end
-
+
def test_route_with_subdomain_and_constraints_must_receive_params
name_param = nil
set.draw do
@@ -1418,7 +1418,7 @@ def test_route_with_subdomain_and_constraints_must_receive_params
set.recognize_path('http://subdomain.example.org/page/mypage'))
assert_equal(name_param, 'mypage')
end
-
+
def test_route_requirement_recognize_with_ignore_case
set.draw do
get 'page/:name' => 'pages#show',
View
9 actionpack/test/dispatch/routing_test.rb
@@ -171,6 +171,8 @@ def self.call(params, request)
post :preview, :on => :collection
end
end
+
+ post 'new', :action => 'new', :on => :collection, :as => :new
end
resources :replies do
@@ -876,6 +878,12 @@ def test_projects
assert_equal '/projects/1/edit', edit_project_path(:id => '1')
end
+ def test_projects_with_post_action_and_new_path_on_collection
+ post '/projects/new'
+ assert_equal "project#new", @response.body
+ assert_equal "/projects/new", new_projects_path
+ end
+
def test_projects_involvements
get '/projects/1/involvements'
assert_equal 'involvements#index', @response.body
@@ -2450,7 +2458,6 @@ def app; Routes end
get "/foo/bar/baz"
assert_equal "/pooh", @response.body
end
-
end
class TestTildeAndMinusPaths < ActionDispatch::IntegrationTest
Please sign in to comment.
Something went wrong with that request. Please try again.