diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/requests/api/commit_statuses_spec.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/requests/api/commit_statuses_spec.rb')
-rw-r--r-- | spec/requests/api/commit_statuses_spec.rb | 66 |
1 files changed, 52 insertions, 14 deletions
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb index ac125e81acd..ccc9f8c50c4 100644 --- a/spec/requests/api/commit_statuses_spec.rb +++ b/spec/requests/api/commit_statuses_spec.rb @@ -3,12 +3,12 @@ require 'spec_helper' RSpec.describe API::CommitStatuses do - let!(:project) { create(:project, :repository) } - let(:commit) { project.repository.commit } - let(:guest) { create_user(:guest) } - let(:reporter) { create_user(:reporter) } - let(:developer) { create_user(:developer) } - let(:sha) { commit.id } + let_it_be(:project) { create(:project, :repository) } + let_it_be(:commit) { project.repository.commit } + let_it_be(:guest) { create_user(:guest) } + let_it_be(:reporter) { create_user(:reporter) } + let_it_be(:developer) { create_user(:developer) } + let_it_be(:sha) { commit.id } describe "GET /projects/:id/repository/commits/:sha/statuses" do let(:get_url) { "/projects/#{project.id}/repository/commits/#{sha}/statuses" } @@ -233,27 +233,44 @@ RSpec.describe API::CommitStatuses do end end - context 'when updatig a commit status' do + context 'when updating a commit status' do + let(:parameters) do + { + state: 'success', + name: 'coverage', + ref: 'master' + } + end + + let(:updatable_optional_attributes) do + { + description: 'new description', + coverage: 90.0 + } + end + + # creating the initial commit status before do post api(post_url, developer), params: { state: 'running', context: 'coverage', ref: 'master', description: 'coverage test', - coverage: 0.0, + coverage: 10.0, target_url: 'http://gitlab.com/status' } + end + subject(:send_request) do post api(post_url, developer), params: { - state: 'success', - name: 'coverage', - ref: 'master', - description: 'new description', - coverage: 90.0 + **parameters, + **updatable_optional_attributes } end it 'updates a commit status' do + send_request + expect(response).to have_gitlab_http_status(:created) expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq('success') @@ -265,7 +282,28 @@ RSpec.describe API::CommitStatuses do end it 'does not create a new commit status' do - expect(CommitStatus.count).to eq 1 + expect { send_request }.not_to change { CommitStatus.count } + end + + context 'when the `state` parameter is sent the same' do + let(:parameters) do + { + state: 'running', + name: 'coverage', + ref: 'master' + } + end + + it 'does not update the commit status' do + send_request + + expect(response).to have_gitlab_http_status(:bad_request) + + commit_status = project.commit_statuses.find_by!(name: 'coverage') + + expect(commit_status.description).to eq('coverage test') + expect(commit_status.coverage).to eq(10.0) + end end end |