I tried using the code in the RailsGuides and some other code I found on Google, but nothing is working.
How do you do a simple integ开发者_JAVA技巧ration test in Rails 3 using Test::Unit? How do you make the session persist across http requests?
The following code fails because Expected response to be a <:success>, but was <302>
. I think it is because the session is lost after the post request.
class UserFlowsTest < ActionDispatch::IntegrationTest
fixtures :all
test "client can get client dashboard" do
post '/login', :login=> users(:client).login, :password => 'thepassword'
get '/dash'
assert_response :success
end
end
Working in Rails 3.07.
Thanks.
It turns out the above code is correct.
I had changed part of the user validation code, causing a redirect to the login form when I did not intend. That's why the response was 302 (redirect).
精彩评论