Mitchell Hashimoto
2005-Dec-29 23:42 UTC
Posting to a separate controller in a functional test
Hi,
I need to post to a controller to log in a user in a functional test,
but I''m not sure what to do to post to a separate controller.
I''ve
tried:
post { :controller => :account, :action => :do_login }, { bla bla bla }
But that doesnt seem to have worked. Help?
Mitch
--
Posted via http://www.ruby-forum.com/.
Sandi Metz
2005-Dec-30 19:27 UTC
Re: Posting to a separate controller in a functional test
I had this same problem and managed to post to a different controller by
explicitly setting the @controller variable.
In my home_controller_test.rb, where
def setup
@controller = HomeController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
I had to
@controller = LoginController.new
post :login, :user => {:name => name, :password => password}
to get a post to go to the LoginController.
Hope this helps,
Sandi
Mitchell Hashimoto wrote:
>Hi,
>
>I need to post to a controller to log in a user in a functional test,
>but I''m not sure what to do to post to a separate controller.
I''ve
>tried:
>
>post { :controller => :account, :action => :do_login }, { bla bla bla
}
>
>But that doesnt seem to have worked. Help?
>
>Mitch
>
>
>