Ben Lisbakken
2006-Aug-24 23:02 UTC
[Rails] How to test a controller action which is passed params from a form?
here''s my code for an action (add_user) in my login_controller, as well as the form that calls add_user: http://rafb.net/paste/results/3Paw8119.html So in my test of this controller, I want to test add_user. So I need to pass it the name and password. How do I do this? I know this doesn''t work: process ''add_user'', ''name'' => ''Ben'', ''password'' => ''password'' Thanks! Ben Lisbakken --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Chris Hall
2006-Aug-24 23:33 UTC
[Rails] Re: How to test a controller action which is passed params from a form?
from your posted source, your input field names would be generated by rails as
user[name]
user[password]
user[password_confirmation]
so try
process ''add_user'', { ''user[name]'' =>
''Bob'', ''user[password]'' =>
''password'', ''user[password_confirmation]''
=> ''password'' }
chris
On 8/24/06, Ben Lisbakken
<lisbakke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> here''s my code for an action (add_user) in my login_controller, as
well
> as the form that calls add_user:
> http://rafb.net/paste/results/3Paw8119.html
>
> So in my test of this controller, I want to test add_user. So I need
> to pass it the name and password. How do I do this?
>
> I know this doesn''t work:
> process ''add_user'', ''name'' =>
''Ben'', ''password'' =>
''password''
>
>
> Thanks!
> Ben Lisbakken
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---