diff --git a/src/api/app/models/bs_request.rb b/src/api/app/models/bs_request.rb index e833cd3e874..540223fdf29 100644 --- a/src/api/app/models/bs_request.rb +++ b/src/api/app/models/bs_request.rb @@ -1185,19 +1185,15 @@ def check_bs_request_actions!(opts = {}) raisepriority(action.minimum_priority) end - return unless persisted? - - # rubocop:disable Style/GuardClause - if priority_changed? - HistoryElement::RequestPriorityChange.create({ - request: self, - # We need to have a user here - user: User.find_nobody!, - description_extension: "#{priority_was} => #{priority}", - comment: "Automatic priority bump: Priority of related action increased." - }) - end - # rubocop:enable Style/GuardClause + return unless persisted? && priority_changed? + + HistoryElement::RequestPriorityChange.create({ + request: self, + # We need to have a user here + user: User.find_nobody!, + description_extension: "#{priority_was} => #{priority}", + comment: "Automatic priority bump: Priority of related action increased." + }) end def _assignreview_update_reviews(reviewer, opts, new_review = nil) diff --git a/src/api/spec/models/bs_request_spec.rb b/src/api/spec/models/bs_request_spec.rb index cffb29d00ff..cdd72ec2eab 100644 --- a/src/api/spec/models/bs_request_spec.rb +++ b/src/api/spec/models/bs_request_spec.rb @@ -273,9 +273,7 @@ end it 'does not change the priority of the bs request' do - # rubocop:disable Lint/AmbiguousBlockAssociation - expect { bs_request.sanitize! }.not_to change{ HistoryElement::RequestPriorityChange.count } - # rubocop:enable Lint/AmbiguousBlockAssociation + expect { bs_request.sanitize! }.not_to(change { HistoryElement::RequestPriorityChange.count }) expect(bs_request.priority).to eq('moderate') end end