Skip to content
Snippets Groups Projects
Unverified Commit 1d2fb8cf authored by Peter Leitzen's avatar Peter Leitzen
Browse files

Add http status cop to all group controller specs

347 files inspected, 176 offenses detected, 176 offenses corrected
parent a11fca06
No related branches found
No related tags found
No related merge requests found
Showing
with 79 additions and 77 deletions
Loading
Loading
@@ -343,6 +343,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/controllers/*.rb'
- 'spec/controllers/projects/**/*.rb'
- 'ee/spec/controllers/projects/**/*.rb'
- 'spec/controllers/groups/**/*.rb'
- 'ee/spec/controllers/groups/**/*.rb'
- 'spec/requests/*.rb'
- 'ee/spec/requests/*.rb'
 
Loading
Loading
Loading
Loading
@@ -32,7 +32,7 @@
 
request
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
 
Loading
Loading
@@ -87,7 +87,7 @@
it 'renders 404' do
request
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
Loading
Loading
Loading
Loading
@@ -17,7 +17,7 @@
it 'returns 200 status' do
get :epics, params: { group_id: group }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
 
it 'returns the correct response' do
Loading
Loading
@@ -41,7 +41,7 @@
 
get :milestones, params: { group_id: group }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.count).to eq(1)
expect(json_response.first).to include(
'iid' => group_milestone.iid, 'title' => group_milestone.title
Loading
Loading
@@ -53,7 +53,7 @@
it 'returns 200 status' do
get :commands, params: { group_id: group, type: 'Epic', type_id: epic.iid }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
 
it 'returns the correct response' do
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@
 
get :index, params: { group_id: group }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
 
Loading
Loading
@@ -44,7 +44,7 @@
 
get :index, params: { group_id: group.id }
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
 
it 'renders 404 when it is not gitlab.com' do
Loading
Loading
@@ -54,7 +54,7 @@
 
get :index, params: { group_id: group }
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
Loading
Loading
Loading
Loading
@@ -37,7 +37,7 @@
it 'returns a not found 404 response' do
list_boards format: :json
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(response.content_type).to eq 'application/json'
end
end
Loading
Loading
@@ -68,7 +68,7 @@ def list_boards(format: :html)
 
list_boards(recent: true)
 
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
Loading
Loading
Loading
Loading
@@ -42,7 +42,7 @@
it 'renders not found' do
get :prometheus_proxy, params: prometheus_proxy_params
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
 
context 'with invalid clusterable id' do
Loading
Loading
Loading
Loading
@@ -45,7 +45,7 @@ def create_push_event(author, project)
 
get :show, params: { group_id: group.path }
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
 
context 'unlicensed but we show promotions' do
Loading
Loading
@@ -60,14 +60,14 @@ def create_push_event(author, project)
 
get :show, params: { group_id: group.path }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
 
it 'sets instance variables properly', :aggregate_failures do
get :show, params: { group_id: group.path }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
 
expect(assigns[:data_collector].users).to match_array([user, user2, user3])
expect(assigns[:data_collector].total_events_by_author_count.values.sum).to eq(6)
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@
it 'returns 200 and renders the view' do
get :show, params: { group_id: group.to_param }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('groups/dependency_proxies/show')
end
end
Loading
Loading
@@ -28,7 +28,7 @@
it 'returns 404 when feature is disabled' do
get :show, params: { group_id: group.to_param }
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
 
Loading
Loading
@@ -41,14 +41,14 @@
it 'redirects back to show page' do
put :update, params: update_params
 
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
 
it 'returns 404 when feature is disabled' do
put :update, params: update_params
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
 
def update_params
Loading
Loading
Loading
Loading
@@ -40,7 +40,7 @@
it 'proxies status from the remote token request' do
get_manifest
 
expect(response).to have_gitlab_http_status(503)
expect(response).to have_gitlab_http_status(:service_unavailable)
expect(response.body).to eq('Service Unavailable')
end
end
Loading
Loading
@@ -57,7 +57,7 @@
it 'proxies status from the remote manifest request' do
get_manifest
 
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(response.body).to be_empty
end
end
Loading
Loading
@@ -65,7 +65,7 @@
it 'returns 200 with manifest file' do
get_manifest
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq(manifest)
end
end
Loading
Loading
@@ -73,7 +73,7 @@
it 'returns 404 when feature is disabled' do
get_manifest
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
 
def get_manifest
Loading
Loading
@@ -108,7 +108,7 @@ def get_manifest
it 'proxies status from the remote blob request' do
get_blob
 
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(response.body).to be_empty
end
end
Loading
Loading
@@ -130,7 +130,7 @@ def get_manifest
it 'returns 404 when feature is disabled' do
get_blob
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
 
def get_blob
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@
end
 
it 'returns 400 status' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
 
Loading
Loading
@@ -59,7 +59,7 @@
 
subject
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
Loading
Loading
@@ -84,7 +84,7 @@
subject
list_service_response = EpicIssues::ListService.new(epic, user).execute
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq('message' => nil, 'issuables' => list_service_response.as_json)
end
 
Loading
Loading
@@ -97,7 +97,7 @@
it 'returns correct response for the correct issue reference' 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 EpicIssue record' do
Loading
Loading
Loading
Loading
@@ -22,7 +22,7 @@
end
 
it 'returns 400 status' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
 
Loading
Loading
@@ -50,7 +50,7 @@
it 'returns the correct JSON response' do
list_service_response = EpicLinks::ListService.new(parent_epic, user).execute
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq(list_service_response.as_json)
end
end
Loading
Loading
@@ -61,7 +61,7 @@
 
subject
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
Loading
Loading
@@ -90,7 +90,7 @@
subject
list_service_response = EpicLinks::ListService.new(parent_epic, user).execute
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq('message' => nil, 'issuables' => list_service_response.as_json)
end
 
Loading
Loading
@@ -103,7 +103,7 @@
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 update parent attribute' do
Loading
Loading
@@ -140,7 +140,7 @@
it 'returns status 200' do
subject
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
 
it 'updates the epic position' do
Loading
Loading
@@ -153,7 +153,7 @@
it 'returns status 404' do
subject
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
Loading
Loading
@@ -162,7 +162,7 @@
it 'returns status 403' do
subject
 
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
Loading
Loading
Loading
Loading
@@ -66,13 +66,13 @@
it "returns status 302 for html" do
post :create, params: request_params.merge(format: :html)
 
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
 
it "returns status 200 for json" do
post :create, params: request_params
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(parsed_response[:id]).not_to be_nil
end
 
Loading
Loading
@@ -95,7 +95,7 @@
it "creates reply note for discussion" do
post :create, params: request_params
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(parsed_response[:errors]).to be_nil
end
end
Loading
Loading
@@ -143,7 +143,7 @@
it "returns status 200" do
delete :destroy, params: request_params
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
 
it "deletes the note" do
Loading
Loading
@@ -159,7 +159,7 @@
it "returns status 404" do
delete :destroy, params: request_params
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
Loading
Loading
@@ -183,7 +183,7 @@
post(:toggle_award_emoji, params: request_params.merge(name: "thumbsup"))
end.to change { note.award_emoji.count }.by(1)
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
 
it "removes the already awarded emoji" do
Loading
Loading
@@ -193,7 +193,7 @@
post(:toggle_award_emoji, params: request_params.merge(name: "thumbsup"))
end.to change { AwardEmoji.count }.by(-1)
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
Loading
Loading
@@ -17,7 +17,7 @@
it 'returns 404 status' do
subject
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
 
Loading
Loading
@@ -56,7 +56,7 @@
it "returns index" do
get :index, params: { group_id: group }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
 
context 'when there is no logged in user' do
Loading
Loading
@@ -67,7 +67,7 @@
get :index, params: { group_id: group, sort: 'start_date_asc' }
 
expect(cookies['epic_sort']).to eq('start_date_asc')
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
 
Loading
Loading
@@ -77,7 +77,7 @@
get :index, params: { group_id: group, sort: 'start_date_asc' }
 
expect(user.user_preference.epics_sort).to eq('start_date_asc')
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
 
Loading
Loading
@@ -88,7 +88,7 @@
get :index, params: { group_id: group, sort: 'start_date_asc' }
 
expect(user.reload.user_preference.epics_sort).to eq('start_date_asc')
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
Loading
Loading
@@ -110,7 +110,7 @@
get :index, params: { group_id: group, page: last_page.to_param }
 
expect(assigns(:epics).current_page).to eq(last_page)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
 
it_behaves_like 'disabled when using an external authorization service' do
Loading
Loading
@@ -216,7 +216,7 @@ def list_epics
it 'the link to the issue is included' do
get :discussions, params: { group_id: group, id: epic.to_param }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1)
discussion = json_response[0]
notes = discussion["notes"]
Loading
Loading
@@ -266,7 +266,7 @@ def show_epic(format = :html)
it 'returns a not found 404 response' do
show_epic
 
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(response.content_type).to eq 'text/html'
end
end
Loading
Loading
@@ -285,7 +285,7 @@ def show_epic(format = :html)
group.add_developer(user)
show_epic(:json)
 
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('entities/epic', dir: 'ee')
end
 
