Tag change notices
This adds a small notice at the bottom of post searches if a single tag search is the target of any tag change request.
This commit is contained in:
@@ -26,6 +26,28 @@ class AliasAndImplicationImporterTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "#affected_tags" do
|
||||
setup do
|
||||
FactoryBot.create(:post, tag_string: "aaa")
|
||||
FactoryBot.create(:post, tag_string: "bbb")
|
||||
FactoryBot.create(:post, tag_string: "ccc")
|
||||
FactoryBot.create(:post, tag_string: "ddd")
|
||||
FactoryBot.create(:post, tag_string: "eee")
|
||||
|
||||
@script = "create alias aaa -> 000\n" +
|
||||
"create implication bbb -> 111\n" +
|
||||
"remove alias ccc -> 222\n" +
|
||||
"remove implication ddd -> 333\n" +
|
||||
"mass update eee -> 444\n"
|
||||
end
|
||||
|
||||
subject { AliasAndImplicationImporter.new(@script, nil) }
|
||||
|
||||
should "return the correct tags" do
|
||||
assert_equal(%w(aaa 000 bbb 111 ccc 222 ddd 333 eee 444), subject.affected_tags)
|
||||
end
|
||||
end
|
||||
|
||||
context "#estimate_update_count" do
|
||||
setup do
|
||||
FactoryBot.create(:post, tag_string: "aaa")
|
||||
|
||||
@@ -35,6 +35,33 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "#update_notice" do
|
||||
setup do
|
||||
@mock_redis = MockRedis.new
|
||||
@forum_topic = FactoryBot.create(:forum_topic)
|
||||
TagChangeNoticeService.stubs(:redis_client).returns(@mock_redis)
|
||||
end
|
||||
|
||||
should "update redis" do
|
||||
@script = "create alias aaa -> 000\n" +
|
||||
"create implication bbb -> 111\n" +
|
||||
"remove alias ccc -> 222\n" +
|
||||
"remove implication ddd -> 333\n" +
|
||||
"mass update eee -> 444\n"
|
||||
FactoryBot.create(:bulk_update_request, script: @script, forum_topic: @forum_topic)
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:aaa"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:000"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:bbb"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:111"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:ccc"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:222"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:ddd"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:333"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:eee"))
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:444"))
|
||||
end
|
||||
end
|
||||
|
||||
context "on approval" do
|
||||
setup do
|
||||
@script = %q(
|
||||
|
||||
@@ -69,6 +69,19 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "#update_notice" do
|
||||
setup do
|
||||
@mock_redis = MockRedis.new
|
||||
@forum_topic = FactoryBot.create(:forum_topic)
|
||||
TagChangeNoticeService.stubs(:redis_client).returns(@mock_redis)
|
||||
end
|
||||
|
||||
should "update redis" do
|
||||
FactoryBot.create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb", skip_secondary_validations: true, forum_topic: @forum_topic)
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:aaa"))
|
||||
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)
|
||||
|
||||
@@ -65,6 +65,19 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "#update_notice" do
|
||||
setup do
|
||||
@mock_redis = MockRedis.new
|
||||
@forum_topic = FactoryBot.create(:forum_topic)
|
||||
TagChangeNoticeService.stubs(:redis_client).returns(@mock_redis)
|
||||
end
|
||||
|
||||
should "update redis" do
|
||||
FactoryBot.create(:tag_implication, antecedent_name: "aaa", consequent_name: "bbb", skip_secondary_validations: true, forum_topic: @forum_topic)
|
||||
assert_equal(@forum_topic.id.to_s, @mock_redis.get("tcn:aaa"))
|
||||
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