Skip to content

Commit

Permalink
Merge pull request #6447 from adrianschroeter/auto_accept
Browse files Browse the repository at this point in the history
[api] ensure right user when doing auto_accept in a loop
  • Loading branch information
bgeuken authored Dec 4, 2018
2 parents c3c787a + fe91d48 commit 4584b12
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/api/app/models/bs_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 4584b12

Please sign in to comment.