Consider following situation: you’ve got controller Foo that has
following routing rules related:
map.connect ‘/foo’, :controller => ‘foo’, :action => ‘index’
map.foo ‘/foo/:x/:y/:z/:action’, :controller => ‘foo’
You want all Foo actions to make use of partial url rewriting, so
instead of writing:
def bar
params[:x], params[:y] and params[:z] contain action parameters
redirect_to :action => ‘baz’, :x => params[:x], :y => params[:y], :z
=> params[:z]
end
you could write just
def bar
redirect_to :action => ‘baz’
end
and have all those x, y and z parameters inherited from bar action.
So far, rails has that feature available.
Then you write a functional test something like this:
def test_bar
get :bar, :x => 1, :y => 5, :z => 2
assert_redirected_to :action => :baz, :x => 1, :y => 5, :z => 2
end
As far as I see, now assert_redirected_to only matches parameters
supplied to it with parameters supplied to redirect_to method. I think,
that assert should work something like this:
- construct url with parameters supplied for redirect_to method
- ask routing to recognize the url and get the parameters
- match resulting parameters with parameters supplied for
assert_redirected_to
Any objections ?