* Add a gap between thumbnails on mobile. * Adjust CSS for scores and vote buttons. * Include "Private favorites" as an incentive on the user upgrade page. * Fix vote buttons not being visible beneath thumbnails on mobile. * Fix the "Show scores" link not preserving the current page number. * Fix vote buttons being unintentionally enabled for all thumbnails by default. * Fix banned and restricted users being able to favorite posts by tagging them with `fav:self`. * Fix search engines being able to crawl /posts?view=score pages. * Fix broken tests.
57 lines
1.7 KiB
Ruby
57 lines
1.7 KiB
Ruby
require "test_helper"
|
|
|
|
class PostVotesComponentTest < ViewComponent::TestCase
|
|
def render_post_votes(post, current_user:)
|
|
render_inline(PostVotesComponent.new(post: post, current_user: current_user))
|
|
end
|
|
|
|
context "The PostVotesComponent" do
|
|
setup do
|
|
@post = as(create(:user)) { create(:post) }
|
|
end
|
|
|
|
context "for a user who can't vote" do
|
|
should "show the vote buttons" do
|
|
render_post_votes(@post, current_user: User.anonymous)
|
|
|
|
assert_css(".post-score")
|
|
assert_css(".post-upvote-link.inactive-link")
|
|
assert_css(".post-downvote-link.inactive-link")
|
|
end
|
|
end
|
|
|
|
context "for a user who can vote" do
|
|
setup do
|
|
@user = create(:gold_user)
|
|
end
|
|
|
|
should "show the vote buttons" do
|
|
render_post_votes(@post, current_user: @user)
|
|
|
|
assert_css(".post-upvote-link.inactive-link")
|
|
assert_css(".post-downvote-link.inactive-link")
|
|
end
|
|
|
|
context "for a downvoted post" do
|
|
should "highlight the downvote button as active" do
|
|
create(:post_vote, post: @post, user: @user, score: -1)
|
|
as(@user) { render_post_votes(@post, current_user: @user) }
|
|
|
|
assert_css(".post-upvote-link.inactive-link")
|
|
assert_css(".post-downvote-link.active-link")
|
|
end
|
|
end
|
|
|
|
context "for an upvoted post" do
|
|
should "highlight the upvote button as active" do
|
|
create(:post_vote, post: @post, user: @user, score: 1)
|
|
as(@user) { render_post_votes(@post, current_user: @user) }
|
|
|
|
assert_css(".post-upvote-link.active-link")
|
|
assert_css(".post-downvote-link.inactive-link")
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|