Fix #3554: approving BUR with nil forum_post_id doesn't update forum.
Wrap `approve!` and `reject!` in transactions so that if there's an error in approving or rejecting a BUR, it leaves the BUR's status unchanged instead of updating the BUR but not updating the forum.
This commit is contained in:
@@ -90,10 +90,12 @@ class BulkUpdateRequest < ApplicationRecord
|
||||
end
|
||||
|
||||
def approve!(approver)
|
||||
CurrentUser.scoped(approver) do
|
||||
AliasAndImplicationImporter.new(script, forum_topic_id, "1", true).process!
|
||||
update(status: "approved", approver: CurrentUser.user, skip_secondary_validations: true)
|
||||
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been approved by @#{approver.name}.", "APPROVED")
|
||||
transaction do
|
||||
CurrentUser.scoped(approver) do
|
||||
AliasAndImplicationImporter.new(script, forum_topic_id, "1", true).process!
|
||||
update(status: "approved", approver: CurrentUser.user, skip_secondary_validations: true)
|
||||
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been approved by @#{approver.name}.", "APPROVED")
|
||||
end
|
||||
end
|
||||
|
||||
rescue AliasAndImplicationImporter::Error => x
|
||||
@@ -118,8 +120,10 @@ class BulkUpdateRequest < ApplicationRecord
|
||||
end
|
||||
|
||||
def reject!(rejector)
|
||||
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been rejected by @#{rejector.name}.", "REJECTED")
|
||||
update_attribute(:status, "rejected")
|
||||
transaction do
|
||||
update(status: "rejected")
|
||||
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been rejected by @#{rejector.name}.", "REJECTED")
|
||||
end
|
||||
end
|
||||
|
||||
def bulk_update_request_link
|
||||
|
||||
Reference in New Issue
Block a user