functional test question

I have a view that passes two params hashes (:user and :school) to my
controller action. In the functional test for the controller action,
how do pass these two hashes?

I tried the following that did not work
  get(:create, [:user => {:firstname => 'xxx', :lastname =>
'yyyy'}, :school => {:id => 1}] )

It seems to pick only the first array element.

Anybody run into this issue and knows how to do this?

-Navjeet

njs wrote:

I tried the following that did not work
get(:create, [:user => {:firstname => 'xxx', :lastname =>
'yyyy'}, :school => {:id => 1}] )

You are thinking too hard. Rails typically requires less effort.

get :create, :user => {:firstname => 'xxx', :lastname => 'yyyy'}, :school => {:id => 1}

Now get inside def create, and add

   p params

Run the test, and you will see how your parameters pass thru.

Anybody run into this issue and knows how to do this?

Have you read /Agile Web Development with Rails/? It covers all this stuff.

Hi --

I have a view that passes two params hashes (:user and :school) to my
controller action. In the functional test for the controller action,
how do pass these two hashes?

I tried the following that did not work
  get(:create, [:user => {:firstname => 'xxx', :lastname =>
'yyyy'}, :school => {:id => 1}] )

It seems to pick only the first array element.

Anybody run into this issue and knows how to do this?

You don't need to wrap your hashes in an array. In fact, you need not to :slight_smile:

  get(:create,
        :user => {:firstname => 'xxx', :lastname => 'yyyy'},
        :school => {:id => 1})

:user and :school are themselves hash keys, and the hash to which they
belong is implicit in your argument list, based on the Ruby rule that
if the last thing in an argument list is a literal hash, you can leave
off the curly braces.

David