policies: remove current request from context.

This refactors Pundit policies to only rely on the current user, not on
the current user and the current HTTP request. In retrospect, it was a
bad idea to include the current request in the Pundit context. It bleeds
out everywhere and there are many contexts (in tests and models) where
we only have the current user, not the current request. The previous
commit got rid of the only two places where we used it.
This commit is contained in:
evazion
2021-01-17 00:41:09 -06:00
parent 6671711784
commit 054ac51d47
13 changed files with 24 additions and 23 deletions

View File

@@ -7,7 +7,7 @@ class CommentComponent < ApplicationComponent
def self.with_collection(comments, current_user:, **options)
dtext_data = DText.preprocess(comments.map(&:body))
# XXX
#comments = comments.includes(:moderation_reports) if Pundit.policy!([current_user, nil], ModerationReport).show?
#comments = comments.includes(:moderation_reports) if Pundit.policy!(current_user, ModerationReport).show?
super(comments, current_user: current_user, dtext_data: dtext_data, **options)
end