Merge branch 'ccr/6699_image_for_object_error' into 'master'
Handled exception during file upload See merge request gitlab-org/gitlab-ce!21528
This commit is contained in:
commit
2d16f4794b
|
@ -53,6 +53,8 @@ module UploadsActions
|
||||||
maximum_size: Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i)
|
maximum_size: Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i)
|
||||||
|
|
||||||
render json: authorized
|
render json: authorized
|
||||||
|
rescue SocketError
|
||||||
|
render json: "Error uploading file", status: :internal_server_error
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
title: Handles exception during file upload - replaces the stack trace with a small
|
||||||
|
error message.
|
||||||
|
merge_request: 21528
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -18,6 +18,20 @@ describe Projects::UploadsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when exception occurs" do
|
||||||
|
before do
|
||||||
|
allow(FileUploader).to receive(:workhorse_authorize).and_raise(SocketError.new)
|
||||||
|
sign_in(create(:user))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "responds with status internal_server_error" do
|
||||||
|
post_authorize
|
||||||
|
|
||||||
|
expect(response).to have_gitlab_http_status(500)
|
||||||
|
expect(response.body).to eq('Error uploading file')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def post_authorize(verified: true)
|
def post_authorize(verified: true)
|
||||||
request.headers.merge!(workhorse_internal_api_request_header) if verified
|
request.headers.merge!(workhorse_internal_api_request_header) if verified
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue