Anyone know how to set the devise helper function #current_user in a controller test (using fixture data) for a Rails 5 app? I've tried the following:
sign_in users(:example_user)
@current_user = users(:example_user)
current_user = users(:example_user)
@controller.stubs(:current_user).returns(users(:example_user))
.
I'm writing tests for the paper_trail gem, which uses #current_user to set the 'whodunnit' attribute (i.e. id of current_user) on the version.
ActionDispatch::IntegrationTest
as this is a more future proof way forward. An added bonus is you can simply useinclude Warden::Test::Helpers
and login users withlogin_as @user
– YoghActionDispatch::IntegrationTest
and stop poking around in the internals. – Yoghlogin_as
on my paper_trail projects. To the OP: re: paper_trail, make sure to read section 4.a. Finding Out Who Was Responsible For A Change – Adeline