Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-21 15:09:07 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-21 15:09:07 +0300
commit2a040e2655fe0a99df61ad0a7bd0c27e68af0c38 (patch)
treea245cd0d6dd10f185e2fd098e371adc1ea03b72b /spec/requests/api/commits_spec.rb
parenta53d2c37c4934f564caa94543dd4cf5af1703e2d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/commits_spec.rb')
-rw-r--r--spec/requests/api/commits_spec.rb110
1 files changed, 55 insertions, 55 deletions
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index c179de249d5..4b110874df0 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -28,7 +28,7 @@ describe API::Commits do
get api(route, current_user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema(schema)
expect(json_response.first['id']).to eq(commit.id)
expect(json_response.first['committer_name']).to eq(commit.committer_name)
@@ -123,7 +123,7 @@ describe API::Commits do
it "returns an invalid parameter error message" do
get api("/projects/#{project_id}/repository/commits?since=invalid-date", user)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('since is invalid')
end
end
@@ -305,13 +305,13 @@ describe API::Commits do
it 'returns a 403 unauthorized for user without permissions' do
post api(url, guest)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it 'returns a 400 bad request if no params are given' do
post api(url, user)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
describe 'create' do
@@ -365,7 +365,7 @@ describe API::Commits do
it 'a new file in project repo' do
post api(url, user), params: valid_c_params
- expect(response).to have_gitlab_http_status(201)
+ 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)
@@ -374,7 +374,7 @@ describe API::Commits do
it 'a new file with utf8 chars in project repo' do
post api(url, user), params: valid_utf8_c_params
- expect(response).to have_gitlab_http_status(201)
+ 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)
@@ -383,7 +383,7 @@ describe API::Commits do
it 'returns a 400 bad request if file exists' do
post api(url, user), params: invalid_c_params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
context 'with project path containing a dot in URL' do
@@ -392,7 +392,7 @@ describe API::Commits do
it 'a new file in project repo' do
post api(url, user), params: valid_c_params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
end
end
@@ -414,7 +414,7 @@ describe API::Commits do
it 'returns a 403' do
post api(url, guest), params: valid_c_params
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
context 'when start_project is provided' do
@@ -456,7 +456,7 @@ describe API::Commits do
it 'returns a 400' do
post api(url, guest), params: valid_c_params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq("A branch called 'master' already exists. Switch to that branch in order to make changes")
end
@@ -510,7 +510,7 @@ describe API::Commits do
it 'returns a 403' do
post api(url, guest), params: valid_c_params
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
@@ -528,7 +528,7 @@ describe API::Commits do
it 'returns a 403' do
post api(url, guest), params: valid_c_params
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
@@ -545,7 +545,7 @@ describe API::Commits do
valid_c_params[:start_branch] = 'master'
post api(url, user), params: valid_c_params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('start_branch, start_sha are mutually exclusive')
end
@@ -553,7 +553,7 @@ describe API::Commits do
valid_c_params[:branch] = 'master'
post api(url, user), params: valid_c_params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq("A branch called 'master' already exists. Switch to that branch in order to make changes")
end
@@ -561,7 +561,7 @@ describe API::Commits do
valid_c_params[:start_sha] = '1' * 40
post api(url, user), params: valid_c_params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq("Cannot find start_sha '#{valid_c_params[:start_sha]}'")
end
@@ -569,7 +569,7 @@ describe API::Commits do
valid_c_params[:start_sha] = start_sha.slice(0, 7)
post api(url, user), params: valid_c_params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq("Invalid start_sha '#{valid_c_params[:start_sha]}'")
end
@@ -630,14 +630,14 @@ describe API::Commits do
it 'an existing file in project repo' do
post api(url, user), params: valid_d_params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['title']).to eq(message)
end
it 'returns a 400 bad request if file does not exist' do
post api(url, user), params: invalid_d_params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
@@ -675,14 +675,14 @@ describe API::Commits do
it 'an existing file in project repo' do
post api(url, user), params: valid_m_params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['title']).to eq(message)
end
it 'returns a 400 bad request if file does not exist' do
post api(url, user), params: invalid_m_params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
@@ -718,14 +718,14 @@ describe API::Commits do
it 'an existing file in project repo' do
post api(url, user), params: valid_u_params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['title']).to eq(message)
end
it 'returns a 400 bad request if file does not exist' do
post api(url, user), params: invalid_u_params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
@@ -750,7 +750,7 @@ describe API::Commits do
it 'responds with success' do
post api(url, user), params: params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['title']).to eq(message)
end
@@ -760,7 +760,7 @@ describe API::Commits do
it 'responds with success' do
post api(url, user), params: params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['title']).to eq(message)
end
end
@@ -771,7 +771,7 @@ describe API::Commits do
it "responds with 400" do
post api(url, user), params: params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq("A file with this name doesn't exist")
end
end
@@ -849,28 +849,28 @@ describe API::Commits do
it 'are committed as one in project repo' do
post api(url, user), params: valid_mo_params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['title']).to eq(message)
end
it 'includes the commit stats' do
post api(url, user), params: valid_mo_params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response).to include 'stats'
end
it "doesn't include the commit stats when stats is false" do
post api(url, user), params: valid_mo_params.merge(stats: false)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response).not_to include 'stats'
end
it 'return a 400 bad request if there are any issues' do
post api(url, user), params: invalid_mo_params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
@@ -937,7 +937,7 @@ describe API::Commits do
refs = project.repository.branch_names_contains(commit_id).map {|name| ['branch', name]}
refs.concat(project.repository.tag_names_contains(commit_id).map {|name| ['tag', name]})
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.map { |r| [r['type'], r['name']] }.compact).to eq(refs)
@@ -949,7 +949,7 @@ describe API::Commits do
refs = project.repository.branch_names_contains(commit_id).map {|name| ['branch', name]}
refs.concat(project.repository.tag_names_contains(commit_id).map {|name| ['tag', name]})
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.map { |r| [r['type'], r['name']] }.compact).to eq(refs)
end
@@ -958,7 +958,7 @@ describe API::Commits do
refs = project.repository.branch_names_contains(commit_id).map {|name| ['branch', name]}
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.map { |r| [r['type'], r['name']] }.compact).to eq(refs)
end
@@ -967,7 +967,7 @@ describe API::Commits do
refs = project.repository.tag_names_contains(commit_id).map {|name| ['tag', name]}
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.map { |r| [r['type'], r['name']] }.compact).to eq(refs)
end
end
@@ -982,7 +982,7 @@ describe API::Commits do
it 'returns the ref last commit' do
get api(route, current_user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/commit/detail')
expect(json_response['id']).to eq(commit.id)
expect(json_response['short_id']).to eq(commit.short_id)
@@ -1030,7 +1030,7 @@ describe API::Commits do
it 'includes status as "created" and a last_pipeline object' do
get api(route, current_user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/commit/detail')
expect(json_response['status']).to eq('created')
expect(json_response['last_pipeline']['id']).to eq(pipeline.id)
@@ -1047,7 +1047,7 @@ describe API::Commits do
it 'includes a "success" status' do
get api(route, current_user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/commit/detail')
expect(json_response['status']).to eq('success')
end
@@ -1065,7 +1065,7 @@ describe API::Commits do
get api(route, current_user)
expect(response).to match_response_schema('public_api/v4/commit/detail')
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['last_pipeline']).to be_nil
end
end
@@ -1076,21 +1076,21 @@ describe API::Commits do
it 'is not present return stats by default' do
get api(route, user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include 'stats'
end
it "is false it does not include stats" do
get api(route, user), params: { stats: false }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to include 'stats'
end
it "is true it includes stats" do
get api(route, user), params: { stats: true }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include 'stats'
end
end
@@ -1227,7 +1227,7 @@ describe API::Commits do
it 'returns the diff of the selected commit' do
get api(route, current_user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response.size).to be >= 1
expect(json_response.first.keys).to include 'diff'
@@ -1241,7 +1241,7 @@ describe API::Commits do
it 'respects the limit' do
get api(route, current_user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response.size).to be <= 1
end
@@ -1338,7 +1338,7 @@ describe API::Commits do
it 'returns the diff of the selected commit' do
get api(route, current_user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/commit_notes')
expect(json_response.size).to eq(2)
expect(json_response.first['note']).to eq('a comment on a commit')
@@ -1428,7 +1428,7 @@ describe API::Commits do
it 'returns the comments for the target project' do
get api(route, guest)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/commit_notes')
expect(json_response.size).to eq(1)
expect(json_response.first['note']).to eq('a comment on a commit for fork')
@@ -1448,7 +1448,7 @@ describe API::Commits do
it 'cherry-picks the ref commit' do
post api(route, current_user), params: { branch: branch }
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/commit/basic')
expect(json_response['title']).to eq(commit.title)
expect(json_response['message']).to eq(commit.cherry_pick_message(user))
@@ -1608,7 +1608,7 @@ describe API::Commits do
it 'reverts the ref commit' do
post api(route, current_user), params: { branch: branch }
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/commit/basic')
expect(json_response['message']).to eq(commit.revert_message(user))
@@ -1694,7 +1694,7 @@ describe API::Commits do
# Second one is redundant and should be empty
post api(route, current_user), params: { branch: 'markdown' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error_code']).to eq 'empty'
end
end
@@ -1733,7 +1733,7 @@ describe API::Commits do
it 'creates the comment' do
post api(route, current_user), params: { note: note }
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/commit_note')
expect(json_response['note']).to eq('My comment')
expect(json_response['path']).to be_nil
@@ -1774,7 +1774,7 @@ describe API::Commits do
it 'returns the inline comment' do
post api(route, current_user), params: { note: 'My comment', path: project.repository.commit.raw_diffs.first.new_path, line: 1, line_type: 'new' }
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/commit_note')
expect(json_response['note']).to eq('My comment')
expect(json_response['path']).to eq(project.repository.commit.raw_diffs.first.new_path)
@@ -1794,7 +1794,7 @@ describe API::Commits do
it 'returns 400 if note is missing' do
post api(route, current_user)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
context 'when ref contains a dot' do
@@ -1839,7 +1839,7 @@ describe API::Commits do
it 'returns the correct merge request' do
get api("/projects/#{project.id}/repository/commits/#{commit.id}/merge_requests", user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response.length).to eq(1)
expect(json_response[0]['id']).to eq(merged_mr.id)
@@ -1850,13 +1850,13 @@ describe API::Commits do
get api("/projects/#{project.id}/repository/commits/#{commit.id}/merge_requests", user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it 'responds 404 when the commit does not exist' do
get api("/projects/#{project.id}/repository/commits/a7d26f00c35b/merge_requests", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
context 'public project' do
@@ -1866,7 +1866,7 @@ describe API::Commits do
it 'responds 403 when only members are allowed to read merge requests' do
get api("/projects/#{project.id}/repository/commits/#{commit.id}/merge_requests", non_member)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
@@ -1900,7 +1900,7 @@ describe API::Commits do
it 'returns correct JSON' do
get api(route, current_user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['gpg_key_id']).to eq(commit.signature.gpg_key_id)
expect(json_response['gpg_key_subkey_id']).to eq(commit.signature.gpg_key_subkey_id)
expect(json_response['gpg_key_primary_keyid']).to eq(commit.signature.gpg_key_primary_keyid)