Commit 867496ea authored by Imre Farkas's avatar Imre Farkas

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

Add http status cop to subfolders of api specs

See merge request gitlab-org/gitlab!25162
parents abf48882 1d6bb047
......@@ -345,6 +345,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/controllers/**/*'
- 'spec/requests/*.rb'
- 'ee/spec/requests/*.rb'
- 'spec/requests/api/*/**/*.rb'
- 'ee/spec/requests/api/*/**/*.rb'
Style/MultilineWhenThen:
Enabled: false
......
......@@ -50,7 +50,7 @@ describe 'Epics through GroupQuery' do
it_behaves_like 'a working graphql query'
it 'returns epics successfully' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(graphql_errors).to be_nil
expect(epic_node_array('id').first).to eq epic.to_global_id.to_s
expect(graphql_data['group']['epicsEnabled']).to be_truthy
......
......@@ -59,7 +59,7 @@ describe 'Timelogs through GroupQuery' do
it_behaves_like 'a working graphql query'
it 'returns timelogs successfully' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(graphql_errors).to be_nil
expect(node_array.size).to eq 1
expect(graphql_data['group']['groupTimelogsEnabled']).to be_truthy
......
......@@ -31,7 +31,7 @@ describe 'getting group information' do
it 'allows access via session' do
post_graphql(group_query(group), current_user: user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(graphql_data['group']['id']).to eq(group.to_global_id.to_s)
end
......@@ -39,7 +39,7 @@ describe 'getting group information' do
token = create(:personal_access_token, user: user).token
post_graphql(group_query(group), headers: { 'Authorization' => "Bearer #{token}" })
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(graphql_data['group']['id']).to eq(group.to_global_id.to_s)
end
end
......
......@@ -55,7 +55,7 @@ describe API::Internal::Base do
it 'includes current Geo secondary lag in the output' do
post api('/internal/post_receive'), params: valid_params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['messages']).to include({
'type' => 'basic',
'message' => "Current replication lag: 17 seconds"
......@@ -69,7 +69,7 @@ describe API::Internal::Base do
it 'does not include current Geo secondary lag in the output' do
post api('/internal/post_receive'), params: valid_params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['messages']).not_to include({ 'message' => a_string_matching('replication lag'), 'type' => anything })
end
end
......@@ -80,7 +80,7 @@ describe API::Internal::Base do
it 'does not include current Geo secondary lag in the output' do
post api('/internal/post_receive'), params: valid_params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['messages']).not_to include({ 'message' => a_string_matching('replication lag'), 'type' => anything })
end
end
......@@ -90,7 +90,7 @@ describe API::Internal::Base do
it 'does not include current Geo secondary lag in the output' do
post api('/internal/post_receive'), params: valid_params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['messages']).not_to include({ 'message' => a_string_matching('replication lag'), 'type' => anything })
end
end
......@@ -105,7 +105,7 @@ describe API::Internal::Base do
it 'does not include current Geo secondary lag in the output' do
post api('/internal/post_receive'), params: valid_params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['messages']).not_to include({ 'message' => a_string_matching('replication lag'), 'type' => anything })
end
end
......@@ -130,7 +130,7 @@ describe API::Internal::Base do
protocol: 'ssh'
})
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
......@@ -158,7 +158,7 @@ describe API::Internal::Base do
end
it "does not allow access because project can't be found" do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -174,7 +174,7 @@ describe API::Internal::Base do
end
it "allows access" do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -184,7 +184,7 @@ describe API::Internal::Base do
end
it "does not allow access because project can't be found" do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -227,7 +227,7 @@ describe API::Internal::Base do
it "allows access" do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -235,7 +235,7 @@ describe API::Internal::Base do
it "does not allow access" do
subject
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
expect(json_response['message']).to eql('Project requires smartcard login. Please login to GitLab using a smartcard.')
end
end
......@@ -248,7 +248,7 @@ describe API::Internal::Base do
it "allows access" do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -318,7 +318,7 @@ describe API::Internal::Base do
lfs_auth_user(user.id, project)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['repository_http_path']).to eq(geo_primary_http_url_to_repo(project))
end
end
......
This diff is collapsed.
......@@ -29,7 +29,7 @@ describe 'Milestones through GroupQuery' do
it_behaves_like 'a working graphql query'
it 'returns milestones successfully' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(graphql_errors).to be_nil
expect_array_response(milestone_1.to_global_id.to_s, milestone_2.to_global_id.to_s, milestone_3.to_global_id.to_s, milestone_4.to_global_id.to_s)
end
......
......@@ -55,7 +55,7 @@ describe 'getting group information' do
post_graphql(group_query(group1), current_user: user1)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(graphql_data['group']['id']).to eq(group1.to_global_id.to_s)
expect(graphql_data['group']['name']).to eq(group1.name)
expect(graphql_data['group']['path']).to eq(group1.path)
......
......@@ -33,7 +33,7 @@ describe 'getting task completion status information' do
it 'returns the expected task completion status' do
post_graphql(create_task_completion_status_query_for(type, item.iid), current_user: user1)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
task_completion_status = graphql_data.dig('project', type, 'taskCompletionStatus')
expect(task_completion_status).not_to be_nil
......
This diff is collapsed.
......@@ -22,7 +22,7 @@ describe API::Internal::Pages do
it 'responds with 404 Not Found' do
query_host('pages.gitlab.io')
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -31,7 +31,7 @@ describe API::Internal::Pages do
it 'responds with 401 Unauthorized' do
query_host('pages.gitlab.io')
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
......@@ -51,7 +51,7 @@ describe API::Internal::Pages do
it 'responds with 204 no content' do
query_host('pages.gitlab.io')
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
expect(response.body).to be_empty
end
end
......@@ -65,7 +65,7 @@ describe API::Internal::Pages do
it 'responds with 204 No Content' do
query_host('pages.gitlab.io')
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
......@@ -75,7 +75,7 @@ describe API::Internal::Pages do
query_host('pages.gitlab.io')
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('internal/pages/virtual_domain')
expect(json_response['certificate']).to eq(pages_domain.certificate)
......@@ -114,7 +114,7 @@ describe API::Internal::Pages do
query_host('mygroup.gitlab-pages.io')
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('internal/pages/virtual_domain')
expect(json_response['lookup_paths']).to eq(
......@@ -141,7 +141,7 @@ describe API::Internal::Pages do
query_host('mygroup.gitlab-pages.io')
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('internal/pages/virtual_domain')
expect(json_response['lookup_paths']).to eq(
......
......@@ -72,7 +72,7 @@ describe API::Issues do
it 'returns issues statistics' do
get api("/groups/#{group.id}/issues_statistics", user), params: params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['statistics']).not_to be_nil
expect(json_response['statistics']['counts']['all']).to eq counts[:all]
expect(json_response['statistics']['counts']['closed']).to eq counts[:closed]
......@@ -343,7 +343,7 @@ describe API::Issues do
it 'exposes known attributes' do
get api(base_url, admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.last.keys).to include(*%w(id iid project_id title description))
expect(json_response.last).not_to have_key('subscribed')
end
......@@ -527,7 +527,7 @@ describe API::Issues do
it 'returns an array of issues with no milestone' do
get api(base_url, user), params: { milestone: no_milestone_title }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect_paginated_array_response(group_confidential_issue.id)
end
......@@ -674,14 +674,14 @@ describe API::Issues do
it 'returns error when multiple assignees are passed' do
get api(base_url, user), params: { assignee_username: [assignee.username, another_assignee.username], scope: 'all' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["error"]).to include("allows one value, but found 2")
end
it 'returns error when assignee_username and assignee_id are passed together' do
get api(base_url, user), params: { assignee_username: [assignee.username], assignee_id: another_assignee.id, scope: 'all' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["error"]).to include("mutually exclusive")
end
end
......
......@@ -93,7 +93,7 @@ describe API::Issues do
it 'returns project issues statistics' do
get api("/issues_statistics", user), params: params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['statistics']).not_to be_nil
expect(json_response['statistics']['counts']['all']).to eq counts[:all]
expect(json_response['statistics']['counts']['closed']).to eq counts[:closed]
......@@ -196,7 +196,7 @@ describe API::Issues do
get api("/projects/#{max_project_id + 1}/issues", non_member)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 404 on private projects for other users' do
......@@ -205,7 +205,7 @@ describe API::Issues do
get api("/projects/#{private_project.id}/issues", non_member)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns no issues when user has access to project but not issues' do
......@@ -472,7 +472,7 @@ describe API::Issues do
it 'exposes known attributes' do
get api("#{base_url}/issues", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.last.keys).to include(*%w(id iid project_id title description))
expect(json_response.last).not_to have_key('subscribed')
end
......@@ -565,14 +565,14 @@ describe API::Issues do
it 'returns error when multiple assignees are passed' do
get api("/issues", user), params: { assignee_username: [assignee.username, another_assignee.username], scope: 'all' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["error"]).to include("allows one value, but found 2")
end
it 'returns error when assignee_username and assignee_id are passed together' do
get api("/issues", user), params: { assignee_username: [assignee.username], assignee_id: another_assignee.id, scope: 'all' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["error"]).to include("mutually exclusive")
end
end
......@@ -583,14 +583,14 @@ describe API::Issues do
it 'returns public issues' do
get api("/projects/#{project.id}/issues/#{issue.iid}")
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
it 'exposes known attributes' do
get api("/projects/#{project.id}/issues/#{issue.iid}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(issue.id)
expect(json_response['iid']).to eq(issue.iid)
expect(json_response['project_id']).to eq(issue.project.id)
......@@ -630,7 +630,7 @@ describe API::Issues do
it 'exposes the closed_at attribute' do
get api("/projects/#{project.id}/issues/#{closed_issue.iid}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['closed_at']).to be_present
end
......@@ -650,39 +650,39 @@ describe API::Issues do
it 'returns a project issue by internal id' do
get api("/projects/#{project.id}/issues/#{issue.iid}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(issue.title)
expect(json_response['iid']).to eq(issue.iid)
end
it 'returns 404 if issue id not found' do
get api("/projects/#{project.id}/issues/54321", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 404 if the issue ID is used' do
get api("/projects/#{project.id}/issues/#{issue.id}", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
context 'confidential issues' do
it 'returns 404 for non project members' do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 404 for project members with guest role' do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns confidential issue for project members' do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
end
......@@ -690,7 +690,7 @@ describe API::Issues do
it 'returns confidential issue for author' do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
end
......@@ -698,7 +698,7 @@ describe API::Issues do
it 'returns confidential issue for assignee' do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", assignee)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
end
......@@ -706,7 +706,7 @@ describe API::Issues do
it 'returns confidential issue for admin' do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
end
......@@ -744,7 +744,7 @@ describe API::Issues do
it "returns 404 when issue doesn't exists" do
get api("/projects/#{project.id}/issues/0/closed_by", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -774,7 +774,7 @@ describe API::Issues do
get_related_merge_requests(project.id, issue.iid)
expect_paginated_array_response(related_mr.id)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.last).not_to have_key('subscribed')
end
......@@ -785,7 +785,7 @@ describe API::Issues do
get_related_merge_requests(private_project.id, private_issue.iid)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -824,7 +824,7 @@ describe API::Issues do
it "returns 404 when issue doesn't exists" do
get_related_merge_requests(project.id, 0, user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -835,14 +835,14 @@ describe API::Issues do
it 'returns unauthorized' do
get api("/projects/#{project.id}/issues/#{issue.iid}/user_agent_detail")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
it 'exposes known attributes' do
get api("/projects/#{project.id}/issues/#{issue.iid}/user_agent_detail", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['user_agent']).to eq(user_agent_detail.user_agent)
expect(json_response['ip_address']).to eq(user_agent_detail.ip_address)
expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
......@@ -851,7 +851,7 @@ describe API::Issues do
it 'returns unauthorized for non-admin users' do
get api("/projects/#{project.id}/issues/#{issue.iid}/user_agent_detail", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -863,7 +863,7 @@ describe API::Issues do
it 'returns 404 if the issue is confidential' do
post api("/projects/#{project.id}/issues/#{confidential_issue.iid}/participants", non_member)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -76,7 +76,7 @@ describe API::Issues do
it 'returns issues statistics' do
get api("/issues_statistics", user), params: params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['statistics']).not_to be_nil
expect(json_response['statistics']['counts']['all']).to eq counts[:all]
expect(json_response['statistics']['counts']['closed']).to eq counts[:closed]
......@@ -89,39 +89,39 @@ describe API::Issues do
it 'returns an array of all issues' do
get api('/issues'), params: { scope: 'all' }
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
end
it 'returns authentication error without any scope' do
get api('/issues')
expect(response).to have_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns authentication error when scope is assigned-to-me' do
get api('/issues'), params: { scope: 'assigned-to-me' }
expect(response).to have_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns authentication error when scope is created-by-me' do
get api('/issues'), params: { scope: 'created-by-me' }
expect(response).to have_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns an array of issues matching state in milestone' do
get api('/issues'), params: { milestone: 'foo', scope: 'all' }
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect_paginated_array_response([])
end
it 'returns an array of issues matching state in milestone' do
get api('/issues'), params: { milestone: milestone.title, scope: 'all' }
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect_paginated_array_response([issue.id, closed_issue.id])
end
......@@ -129,19 +129,19 @@ describe API::Issues do
it 'returns authentication error without any scope' do
get api('/issues_statistics')
expect(response).to have_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns authentication error when scope is assigned_to_me' do
get api('/issues_statistics'), params: { scope: 'assigned_to_me' }
expect(response).to have_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns authentication error when scope is created_by_me' do
get api('/issues_statistics'), params: { scope: 'created_by_me' }
expect(response).to have_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
context 'no state is treated as all state' do
......@@ -642,14 +642,14 @@ describe API::Issues do
it 'accepts only predefined order by params' do
API::Helpers::IssuesHelpers.sort_options.each do |sort_opt|
get api('/issues', user), params: { order_by: sort_opt, sort: 'asc' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
it 'fails to sort with non predefined options' do
%w(milestone title abracadabra).each do |sort_opt|
get api('/issues', user), params: { order_by: sort_opt, sort: 'asc' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -657,14 +657,14 @@ describe API::Issues do
it 'matches V4 response schema' do
get api('/issues', 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/issues')
end
it 'returns a related merge request count of 0 if there are no related merge requests' do
get api('/issues', 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/issues')
expect(json_response.first).to include('merge_requests_count' => 0)
end
......@@ -674,7 +674,7 @@ describe API::Issues do
get api('/issues', 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/issues')
expect(json_response.first).to include('merge_requests_count' => 1)
end
......@@ -767,14 +767,14 @@ describe API::Issues do
it 'returns error when multiple assignees are passed' do
get api("/issues", user), params: { assignee_username: [assignee.username, another_assignee.username], scope: 'all' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["error"]).to include("allows one value, but found 2")
end
it 'returns error when assignee_username and assignee_id are passed together' do
get api("/issues", user), params: { assignee_username: [assignee.username], assignee_id: another_assignee.id, scope: 'all' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["error"]).to include("mutually exclusive")
end
end
......@@ -835,7 +835,7 @@ describe API::Issues do
it 'exposes full reference path' do
get api("/projects/#{project.id}/issues/#{issue.iid}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['references']['short']).to eq("##{issue.iid}")
expect(json_response['references']['relative']).to eq("##{issue.iid}")
expect(json_response['references']['full']).to eq("#{project.parent.path}/#{project.path}##{issue.iid}")
......@@ -845,12 +845,12 @@ describe API::Issues do
describe 'DELETE /projects/:id/issues/:issue_iid' do
it 'rejects a non member from deleting an issue' do
delete api("/projects/#{project.id}/issues/#{issue.iid}", non_member)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'rejects a developer from deleting an issue' do
delete api("/projects/#{project.id}/issues/#{issue.iid}", author)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
context 'when the user is project owner' do
......@@ -860,7 +860,7 @@ describe API::Issues do
it 'deletes the issue if an admin requests it' do
delete api("/projects/#{project.id}/issues/#{issue.iid}", owner)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it_behaves_like '412 response' do
......@@ -872,14 +872,14 @@ describe API::Issues do
it 'returns 404 when trying to delete an issue' do
delete api("/projects/#{project.id}/issues/123", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
it 'returns 404 when using the issue ID instead of IID' do
delete api("/projects/#{project.id}/issues/#{issue.id}", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......
......@@ -32,7 +32,7 @@ describe API::Pages do
it 'returns 204' do
delete api("/projects/#{project.id}/pages", admin)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'removes the pages' do
......@@ -53,7 +53,7 @@ describe API::Pages do
it 'returns 204' do
delete api("/projects/#{project.id}/pages", admin)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
......@@ -63,7 +63,7 @@ describe API::Pages do
delete api("/projects/#{id}/pages", admin)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
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