diff options
author | Rémy Coutable <remy@rymai.me> | 2017-10-18 10:38:16 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-10-18 10:38:16 +0000 |
commit | 220a5c375972462a3c583a106c5ca4c8a2138267 (patch) | |
tree | 365c8941f9400dcb0210483aa5c1bca2225827a5 /spec | |
parent | be3bddf90d81b84243b74c3013202aad1c4ab3a9 (diff) | |
parent | 26ec874f77b00124615ff55d48ca79f7631a6c15 (diff) | |
download | gitlab-ce-220a5c375972462a3c583a106c5ca4c8a2138267.tar.gz |
Merge branch '37032-get-project-branch-invalid-name-message' into 'master'
Get Project Branch API shows an helpful error message on invalid refname
Closes #37032
See merge request gitlab-org/gitlab-ce!14884
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/branches_spec.rb | 36 | ||||
-rw-r--r-- | spec/support/shared_examples/requests/api/status_shared_examples.rb | 7 |
2 files changed, 43 insertions, 0 deletions
diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb index 16b12446ed4..e433597f58b 100644 --- a/spec/requests/api/branches_spec.rb +++ b/spec/requests/api/branches_spec.rb @@ -110,6 +110,15 @@ describe API::Branches do end end + context 'when the branch refname is invalid' do + let(:branch_name) { 'branch*' } + let(:message) { 'The branch refname is invalid' } + + it_behaves_like '400 response' do + let(:request) { get api(route, current_user) } + end + end + context 'when repository is disabled' do include_context 'disabled repository' @@ -234,6 +243,15 @@ describe API::Branches do end end + context 'when the branch refname is invalid' do + let(:branch_name) { 'branch*' } + let(:message) { 'The branch refname is invalid' } + + it_behaves_like '400 response' do + let(:request) { put api(route, current_user) } + end + end + context 'when repository is disabled' do include_context 'disabled repository' @@ -359,6 +377,15 @@ describe API::Branches do end end + context 'when the branch refname is invalid' do + let(:branch_name) { 'branch*' } + let(:message) { 'The branch refname is invalid' } + + it_behaves_like '400 response' do + let(:request) { put api(route, current_user) } + end + end + context 'when repository is disabled' do include_context 'disabled repository' @@ -520,6 +547,15 @@ describe API::Branches do expect(response).to have_gitlab_http_status(404) end + context 'when the branch refname is invalid' do + let(:branch_name) { 'branch*' } + let(:message) { 'The branch refname is invalid' } + + it_behaves_like '400 response' do + let(:request) { delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user) } + end + end + it_behaves_like '412 response' do let(:request) { api("/projects/#{project.id}/repository/branches/#{branch_name}", user) } end diff --git a/spec/support/shared_examples/requests/api/status_shared_examples.rb b/spec/support/shared_examples/requests/api/status_shared_examples.rb index 7d7f66adeab..0ed917e448a 100644 --- a/spec/support/shared_examples/requests/api/status_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/status_shared_examples.rb @@ -3,6 +3,8 @@ # Requires an API request: # let(:request) { get api("/projects/#{project.id}/repository/branches", user) } shared_examples_for '400 response' do + let(:message) { nil } + before do # Fires the request request @@ -10,6 +12,10 @@ shared_examples_for '400 response' do it 'returns 400' do expect(response).to have_gitlab_http_status(400) + + if message.present? + expect(json_response['message']).to eq(message) + end end end @@ -26,6 +32,7 @@ end shared_examples_for '404 response' do let(:message) { nil } + before do # Fires the request request |