Commit eac3ad67 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'pl-rubocop-have-gitlab-http-status-ee-spec-support-shared-examples' into 'master'

Add cop HaveGitlabHttpStatus in EE shared examples

See merge request gitlab-org/gitlab!23295
parents ad66b824 75087619
......@@ -347,6 +347,7 @@ RSpec/HaveGitlabHttpStatus:
Enabled: true
Include:
- 'spec/support/shared_examples/**/*'
- 'ee/spec/support/shared_examples/**/*'
Style/MultilineWhenThen:
Enabled: false
......
......@@ -30,7 +30,7 @@ RSpec.shared_examples ProjectVulnerabilityFindingsActions do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.length).to eq 2
expect(json_response.first['id']).to be(critical_vulnerability.id)
expect(response).to match_response_schema('vulnerabilities/occurrence_list', dir: 'ee')
......@@ -130,7 +130,7 @@ RSpec.shared_examples ProjectVulnerabilityFindingsActions do
end
it 'returns vulnerability findings counts for all report types' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['high']).to eq(3)
expect(json_response['low']).to eq(2)
expect(json_response['medium']).to eq(2)
......
......@@ -16,7 +16,7 @@ RSpec.shared_examples SecurityDashboardsPermissions do
security_dashboard_action
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -31,7 +31,7 @@ RSpec.shared_examples SecurityDashboardsPermissions do
security_dashboard_action
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -41,7 +41,7 @@ RSpec.shared_examples SecurityDashboardsPermissions do
security_dashboard_action
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......
......@@ -8,14 +8,14 @@ RSpec.shared_examples 'multiple issue boards show' do
it 'lets user view board1' do
show(board1)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:board)).to eq(board1)
end
it 'lets user view board2' do
show(board2)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:board)).to eq(board2)
end
end
......@@ -28,7 +28,7 @@ RSpec.shared_examples 'multiple issue boards show' do
it 'let user view the default shown board' do
show(board2)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:board)).to eq(board2)
end
......@@ -36,9 +36,9 @@ RSpec.shared_examples 'multiple issue boards show' do
show(board1)
if parent.is_a?(Project)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
else
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -35,10 +35,10 @@ RSpec.shared_examples 'redirects to last visited board' do
if parent.is_a?(Group)
expect(response).to render_template :index
expect(response.content_type).to eq 'text/html'
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
else
expect(response.content_type).to eq 'text/html'
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
end
......
......@@ -20,7 +20,7 @@ RSpec.shared_examples 'Insights page' do
it 'has correct title' do
visit route
expect(page).to have_gitlab_http_status(200)
expect(page).to have_gitlab_http_status(:ok)
expect(page).to have_content('Insights')
end
......@@ -52,7 +52,7 @@ RSpec.shared_examples 'Insights page' do
it 'returns 404' do
visit route
expect(page).to have_gitlab_http_status(404)
expect(page).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -66,7 +66,7 @@ RSpec.shared_examples 'Insights page' do
it 'returns 404' do
visit route
expect(page).to have_gitlab_http_status(404)
expect(page).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -6,7 +6,7 @@ RSpec.shared_examples 'assignee board list' do
other_user = create(:user)
post api(url, user), params: { assignee_id: other_user.id }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response.dig('message', 'error')).to eq('User not found!')
end
......@@ -15,7 +15,7 @@ RSpec.shared_examples 'assignee board list' do
post api(url, user), params: { assignee_id: user.id }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response.dig('message', 'list_type'))
.to contain_exactly('Assignee lists not available with your current license')
end
......@@ -25,7 +25,7 @@ RSpec.shared_examples 'assignee board list' do
post api(url, user), params: { assignee_id: user.id }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response.dig('assignee', 'id')).to eq(user.id)
end
end
......
......@@ -6,7 +6,7 @@ RSpec.shared_examples 'milestone board list' do
other_milestone = create(:milestone)
post api(url, user), params: { milestone_id: other_milestone.id }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response.dig('message', 'error')).to eq('Milestone not found!')
end
......@@ -15,7 +15,7 @@ RSpec.shared_examples 'milestone board list' do
post api(url, user), params: { milestone_id: milestone.id }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response.dig('message', 'list_type'))
.to contain_exactly('Milestone lists not available with your current license')
end
......@@ -25,7 +25,7 @@ RSpec.shared_examples 'milestone board list' do
post api(url, user), params: { milestone_id: milestone.id }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response.dig('milestone', 'id')).to eq(milestone.id)
end
end
......
......@@ -7,7 +7,7 @@ RSpec.shared_examples 'group and project milestone burndowns' do |route_definiti
it 'returns burndown events list' do
get api(resource_route, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(json_response.first['created_at'].to_time).to eq(Date.today.middle_of_day)
expect(json_response.first['weight']).to eq(5)
......@@ -22,7 +22,7 @@ RSpec.shared_examples 'group and project milestone burndowns' do |route_definiti
get api(resource_route, outside_user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -13,7 +13,7 @@ RSpec.shared_examples 'multiple and scoped issue boards' do |route_definition|
it 'creates a board' do
post api(root_url, user), params: { name: "new board" }
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/board', dir: "ee")
end
......@@ -25,7 +25,7 @@ RSpec.shared_examples 'multiple and scoped issue boards' do |route_definition|
it 'updates a board' do
put api(url, user), params: { name: 'new name', weight: 4, labels: 'foo, bar' }
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/board', dir: "ee")
......@@ -43,14 +43,14 @@ RSpec.shared_examples 'multiple and scoped issue boards' do |route_definition|
.and not_change { board.reload.weight }
.and not_change { board.reload.labels.map(&:title).sort }
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/board', dir: "ee")
end
it 'allows removing optional attributes' do
put api(url, user), params: { name: 'new name', assignee_id: nil, milestone_id: nil, weight: nil, labels: nil }
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/board', dir: "ee")
board.reload
......@@ -69,7 +69,7 @@ RSpec.shared_examples 'multiple and scoped issue boards' do |route_definition|
it 'deletes a board' do
delete api(url, user)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
end
......
......@@ -13,7 +13,7 @@ RSpec.shared_examples 'an API endpoint for creating project approval rule' do
it 'returns 400 status' do
post api(url, current_user)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -21,7 +21,7 @@ RSpec.shared_examples 'an API endpoint for creating project approval rule' do
it 'returns 403' do
post api(url, user2), params: params
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -29,7 +29,7 @@ RSpec.shared_examples 'an API endpoint for creating project approval rule' do
it 'returns 201 status' do
post api(url, current_user), params: params
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema(schema, dir: 'ee')
end
......@@ -68,7 +68,7 @@ RSpec.shared_examples 'an API endpoint for creating project approval rule' do
post api(url, current_user), params: params.merge(name: rule_name)
end.to change { ApprovalProjectRule.report_approver.count }.from(0).to(1)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
end
end
......@@ -109,7 +109,7 @@ RSpec.shared_examples 'an API endpoint for updating project approval rule' do
put api(url, current_user), params: { users: [], groups: [] }.to_json, headers: { CONTENT_TYPE: 'application/json' }
end.to change { approval_rule.users.count + approval_rule.groups.count }.from(2).to(0)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema(schema, dir: 'ee')
end
end
......@@ -123,7 +123,7 @@ RSpec.shared_examples 'an API endpoint for updating project approval rule' do
expect(approval_rule.users).to contain_exactly(approver)
expect(approval_rule.groups).to be_empty
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -149,7 +149,7 @@ RSpec.shared_examples 'an API endpoint for updating project approval rule' do
put api(url, user2), params: { users: [], groups: [] }.to_json, headers: { CONTENT_TYPE: 'application/json' }
end.not_to change { approval_rule.approvers.size }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -159,7 +159,7 @@ RSpec.shared_examples 'an API endpoint for deleting project approval rule' do
delete api(url, user)
expect(ApprovalProjectRule.exists?(id: approval_rule.id)).to eq(false)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
context 'when approval rule not found' do
......@@ -169,7 +169,7 @@ RSpec.shared_examples 'an API endpoint for deleting project approval rule' do
it 'returns not found' do
delete api(url, user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -177,7 +177,7 @@ RSpec.shared_examples 'an API endpoint for deleting project approval rule' do
it 'returns forbidden' do
delete api(url, user2)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -9,7 +9,7 @@ RSpec.shared_examples 'forbids access to vulnerability API endpoint in case of d
it 'responds with "not found"' do
subject
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -21,7 +21,7 @@ RSpec.shared_examples 'forbids access to vulnerability API endpoint in case of d
it 'responds with 403 Forbidden' do
subject
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -32,6 +32,6 @@ RSpec.shared_examples 'responds with "not found" for an unknown vulnerability ID
it do
subject
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
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