Note that there are some explanatory texts on larger screens.

plurals
  1. PORSpec/Capybara Request Specs -- Can't get Devise to POST new user session
    text
    copied!<p>I'm trying to start a new user session by creating a helper that POSTs a new user session. Here is what I have</p> <pre><code>def login(user) post user_session_path, :login =&gt; user.username, :password =&gt; user.password end </code></pre> <p>And for user</p> <pre><code>user = Factory.create(:user) </code></pre> <p>I have a test in RSpec that directs the user to a page that requires authentication. Using the helper, I expect a new user session to be created. However, running the spec, it is telling me the current page is the login screen. This tells a new user session isn't being created and the user is being redirected to the login screen when accessing the restricted resource with no user session. Looking at the test logs, this is the case.</p> <p>Also looking at the logs, it is saying the POST action is unauthorized.</p> <pre><code>Started POST "/login" for 127.0.0.1 at 2012-02-04 13:34:59 -0800 Processing by SessionsController#create as HTML Parameters: {"login"=&gt;"foo12", "password"=&gt;"[FILTERED]"} Completed 401 Unauthorized in 1ms Processing by SessionsController#new as HTML Parameters: {"login"=&gt;"foo12", "password"=&gt;"[FILTERED]"} Rendered devise/shared/_links.erb (1.4ms) Completed 200 OK in 15ms (Views: 12.7ms | ActiveRecord: 0.0ms) </code></pre> <p>I tried manually using the login page through a browser and was able to create a session just fine. I've also wrote up a test with Capybara that visits the login page, fills in the user credentials, and submit. This creates a new user session with no problems.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload