diff options
Diffstat (limited to 'spec/controllers/projects/blob_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/blob_controller_spec.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index ad04c6e61e8..9fee97f938c 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Projects::BlobController do +RSpec.describe Projects::BlobController do include ProjectForksHelper let(:project) { create(:project, :public, :repository) } @@ -378,6 +378,22 @@ describe Projects::BlobController do expect(response).to redirect_to(after_delete_path) 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 context 'if deleted file is the last one in a subdirectory' do |