diff --git a/src/api/app/models/bs_request.rb b/src/api/app/models/bs_request.rb index 77b1a21fb84..31f31e55170 100644 --- a/src/api/app/models/bs_request.rb +++ b/src/api/app/models/bs_request.rb @@ -969,8 +969,12 @@ def auto_accept return if approver && state == :review with_lock do - User.current ||= User.find_by_login(creator) if accept_at - User.current = User.find_by_login(approver) if approver + if accept_at + User.current = User.find_by_login(creator) + elsif approver + User.current = User.find_by_login(approver) + end + raise 'Request lacks definition of owner for auto accept' unless User.current begin change_state(newstate: 'accepted', comment: 'Auto accept')