diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-13 11:33:28 +0300 |
---|---|---|
committer | Ruben Davila <rdavila84@gmail.com> | 2016-09-14 04:54:27 +0300 |
commit | b015ff3938a5ebc3d931f84ed55385d5de485ee9 (patch) | |
tree | e533b8237f13c9f48aecfb86845235819c89fff5 /spec | |
parent | 355abf44135ec79e0c1ee95732a6865949583581 (diff) |
Merge branch 'fix-commit-status' into 'master'
Fix an error where we were unable to create a CommitStatus for running state
Due to severe refactoring of Pipeline we introduced regression in how CommitStatus is handled. We received an report that it's impossible to create a CommitStatus with state `running` when there were not previous status.
The support for Commit Statuses should be simplified. Right now I'm doing minimal change to move forward and fix a bug, but I'll create a new MR that will move all logic that is now part of `lib/api/commit_statuses.rb` to separate service to simplify the implementation.
This error happens due to the fact that we introduced additional status of builds: `created`.
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/21345
See merge request !6107
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/commit_statuses_spec.rb | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb index 2d6093fec7a..7aa7e85a9e2 100644 --- a/spec/requests/api/commit_statuses_spec.rb +++ b/spec/requests/api/commit_statuses_spec.rb @@ -117,17 +117,36 @@ describe API::CommitStatuses, api: true do let(:post_url) { "/projects/#{project.id}/statuses/#{sha}" } context 'developer user' do - context 'only required parameters' do - before { post api(post_url, developer), state: 'success' } + %w[pending running success failed canceled].each do |status| + context "for #{status}" do + context 'uses only required parameters' do + it 'creates commit status' do + post api(post_url, developer), state: status + + expect(response).to have_http_status(201) + expect(json_response['sha']).to eq(commit.id) + expect(json_response['status']).to eq(status) + expect(json_response['name']).to eq('default') + expect(json_response['ref']).not_to be_empty + expect(json_response['target_url']).to be_nil + expect(json_response['description']).to be_nil + end + end + end + end - it 'creates commit status' do - expect(response).to have_http_status(201) - expect(json_response['sha']).to eq(commit.id) - expect(json_response['status']).to eq('success') - expect(json_response['name']).to eq('default') - expect(json_response['ref']).to be_nil - expect(json_response['target_url']).to be_nil - expect(json_response['description']).to be_nil + context 'transitions status from pending' do + before do + post api(post_url, developer), state: 'pending' + end + + %w[running success failed canceled].each do |status| + it "to #{status}" do + expect { post api(post_url, developer), state: status }.not_to change { CommitStatus.count } + + expect(response).to have_http_status(201) + expect(json_response['status']).to eq(status) + end end end |