I have an app with admin users created with the devise gem.
I have succeeded in redirecting anyone who tries to access an admin
page but is NOT logged in as an admin to the root_path
However, I’m having difficulty getting the tests to pass in my
test. (I’m using Capybara and minitest.)
In the admins controller, the first line under “def index” is:
redirect_to(root_path) unless admin_signed_in?
In the integration test, I start with the following code:
test_prepare # From test/test_helper.rb
@u1 = users(:connery) # From test/fixtures/users.yml
@a1 = admins(:vivian_kensington) # From test/fixtures/admin.yml
fill_in(‘Email’, with: ‘[email protected]’)
fill_in(‘Password’, with: ‘original’)
How do I test for the redirect? The path parameter at this point is nil
and NOT root_path or ‘/’.