Fix #4525: Show mod report notices next to reported content.

This commit is contained in:
evazion
2021-01-15 19:54:21 -06:00
parent 37792bd5dd
commit b4530183f4
20 changed files with 153 additions and 57 deletions

View File

@@ -0,0 +1,44 @@
require "test_helper"
class CommentComponentTest < ViewComponent::TestCase
def render_comment(comment, current_user: User.anonymous, **options)
as(current_user) do
render_inline(CommentComponent.new(comment: comment, current_user: current_user, **options))
end
end
context "The CommentComponent" do
setup do
@comment = as(create(:user)) { create(:comment) }
end
context "for a regular comment" do
should "render for Anonymous" do
render_comment(@comment, current_user: User.anonymous)
assert_css("article#comment_#{@comment.id}")
end
should "render for a Member" do
render_comment(@comment, current_user: create(:user))
assert_css("article#comment_#{@comment.id}")
end
end
context "for a comment with moderation reports" do
should "show the report notice to moderators" do
create(:moderation_report, model: @comment)
render_comment(@comment, current_user: create(:moderator_user))
assert_css(".moderation-report-notice")
end
should "not show the report notice to regular users" do
render_comment(@comment, current_user: User.anonymous)
assert_no_css(".moderation-report-notice")
end
end
end
end