aliases/implications: change automatic retirement rules.

Change the rules for automatically retiring aliases and implications:

* Retire aliases to tags that are empty, or that are for a general or
  artist tag that hasn't received any new posts in the last two years.
* Retire implications from tags that are empty.
* Don't retire aliases or implications for character, copyright, or
  meta tags any more, unless the tags are empty.
This commit is contained in:
evazion
2021-11-05 05:46:50 -05:00
parent 65ab7f1eb5
commit a5f589f9e0
6 changed files with 136 additions and 92 deletions

View File

@@ -1,62 +0,0 @@
require 'test_helper'
class TagRelationshipRetirementServiceTest < ActiveSupport::TestCase
context ".forum_topic" do
subject { TagRelationshipRetirementService }
should "create a new topic if one doesn't already exist" do
assert_difference(-> { ForumTopic.count }) do
subject.forum_topic
end
end
should "create a new post if one doesn't already exist" do
assert_difference(-> { ForumPost.count }) do
subject.forum_topic
end
end
end
context ".each_candidate" do
subject { TagRelationshipRetirementService }
setup do
subject.stubs(:is_unused?).returns(true)
@new_alias = create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb")
@old_alias = create(:tag_alias, antecedent_name: "ccc", consequent_name: "ddd", created_at: 3.years.ago)
end
should "find old tag relationships" do
subject.each_candidate(TagAlias) do |rel|
assert_equal(@old_alias, rel)
end
end
should "not find new tag relationships" do
subject.each_candidate(TagAlias) do |rel|
assert_not_equal(@new_alias, rel)
end
end
end
context ".is_unused?" do
subject { TagRelationshipRetirementService }
setup do
@new_alias = create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb")
@new_post = create(:post, tag_string: "bbb")
@old_alias = create(:tag_alias, antecedent_name: "ccc", consequent_name: "ddd", created_at: 3.years.ago)
@old_post = create(:post, tag_string: "ddd", created_at: 3.years.ago)
end
should "return true if no recent post exists" do
assert(subject.is_unused?("ddd"))
end
should "return false if a recent post exists" do
refute(subject.is_unused?("bbb"))
end
end
end