votes: make upvotes visible to everyone by default.
Make upvotes public the same way favorites are public: * Rename the "Private favorites" account setting to "Private favorites and upvotes". * Make upvotes public, unless the user has private upvotes enabled. Note that private upvotes are still visible to admins. Downvotes are still hidden to everyone except for admins. * Make https://danbooru.donmai.us/post_votes visible to all users. This page shows all public upvotes. Private upvotes and downvotes are only visible on the page to admins and to the voter themselves. * Make votes searchable with the `upvote:username` and `downvote:username` metatags. These already existed before, but they were only usable by admins and by people searching for their own votes. Upvotes are public to discourage users from upvoting with multiple accounts. Upvote abuse is obvious to everyone when upvotes are public. The other reason is to make upvotes consistent with favorites, which are already public.
This commit is contained in:
@@ -973,6 +973,75 @@ class PostQueryBuilderTest < ActiveSupport::TestCase
|
||||
assert_tag_match(all - [e], "-rating:e")
|
||||
end
|
||||
|
||||
context "for the upvote:<user> metatag" do
|
||||
setup do
|
||||
@user = create(:user)
|
||||
@upvote = create(:post_vote, user: @user, score: 1)
|
||||
@downvote = create(:post_vote, user: @user, score: -1)
|
||||
end
|
||||
|
||||
should "show public upvotes to all users" do
|
||||
as(User.anonymous) do
|
||||
assert_tag_match([@upvote.post], "upvote:#{@user.name}")
|
||||
assert_tag_match([@downvote.post], "-upvote:#{@user.name}")
|
||||
end
|
||||
end
|
||||
|
||||
should "not show private upvotes to other users" do
|
||||
@user.update!(enable_private_favorites: true)
|
||||
|
||||
as(User.anonymous) do
|
||||
assert_tag_match([], "upvote:#{@user.name}")
|
||||
assert_tag_match([@downvote.post, @upvote.post], "-upvote:#{@user.name}")
|
||||
end
|
||||
end
|
||||
|
||||
should "show private upvotes to admins" do
|
||||
@user.update!(enable_private_favorites: true)
|
||||
|
||||
as(create(:admin_user)) do
|
||||
assert_tag_match([@upvote.post], "upvote:#{@user.name}")
|
||||
assert_tag_match([@downvote.post], "-upvote:#{@user.name}")
|
||||
end
|
||||
end
|
||||
|
||||
should "show private upvotes to the voter themselves" do
|
||||
as(@user) do
|
||||
assert_tag_match([@upvote.post], "upvote:#{@user.name}")
|
||||
assert_tag_match([@downvote.post], "-upvote:#{@user.name}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "for the downvote:<user> metatag" do
|
||||
setup do
|
||||
@user = create(:user, enable_private_favorites: true)
|
||||
@upvote = create(:post_vote, user: @user, score: 1)
|
||||
@downvote = create(:post_vote, user: @user, score: -1)
|
||||
end
|
||||
|
||||
should "not show downvotes to other users" do
|
||||
as(User.anonymous) do
|
||||
assert_tag_match([], "downvote:#{@user.name}")
|
||||
assert_tag_match([@downvote.post, @upvote.post], "-downvote:#{@user.name}")
|
||||
end
|
||||
end
|
||||
|
||||
should "show downvotes to admins" do
|
||||
as(create(:admin_user)) do
|
||||
assert_tag_match([@downvote.post], "downvote:#{@user.name}")
|
||||
assert_tag_match([@upvote.post], "-downvote:#{@user.name}")
|
||||
end
|
||||
end
|
||||
|
||||
should "show downvotes to the voter themselves" do
|
||||
as(@user) do
|
||||
assert_tag_match([@downvote.post], "downvote:#{@user.name}")
|
||||
assert_tag_match([@upvote.post], "-downvote:#{@user.name}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
should "return posts for a upvote:<user>, downvote:<user> metatag" do
|
||||
CurrentUser.scoped(create(:mod_user)) do
|
||||
upvoted = create(:post, tag_string: "upvote:self")
|
||||
|
||||
Reference in New Issue
Block a user