Loading
Loading
@@ -293,7 +293,7 @@ def show_epic(format = :html)
it 'returns a not found 404 response' do
show_epic(:json)
 
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(response.content_type).to eq 'application/json'
end
end
Loading
Loading
@@ -384,7 +384,7 @@ def update_epic(epic, params)
it 'returns a not found 404 response' do
subject
 
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
 
Loading
Loading
@@ -409,7 +409,7 @@ def update_epic(epic, params)
it 'returns 200 response' do
subject
 
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
 
it 'creates a new epic' do
Loading
Loading
@@ -435,7 +435,7 @@ def update_epic(epic, params)
end
 
it 'returns 422 response' do
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
 
it 'does not create a new epic' do
Loading
Loading
@@ -449,7 +449,7 @@ def update_epic(epic, params)
group.add_guest(user)
subject
 
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
Loading
Loading
@@ -463,14 +463,14 @@ def update_epic(epic, params)
group.add_developer(user)
delete :destroy, params: { group_id: group, id: epic.to_param, destroy_confirm: true }
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
 
it "deletes the epic" do
group.add_owner(user)
delete :destroy, params: { group_id: group, id: epic.to_param, destroy_confirm: true }
 
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(controller).to set_flash[:notice].to(/The epic was successfully deleted\./)
end
end
Loading
Loading
Loading
Loading
@@ -72,7 +72,7 @@
},
format: :js
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
Loading
Loading
Loading
Loading
@@ -88,7 +88,7 @@
it 'prevents access to group resources' do
get :show, params: { id: group }
 
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response.location).to match(/groups\/#{group.to_param}\/-\/saml\/sso\?redirect=.+&token=/)
end
end
Loading
Loading
@@ -103,7 +103,7 @@
it 'allows access to group resources' do
get :show, params: { id: group }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@
it 'is successfull' do
get :index, params: { group_id: group.to_param }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
 
Loading
Loading
@@ -43,7 +43,7 @@
 
post :create, params: { group_id: group.to_param, hook: hook_params }
 
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(group.hooks.size).to eq(1)
expect(group.hooks.first).to have_attributes(hook_params)
end
Loading
Loading
@@ -55,7 +55,7 @@
it 'is successfull' do
get :edit, params: { group_id: group.to_param, id: hook }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:edit)
expect(group.hooks.size).to eq(1)
end
Loading
Loading
@@ -85,7 +85,7 @@
it 'is successfull' do
patch :update, params: { group_id: group.to_param, id: hook, hook: hook_params }
 
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(group_hooks_path(group))
expect(group.hooks.size).to eq(1)
expect(group.hooks.first).to have_attributes(hook_params)
Loading
Loading
@@ -102,7 +102,7 @@
it 'renders "edit" template' do
patch :update, params: { group_id: group.to_param, id: hook, hook: hook_params }
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:edit)
expect(group.hooks.size).to eq(1)
expect(group.hooks.first).not_to have_attributes(hook_params)
Loading
Loading
@@ -119,7 +119,7 @@
 
post :test, params: { group_id: group.to_param, id: hook }
 
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(flash[:alert]).to eq('Hook execution failed. Ensure the group has a project with commits.')
end
end
Loading
Loading
@@ -135,7 +135,7 @@
 
post :test, params: { group_id: group.to_param, id: hook }
 
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(flash[:notice]).to eq('Hook executed successfully: HTTP 200')
end
end
Loading
Loading
@@ -150,7 +150,7 @@
 
post :test, params: { group_id: group.to_param, id: hook, trigger: trigger }
 
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(flash[:notice]).to eq('Hook executed successfully: HTTP 200')
end
end
Loading
Loading
@@ -167,7 +167,7 @@
it 'renders a 404' do
get :index, params: { group_id: group.to_param }
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@
it 'returns 404 status' do
subject
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
 
Loading
Loading
@@ -31,7 +31,7 @@
it 'returns 200 status' do
subject
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
 
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@
it 'renders 404' do
get :show, params: { group_id: group.to_param }
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
 
Loading
Loading
@@ -32,7 +32,7 @@
it 'renders 404' do
get :show, params: { group_id: group.to_param }
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
 
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@
 
it 'returns 404 status' do
subject
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
 
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@
it 'returns 404 status' do
subject
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment