diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/requests/api/commits_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/requests/api/commits_spec.rb')
-rw-r--r-- | spec/requests/api/commits_spec.rb | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index 86b3dd4095f..a423c92e2fb 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -356,28 +356,35 @@ describe API::Commits do } end + shared_examples_for "successfully creates the commit" do + it "creates the commit" do + expect(response).to have_gitlab_http_status(:created) + expect(json_response['title']).to eq(message) + expect(json_response['committer_name']).to eq(user.name) + expect(json_response['committer_email']).to eq(user.email) + end + end + it 'does not increment the usage counters using access token authentication' do expect(::Gitlab::UsageDataCounters::WebIdeCounter).not_to receive(:increment_commits_count) post api(url, user), params: valid_c_params end - it 'a new file in project repo' do - post api(url, user), params: valid_c_params + context 'a new file in project repo' do + before do + post api(url, user), params: valid_c_params + end - expect(response).to have_gitlab_http_status(:created) - expect(json_response['title']).to eq(message) - expect(json_response['committer_name']).to eq(user.name) - expect(json_response['committer_email']).to eq(user.email) + it_behaves_like "successfully creates the commit" end - it 'a new file with utf8 chars in project repo' do - post api(url, user), params: valid_utf8_c_params + context 'a new file with utf8 chars in project repo' do + before do + post api(url, user), params: valid_utf8_c_params + end - expect(response).to have_gitlab_http_status(:created) - expect(json_response['title']).to eq(message) - expect(json_response['committer_name']).to eq(user.name) - expect(json_response['committer_email']).to eq(user.email) + it_behaves_like "successfully creates the commit" end it 'returns a 400 bad request if file exists' do |