Tag nuke: remove implications to a tag before nuking it
This commit is contained in:
@@ -15,6 +15,7 @@ class BulkUpdateRequestProcessor
|
|||||||
class Error < StandardError; end
|
class Error < StandardError; end
|
||||||
|
|
||||||
attr_reader :bulk_update_request
|
attr_reader :bulk_update_request
|
||||||
|
|
||||||
delegate :script, :forum_topic, to: :bulk_update_request
|
delegate :script, :forum_topic, to: :bulk_update_request
|
||||||
validate :validate_script
|
validate :validate_script
|
||||||
validate :validate_script_length
|
validate :validate_script_length
|
||||||
@@ -153,6 +154,12 @@ class BulkUpdateRequestProcessor
|
|||||||
TagBatchChangeJob.perform_later(args[0], args[1])
|
TagBatchChangeJob.perform_later(args[0], args[1])
|
||||||
|
|
||||||
when :nuke
|
when :nuke
|
||||||
|
# Reject existing implications from any other tag to the one we're nuking
|
||||||
|
# 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(&:reject!)
|
||||||
|
end
|
||||||
|
|
||||||
TagBatchChangeJob.perform_later(args[0], "-#{args[0]}")
|
TagBatchChangeJob.perform_later(args[0], "-#{args[0]}")
|
||||||
|
|
||||||
when :rename
|
when :rename
|
||||||
|
|||||||
@@ -320,11 +320,11 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "the nuke command" do
|
context "the nuke command" do
|
||||||
should "remove tags" do
|
should "remove tags" do
|
||||||
@p1 = create(:post, tag_string: "foo")
|
@post = create(:post, tag_string: "foo bar")
|
||||||
@p2 = create(:post, tag_string: "bar")
|
@bur1 = create_bur!("imply foo -> bar", @admin)
|
||||||
@bur = create_bur!("nuke foo", @admin)
|
@bur2 = create_bur!("nuke bar", @admin)
|
||||||
|
|
||||||
assert_equal("tagme", @p1.reload.tag_string)
|
assert_equal("foo", @post.reload.tag_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "remove pools" do
|
should "remove pools" do
|
||||||
|
|||||||
Reference in New Issue
Block a user