Forum: Ruby on Rails Posting to a separate controller in a functional test

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
54079122b67de9677c1f93933ce8b63a?d=identicon&s=25 Mitchell Hashimoto (mitchellh)
on 2005-12-30 00:42
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
Ec2248a75e96081bb3f4547caa896224?d=identicon&s=25 Sandi Metz (Guest)
on 2005-12-30 20:29
(Received via mailing list)
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
This topic is locked and can not be replied to.