posts: restrict banned paid rewards for non-approvers.

This commit is contained in:
evazion
2020-07-06 13:51:07 -05:00
parent 0c7d48d890
commit 40a114c99c
2 changed files with 20 additions and 1 deletions

View File

@@ -1474,7 +1474,8 @@ class Post < ApplicationRecord
end
def banblocked?(user = CurrentUser.user)
is_banned? && !user.is_gold?
return false unless is_banned?
(has_tag?("paid_reward") && !user.is_approver?) || !user.is_gold?
end
def visible?(user = CurrentUser.user)

View File

@@ -374,6 +374,24 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
end
end
context "with banned paid_reward posts" do
setup do
as(@user) { @post.update!(tag_string: "paid_reward", is_banned: true) }
end
should "show banned paid_rewards to approvers" do
get_auth posts_path, create(:approver)
assert_response :success
assert_select "#post_#{@post.id}", 1
end
should "not show banned paid_rewards to non-approvers" do
get_auth posts_path, create(:gold_user)
assert_response :success
assert_select "#post_#{@post.id}", 0
end
end
context "in safe mode" do
should "not include the rating:s tag in the page title" do
get posts_path(tags: "1girl", safe_mode: true)