I have several actions that are protected by filters that check for logged_in?
and admin?
and spit out 401 or 403 errors respectively if the tests fail. What's a good way of getting around these filters in development mode only so I can test out my app?
I can't go through the actual login procedure because it relies on infrastructure I don't have access to during development.
I'd also like to be able to check that the 401s and 403s properly, so I don't want to just turn all the auth filters off completely. And I want it defined in as few places as possible so I don't accidentally let the world bypass the filters in production.
Has anyone found a good overriding mechanism? Some ideas I've come up with:
- add a check for
params[:logged_in] && RAILS_ENV =~ /dev/
andparams[:admin] && RAILS_ENV =~ /dev/
in the filters respectively. That works forGET
s, but I have to add extra hidden fields to all my forms and my AJAX requests. - add a link available in devevelopment mode only that mocks a login as a regular user or as an admin. This seems to be a better option all around.