I am having awful trouble getting functional tests to work when using devise and declarative authorization. I can use the devise test helpers to sign_in a user and then the current_user variable is populated in the controller. But as soon as I use the post_with test helper for declarative authorization the current_user becomes nil.
Can anybody point me at an example of how to write functional tests when using devise and declarative authorization together?
Thanks
I had the same problem.
You can’t use declarative authorizations testhelper such as post_with in functional tests with devise.
For functional test you mus use the devise testhelper such as sign_in and sign_out. I’ve wrote a helper which uses the devise test helper methods for functional tests:
This helper i use in the following way:
Hope that helps.