diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 15da17a810..b84a10c706 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -86,7 +86,9 @@ module OpenProject::RSpecLazinessWarn def self.warn_if_user_current_set(example) # Using the hacky way of getting current_user to avoid under the hood creation of AnonymousUser # which might break other tests and at least leaves this user in the db after the test is run. - unless User.instance_variable_get(:@current_user).nil? + current_user = User.instance_variable_get(:@current_user) + + unless current_user.nil? || current_user.is_a?(AnonymousUser) # we only want an abbreviated_stacktrace because the logfiles # might otherwise not be capable to show all the warnings.