summaryrefslogtreecommitdiff
path: root/spec/requests/api/files_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-21 12:09:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-21 12:09:07 +0000
commit2a040e2655fe0a99df61ad0a7bd0c27e68af0c38 (patch)
treea245cd0d6dd10f185e2fd098e371adc1ea03b72b /spec/requests/api/files_spec.rb
parenta53d2c37c4934f564caa94543dd4cf5af1703e2d (diff)
downloadgitlab-ce-2a040e2655fe0a99df61ad0a7bd0c27e68af0c38.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/files_spec.rb')
-rw-r--r--spec/requests/api/files_spec.rb80
1 files changed, 40 insertions, 40 deletions
diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb
index efad443de3f..3596647015c 100644
--- a/spec/requests/api/files_spec.rb
+++ b/spec/requests/api/files_spec.rb
@@ -58,7 +58,7 @@ describe API::Files do
it 'returns file attributes in headers' do
head api(route(file_path), current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['X-Gitlab-File-Path']).to eq(CGI.unescape(file_path))
expect(response.headers['X-Gitlab-File-Name']).to eq('popen.rb')
expect(response.headers['X-Gitlab-Last-Commit-Id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
@@ -72,7 +72,7 @@ describe API::Files do
head api(route(file_path), current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['X-Gitlab-File-Name']).to eq('commit.js.coffee')
expect(response.headers['X-Gitlab-Content-Sha256']).to eq('08785f04375b47f81f46e68cc125d5ef368aa20576ddb53f91f4d83f1d04b929')
end
@@ -81,7 +81,7 @@ describe API::Files do
it "responds with a 400 status" do
head api(route("any%2Ffile"), current_user)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
@@ -91,7 +91,7 @@ describe API::Files do
head api(route('app%2Fmodels%2Fapplication%2Erb'), current_user), params: params
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -101,7 +101,7 @@ describe API::Files do
it "responds with a 403 status" do
head api(route(file_path), current_user), params: params
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
@@ -119,7 +119,7 @@ describe API::Files do
head api(route(file_path), current_user), params: params
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -148,7 +148,7 @@ describe API::Files do
it 'returns file attributes as json' do
get api(route(file_path), current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['file_path']).to eq(CGI.unescape(file_path))
expect(json_response['file_name']).to eq('popen.rb')
expect(json_response['last_commit_id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
@@ -161,7 +161,7 @@ describe API::Files do
get api(route(file_path), current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq('application/json')
end
@@ -172,7 +172,7 @@ describe API::Files do
get api(route(file_path), current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['file_name']).to eq('commit.js.coffee')
expect(json_response['content_sha256']).to eq('08785f04375b47f81f46e68cc125d5ef368aa20576ddb53f91f4d83f1d04b929')
expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n")
@@ -184,7 +184,7 @@ describe API::Files do
get api(url, current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(headers[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end
@@ -193,7 +193,7 @@ describe API::Files do
get api(url, current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'sets inline content disposition by default' do
@@ -294,7 +294,7 @@ describe API::Files do
it 'returns file attributes in headers' do
head api(route(file_path) + '/blame', current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['X-Gitlab-File-Path']).to eq(CGI.unescape(file_path))
expect(response.headers['X-Gitlab-File-Name']).to eq('popen.rb')
expect(response.headers['X-Gitlab-Last-Commit-Id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
@@ -305,7 +305,7 @@ describe API::Files do
it 'returns blame file attributes as json' do
get api(route(file_path) + '/blame', current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.map { |x| x['lines'].size }).to eq(expected_blame_range_sizes)
expect(json_response.map { |x| x['commit']['id'] }).to eq(expected_blame_range_commit_ids)
range = json_response[0]
@@ -329,7 +329,7 @@ describe API::Files do
get api(url, current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns file by commit sha' do
@@ -339,7 +339,7 @@ describe API::Files do
get api(route(file_path) + '/blame', current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
context 'when mandatory params are not given' do
@@ -411,7 +411,7 @@ describe API::Files do
get api(route(file_path) + '/blame', personal_access_token: token), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -424,7 +424,7 @@ describe API::Files do
get api(url, current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns raw file info for files with dots' do
@@ -433,7 +433,7 @@ describe API::Files do
get api(url, current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns file by commit sha' do
@@ -444,7 +444,7 @@ describe API::Files do
get api(route(file_path) + "/raw", current_user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'sets no-cache headers' do
@@ -520,7 +520,7 @@ describe API::Files do
get api(route(file_path) + "/raw", personal_access_token: token), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -538,7 +538,7 @@ describe API::Files do
it "creates a new file in project repo" do
post api(route(file_path), user), params: params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response["file_path"]).to eq(CGI.unescape(file_path))
last_commit = project.repository.commit.raw
expect(last_commit.author_email).to eq(user.email)
@@ -548,7 +548,7 @@ describe API::Files do
it "returns a 400 bad request if no mandatory params given" do
post api(route("any%2Etxt"), user)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns a 400 bad request if the commit message is empty' do
@@ -556,7 +556,7 @@ describe API::Files do
post api(route(file_path), user), params: params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it "returns a 400 if editor fails to create file" do
@@ -566,7 +566,7 @@ describe API::Files do
post api(route("any%2Etxt"), user), params: params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
context 'with PATs' do
@@ -575,7 +575,7 @@ describe API::Files do
post api(route(file_path), personal_access_token: token), params: params
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it 'returns 201 with `api` scope' do
@@ -583,7 +583,7 @@ describe API::Files do
post api(route(file_path), personal_access_token: token), params: params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
end
end
@@ -593,7 +593,7 @@ describe API::Files do
post api(route("new_file_with_author%2Etxt"), user), params: params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response.content_type).to eq('application/json')
last_commit = project.repository.commit.raw
expect(last_commit.author_email).to eq(author_email)
@@ -607,7 +607,7 @@ describe API::Files do
it "creates a new file in project repo" do
post api(route("newfile%2Erb"), user), params: params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['file_path']).to eq('newfile.rb')
last_commit = project.repository.commit.raw
expect(last_commit.author_email).to eq(user.email)
@@ -628,7 +628,7 @@ describe API::Files do
it "updates existing file in project repo" do
put api(route(file_path), user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['file_path']).to eq(CGI.unescape(file_path))
last_commit = project.repository.commit.raw
expect(last_commit.author_email).to eq(user.email)
@@ -640,7 +640,7 @@ describe API::Files do
put api(route(file_path), user), params: params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it "returns a 400 bad request if update existing file with stale last commit id" do
@@ -648,7 +648,7 @@ describe API::Files do
put api(route(file_path), user), params: params_with_stale_id
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq(_('You are attempting to update a file that has changed since you started editing it.'))
end
@@ -659,13 +659,13 @@ describe API::Files do
put api(route(file_path), user), params: params_with_correct_id
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it "returns a 400 bad request if no params given" do
put api(route(file_path), user)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
context "when specifying an author" do
@@ -674,7 +674,7 @@ describe API::Files do
put api(route(file_path), user), params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
last_commit = project.repository.commit.raw
expect(last_commit.author_email).to eq(author_email)
expect(last_commit.author_name).to eq(author_name)
@@ -693,13 +693,13 @@ describe API::Files do
it "deletes existing file in project repo" do
delete api(route(file_path), user), params: params
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end
it "returns a 400 bad request if no params given" do
delete api(route(file_path), user)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns a 400 bad request if the commit message is empty' do
@@ -707,7 +707,7 @@ describe API::Files do
delete api(route(file_path), user), params: params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it "returns a 400 if fails to delete file" do
@@ -717,7 +717,7 @@ describe API::Files do
delete api(route(file_path), user), params: params
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
context "when specifying an author" do
@@ -726,7 +726,7 @@ describe API::Files do
delete api(route(file_path), user), params: params
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end
end
end
@@ -754,7 +754,7 @@ describe API::Files do
it "remains unchanged" do
get api(route(file_path), user), params: get_params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['file_path']).to eq(CGI.unescape(file_path))
expect(json_response['file_name']).to eq(CGI.unescape(file_path))
expect(json_response['content']).to eq(put_params[:content])