FIX: Return 404 if id is not valid.
This commit is contained in:
parent
d10fe51b72
commit
68300f515c
|
@ -6,6 +6,8 @@ class PostActionsController < ApplicationController
|
|||
before_filter :fetch_post_action_type_id_from_params
|
||||
|
||||
def create
|
||||
raise Discourse::NotFound if @post.blank?
|
||||
|
||||
taken = PostAction.counts_for([@post], current_user)[@post.id]
|
||||
|
||||
guardian.ensure_post_can_act!(
|
||||
|
|
|
@ -31,6 +31,11 @@ describe PostActionsController do
|
|||
expect { xhr :post, :create, post_action_type_id: PostActionType.types[:like] }.to raise_error(ActionController::ParameterMissing)
|
||||
end
|
||||
|
||||
it 'fails when the id is invalid' do
|
||||
xhr :post, :create, post_action_type_id: PostActionType.types[:like], id: -1
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it 'raises an error when the post_action_type_id index is missing' do
|
||||
expect { xhr :post, :create, id: @post.id }.to raise_error(ActionController::ParameterMissing)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue