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:
@@ -80,6 +80,16 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "#reject!" do
|
||||
should "not be blocked by validations" do
|
||||
ta1 = create(:tag_alias, antecedent_name: "kitty", consequent_name: "kitten", status: "active")
|
||||
ta2 = build(:tag_alias, antecedent_name: "cat", consequent_name: "kitty", status: "pending")
|
||||
|
||||
ta2.reject!
|
||||
assert_equal("deleted", ta2.reload.status)
|
||||
end
|
||||
end
|
||||
|
||||
context "on secondary validation" do
|
||||
should "warn about missing wiki pages" do
|
||||
ti = FactoryBot.build(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb", skip_secondary_validations: false)
|
||||
|
||||
@@ -76,6 +76,16 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "#reject!" do
|
||||
should "not be blocked by alias validations" do
|
||||
ti = create(:tag_implication, antecedent_name: "cat", consequent_name: "animal", status: "pending")
|
||||
ta = create(:tag_alias, antecedent_name: "cat", consequent_name: "kitty", status: "active")
|
||||
|
||||
ti.reject!
|
||||
assert_equal("deleted", ti.reload.status)
|
||||
end
|
||||
end
|
||||
|
||||
context "on secondary validation" do
|
||||
should "warn if either tag is missing a wiki" do
|
||||
ti = FactoryBot.build(:tag_implication, antecedent_name: "aaa", consequent_name: "bbb", skip_secondary_validations: false)
|
||||
|
||||
Reference in New Issue
Block a user