comments: fix modreport notices being visible to Members.
Fix the "This comment has been reported" notice being visible for Members.
This commit is contained in:
@@ -24,6 +24,6 @@ class CommentComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def has_moderation_reports?
|
||||
policy(ModerationReport).show? && comment.moderation_reports.present?
|
||||
policy(ModerationReport).can_see_moderation_reports? && comment.moderation_reports.present?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,10 @@ class ModerationReportPolicy < ApplicationPolicy
|
||||
unbanned? && policy(record.model).reportable?
|
||||
end
|
||||
|
||||
def can_see_moderation_reports?
|
||||
user.is_moderator?
|
||||
end
|
||||
|
||||
def permitted_attributes
|
||||
[:model_type, :model_id, :reason]
|
||||
end
|
||||
|
||||
@@ -58,7 +58,8 @@ class CommentComponentTest < ViewComponent::TestCase
|
||||
end
|
||||
|
||||
should "not show the report notice to regular users" do
|
||||
render_comment(@comment, current_user: User.anonymous)
|
||||
create(:moderation_report, model: @comment)
|
||||
render_comment(@comment, current_user: create(:user))
|
||||
|
||||
assert_no_css(".moderation-report-notice")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user