Assert_redirected_to behaviour

Consider following situation: you’ve got controller Foo that has
following routing rules related:

map.connect ‘/foo’, :controller => ‘foo’, :action => ‘index’ ‘/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]

you could write just

def bar
redirect_to :action => ‘baz’

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

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:

  1. construct url with parameters supplied for redirect_to method
  2. ask routing to recognize the url and get the parameters
  3. match resulting parameters with parameters supplied for

Any objections ?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs