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
|
end
|
||||||
|
|
||||||
def has_moderation_reports?
|
def has_moderation_reports?
|
||||||
policy(ModerationReport).show? && comment.moderation_reports.present?
|
policy(ModerationReport).can_see_moderation_reports? && comment.moderation_reports.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ class ModerationReportPolicy < ApplicationPolicy
|
|||||||
unbanned? && policy(record.model).reportable?
|
unbanned? && policy(record.model).reportable?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_see_moderation_reports?
|
||||||
|
user.is_moderator?
|
||||||
|
end
|
||||||
|
|
||||||
def permitted_attributes
|
def permitted_attributes
|
||||||
[:model_type, :model_id, :reason]
|
[:model_type, :model_id, :reason]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ class CommentComponentTest < ViewComponent::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "not show the report notice to regular users" do
|
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")
|
assert_no_css(".moderation-report-notice")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user