A platform for community discussion. Free, open, simple.
FIX: fail early when flagging as anonymous (#37771)
Joffrey JAFFEUX97586c948d13
diff --git a/plugins/discourse-post-voting/app/controllers/post_voting/comments_controller.rb b/plugins/discourse-post-voting/app/controllers/post_voting/comments_controller.rbindex aeddbe420ae..35d127d241d 100644--- a/plugins/discourse-post-voting/app/controllers/post_voting/comments_controller.rb+++ b/plugins/discourse-post-voting/app/controllers/post_voting/comments_controller.rb@@ -6,7 +6,7 @@ module PostVotingbefore_action :find_post, only: %i[load_more_comments create]before_action :ensure_post_voting_enabled, only: %i[load_more_comments create]- before_action :ensure_logged_in, only: %i[create destroy update]+ before_action :ensure_logged_in, only: %i[create destroy update flag]def load_more_comments@guardian.ensure_can_see!(@post)diff --git a/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rb b/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rbindex dd2e2df404b..51fd9660c7e 100644--- a/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rb+++ b/plugins/discourse-post-voting/spec/requests/post_voting/comments_controller_spec.rb@@ -275,6 +275,19 @@ RSpec.describe PostVoting::CommentsController doendend+ describe "#flag" do+ it "should return 403 with not_logged_in error for an anon user" do+ put "/post_voting/comments/flag.json",+ params: {+ comment_id: comment.id,+ flag_type_id: ReviewableScore.types[:off_topic],+ }++ expect(response.status).to eq(403)+ expect(response.parsed_body["error_type"]).to eq("not_logged_in")+ end+ end+describe "#destroy" doit "should return 403 for an anon user" dodelete "/post_voting/comments.json", params: { comment_id: comment.id }