diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-13 08:33:28 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-13 08:33:28 +0000 |
commit | f7be904afa2edf731e87f1f60918c0d82234eff4 (patch) | |
tree | 61050d2fcd176f40e0b1e78f9dc19c1fd8f6dee3 /spec | |
parent | 60dc0d16d57dc98458358e3edbe892adb39b82de (diff) | |
parent | 46b83f06055b5abda6aa63fe42b4efd890fed774 (diff) | |
download | gitlab-ce-f7be904afa2edf731e87f1f60918c0d82234eff4.tar.gz |
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 |