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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user