posts: autoban uploads tagged paid_reward.

This commit is contained in:
evazion
2020-07-06 13:18:55 -05:00
parent 722bb6deae
commit 0c7d48d890
2 changed files with 16 additions and 1 deletions

View File

@@ -300,7 +300,7 @@ class Post < ApplicationRecord
end
def autoban
if has_tag?("banned_artist")
if has_tag?("banned_artist") || has_tag?("paid_reward")
self.is_banned = true
end
end

View File

@@ -25,6 +25,7 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
assert_equal("completed", upload.status)
assert_equal(Post.last, upload.post)
assert_equal(upload.post.md5, upload.md5)
upload
end
context "The uploads controller" do
@@ -284,6 +285,20 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
end
end
context "when the upload is tagged banned_artist" do
should "autoban the post" do
upload = assert_successful_upload("test/files/test.jpg", tag_string: "banned_artist")
assert_equal(true, upload.post.is_banned?)
end
end
context "when the upload is tagged paid_reward" do
should "autoban the post" do
upload = assert_successful_upload("test/files/test.jpg", tag_string: "paid_reward")
assert_equal(true, upload.post.is_banned?)
end
end
context "uploading a file from your computer" do
should_upload_successfully("test/files/test.jpg")
should_upload_successfully("test/files/test.png")