Hello,
I am trying to perform a user login in a before block in my integration tests, because authentication is necessary prior to entering the site.
Authentication is handled by LDAP, but I am stubbing that out for the time being.
The following approach is not working:
feature 'admin access' do
before do
login(user)
end
scenario "can view Projects link" do
visit root_path
page.must_have_link 'Projects'
end
end
def login(user)
visit new_user_session_path
# FIXME: Bypass LDAP authentication for the time being
User.stubs(:authenticate_with_ldap).returns(user)
page.find('#user_username').set(user.username)
page.find('#user_password').set('123456')
page.find('input[type=submit]').click
end
I can see that the session controller handles the login successfully and redirects to the after_sign_in_path for the user.
However the test fails with the following error:
No route matches [GET] "/path-to/users/sign_in"
(My app is mounted in a sub-directory named path-to, using the relative_url_root configuration parameter).
When I debug the session controller and check the response the session controller provides, I see that the body contains:
'You are being redirected'
I have no idea why there is a routing error, for the login page no less, even though the test clearly manages to navigate to the login page and authenticate providing username and password successfully....
Any clues as to why I might be encountering these issues?
Thank you,
Mark