Fix #4168: Ignore validations when rejecting tag changes.

* Only check for conflicts with existing aliases/implications when
  requests are created or approved, not when requests are rejected.

* Use `update!(status: "deleted")` instead of `update(status: "deleted")`
  so that if rejecting the request fails we fail immediately instead of
  continuing on and updating the forum topic.

* Wrap `reject!` and `TagChangeRequestPruner.reject_expired` in
  transactions so that if updating either the request or the forum
  fails, they both get rolled back.
This commit is contained in:
evazion
2019-09-17 01:04:01 -05:00
parent 6013b00fee
commit e3ae87cff7
6 changed files with 50 additions and 17 deletions

View File

@@ -29,14 +29,16 @@ class TagChangeRequestPruner
def reject_expired(model)
model.expired.pending.find_each do |tag_change|
if tag_change.forum_topic
name = model.model_name.human.downcase
body = "This #{name} has been rejected because it was not approved within 60 days."
tag_change.forum_updater.update(body)
end
transaction do
if tag_change.forum_topic
name = model.model_name.human.downcase
body = "This #{name} has been rejected because it was not approved within 60 days."
tag_change.forum_updater.update(body)
end
CurrentUser.as_system do
tag_change.reject!
CurrentUser.as_system do
tag_change.reject!
end
end
end
end