Do not create ErrorReport on files api 404
closes ADMIN-1130 Test plan - Run /api/v1/courses/:course_id/files/(id that doesn't exist, or is deleted) - Ensure you don't get a new error report for it Change-Id: I9df392d22ca0ecfae18a5f2576e99d907b9a77a3 Reviewed-on: https://gerrit.instructure.com/153301 Tested-by: Jenkins Reviewed-by: Ed Schiebel <eschiebel@instructure.com> QA-Review: Luke Kingsley <lkingsley@instructure.com> Product-Review: Mysti Sadler <mysti@instructure.com>
This commit is contained in:
parent
07e31e0ad7
commit
882df38a7b
|
@ -444,8 +444,11 @@ class FilesController < ApplicationController
|
||||||
# @returns File
|
# @returns File
|
||||||
def api_show
|
def api_show
|
||||||
get_context
|
get_context
|
||||||
@attachment = @context ? @context.attachments.find(params[:id]) : Attachment.find(params[:id])
|
@attachment = @context ? @context.attachments.not_deleted.find_by(id: params[:id]) : Attachment.not_deleted.find_by(id: params[:id])
|
||||||
raise ActiveRecord::RecordNotFound if @attachment.deleted?
|
unless @attachment
|
||||||
|
render json: { errors: [{message: "The specified resource does not exist."}] }, status: 404
|
||||||
|
return
|
||||||
|
end
|
||||||
params[:include] = Array(params[:include])
|
params[:include] = Array(params[:include])
|
||||||
if authorized_action(@attachment,@current_user,:read)
|
if authorized_action(@attachment,@current_user,:read)
|
||||||
render :json => attachment_json(@attachment, @current_user, {}, { include: params[:include], omit_verifier_in_app: !value_to_boolean(params[:use_verifiers]) })
|
render :json => attachment_json(@attachment, @current_user, {}, { include: params[:include], omit_verifier_in_app: !value_to_boolean(params[:use_verifiers]) })
|
||||||
|
|
|
@ -927,7 +927,7 @@ describe "Files API", type: :request do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return not found error" do
|
it "should return not found error" do
|
||||||
api_call(:get, "/api/v1/files/0", @file_path_options.merge(:id => '0'), {}, {}, :expected_status => 404)
|
expect{api_call(:get, "/api/v1/files/0", @file_path_options.merge(id: '0'), {}, {}, expected_status: 404)}.not_to change { ErrorReport.count }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return not found for deleted attachment" do
|
it "should return not found for deleted attachment" do
|
||||||
|
|
Loading…
Reference in New Issue