Using Minitest with include Devise::Test::IntegrationHelpers
there is a method to ensure a user’s most recently invoked object is being processed. This method is run via callback:
before_action :proper_object_access, only: %i[ create update destroy ]
Out of curiosity, the following is intercepted in the method:
puts '1'
puts current_user.inspect
puts parti_id
puts @shop.id
puts sus.inspect
if [some logic]
puts 'OK'
The console with the application running, as expected, logs
1
#<User id: 21, email: "[...]
22
3
[21]
OK
but the test logs:
1
#<User id: 402000716, email: [...]
375452984
575799906
[402000716]
OK
[some other data intercepted via puts]
1
nil
375452984
575799906
[402000716]
for the testing line delete crecipe_url(@crecipe), params: { [...]
Thus, it appears the callback is being run a second time, the latter losing the signed_in user.
Why would a callback be run twice?