Forum: Ruby on Rails assert_redirected_to behaviour

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Maxim K. (Guest)
on 2006-03-22 13:08
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 topic is locked and can not be replied to.