This test of my signups controller fails on the last line: it gets
redirected to the account/login page.
get :signup, :id => 1 # must be logged in to view this page
assert_redirected_to :action => 'login'
login_as :quentin
post :create, :form_data => {:first_name => "joe", :last_name =>
The create action does require login, but if I comment out the first two
lines, then it passes, so the login seems to work. Somehow the first get
request is changing what happens when i call login_as and then post to
signups/create. I assume I just don’t understand something about why
that would change some important state. Maybe I’m only supposed to have
one get or post per test? Can someone explain it?
I also tried this and it passes:
login_as :quentin
get :signup, :id => 1
post :create, :form_data => {:first_name => "joe", :last_name =>
Functional test you will only deal with testing one action. In
integration tests you can test across different controllers and
action.
I thought functional tests were supposed to focus on individual
controllers, not individual actions. This test does not touch multiple
controllers except that some actions redirect elsewhere and you can make
assertions about where it’s redirected. Are you saying you can’t use get
or post twice in one functional test, or what did I do wrong? What if
they were both for the same action?