I’m having trouble with my routing, and was wondering if anyone else
had seen something similar.
I’ve got these two routes:
map.login ‘/login’, :controller => ‘sessions’, :action =>
‘new’, :requirements => { :method => :get }
map.connect ‘/login’, :controller => ‘sessions’, :action =>
‘create’, :requirements => { :method => :post }
and I have these tests:
a. assert_recognizes({:controller => ‘sessions’, :action => ‘new’},
{:path => ‘/login’, :method => :get})
b. assert_recognizes({:controller => ‘sessions’, :action => ‘create’},
{:path => ‘/login’, :method => :post})
I get the failure messages:
a. The recognized options <{“action”=>“new”, “method”=>:get,
“controller”=>“sessions”}> did not match <{“action”=>“new”,
“controller”=>“sessions”}>, difference: <{“method”=>:get}>
b. The recognized options <{“action”=>“new”, “method”=>:get,
“controller”=>“sessions”}> did not match <{“action”=>“create”,
“controller”=>“sessions”}>, difference: <{“action”=>“create”,
“method”=>:post}>
I have two problems:
-
In the API for AssertRouting, it shows these calls without
{ :method => xxx } in the first argument. Changing the first call to
assert_recognizes({:controller => ‘sessions’, :action =>
‘new’, :method => :get}, {:path => ‘/login’, :method => :get})
works, but I feel like I shouldn’t need to do that. -
Even if I change the second call to
assert_recognizes({:controller => ‘sessions’, :action =>
‘create’, :method => :post}, {:path => ‘/login’, :method => :post})
it still fails with the same error. It’s as though Rails is ignoring
the requirements of the first route.
Thanks in advance for any help,
Gaius