diff options
author | Stan Hu <stanhu@gmail.com> | 2018-07-08 14:57:30 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-07-08 14:57:30 -0700 |
commit | 589a28889a3c383131e67343e121443e3c88e4a8 (patch) | |
tree | 89fa83a198f3c401e9870c62ec3bcee3990b24d8 | |
parent | ed166b791ff5de4216799c2b77dc8cf70dc31df3 (diff) | |
download | gitlab-ce-589a28889a3c383131e67343e121443e3c88e4a8.tar.gz |
Test server connection error
-rw-r--r-- | app/controllers/import/bitbucket_server_controller.rb | 2 | ||||
-rw-r--r-- | spec/controllers/import/bitbucket_server_controller_spec.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/import/bitbucket_server_controller.rb b/app/controllers/import/bitbucket_server_controller.rb index d082c531430..56bd0c1d2c0 100644 --- a/app/controllers/import/bitbucket_server_controller.rb +++ b/app/controllers/import/bitbucket_server_controller.rb @@ -51,7 +51,7 @@ class Import::BitbucketServerController < Import::BaseController render json: { errors: 'This namespace has already been taken! Please choose another one.' }, status: :unprocessable_entity end rescue *SERVER_ERRORS => e - render json: { errors: "Unable to connect to server: #{e}" } + render json: { errors: "Unable to connect to server: #{e}" }, status: :unprocessable_entity end def configure diff --git a/spec/controllers/import/bitbucket_server_controller_spec.rb b/spec/controllers/import/bitbucket_server_controller_spec.rb index 2ff7939d36f..73e4417b7b1 100644 --- a/spec/controllers/import/bitbucket_server_controller_spec.rb +++ b/spec/controllers/import/bitbucket_server_controller_spec.rb @@ -78,6 +78,11 @@ describe Import::BitbucketServerController do end it "returns an error when the server can't be contacted" do + expect(client).to receive(:repo).with(project_key, repo_slug).and_raise(Errno::ECONNREFUSED) + + post :create, project: project_key, repository: repo_slug, format: :json + + expect(response).to have_gitlab_http_status(422) end end |