I am trying to use the application.html.erb file to create a navbar on all of my pages. I want some of the links to only show if a user is logged in, and some to show if a user is not logged in, so I have the following in views/layouts/application.html.erb:
...
<% if user_signed_in? %>
# Show some links
<% end %>
<% if not user_signed_in? %>
# Show some other links
<% end %>
...
This works when I go to the site, but the issue comes when I try to test with rake.
When I run my tests, I get the following error:
AppointmentsControllerTest#test_should_get_index: ActionView::Template::Error: Devise could not find the
Warden::Proxy
instance on your request environment. Make sure that your application is loading Devise and Warden as expected and that theWarden::Manager
middleware is present in your middleware stack. If you are seeing this on one of your tests, ensure that your tests are either executing the Rails middleware stack or that your tests are using theDevise::Test::ControllerHelpers
module to inject therequest.env['warden']
object for you.
All of the similar errors I found online do not seem to apply to this situation. I understand that there is an issue with Devise not being loaded while testing, but cannot figure out how to fix it. I have tried many different things and nothing has worked.
Any help is appreciated. Thanks!