From d03b150180983badd892acbbfadded90e1cb7bf2 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 6 Sep 2021 00:24:14 -0500 Subject: [PATCH] BURs: fix tag nukes not removing antecedent implications. Fix a bug where if A implied B, and A was nuked, then the A->B implication wasn't removed. --- app/logical/bulk_update_request_processor.rb | 1 + test/unit/bulk_update_request_test.rb | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/logical/bulk_update_request_processor.rb b/app/logical/bulk_update_request_processor.rb index 65895d06c..ed0fb3c61 100644 --- a/app/logical/bulk_update_request_processor.rb +++ b/app/logical/bulk_update_request_processor.rb @@ -158,6 +158,7 @@ class BulkUpdateRequestProcessor # otherwise the tag won't be removed from posts that have those other tags if PostQueryBuilder.new(args[0]).is_simple_tag? TagImplication.active.where(consequent_name: args[0]).each { |ti| ti.reject!(User.system) } + TagImplication.active.where(antecedent_name: args[0]).each { |ti| ti.reject!(User.system) } end TagBatchChangeJob.perform_later(args[0], "-#{args[0]}") diff --git a/test/unit/bulk_update_request_test.rb b/test/unit/bulk_update_request_test.rb index 5a14b4397..5e93405c4 100644 --- a/test/unit/bulk_update_request_test.rb +++ b/test/unit/bulk_update_request_test.rb @@ -327,10 +327,12 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase end should "remove implications" do - @ti = create(:tag_implication, antecedent_name: "foo", consequent_name: "bar") - create_bur!("nuke bar", @admin) + @ti1 = create(:tag_implication, antecedent_name: "fly", consequent_name: "insect") + @ti2 = create(:tag_implication, antecedent_name: "insect", consequent_name: "bug") + create_bur!("nuke insect", @admin) - assert_equal("deleted", @ti.reload.status) + assert_equal("deleted", @ti1.reload.status) + assert_equal("deleted", @ti2.reload.status) end should "remove pools" do