Fix #4957: Autotag non-web_source.
Autotag non-web_source on posts that have a non-http:// or https:// URL. Add a fix script to backfill old posts. Syntactically invalid URLs are still considered web sources. For example, `https://google,com` technically isn't a valid URL, but it's not considered a non-web source.
This commit is contained in:
@@ -1046,6 +1046,30 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "a post with a non-web source" do
|
||||
should "automatically add the non-web_source tag" do
|
||||
@post.update!(source: "this was once revealed to me in a dream")
|
||||
@post.save!
|
||||
assert_equal("non-web_source tag1 tag2", @post.tag_string)
|
||||
end
|
||||
end
|
||||
|
||||
context "a post with a blank source" do
|
||||
should "remove the non-web_source tag" do
|
||||
@post.update!(source: "", tag_string: "non-web_source")
|
||||
@post.save!
|
||||
assert_equal("tagme", @post.tag_string)
|
||||
end
|
||||
end
|
||||
|
||||
context "a post with a https:// source" do
|
||||
should "remove the non-web_source tag" do
|
||||
@post.update!(source: "https://www.google.com", tag_string: "non-web_source")
|
||||
@post.save!
|
||||
assert_equal("tagme", @post.tag_string)
|
||||
end
|
||||
end
|
||||
|
||||
should "have an array representation of its tags" do
|
||||
post = FactoryBot.create(:post)
|
||||
post.reload
|
||||
|
||||
Reference in New Issue
Block a user