Commit fb917f7b authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'sh-fix-delete-blob-failure' into 'master'

Fix 500 error in BlobController#delete

See merge request gitlab-org/gitlab!34367
parents 3ca6eda9 ac331996
...@@ -94,7 +94,6 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -94,7 +94,6 @@ class Projects::BlobController < Projects::ApplicationController
def destroy def destroy
create_commit(Files::DeleteService, success_notice: _("The file has been successfully deleted."), create_commit(Files::DeleteService, success_notice: _("The file has been successfully deleted."),
success_path: -> { after_delete_path }, success_path: -> { after_delete_path },
failure_view: :show,
failure_path: project_blob_path(@project, @id)) failure_path: project_blob_path(@project, @id))
end end
......
---
title: Fix 500 error in BlobController#delete
merge_request: 34367
author:
type: fixed
...@@ -378,6 +378,22 @@ RSpec.describe Projects::BlobController do ...@@ -378,6 +378,22 @@ RSpec.describe Projects::BlobController do
expect(response).to redirect_to(after_delete_path) expect(response).to redirect_to(after_delete_path)
end end
context 'when a validation failure occurs' do
let(:failure_path) { project_blob_path(project, default_params[:id]) }
render_views
it 'redirects to a valid page' do
expect_next_instance_of(Files::DeleteService) do |instance|
expect(instance).to receive(:validate!).and_raise(Commits::CreateService::ValidationError, "validation error")
end
delete :destroy, params: default_params
expect(response).to redirect_to(failure_path)
end
end
end end
context 'if deleted file is the last one in a subdirectory' do context 'if deleted file is the last one in a subdirectory' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment