Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
6 changed files
with
136 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
require 'test_helper' | ||
|
||
class RetireTagRelationshipsJobTest < ActiveJob::TestCase | ||
context "RetireTagRelationshipsJob" do | ||
should "create a new forum topic if one doesn't already exist" do | ||
create(:tag_alias, created_at: 3.years.ago, antecedent_name: "0", consequent_name: "1") | ||
RetireTagRelationshipsJob.perform_now | ||
|
||
assert_equal(true, ForumTopic.exists?(title: TagRelationshipRetirementService::FORUM_TOPIC_TITLE)) | ||
assert_equal(true, ForumPost.exists?(body: TagRelationshipRetirementService::FORUM_TOPIC_BODY)) | ||
end | ||
|
||
should "retire inactive gentag and artist aliases" do | ||
ta0 = create(:tag_alias, created_at: 3.years.ago, antecedent_name: "0", consequent_name: "artist") | ||
ta1 = create(:tag_alias, created_at: 3.years.ago, antecedent_name: "1", consequent_name: "general") | ||
ta2 = create(:tag_alias, created_at: 3.years.ago, antecedent_name: "2", consequent_name: "character") | ||
ta3 = create(:tag_alias, created_at: 3.years.ago, antecedent_name: "3", consequent_name: "copyright") | ||
ta4 = create(:tag_alias, created_at: 3.years.ago, antecedent_name: "4", consequent_name: "meta") | ||
|
||
as(User.system) do | ||
create(:post, created_at: 3.years.ago, tag_string: "art:artist") | ||
create(:post, created_at: 3.years.ago, tag_string: "gen:general") | ||
create(:post, created_at: 3.years.ago, tag_string: "char:character") | ||
create(:post, created_at: 3.years.ago, tag_string: "copy:copyright") | ||
create(:post, created_at: 3.years.ago, tag_string: "meta:meta") | ||
end | ||
|
||
RetireTagRelationshipsJob.perform_now | ||
|
||
assert_equal(true, ta0.reload.is_retired?) | ||
assert_equal(true, ta1.reload.is_retired?) | ||
assert_equal(false, ta2.reload.is_retired?) | ||
assert_equal(false, ta3.reload.is_retired?) | ||
assert_equal(false, ta4.reload.is_retired?) | ||
end | ||
|
||
should "not retire old aliases with recent posts" do | ||
ta0 = create(:tag_alias, created_at: 3.years.ago, antecedent_name: "0", consequent_name: "artist") | ||
ta1 = create(:tag_alias, created_at: 3.years.ago, antecedent_name: "1", consequent_name: "general") | ||
ta2 = create(:tag_alias, created_at: 3.years.ago, antecedent_name: "2", consequent_name: "character") | ||
ta3 = create(:tag_alias, created_at: 3.years.ago, antecedent_name: "3", consequent_name: "copyright") | ||
ta4 = create(:tag_alias, created_at: 3.years.ago, antecedent_name: "4", consequent_name: "meta") | ||
|
||
as(User.system) do | ||
create(:post, created_at: 1.week.ago, tag_string: "art:artist") | ||
create(:post, created_at: 1.week.ago, tag_string: "gen:general") | ||
create(:post, created_at: 1.week.ago, tag_string: "char:character") | ||
create(:post, created_at: 1.week.ago, tag_string: "copy:copyright") | ||
create(:post, created_at: 1.week.ago, tag_string: "meta:meta") | ||
end | ||
|
||
RetireTagRelationshipsJob.perform_now | ||
|
||
assert_equal(false, ta0.reload.is_retired?) | ||
assert_equal(false, ta1.reload.is_retired?) | ||
assert_equal(false, ta2.reload.is_retired?) | ||
assert_equal(false, ta3.reload.is_retired?) | ||
assert_equal(false, ta4.reload.is_retired?) | ||
end | ||
|
||
should "retire empty aliases" do | ||
create(:tag, name: "artist", post_count: 0, category: Tag.categories.artist) | ||
create(:tag, name: "general", post_count: 0, category: Tag.categories.general) | ||
create(:tag, name: "character", post_count: 0, category: Tag.categories.character) | ||
create(:tag, name: "copyright", post_count: 0, category: Tag.categories.copyright) | ||
create(:tag, name: "meta", post_count: 0, category: Tag.categories.meta) | ||
|
||
ta0 = create(:tag_alias, antecedent_name: "0", consequent_name: "artist") | ||
ta1 = create(:tag_alias, antecedent_name: "1", consequent_name: "general") | ||
ta2 = create(:tag_alias, antecedent_name: "2", consequent_name: "character") | ||
ta3 = create(:tag_alias, antecedent_name: "3", consequent_name: "copyright") | ||
ta4 = create(:tag_alias, antecedent_name: "4", consequent_name: "meta") | ||
|
||
RetireTagRelationshipsJob.perform_now | ||
|
||
assert_equal(true, ta0.reload.is_retired?) | ||
assert_equal(true, ta1.reload.is_retired?) | ||
assert_equal(true, ta2.reload.is_retired?) | ||
assert_equal(true, ta3.reload.is_retired?) | ||
assert_equal(true, ta4.reload.is_retired?) | ||
end | ||
|
||
should "retire empty implications" do | ||
create(:tag, name: "artist", post_count: 0, category: Tag.categories.artist) | ||
create(:tag, name: "general", post_count: 0, category: Tag.categories.general) | ||
create(:tag, name: "character", post_count: 0, category: Tag.categories.character) | ||
create(:tag, name: "copyright", post_count: 0, category: Tag.categories.copyright) | ||
create(:tag, name: "meta", post_count: 0, category: Tag.categories.meta) | ||
|
||
ta0 = create(:tag_implication, antecedent_name: "artist", consequent_name: "1") | ||
ta1 = create(:tag_implication, antecedent_name: "general", consequent_name: "1") | ||
ta2 = create(:tag_implication, antecedent_name: "character", consequent_name: "1") | ||
ta3 = create(:tag_implication, antecedent_name: "copyright", consequent_name: "1") | ||
ta4 = create(:tag_implication, antecedent_name: "meta", consequent_name: "1") | ||
|
||
RetireTagRelationshipsJob.perform_now | ||
|
||
assert_equal(true, ta0.reload.is_retired?) | ||
assert_equal(true, ta1.reload.is_retired?) | ||
assert_equal(true, ta2.reload.is_retired?) | ||
assert_equal(true, ta3.reload.is_retired?) | ||
assert_equal(true, ta4.reload.is_retired?) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.