Whenever we use deep nested routes, we might end up with a lot
of recurrent parameters.
Currently, it seems we have no other choice but to repeat them all
when making the request to test the action.
The patch I've written and I suggest allows to define some
"global parameters".
These global parameters are defined before to call the process
method and so allows us to avoid defining them for every
request.
So we can have the following :
class PostsControllerTest < ActionController::TestCase
def setup
@request.global_parameters[:test] = 'foo'
end
test "it should make a request" do
get :index
end
end
Our get request will have the parameter "test" provided with the
value "foo".
My patch does a merge of the global parameters with the
request's parameters. So if you provide parameters directly in the
get method, they'll override the global ones.
In the class, if we add a test
test "it should make a second request" do
get :index, :test => 'bar'
end
The test parameter will have the 'bar' value.
The global parameters are reseted after every request. So you
can't put them in the initialize method. But they're not spread
across controllers.
My patch is currently only for Rails 3. And I'd like some
comments about this before to also do it for rails 2.3.
But if this works, I'll make a second patch.