Commit a7eb81e3 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'pl-rubocop-have-gitlab-http-status-spec-requests-api-4' into 'master'

Add http status cop to api specs a-o

See merge request gitlab-org/gitlab!25173
parents f7162d5f 765fc43b
......@@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/requests/{groups,projects,repositories}/**/*'
- 'spec/requests/api/*/**/*.rb'
- 'ee/spec/requests/api/*/**/*.rb'
- 'spec/requests/api/[a-l]*.rb'
- 'ee/spec/requests/api/[a-l]*.rb'
- 'spec/requests/api/[a-o]*.rb'
- 'ee/spec/requests/api/[a-o]*.rb'
Style/MultilineWhenThen:
Enabled: false
......
......@@ -25,7 +25,7 @@ describe API::ManagedLicenses do
it 'returns a forbidden status' do
get api("/projects/#{project.id}/managed_licenses", dev_user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -33,7 +33,7 @@ describe API::ManagedLicenses do
it 'returns project managed licenses' do
get api("/projects/#{project.id}/managed_licenses", dev_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('managed_licenses', dir: 'ee')
expect(json_response).to be_a(Array)
expect(json_response.first['id']).to eq(software_license_policy.id)
......@@ -46,7 +46,7 @@ describe API::ManagedLicenses do
it 'returns project managed licenses to users with read permissions' do
get api("/projects/#{project.id}/managed_licenses", reporter_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('managed_licenses', dir: 'ee')
expect(json_response).to be_a(Array)
expect(json_response.first['id']).to eq(software_license_policy.id)
......@@ -59,14 +59,14 @@ describe API::ManagedLicenses do
it 'returns project managed licenses for public project' do
get api("/projects/#{project.id}/managed_licenses")
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('managed_licenses', dir: 'ee')
end
it 'responses with 404 Not Found for not existing project' do
get api("/projects/0/managed_licenses")
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
context 'when project is private' do
......@@ -77,7 +77,7 @@ describe API::ManagedLicenses do
it 'responses with 404 Not Found' do
get api("/projects/#{project.id}/managed_licenses")
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -88,7 +88,7 @@ describe API::ManagedLicenses do
it 'returns project managed license details' do
get api("/projects/#{project.id}/managed_licenses/#{software_license_policy.id}", dev_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('software_license_policy', dir: 'ee')
expect(json_response['id']).to eq(software_license_policy.id)
expect(json_response['name']).to eq(software_license_policy.name)
......@@ -99,7 +99,7 @@ describe API::ManagedLicenses do
escaped_name = CGI.escape(software_license_policy.name)
get api("/projects/#{project.id}/managed_licenses/#{escaped_name}", dev_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('software_license_policy', dir: 'ee')
expect(json_response['id']).to eq(software_license_policy.id)
expect(json_response['name']).to eq(software_license_policy.name)
......@@ -109,7 +109,7 @@ describe API::ManagedLicenses do
it 'responds with 404 Not Found if requesting non-existing managed license' do
get api("/projects/#{project.id}/managed_licenses/1234512345", dev_user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -117,7 +117,7 @@ describe API::ManagedLicenses do
it 'returns project managed license details' do
get api("/projects/#{project.id}/managed_licenses/#{software_license_policy.id}", reporter_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('software_license_policy', dir: 'ee')
expect(json_response['id']).to eq(software_license_policy.id)
expect(json_response['name']).to eq(software_license_policy.name)
......@@ -129,7 +129,7 @@ describe API::ManagedLicenses do
it 'does not return project managed license details' do
get api("/projects/#{project.id}/managed_licenses/#{software_license_policy.id}")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
......@@ -145,7 +145,7 @@ describe API::ManagedLicenses do
}
end.to change {project.software_license_policies.count}.by(1)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('software_license_policy', dir: 'ee')
expect(json_response).to have_key('id')
expect(json_response['name']).to eq('NEW_LICENSE_NAME')
......@@ -161,7 +161,7 @@ describe API::ManagedLicenses do
}
end.not_to change {project.software_license_policies.count}
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -173,7 +173,7 @@ describe API::ManagedLicenses do
approval_status: 'approved'
}
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -185,7 +185,7 @@ describe API::ManagedLicenses do
approval_status: 'approved'
}
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -197,7 +197,7 @@ describe API::ManagedLicenses do
approval_status: 'approved'
}
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
......@@ -214,7 +214,7 @@ describe API::ManagedLicenses do
updated_software_license_policy = project.software_license_policies.reload.first
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('software_license_policy', dir: 'ee')
# Check that response is equal to the updated object
......@@ -234,7 +234,7 @@ describe API::ManagedLicenses do
it 'responds with 404 Not Found if requesting non-existing managed license' do
patch api("/projects/#{project.id}/managed_licenses/1234512345", maintainer_user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -242,7 +242,7 @@ describe API::ManagedLicenses do
it 'does not update managed license' do
patch api("/projects/#{project.id}/managed_licenses/#{software_license_policy.id}", dev_user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -250,7 +250,7 @@ describe API::ManagedLicenses do
it 'does not update managed license' do
patch api("/projects/#{project.id}/managed_licenses/#{software_license_policy.id}", reporter_user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -258,7 +258,7 @@ describe API::ManagedLicenses do
it 'does not update managed license' do
patch api("/projects/#{project.id}/managed_licenses/#{software_license_policy.id}")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
......@@ -269,7 +269,7 @@ describe API::ManagedLicenses do
expect do
delete api("/projects/#{project.id}/managed_licenses/#{software_license_policy.id}", maintainer_user)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.to change {project.software_license_policies.count}.by(-1)
end
......@@ -277,7 +277,7 @@ describe API::ManagedLicenses do
expect do
delete api("/projects/#{project.id}/managed_licenses/1234512345", maintainer_user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end.not_to change {project.software_license_policies.count}
end
end
......@@ -287,7 +287,7 @@ describe API::ManagedLicenses do
expect do
delete api("/projects/#{project.id}/managed_licenses/#{software_license_policy.id}", dev_user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end.not_to change {project.software_license_policies.count}
end
end
......@@ -297,7 +297,7 @@ describe API::ManagedLicenses do
expect do
delete api("/projects/#{project.id}/managed_licenses/#{software_license_policy.id}", reporter_user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end.not_to change {project.software_license_policies.count}
end
end
......@@ -307,7 +307,7 @@ describe API::ManagedLicenses do
expect do
delete api("/projects/#{project.id}/managed_licenses/#{software_license_policy.id}")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end.not_to change {project.software_license_policies.count}
end
end
......
......@@ -32,7 +32,7 @@ describe API::Members do
it 'matches json schema' do
get api("/groups/#{group.to_param}/members", owner)
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/members')
end
......@@ -50,7 +50,7 @@ describe API::Members do
it 'returns a list of users with group SAML identities info' do
get api("/groups/#{group.to_param}/members", owner)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2)
expect(json_response.first['group_saml_identity']).to match(kind_of(Hash))
end
......@@ -58,7 +58,7 @@ describe API::Members do
it 'allows to filter by linked identity presence' do
get api("/groups/#{group.to_param}/members?with_saml_identity=true", owner)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1)
expect(json_response.any? { |member| member['id'] == maintainer.id }).to be_falsey
end
......@@ -68,14 +68,14 @@ describe API::Members do
it 'returns a list of users without group SAML identities info' do
get api("/groups/#{group.to_param}/members", maintainer)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.map(&:keys).flatten).not_to include('group_saml_identity')
end
it 'ignores filter by linked identity presence' do
get api("/groups/#{group.to_param}/members?with_saml_identity=true", maintainer)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2)
expect(json_response.any? { |member| member['id'] == maintainer.id }).to be_truthy
end
......@@ -87,7 +87,7 @@ describe API::Members do
it 'returns a list of users that does not contain the is_using_seat attribute' do
get api(api_url, owner)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1)
expect(json_response.first.keys).not_to include('is_using_seat')
end
......@@ -97,7 +97,7 @@ describe API::Members do
it 'returns a list of users that contains the is_using_seat attribute' do
get api("/groups/#{group.to_param}/members?show_seat_info=true", owner)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1)
expect(json_response.first['is_using_seat']).to be_truthy
end
......@@ -128,7 +128,7 @@ describe API::Members do
expect do
post api(url, owner), params: params
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end.to change { AuditEvent.count }.by(1)
end
......@@ -138,7 +138,7 @@ describe API::Members do
expect do
post api(url, owner), params: params
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end.not_to change { AuditEvent.count }
end
end
......
......@@ -17,7 +17,7 @@ describe API::MergeRequestApprovalRules do
end
it 'responds with 403' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -32,7 +32,7 @@ describe API::MergeRequestApprovalRules do
let(:current_user) { other_user }
it 'responds with 403' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -43,7 +43,7 @@ describe API::MergeRequestApprovalRules do
let(:approval_rule) { create(:code_owner_rule, merge_request: merge_request) }
it 'responds with 403' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -60,7 +60,7 @@ describe API::MergeRequestApprovalRules do
end
it 'responds with 403' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -89,7 +89,7 @@ describe API::MergeRequestApprovalRules do
end
it 'matches the response schema' do
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/merge_request_approval_rules', dir: 'ee')
rules = json_response
......@@ -172,7 +172,7 @@ describe API::MergeRequestApprovalRules do
end
it 'matches the response schema' do
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/merge_request_approval_rule', dir: 'ee')
rule = json_response
......@@ -286,7 +286,7 @@ describe API::MergeRequestApprovalRules do
it_behaves_like 'a protected API endpoint that only allows action on regular merge request approval rule'
it 'matches the response schema' do
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/merge_request_approval_rule', dir: 'ee')
rule = json_response
......@@ -363,7 +363,7 @@ describe API::MergeRequestApprovalRules do
it_behaves_like 'a protected API endpoint that only allows action on regular merge request approval rule'
it 'responds with 204' do
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
end
......
......@@ -66,7 +66,7 @@ describe API::MergeRequestApprovals do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/approvals", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approvals_required']).to eq 2
expect(json_response['approvals_left']).to eq 1
expect(json_response['approval_rules_left']).to be_empty
......@@ -86,7 +86,7 @@ describe API::MergeRequestApprovals do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/approvals", approver)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approvals_required']).to eq 2
expect(json_response['approvals_left']).to eq 2
......@@ -111,7 +111,7 @@ describe API::MergeRequestApprovals do
it 'hides private group' do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/approvals", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approver_groups'].size).to eq(0)
end
......@@ -119,7 +119,7 @@ describe API::MergeRequestApprovals do
it 'shows all approver groups' do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/approvals", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approver_groups'].size).to eq(1)
end
end
......@@ -132,7 +132,7 @@ describe API::MergeRequestApprovals do
end
it 'returns a 200' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approved']).to be true
expect(json_response['message']).to eq(nil)
end
......@@ -154,7 +154,7 @@ describe API::MergeRequestApprovals do
it 'retrieves the approval rules details' do
get api(url, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['rules'].size).to eq(1)
rule_response = json_response['rules'].first
......@@ -182,7 +182,7 @@ describe API::MergeRequestApprovals do
it 'retrieves the approval state details' do
get api(url, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['rules'].size).to eq(1)
rule_response = json_response['rules'].first
......@@ -207,7 +207,7 @@ describe API::MergeRequestApprovals do
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/approvals", current_user), params: { approvals_required: 5 }
end.to change { merge_request.reload.approvals_before_merge }.from(nil).to(5)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['approvals_required']).to eq(5)
end
end
......@@ -222,7 +222,7 @@ describe API::MergeRequestApprovals do
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/approvals", current_user), params: { approvals_required: 5 }
end.not_to change { merge_request.reload.approvals_before_merge }
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
end
......@@ -251,7 +251,7 @@ describe API::MergeRequestApprovals do
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/approvals", user2), params: { approvals_required: 5 }
end.not_to change { merge_request.reload.approvals_before_merge }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -285,7 +285,7 @@ describe API::MergeRequestApprovals do
end.to change { merge_request.approvers.count }.from(0).to(1)
.and change { merge_request.approver_groups.count }.from(0).to(1)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approvers'][0]['user']['username']).to eq(approver.username)
expect(json_response['approver_groups'][0]['group']['name']).to eq(group.name)
end
......@@ -300,7 +300,7 @@ describe API::MergeRequestApprovals do
end.to change { merge_request.approvers.count }.from(1).to(0)
.and change { merge_request.approver_groups.count }.from(1).to(0)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approvers']).to eq([])
end
......@@ -315,7 +315,7 @@ describe API::MergeRequestApprovals do
end.to change { merge_request.approvers.count }.from(1).to(0)
.and change { merge_request.approver_groups.count }.from(1).to(0)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approvers']).to eq([])
end
end
......@@ -328,7 +328,7 @@ describe API::MergeRequestApprovals do
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/approvers", current_user),
params: { approver_ids: [approver.id], approver_group_ids: [private_group.id, group.id] }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['approver_groups'].size).to eq(expected_group_size)
end
end
......@@ -358,7 +358,7 @@ describe API::MergeRequestApprovals do
params: { approver_ids: [approver.id], approver_group_ids: [group.id] }
end.to not_change { merge_request.approvers.count }.and not_change { merge_request.approver_groups.count }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -372,7 +372,7 @@ describe API::MergeRequestApprovals do
end
it 'returns a 401' do
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
......@@ -395,7 +395,7 @@ describe API::MergeRequestApprovals do
end
it 'approves the merge request' do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['approvals_left']).to eq(1)
expect(json_response['approved_by'][0]['user']['username']).to eq(approver.username)
expect(json_response['user_has_approved']).to be true
......@@ -409,7 +409,7 @@ describe API::MergeRequestApprovals do
end
it 'approves the merge request' do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['approvals_left']).to eq(1)
expect(json_response['approved_by'][0]['user']['username']).to eq(approver.username)
expect(json_response['user_has_approved']).to be true
......@@ -423,7 +423,7 @@ describe API::MergeRequestApprovals do
end
it 'returns a 409' do
expect(response).to have_gitlab_http_status(409)
expect(response).to have_gitlab_http_status(:conflict)
end
it 'does not approve the merge request' do
......@@ -439,7 +439,7 @@ describe API::MergeRequestApprovals do
it 'returns a 401 with no password' do
approve
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'does not approve the merge request with no password' do
......@@ -449,7 +449,7 @@ describe API::MergeRequestApprovals do
it 'returns a 401 with incorrect password' do
approve
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'does not approve the merge request with incorrect password' do
......@@ -459,7 +459,7 @@ describe API::MergeRequestApprovals do
it 'approves the merge request with correct password' do
approve(approval_password: 'password')
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(merge_request.reload.approvals_left).to eq(1)
end
end
......@@ -470,7 +470,7 @@ describe API::MergeRequestApprovals do
approve
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['approver_groups'].size).to eq(0)
end
end
......@@ -495,7 +495,7 @@ describe API::MergeRequestApprovals do
it 'unapproves the merge request' do
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/unapprove", unapprover)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['approvals_left']).to eq(1)
usernames = json_response['approved_by'].map { |u| u['user']['username'] }
expect(usernames).not_to include(unapprover.username)
......@@ -512,7 +512,7 @@ describe API::MergeRequestApprovals do
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/unapprove", unapprover)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['approver_groups'].size).to eq(0)
end
end
......
......@@ -39,7 +39,7 @@ describe API::MergeRequests do
it 'creates merge request with multiple assignees' do
update_merge_request(params)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['assignees'].size).to eq(2)
expect(json_response['assignees'].first['name']).to eq(user.name)
expect(json_response['assignees'].second['name']).to eq(other_user.name)
......@@ -55,7 +55,7 @@ describe API::MergeRequests do
it 'creates merge request with a single assignee' do
update_merge_request(params)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['assignees'].size).to eq(1)
expect(json_response['assignees'].first['name']).to eq(user.name)
expect(json_response.dig('assignee', 'name')).to eq(user.name)
......@@ -74,7 +74,7 @@ describe API::MergeRequests do
]
)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
merge_request.reload
......@@ -107,7 +107,7 @@ describe API::MergeRequests do
it 'creates merge request with multiple assignees' do
create_merge_request(assignee_ids: [user.id, user2.id])
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['assignees'].size).to eq(2)
expect(json_response['assignees'].first['name']).to eq(user.name)
expect(json_response['assignees'].second['name']).to eq(user2.name)
......@@ -123,7 +123,7 @@ describe API::MergeRequests do
it 'creates merge request with a single assignee' do
create_merge_request(assignee_ids: [user.id, user2.id])
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['assignees'].size).to eq(1)
expect(json_response['assignees'].first['name']).to eq(user.name)
expect(json_response.dig('assignee', 'name')).to eq(user.name)
......@@ -135,7 +135,7 @@ describe API::MergeRequests do
it "returns merge_request" do
create_merge_request(squash: true)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['title']).to eq('Test merge_request')
expect(json_response['labels']).to eq(%w(label label2))
expect(json_response['milestone']['id']).to eq(milestone.id)
......@@ -162,7 +162,7 @@ describe API::MergeRequests do
end
it 'sets approvals_before_merge' do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['message']).to eq(nil)
expect(json_response['approvals_before_merge']).to eq(1)
end
......@@ -178,7 +178,7 @@ describe API::MergeRequests do
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
expect(response).to have_gitlab_http_status(406)
expect(response).to have_gitlab_http_status(:not_acceptable)
expect(json_response['message']).to eq('Branch cannot be merged')
end
......@@ -190,7 +190,7 @@ describe API::MergeRequests do
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -261,7 +261,7 @@ describe API::MergeRequests do
let(:approvers_param) { 'any-other-string' }
it 'returns a validation error' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq("approver_ids should be an array, 'None' or 'Any'")
end
end
......@@ -306,7 +306,7 @@ describe API::MergeRequests do
let(:approvals_param) { 'any-other-string' }
it 'returns a validation error' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq("approved_by_ids should be an array, 'None' or 'Any'")
end
end
......
......@@ -17,7 +17,7 @@ describe API::Namespaces do
group_kind_json_response = json_response.find { |resource| resource['kind'] == 'group' }
user_kind_json_response = json_response.find { |resource| resource['kind'] == 'user' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(group_kind_json_response.keys).to contain_exactly('id', 'kind', 'name', 'path', 'full_path',
'parent_id', 'members_count_with_descendants',
......@@ -120,7 +120,7 @@ describe API::Namespaces do
put api("/namespaces/#{group1.full_path}", admin), params: { plan: 'silver', shared_runners_minutes_limit: 9001 }
aggregate_failures do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['plan']).to eq('silver')
expect(json_response['shared_runners_minutes_limit']).to eq(9001)
end
......@@ -129,7 +129,7 @@ describe API::Namespaces do
it 'updates namespace using id' do
put api("/namespaces/#{group1.id}", admin), params: { plan: 'silver', shared_runners_minutes_limit: 9001 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['plan']).to eq('silver')
expect(json_response['shared_runners_minutes_limit']).to eq(9001)
end
......@@ -139,7 +139,7 @@ describe API::Namespaces do
it 'retuns 403' do
put api("/namespaces/#{group1.id}", user), params: { plan: 'silver' }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -147,7 +147,7 @@ describe API::Namespaces do
it 'returns 404' do
put api("/namespaces/12345", admin), params: { plan: 'silver' }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response).to eq('message' => '404 Namespace Not Found')
end
end
......@@ -156,7 +156,7 @@ describe API::Namespaces do
it 'returns validation error' do
put api("/namespaces/#{group1.id}", admin), params: { plan: 'unknown' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('plan' => ['is not included in the list'])
end
end
......@@ -202,7 +202,7 @@ describe API::Namespaces do
it 'returns an unauthroized error' do
do_post(user, params)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -210,13 +210,13 @@ describe API::Namespaces do
it 'fails when some attrs are missing' do
do_post(admin, params.except(:start_date))
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'creates a subscription for the Group' do
do_post(admin, params)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(group1.gitlab_subscription).to be_present
end
......@@ -231,7 +231,7 @@ describe API::Namespaces do
post api("/namespaces/#{group1.full_path}/gitlab_subscription", admin), params: params
aggregate_failures do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(group1.gitlab_subscription).to be_present
end
end
......@@ -258,7 +258,7 @@ describe API::Namespaces do
it 'returns an unauthroized error' do
do_get(developer)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -266,13 +266,13 @@ describe API::Namespaces do
it 'has access to the object' do
do_get(owner)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'is successful using full_path when namespace path contains dots' do
get api("/namespaces/#{group1.full_path}/gitlab_subscription", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns data in a proper format' do
......@@ -312,7 +312,7 @@ describe API::Namespaces do
it 'returns an unauthroized error' do
do_put(namespace.id, user, { seats: 150 })
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -321,7 +321,7 @@ describe API::Namespaces do
it 'returns a 404 error', :quarantine do
do_put(1111, admin, params)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -331,7 +331,7 @@ describe API::Namespaces do
it 'returns a 404 error' do
do_put(namespace_2.id, admin, params)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -339,7 +339,7 @@ describe API::Namespaces do
it 'returns a 400 error' do
do_put(namespace.id, admin, params.merge(seats: nil))
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -347,7 +347,7 @@ describe API::Namespaces do
it 'updates the subscription for the Group' do
do_put(namespace.id, admin, params)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(gitlab_subscription.reload.seats).to eq(150)
expect(gitlab_subscription.plan_name).to eq('silver')
expect(gitlab_subscription.plan_title).to eq('Silver')
......@@ -356,7 +356,7 @@ describe API::Namespaces do
it 'is sucessful using full_path when namespace path contains dots' do
put api("/namespaces/#{namespace.full_path}/gitlab_subscription", admin), params: params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -368,7 +368,7 @@ describe API::Namespaces do
do_put(namespace.id, admin, params.merge(trial_ends_on: date))
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(gitlab_subscription.reload.trial_ends_on).to eq(date)
end
end
......@@ -377,7 +377,7 @@ describe API::Namespaces do
it 'returns 400' do
do_put(namespace.id, admin, params.merge(trial_ends_on: 2.days.ago.to_date))
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(gitlab_subscription.reload.trial_ends_on).to be_nil
end
end
......
......@@ -40,7 +40,7 @@ describe API::Notes do
it 'returns previous issue system notes' do
get api("/groups/#{group.id}/epics/#{promoted_issue_epic.id}/notes", reporter)
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.size).to eq(3)
......@@ -51,7 +51,7 @@ describe API::Notes do
it 'does not return previous issue system notes' do
get api("/groups/#{group.id}/epics/#{promoted_issue_epic.id}/notes", guest)
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.size).to eq(2)
......
......@@ -30,7 +30,7 @@ describe API::NpmPackages do
it 'denies request without oauth token' do
get_package(package)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -80,7 +80,7 @@ describe API::NpmPackages do
get_package_with_token(package)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -89,7 +89,7 @@ describe API::NpmPackages do
get_package(package)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
def get_package(package, params = {})
......@@ -113,21 +113,21 @@ describe API::NpmPackages do
it 'returns the file with an access token' do
get_file_with_token(package_file)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq('application/octet-stream')
end
it 'returns the file with a job token' do
get_file_with_job_token(package_file)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq('application/octet-stream')
end
it 'denies download with no token' do
get_file(package_file)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -137,7 +137,7 @@ describe API::NpmPackages do
it 'returns the file with no token needed' do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq('application/octet-stream')
end
......@@ -156,7 +156,7 @@ describe API::NpmPackages do
get_file_with_token(package_file)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -173,7 +173,7 @@ describe API::NpmPackages do
get_file(package_file)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
def get_file(package_file, params = {})
......@@ -201,7 +201,7 @@ describe API::NpmPackages do
expect { upload_package_with_token(package_name, params) }
.not_to change { project.packages.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
context 'with empty versions' do
......@@ -211,7 +211,7 @@ describe API::NpmPackages do
expect { upload_package_with_token(package_name, params) }
.not_to change { project.packages.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -224,7 +224,7 @@ describe API::NpmPackages do
expect { upload_package_with_token(package_name, params) }
.not_to change { project.packages.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -244,7 +244,7 @@ describe API::NpmPackages do
.and change { Packages::PackageFile.count }.by(1)
.and change { Packages::Tag.count }.by(1)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -253,7 +253,7 @@ describe API::NpmPackages do
.to change { project.packages.count }.by(1)
.and change { Packages::PackageFile.count }.by(1)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
context 'with an authenticated job token' do
......@@ -272,7 +272,7 @@ describe API::NpmPackages do
it 'creates the package metadata' do
upload_package_with_token(package_name, params)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(project.reload.packages.find(json_response['id']).build_info.pipeline).to eq job.pipeline
end
end
......@@ -287,7 +287,7 @@ describe API::NpmPackages do
expect { upload_package_with_token(package_name, params) }
.not_to change { project.packages.count }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -302,7 +302,7 @@ describe API::NpmPackages do
.and change { Packages::Dependency.count}.by(4)
.and change { Packages::DependencyLink.count}.by(6)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
context 'with existing dependencies' do
......@@ -513,7 +513,7 @@ describe API::NpmPackages do
end
def expect_a_valid_package_response
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq('application/json')
expect(response).to match_response_schema('public_api/v4/packages/npm_package', dir: 'ee')
expect(json_response['name']).to eq(package.name)
......
......@@ -16,7 +16,7 @@ describe API::Markdown do
shared_examples "rendered markdown text without GFM" do
it "renders markdown text" do
expect(response).to have_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(response.headers["Content-Type"]).to eq("application/json")
expect(json_response).to be_a(Hash)
expect(json_response["html"]).to eq("<p>#{text}</p>")
......@@ -25,7 +25,7 @@ describe API::Markdown do
shared_examples "404 Project Not Found" do
it "responses with 404 Not Found" do
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(response.headers["Content-Type"]).to eq("application/json")
expect(json_response).to be_a(Hash)
expect(json_response["message"]).to eq("404 Project Not Found")
......@@ -37,7 +37,7 @@ describe API::Markdown do
let(:params) { {} }
it "responses with 400 Bad Request" do
expect(response).to have_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(response.headers["Content-Type"]).to eq("application/json")
expect(json_response).to be_a(Hash)
expect(json_response["error"]).to eq("text is missing")
......@@ -83,7 +83,7 @@ describe API::Markdown do
let(:params) { { text: text, gfm: true } }
it "renders markdown text" do
expect(response).to have_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(response.headers["Content-Type"]).to eq("application/json")
expect(json_response).to be_a(Hash)
expect(json_response["html"]).to include("Hello world!")
......@@ -100,7 +100,7 @@ describe API::Markdown do
let(:user) { project.owner }
it "renders markdown text" do
expect(response).to have_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(response.headers["Content-Type"]).to eq("application/json")
expect(json_response).to be_a(Hash)
expect(json_response["html"]).to include("Hello world!")
......@@ -120,7 +120,7 @@ describe API::Markdown do
shared_examples 'user without proper access' do
it 'does not render the title or link' do
expect(response).to have_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response["html"]).not_to include('Confidential title')
expect(json_response["html"]).not_to include('<a href=')
expect(json_response["html"]).to include('Hello world!')
......@@ -146,7 +146,7 @@ describe API::Markdown do
let(:user) { confidential_issue.author }
it 'renders the title or link' do
expect(response).to have_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response["html"]).to include('Confidential title')
expect(json_response["html"]).to include('Hello world!')
.and include('data-name="tada"')
......
This diff is collapsed.
......@@ -28,12 +28,12 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
it 'returns a 404 when merge_request id is used instead of the iid' do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/versions", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns a 404 when merge_request_iid not found' do
get api("/projects/#{project.id}/merge_requests/0/versions", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -51,17 +51,17 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
it 'returns a 404 when merge_request id is used instead of the iid' do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/versions/#{merge_request_diff.id}", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns a 404 when merge_request version_id is not found' do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/versions/0", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns a 404 when merge_request_iid is not found' do
get api("/projects/#{project.id}/merge_requests/12345/versions/#{merge_request_diff.id}", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
This diff is collapsed.
......@@ -12,7 +12,7 @@ describe API::Namespaces do
context "when unauthenticated" do
it "returns authentication error" do
get api("/namespaces")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
......@@ -23,7 +23,7 @@ describe API::Namespaces do
group_kind_json_response = json_response.find { |resource| resource['kind'] == 'group' }
user_kind_json_response = json_response.find { |resource| resource['kind'] == 'user' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(group_kind_json_response.keys).to include('id', 'kind', 'name', 'path', 'full_path',
'parent_id', 'members_count_with_descendants')
......@@ -34,7 +34,7 @@ describe API::Namespaces do
it "admin: returns an array of all namespaces" do
get api("/namespaces", admin)
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.length).to eq(Namespace.count)
......@@ -43,7 +43,7 @@ describe API::Namespaces do
it "admin: returns an array of matched namespaces" do
get api("/namespaces?search=#{group2.name}", admin)
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.length).to eq(1)
......@@ -77,7 +77,7 @@ describe API::Namespaces do
it "user: returns an array of namespaces" do
get api("/namespaces", 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).to be_an Array
expect(json_response.length).to eq(1)
......@@ -86,7 +86,7 @@ describe API::Namespaces do
it "admin: returns an array of matched namespaces" do
get api("/namespaces?search=#{user.username}", 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).to be_an Array
expect(json_response.length).to eq(1)
......@@ -102,7 +102,7 @@ describe API::Namespaces do
it 'returns namespace details' do
get api("/namespaces/#{namespace_id}", request_actor)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(requested_namespace.id)
expect(json_response['path']).to eq(requested_namespace.path)
......@@ -153,7 +153,7 @@ describe API::Namespaces do
it 'returns not-found' do
get api('/namespaces/0', request_actor)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -162,7 +162,7 @@ describe API::Namespaces do
it 'returns authentication error' do
get api("/namespaces/#{group1.id}")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
......@@ -174,7 +174,7 @@ describe API::Namespaces do
it 'returns not-found' do
get api("/namespaces/#{group2.id}", request_actor)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -182,7 +182,7 @@ describe API::Namespaces do
it 'returns not-found' do
get api("/namespaces/#{user2.namespace.id}", request_actor)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -72,7 +72,7 @@ describe API::Notes do
it "returns an empty array" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes", 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).to be_an Array
expect(json_response).to be_empty
......@@ -86,7 +86,7 @@ describe API::Notes do
it "returns 404" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -95,7 +95,7 @@ describe API::Notes do
it "returns a non-empty array" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes", private_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).to be_an Array
expect(json_response.first['body']).to eq(cross_reference_note.note)
......@@ -114,7 +114,7 @@ describe API::Notes do
shared_examples 'a notes request' do
it 'is a note array response' do
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
end
......@@ -177,7 +177,7 @@ describe API::Notes do
it "returns a 404 error" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes/#{cross_reference_note.id}", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
context "when issue is confidential" do
......@@ -188,7 +188,7 @@ describe API::Notes do
it "returns 404" do
get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{issue_note.id}", private_user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -197,7 +197,7 @@ describe API::Notes do
it "returns an issue note by id" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes/#{cross_reference_note.id}", private_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['body']).to eq(cross_reference_note.note)
end
end
......@@ -237,7 +237,7 @@ describe API::Notes do
it 'returns 200 status' do
subject
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'creates a new note' do
......@@ -251,7 +251,7 @@ describe API::Notes do
it 'returns 403 status' do
subject
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'does not create a new note' do
......
......@@ -11,7 +11,7 @@ describe API::NotificationSettings do
it "returns global notification settings for the current user" do
get api("/notification_settings", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a Hash
expect(json_response['notification_email']).to eq(user.notification_email)
expect(json_response['level']).to eq(user.global_notification_setting.level)
......@@ -24,7 +24,7 @@ describe API::NotificationSettings do
it "updates global notification settings for the current user" do
put api("/notification_settings", user), params: { level: 'watch', notification_email: email.email }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['notification_email']).to eq(email.email)
expect(user.reload.notification_email).to eq(email.email)
expect(json_response['level']).to eq(user.reload.global_notification_setting.level)
......@@ -35,7 +35,7 @@ describe API::NotificationSettings do
it "fails on non-user email address" do
put api("/notification_settings", user), params: { notification_email: 'invalid@example.com' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -43,7 +43,7 @@ describe API::NotificationSettings do
it "returns group level notification settings for the current user" do
get api("/groups/#{group.id}/notification_settings", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a Hash
expect(json_response['level']).to eq(user.notification_settings_for(group).level)
end
......@@ -53,7 +53,7 @@ describe API::NotificationSettings do
it "updates group level notification settings for the current user" do
put api("/groups/#{group.id}/notification_settings", user), params: { level: 'watch' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['level']).to eq(user.reload.notification_settings_for(group).level)
end
end
......@@ -62,7 +62,7 @@ describe API::NotificationSettings do
it "returns project level notification settings for the current user" do
get api("/projects/#{project.id}/notification_settings", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a Hash
expect(json_response['level']).to eq(user.notification_settings_for(project).level)
end
......@@ -72,7 +72,7 @@ describe API::NotificationSettings do
it "updates project level notification settings for the current user" do
put api("/projects/#{project.id}/notification_settings", user), params: { level: 'custom', new_note: true }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['level']).to eq(user.reload.notification_settings_for(project).level)
expect(json_response['events']['new_note']).to be_truthy
expect(json_response['events']['new_issue']).to be_falsey
......@@ -83,7 +83,7 @@ describe API::NotificationSettings do
it "fails on invalid level" do
put api("/projects/#{project.id}/notification_settings", user), params: { level: 'invalid' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -14,7 +14,7 @@ describe 'OAuth tokens' do
request_oauth_token(user)
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
expect(json_response['error']).to eq('invalid_grant')
end
end
......@@ -25,7 +25,7 @@ describe 'OAuth tokens' do
request_oauth_token(user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['access_token']).not_to be_nil
end
end
......@@ -33,7 +33,7 @@ describe 'OAuth tokens' do
shared_examples 'does not create an access token' do
let(:user) { create(:user) }
it { expect(response).to have_gitlab_http_status(401) }
it { expect(response).to have_gitlab_http_status(:unauthorized) }
end
context 'when user is blocked' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment