Fix #4374: Unvoting comments is broken.
This commit is contained in:
@@ -10,13 +10,13 @@ class CommentVotesController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@comment = authorize Comment.find(params[:comment_id])
|
||||
@comment = authorize Comment.find(params[:comment_id]), policy_class: CommentVotePolicy
|
||||
@comment_vote = @comment.vote!(params[:score])
|
||||
respond_with(@comment)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@comment = authorize Comment.find(params[:comment_id])
|
||||
@comment = authorize Comment.find(params[:comment_id]), policy_class: CommentVotePolicy
|
||||
@comment.unvote!
|
||||
respond_with(@comment)
|
||||
end
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
class CommentVotePolicy < ApplicationPolicy
|
||||
def destroy?
|
||||
# XXX permissions are checked in Comment#unvote!
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user