Commit 78634704 authored by Alessio Caiazza's avatar Alessio Caiazza

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

Add http status cop in top-level controller specs

See merge request gitlab-org/gitlab!23735
parents 1fac8bf7 57afac6a
......@@ -343,6 +343,7 @@ RSpec/MissingExampleGroupArgument:
RSpec/UnspecifiedException:
Enabled: false
# Work in progress. See https://gitlab.com/gitlab-org/gitlab/issues/196163
RSpec/HaveGitlabHttpStatus:
Enabled: true
Include:
......@@ -350,6 +351,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/support/shared_examples/**/*'
- 'spec/features/**/*'
- 'ee/spec/features/**/*'
- 'spec/controllers/*.rb'
- 'ee/spec/controllers/*.rb'
Style/MultilineWhenThen:
Enabled: false
......
......@@ -16,7 +16,7 @@ describe GroupsController do
post :create, params: { group: { name: 'new_group', path: "new_group" } }
end.to change { Group.count }.by(1)
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
end
......
......@@ -33,7 +33,7 @@ describe OperationsController do
it 'renders index with 200 status code' do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
......@@ -42,7 +42,7 @@ describe OperationsController do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
......@@ -113,7 +113,7 @@ describe OperationsController do
it 'returns an empty list' do
get :list
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/list', dir: 'ee')
expect(json_response['projects']).to eq([])
end
......@@ -154,7 +154,7 @@ describe OperationsController do
it 'returns a list of added projects' do
get :list
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/list', dir: 'ee')
expect(json_response['projects'].size).to eq(1)
......@@ -178,7 +178,7 @@ describe OperationsController do
get :list
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/list', dir: 'ee')
expect(json_response['projects'].size).to eq(8)
......@@ -189,7 +189,7 @@ describe OperationsController do
get :list
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/list', dir: 'ee')
expect(json_response['projects'].size).to eq(1)
expect(expected_project['id']).to eq(project.id)
......@@ -683,7 +683,7 @@ describe OperationsController do
it 'adds projects to the dasboard' do
post :create, params: { project_ids: [project_a.id, project_b.id.to_s] }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to contain_exactly(project_a.id, project_b.id)
expect(json_response['duplicate']).to be_empty
......@@ -698,7 +698,7 @@ describe OperationsController do
post :create, params: { project_ids: [project_a.id, project_b.id.to_s] }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to contain_exactly(project_a.id, project_b.id)
end
......@@ -706,7 +706,7 @@ describe OperationsController do
it 'cannot add a project twice' do
post :create, params: { project_ids: [project_a.id, project_a.id] }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to contain_exactly(project_a.id)
expect(json_response['duplicate']).to be_empty
......@@ -719,7 +719,7 @@ describe OperationsController do
it 'does not add invalid project ids' do
post :create, params: { project_ids: ['', -1, '-2'] }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to be_empty
expect(json_response['duplicate']).to be_empty
......@@ -741,7 +741,7 @@ describe OperationsController do
it 'does not add already added project' do
post :create, params: { project_ids: [project.id] }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to be_empty
expect(json_response['duplicate']).to contain_exactly(project.id)
......@@ -778,7 +778,7 @@ describe OperationsController do
it 'removes a project successfully' do
delete :destroy, params: { project_id: project.id }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
user.reload
expect(user.ops_dashboard_projects).to eq([])
......@@ -789,7 +789,7 @@ describe OperationsController do
delete :destroy, params: { project_id: project.id }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
user.reload
expect(user.ops_dashboard_projects).to eq([])
end
......@@ -799,7 +799,7 @@ describe OperationsController do
it 'cannot remove invalid project' do
delete :destroy, params: { project_id: -1 }
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
......
......@@ -42,7 +42,7 @@ describe ProjectsController do
id: project.path
}
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -133,7 +133,7 @@ describe ProjectsController do
it 'does not create the project from project template' do
expect { post :create, params: { project: templates_params } }.not_to change { Project.count }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to match(/Template name .* is unknown or invalid/)
end
end
......@@ -154,7 +154,7 @@ describe ProjectsController do
}
project.reload
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
params.except(:repository_size_limit).each do |param, value|
expect(project.public_send(param)).to eq(value)
end
......@@ -177,7 +177,7 @@ describe ProjectsController do
}
project.reload
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(project.approver_groups.pluck(:group_id)).to contain_exactly(params[:approver_group_ids])
expect(project.approvers.pluck(:user_id)).to contain_exactly(params[:approver_ids])
end
......@@ -196,7 +196,7 @@ describe ProjectsController do
}
project.reload
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
params.each do |param, value|
expect(project.public_send(param)).to eq(value)
end
......@@ -218,7 +218,7 @@ describe ProjectsController do
}
project.reload
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(project.service_desk_enabled).to eq(true)
end
......@@ -413,7 +413,7 @@ describe ProjectsController do
delete :destroy, params: { namespace_id: project.namespace, id: project }
expect(project.reload.marked_for_deletion?).to be_truthy
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(project_path(project))
end
......@@ -424,7 +424,7 @@ describe ProjectsController do
delete :destroy, params: { namespace_id: project.namespace, id: project }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:edit)
expect(flash[:alert]).to include(message)
end
......@@ -436,7 +436,7 @@ describe ProjectsController do
delete :destroy, params: { namespace_id: project.namespace, id: project }
expect(project.marked_for_deletion?).to be_falsey
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(dashboard_projects_path)
end
end
......@@ -451,7 +451,7 @@ describe ProjectsController do
delete :destroy, params: { namespace_id: project.namespace, id: project }
expect(project.marked_for_deletion?).to be_falsey
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(dashboard_projects_path)
end
end
......@@ -471,7 +471,7 @@ describe ProjectsController do
expect(project.reload.marked_for_deletion_at).to be_nil
expect(project.reload.archived).to be_falsey
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(edit_project_path(project))
end
......@@ -481,7 +481,7 @@ describe ProjectsController do
post :restore, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:edit)
expect(flash[:alert]).to include(message)
end
......
......@@ -28,7 +28,7 @@ describe AcmeChallengesController do
let(:token) { acme_order.challenge_token }
it 'renders not found' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -37,7 +37,7 @@ describe AcmeChallengesController do
let(:token) { 'wrongtoken' }
it 'renders not found' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -156,7 +156,7 @@ describe ApplicationController do
it 'returns 200 response' do
get :index, format: requested_format
expect(response).to have_gitlab_http_status 200
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -164,7 +164,7 @@ describe ApplicationController do
it 'returns 404 response' do
get :index
expect(response).to have_gitlab_http_status 404
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -181,7 +181,7 @@ describe ApplicationController do
get :index
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'redirects to login page if not authenticated' do
......@@ -202,7 +202,7 @@ describe ApplicationController do
get :index, format: 'unknown'
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
......@@ -489,7 +489,7 @@ describe ApplicationController do
it 'redirects if the user did not accept the terms' do
get :index
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
it 'does not redirect when the user accepted terms' do
......@@ -497,7 +497,7 @@ describe ApplicationController do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -581,21 +581,21 @@ describe ApplicationController do
it 'renders a 404 without a message' do
get :index
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(response).to render_template('errors/not_found')
end
it 'renders a 403 when a message is passed to access denied' do
get :index, params: { message: 'None shall pass' }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
expect(response).to render_template('errors/access_denied')
end
it 'renders a status passed to access denied' do
get :index, params: { status: 401 }
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
......
......@@ -32,7 +32,7 @@ describe AutocompleteController do
get(:users, params: { project_id: 'unknown' })
end
it { expect(response).to have_gitlab_http_status(404) }
it { expect(response).to have_gitlab_http_status(:not_found) }
end
end
......@@ -61,7 +61,7 @@ describe AutocompleteController do
get(:users, params: { group_id: 'unknown' })
end
it { expect(response).to have_gitlab_http_status(404) }
it { expect(response).to have_gitlab_http_status(:not_found) }
end
end
......@@ -140,7 +140,7 @@ describe AutocompleteController do
get(:users, params: { project_id: project.id })
end
it { expect(response).to have_gitlab_http_status(404) }
it { expect(response).to have_gitlab_http_status(:not_found) }
end
describe 'GET #users with unknown project' do
......@@ -148,7 +148,7 @@ describe AutocompleteController do
get(:users, params: { project_id: 'unknown' })
end
it { expect(response).to have_gitlab_http_status(404) }
it { expect(response).to have_gitlab_http_status(:not_found) }
end
describe 'GET #users with inaccessible group' do
......@@ -157,7 +157,7 @@ describe AutocompleteController do
get(:users, params: { group_id: user.namespace.id })
end
it { expect(response).to have_gitlab_http_status(404) }
it { expect(response).to have_gitlab_http_status(:not_found) }
end
describe 'GET #users with no project' do
......@@ -372,7 +372,7 @@ describe AutocompleteController do
it 'returns empty json' do
get :merge_request_target_branches, params: { project_id: project.id }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty
end
end
......@@ -383,7 +383,7 @@ describe AutocompleteController do
get :merge_request_target_branches, params: { project_id: project.id }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty
end
end
......@@ -404,7 +404,7 @@ describe AutocompleteController do
get :merge_request_target_branches, params: params
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to eq({ 'error' => 'At least one of group_id or project_id must be specified' })
end
end
......@@ -416,7 +416,7 @@ describe AutocompleteController do
get :merge_request_target_branches, params: { project_id: project.id }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to contain_exactly({ 'title' => 'feature' })
end
end
......@@ -433,7 +433,7 @@ describe AutocompleteController do
get :merge_request_target_branches, params: { group_id: group.id }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to contain_exactly({ 'title' => 'feature' })
end
end
......
......@@ -9,7 +9,7 @@ describe ChaosController do
get :leakmem
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'call synchronously with params' do
......@@ -17,7 +17,7 @@ describe ChaosController do
get :leakmem, params: { memory_mb: 1, duration_s: 2 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'calls asynchronously' do
......@@ -25,7 +25,7 @@ describe ChaosController do
get :leakmem, params: { async: 1 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -35,7 +35,7 @@ describe ChaosController do
get :cpu_spin
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'calls synchronously with params' do
......@@ -43,7 +43,7 @@ describe ChaosController do
get :cpu_spin, params: { duration_s: 3 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'calls asynchronously' do
......@@ -51,7 +51,7 @@ describe ChaosController do
get :cpu_spin, params: { async: 1 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -61,7 +61,7 @@ describe ChaosController do
get :db_spin
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'calls synchronously with params' do
......@@ -69,7 +69,7 @@ describe ChaosController do
get :db_spin, params: { duration_s: 4, interval_s: 5 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'calls asynchronously' do
......@@ -77,7 +77,7 @@ describe ChaosController do
get :db_spin, params: { async: 1 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -87,7 +87,7 @@ describe ChaosController do
get :sleep
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'calls synchronously with params' do
......@@ -95,7 +95,7 @@ describe ChaosController do
get :sleep, params: { duration_s: 5 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'calls asynchronously' do
......@@ -103,7 +103,7 @@ describe ChaosController do
get :sleep, params: { async: 1 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -113,7 +113,7 @@ describe ChaosController do
get :kill
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'calls asynchronously' do
......@@ -121,7 +121,7 @@ describe ChaosController do
get :kill, params: { async: 1 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -39,7 +39,7 @@ describe GraphqlController do
it 'returns 200 when user can access API' do
post :execute
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns access denied template when user cannot access API' do
......@@ -59,7 +59,7 @@ describe GraphqlController do
it 'returns 200' do
post :execute
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......
......@@ -136,7 +136,7 @@ describe GroupsController do
get :activity, params: { id: group.to_param }, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['count']).to eq(3)
expect(assigns(:projects).limit_value).to be_nil
end
......@@ -151,7 +151,7 @@ describe GroupsController do
post :create, params: { group: { name: 'new_group', path: "new_group" } }
end.to change { Group.count }.by(1)
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
context 'authorization' do
......@@ -162,7 +162,7 @@ describe GroupsController do
post :create, params: { group: { name: 'new_group', path: "new_group" } }
end.to change { Group.count }.by(1)
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
......@@ -367,7 +367,7 @@ describe GroupsController do
it 'updates the path successfully' do
post :update, params: { id: group.to_param, group: { path: 'new_path' } }
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(controller).to set_flash[:notice]
end
......@@ -382,7 +382,7 @@ describe GroupsController do
it 'updates the project_creation_level successfully' do
post :update, params: { id: group.to_param, group: { project_creation_level: ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS } }
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(group.reload.project_creation_level).to eq(::Gitlab::Access::MAINTAINER_PROJECT_ACCESS)
end
......@@ -397,7 +397,7 @@ describe GroupsController do
post :update, params: { id: group.to_param, group: { name: 'new_name' } }
expect(controller).to set_flash[:notice]
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(group.reload.name).to eq('new_name')
end
......@@ -405,7 +405,7 @@ describe GroupsController do
post :update, params: { id: group.to_param, group: { path: 'new_path' } }
expect(assigns(:group).errors[:base].first).to match(/Docker images in their Container Registry/)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -468,7 +468,7 @@ describe GroupsController do
it 'does not redirect' do
get :issues, params: { id: group.to_param }
expect(response).not_to have_gitlab_http_status(301)
expect(response).not_to have_gitlab_http_status(:moved_permanently)
end
end
......@@ -487,7 +487,7 @@ describe GroupsController do
it 'does not redirect' do
get :show, params: { id: group.to_param }
expect(response).not_to have_gitlab_http_status(301)
expect(response).not_to have_gitlab_http_status(:moved_permanently)
end
end
......@@ -554,13 +554,13 @@ describe GroupsController do
it 'does not 404' do
post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } }
expect(response).not_to have_gitlab_http_status(404)
expect(response).not_to have_gitlab_http_status(:not_found)
end
it 'does not redirect to the correct casing' do
post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } }
expect(response).not_to have_gitlab_http_status(301)
expect(response).not_to have_gitlab_http_status(:moved_permanently)
end
end
......@@ -570,7 +570,7 @@ describe GroupsController do
it 'returns not found' do
post :update, params: { id: redirect_route.path, group: { path: 'new_path' } }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -580,13 +580,13 @@ describe GroupsController do
it 'does not 404' do
delete :destroy, params: { id: group.to_param.upcase }
expect(response).not_to have_gitlab_http_status(404)
expect(response).not_to have_gitlab_http_status(:not_found)
end
it 'does not redirect to the correct casing' do
delete :destroy, params: { id: group.to_param.upcase }
expect(response).not_to have_gitlab_http_status(301)
expect(response).not_to have_gitlab_http_status(:moved_permanently)
end
end
......@@ -596,7 +596,7 @@ describe GroupsController do
it 'returns not found' do
delete :destroy, params: { id: redirect_route.path }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -693,7 +693,7 @@ describe GroupsController do
end
it 'is denied' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -755,13 +755,13 @@ describe GroupsController do
it 'is successful' do
get :show, params: { id: group.to_param }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'does not allow other formats' do
get :show, params: { id: group.to_param }, format: :atom
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -769,7 +769,7 @@ describe GroupsController do
it 'is successful' do
get :edit, params: { id: group.to_param }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -777,7 +777,7 @@ describe GroupsController do
it 'is successful' do
get :new
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -786,7 +786,7 @@ describe GroupsController do
get :index
# Redirects to the dashboard
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
......@@ -810,7 +810,7 @@ describe GroupsController do
it 'deletes the group' do
delete :destroy, params: { id: group.to_param }
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
end
......
......@@ -101,7 +101,7 @@ describe HealthCheckController, :request_store do
it 'supports failure plaintext response' do
get :index
expect(response).to have_gitlab_http_status(500)
expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response.content_type).to eq 'text/plain'
expect(response.body).to include('The server is on fire')
end
......@@ -109,7 +109,7 @@ describe HealthCheckController, :request_store do
it 'supports failure json response' do
get :index, format: :json
expect(response).to have_gitlab_http_status(500)
expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false
expect(json_response['message']).to include('The server is on fire')
......@@ -118,7 +118,7 @@ describe HealthCheckController, :request_store do
it 'supports failure xml response' do
get :index, format: :xml
expect(response).to have_gitlab_http_status(500)
expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response.content_type).to eq 'application/xml'
expect(xml_response['healthy']).to be false
expect(xml_response['message']).to include('The server is on fire')
......@@ -127,7 +127,7 @@ describe HealthCheckController, :request_store do
it 'supports failure responses for specific checks' do
get :index, params: { checks: 'email' }, format: :json
expect(response).to have_gitlab_http_status(500)
expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false
expect(json_response['message']).to include('Email is on fire')
......
......@@ -148,7 +148,7 @@ describe HelpController do
context 'for UI Development Kit' do
it 'renders found' do
get :ui
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......
......@@ -17,7 +17,7 @@ describe InvitesController do
get :accept, params: { id: token }
member.reload
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(member.user).to eq(user)
expect(flash[:notice]).to include 'You have been granted'
end
......@@ -28,7 +28,7 @@ describe InvitesController do
get :decline, params: { id: token }
expect {member.reload}.to raise_error ActiveRecord::RecordNotFound
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(flash[:notice]).to include 'You have declined the invitation to join'
end
end
......
......@@ -125,7 +125,7 @@ describe NotificationSettingsController do
notification_setting: { level: :participating }
}
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -195,7 +195,7 @@ describe NotificationSettingsController do
notification_setting: { level: :participating }
}
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -172,7 +172,7 @@ describe OmniauthCallbacksController, type: :controller, do_not_mock_admin_mode:
it 'returns 403' do
post provider
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......
......@@ -15,7 +15,7 @@ describe PasswordsController do
post :create
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(flash[:alert]).to eq _('Password authentication is unavailable.')
end
end
......
......@@ -87,7 +87,7 @@ describe ProfilesController, :request_store do
put :update, params: { user: { status: { message: 'Working hard!' } } }
expect(user.reload.status.message).to eq('Working hard!')
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
......
......@@ -30,7 +30,7 @@ describe RegistrationsController do
it 'renders new template and sets the resource variable' do
expect(subject).to render_template(:new)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:resource)).to be_a(User)
end
end
......@@ -48,7 +48,7 @@ describe RegistrationsController do
it 'renders new template and sets the resource variable' do
subject
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(new_user_session_path(anchor: 'register-pane'))
end
end
......@@ -200,7 +200,7 @@ describe RegistrationsController do
.and_call_original
expect(Gitlab::AuthLogger).to receive(:error).with(auth_log_attributes).once
expect { post(:create, params: user_params, session: session_params) }.not_to change(User, :count)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to be_empty
end
end
......
......@@ -21,13 +21,13 @@ describe SearchController do
it 'blocks access without a project_id' do
get action, params: params
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'allows access with a project_id' do
get action, params: params.merge(project_id: create(:project, :public).id)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -42,13 +42,13 @@ describe SearchController do
it 'renders a 403 when no project is given' do
get action, params: params
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'renders a 200 when a project was set' do
get action, params: params.merge(project_id: project.id)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -57,7 +57,7 @@ describe SearchController do
it 'still allows accessing the search page' do
get :show
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -195,7 +195,7 @@ describe SearchController do
get :count, params: { search: 'hello', scope: 'projects' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ 'count' => '1' })
end
......
......@@ -22,7 +22,7 @@ describe SessionsController do
it 'redirects to :omniauth_authorize_path' do
get(:new)
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to('/saml')
end
end
......@@ -31,7 +31,7 @@ describe SessionsController do
it 'responds with 200' do
get(:new, params: { auto_sign_in: 'false' })
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......
......@@ -51,7 +51,7 @@ describe SnippetsController do
it 'responds with status 200' do
get :new
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
context 'when user is not allowed to create a personal snippet' do
......@@ -60,7 +60,7 @@ describe SnippetsController do
it 'responds with status 404' do
get :new
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -90,7 +90,7 @@ describe SnippetsController do
it 'responds with status 404' do
get :show, params: { id: other_personal_snippet.to_param }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -99,13 +99,13 @@ describe SnippetsController do
get :show, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'responds with status 404 when embeddable content is requested' do
get :show, params: { id: personal_snippet.to_param }, format: :js
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -131,13 +131,13 @@ describe SnippetsController do
get :show, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'responds with status 404 when embeddable content is requested' do
get :show, params: { id: personal_snippet.to_param }, format: :js
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -162,14 +162,14 @@ describe SnippetsController do
get :show, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'responds with status 200 when embeddable content is requested' do
get :show, params: { id: personal_snippet.to_param }, format: :js
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -178,7 +178,7 @@ describe SnippetsController do
get :show, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -192,7 +192,7 @@ describe SnippetsController do
it 'responds with status 404' do
get :show, params: { id: 'doesntexist' }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -234,7 +234,7 @@ describe SnippetsController do
create_snippet(visibility_level: Snippet::PUBLIC)
end.not_to change { Snippet.count }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -496,7 +496,7 @@ describe SnippetsController do
it 'responds with status 404' do
get :raw, params: { id: other_personal_snippet.to_param }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -507,7 +507,7 @@ describe SnippetsController do
it 'responds with status 200' do
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'has expected headers' do
......@@ -517,7 +517,7 @@ describe SnippetsController do
end
it "sets #{Gitlab::Workhorse::DETECT_HEADER} header" do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end
end
......@@ -544,7 +544,7 @@ describe SnippetsController do
get :raw, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -569,7 +569,7 @@ describe SnippetsController do
get :raw, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
context 'CRLF line ending' do
......@@ -596,7 +596,7 @@ describe SnippetsController do
get :raw, params: { id: personal_snippet.to_param }
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -610,7 +610,7 @@ describe SnippetsController do
it 'responds with status 404' do
get :raw, params: { id: 'doesntexist' }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -712,7 +712,7 @@ describe SnippetsController do
it 'responds with status 404' do
delete :destroy, params: { id: snippet.to_param }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
This diff is collapsed.
......@@ -28,7 +28,7 @@ describe UsersController do
it 'renders the show template' do
get :show, params: { username: user.username }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('show')
end
end
......@@ -53,7 +53,7 @@ describe UsersController do
it 'renders show' do
get :show, params: { username: user.username }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('show')
end
end
......@@ -74,7 +74,7 @@ describe UsersController do
it 'renders 404' do
get :show, params: { username: 'nonexistent' }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -130,7 +130,7 @@ describe UsersController do
get :calendar, params: { username: public_user.username }, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -285,7 +285,7 @@ describe UsersController do
context 'format html' do
it 'renders snippets page' do
get :snippets, params: { username: user.username }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('show')
end
end
......@@ -293,7 +293,7 @@ describe UsersController do
context 'format json' do
it 'response with snippets json data' do
get :snippets, params: { username: user.username }, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to have_key('html')
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