Commit 2f40dac3 authored by jacopo's avatar jacopo

Refactor `have_http_status` into `have_gitlab_http_status` in the specs

parent b4dc0ba2
---
title: Refactor have_http_status into have_gitlab_http_status
merge_request: 14958
author: Jacopo Beschi @jacopo-beschi
type: added
......@@ -20,7 +20,7 @@ describe Admin::HooksController do
post :create, hook: hook_params
expect(response).to have_http_status(302)
expect(response).to have_gitlab_http_status(302)
expect(SystemHook.all.size).to eq(1)
expect(SystemHook.first).to have_attributes(hook_params)
end
......
......@@ -22,7 +22,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
it "doesn't sign us in" do
......@@ -46,7 +46,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
it "doesn't sign us in as the impersonator" do
......@@ -65,7 +65,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
it "doesn't sign us in as the impersonator" do
......
......@@ -27,7 +27,7 @@ describe Admin::ProjectsController do
get :index
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(response.body).not_to match(pending_delete_project.name)
expect(response.body).to match(project.name)
end
......
......@@ -11,7 +11,7 @@ describe Admin::RunnersController do
it 'lists all runners' do
get :index
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
end
......@@ -19,13 +19,13 @@ describe Admin::RunnersController do
it 'shows a particular runner' do
get :show, id: runner.id
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
it 'shows 404 for unknown runner' do
get :show, id: 0
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
......@@ -39,7 +39,7 @@ describe Admin::RunnersController do
runner.reload
expect(response).to have_http_status(302)
expect(response).to have_gitlab_http_status(302)
expect(runner.description).to eq(new_desc)
end
end
......@@ -48,7 +48,7 @@ describe Admin::RunnersController do
it 'destroys the runner' do
delete :destroy, id: runner.id
expect(response).to have_http_status(302)
expect(response).to have_gitlab_http_status(302)
expect(Ci::Runner.find_by(id: runner.id)).to be_nil
end
end
......@@ -63,7 +63,7 @@ describe Admin::RunnersController do
runner.reload
expect(response).to have_http_status(302)
expect(response).to have_gitlab_http_status(302)
expect(runner.active).to eq(true)
end
end
......@@ -78,7 +78,7 @@ describe Admin::RunnersController do
runner.reload
expect(response).to have_http_status(302)
expect(response).to have_gitlab_http_status(302)
expect(runner.active).to eq(false)
end
end
......
......@@ -20,7 +20,7 @@ describe Admin::ServicesController do
it 'successfully displays the template' do
get :edit, id: service.id
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
end
end
......@@ -46,7 +46,7 @@ describe Admin::ServicesController do
put :update, id: service.id, service: { active: true }
expect(response).to have_http_status(302)
expect(response).to have_gitlab_http_status(302)
end
it 'does not call the propagation worker when service is not active' do
......@@ -54,7 +54,7 @@ describe Admin::ServicesController do
put :update, id: service.id, service: { properties: {} }
expect(response).to have_http_status(302)
expect(response).to have_gitlab_http_status(302)
end
end
end
......@@ -14,7 +14,7 @@ describe Admin::SpamLogsController do
it 'lists all spam logs' do
get :index
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
end
......@@ -22,14 +22,14 @@ describe Admin::SpamLogsController do
it 'removes only the spam log when removing log' do
expect { delete :destroy, id: first_spam.id }.to change { SpamLog.count }.by(-1)
expect(User.find(user.id)).to be_truthy
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
it 'removes user and his spam logs when removing the user' do
delete :destroy, id: first_spam.id, remove_user: true
expect(flash[:notice]).to eq "User #{user.username} was successfully removed."
expect(response).to have_http_status(302)
expect(response).to have_gitlab_http_status(302)
expect(SpamLog.count).to eq(0)
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
......@@ -42,7 +42,7 @@ describe Admin::SpamLogsController do
it 'submits the log as ham' do
post :mark_as_ham, id: first_spam.id
expect(response).to have_http_status(302)
expect(response).to have_gitlab_http_status(302)
expect(SpamLog.find(first_spam.id).submitted_as_ham).to be_truthy
end
end
......
......@@ -19,7 +19,7 @@ describe Admin::UsersController do
it 'deletes user and ghosts their contributions' do
delete :destroy, id: user.username, format: :json
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(User.exists?(user.id)).to be_falsy
expect(issue.reload.author).to be_ghost
end
......@@ -27,7 +27,7 @@ describe Admin::UsersController do
it 'deletes the user and their contributions when hard delete is specified' do
delete :destroy, id: user.username, hard_delete: true, format: :json
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(User.exists?(user.id)).to be_falsy
expect(Issue.exists?(issue.id)).to be_falsy
end
......
......@@ -61,7 +61,7 @@ describe ApplicationController do
context "when the 'private_token' param is populated with the private token" do
it "logs the user in" do
get :index, private_token: user.private_token
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq("authenticated")
end
end
......@@ -70,7 +70,7 @@ describe ApplicationController do
it "logs the user in" do
@request.headers['PRIVATE-TOKEN'] = user.private_token
get :index
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq("authenticated")
end
end
......@@ -95,7 +95,7 @@ describe ApplicationController do
context "when the 'personal_access_token' param is populated with the personal access token" do
it "logs the user in" do
get :index, private_token: personal_access_token.token
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq('authenticated')
end
end
......@@ -104,7 +104,7 @@ describe ApplicationController do
it "logs the user in" do
@request.headers["PRIVATE-TOKEN"] = personal_access_token.token
get :index
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq('authenticated')
end
end
......@@ -158,7 +158,7 @@ describe ApplicationController do
it 'returns 200 response' do
get :index, private_token: user.private_token, format: requested_format
expect(response).to have_http_status 200
expect(response).to have_gitlab_http_status 200
end
end
......@@ -166,7 +166,7 @@ describe ApplicationController do
it 'returns 404 response' do
get :index, private_token: user.private_token
expect(response).to have_http_status 404
expect(response).to have_gitlab_http_status 404
end
end
end
......@@ -183,7 +183,7 @@ describe ApplicationController do
context 'when the request format is atom' do
it "logs the user in" do
get :index, rss_token: user.rss_token, format: :atom
expect(response).to have_http_status 200
expect(response).to have_gitlab_http_status 200
expect(response.body).to eq 'authenticated'
end
end
......@@ -191,7 +191,7 @@ describe ApplicationController do
context 'when the request format is not atom' do
it "doesn't log the user in" do
get :index, rss_token: user.rss_token
expect(response.status).not_to have_http_status 200
expect(response.status).not_to have_gitlab_http_status 200
expect(response.body).not_to eq 'authenticated'
end
end
......
......@@ -30,7 +30,7 @@ describe AutocompleteController do
get(:users, project_id: 'unknown')
end
it { expect(response).to have_http_status(404) }
it { expect(response).to have_gitlab_http_status(404) }
end
end
......@@ -59,7 +59,7 @@ describe AutocompleteController do
get(:users, group_id: 'unknown')
end
it { expect(response).to have_http_status(404) }
it { expect(response).to have_gitlab_http_status(404) }
end
end
......@@ -138,7 +138,7 @@ describe AutocompleteController do
get(:users, project_id: project.id)
end
it { expect(response).to have_http_status(404) }
it { expect(response).to have_gitlab_http_status(404) }
end
describe 'GET #users with unknown project' do
......@@ -146,7 +146,7 @@ describe AutocompleteController do
get(:users, project_id: 'unknown')
end
it { expect(response).to have_http_status(404) }
it { expect(response).to have_gitlab_http_status(404) }
end
describe 'GET #users with inaccessible group' do
......@@ -155,7 +155,7 @@ describe AutocompleteController do
get(:users, group_id: user.namespace.id)
end
it { expect(response).to have_http_status(404) }
it { expect(response).to have_gitlab_http_status(404) }
end
describe 'GET #users with no project' do
......
......@@ -24,7 +24,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
list_issues user: user, board: 999, list: list2
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
......@@ -62,7 +62,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
list_issues user: user, board: board, list: 999
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
end
......@@ -93,7 +93,7 @@ describe Boards::IssuesController do
it 'returns a forbidden 403 response' do
list_issues user: user, board: board, list: list2
expect(response).to have_http_status(403)
expect(response).to have_gitlab_http_status(403)
end
end
......@@ -116,7 +116,7 @@ describe Boards::IssuesController do
it 'returns a successful 200 response' do
create_issue user: user, board: board, list: list1, title: 'New issue'
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
it 'returns the created issue' do
......@@ -131,7 +131,7 @@ describe Boards::IssuesController do
it 'returns an unprocessable entity 422 response' do
create_issue user: user, board: board, list: list1, title: nil
expect(response).to have_http_status(422)
expect(response).to have_gitlab_http_status(422)
end
end
......@@ -141,7 +141,7 @@ describe Boards::IssuesController do
create_issue user: user, board: board, list: list, title: 'New issue'
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
......@@ -149,7 +149,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
create_issue user: user, board: 999, list: list1, title: 'New issue'
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
......@@ -157,7 +157,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
create_issue user: user, board: board, list: 999, title: 'New issue'
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
end
......@@ -166,7 +166,7 @@ describe Boards::IssuesController do
it 'returns a forbidden 403 response' do
create_issue user: guest, board: board, list: list1, title: 'New issue'
expect(response).to have_http_status(403)
expect(response).to have_gitlab_http_status(403)
end
end
......@@ -187,7 +187,7 @@ describe Boards::IssuesController do
it 'returns a successful 200 response' do
move user: user, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
it 'moves issue to the desired list' do
......@@ -201,19 +201,19 @@ describe Boards::IssuesController do
it 'returns a unprocessable entity 422 response for invalid lists' do
move user: user, board: board, issue: issue, from_list_id: nil, to_list_id: nil
expect(response).to have_http_status(422)
expect(response).to have_gitlab_http_status(422)
end
it 'returns a not found 404 response for invalid board id' do
move user: user, board: 999, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
it 'returns a not found 404 response for invalid issue id' do
move user: user, board: board, issue: double(id: 999), from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
......@@ -227,7 +227,7 @@ describe Boards::IssuesController do
it 'returns a forbidden 403 response' do
move user: guest, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_http_status(403)
expect(response).to have_gitlab_http_status(403)
end
end
......
......@@ -15,7 +15,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
read_board_list user: user, board: board
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(response.content_type).to eq 'application/json'
end
......@@ -39,7 +39,7 @@ describe Boards::ListsController do
it 'returns a forbidden 403 response' do
read_board_list user: user, board: board
expect(response).to have_http_status(403)
expect(response).to have_gitlab_http_status(403)
end
end
......@@ -60,7 +60,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
create_board_list user: user, board: board, label_id: label.id
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
it 'returns the created list' do
......@@ -75,7 +75,7 @@ describe Boards::ListsController do
it 'returns a not found 404 response' do
create_board_list user: user, board: board, label_id: nil
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
......@@ -85,7 +85,7 @@ describe Boards::ListsController do
create_board_list user: user, board: board, label_id: label.id
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
end
......@@ -96,7 +96,7 @@ describe Boards::ListsController do
create_board_list user: guest, board: board, label_id: label.id
expect(response).to have_http_status(403)
expect(response).to have_gitlab_http_status(403)
end
end
......@@ -119,7 +119,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
move user: user, board: board, list: planning, position: 1
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
it 'moves the list to the desired position' do
......@@ -133,7 +133,7 @@ describe Boards::ListsController do
it 'returns an unprocessable entity 422 response' do
move user: user, board: board, list: planning, position: 6
expect(response).to have_http_status(422)
expect(response).to have_gitlab_http_status(422)
end
end
......@@ -141,7 +141,7 @@ describe Boards::ListsController do
it 'returns a not found 404 response' do
move user: user, board: board, list: 999, position: 1
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
......@@ -149,7 +149,7 @@ describe Boards::ListsController do
it 'returns a forbidden 403 response' do
move user: guest, board: board, list: planning, position: 6
expect(response).to have_http_status(403)
expect(response).to have_gitlab_http_status(403)
end
end
......@@ -172,7 +172,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
remove_board_list user: user, board: board, list: planning
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
it 'removes list from board' do
......@@ -184,7 +184,7 @@ describe Boards::ListsController do
it 'returns a not found 404 response' do
remove_board_list user: user, board: board, list: 999
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
end
......@@ -192,7 +192,7 @@ describe Boards::ListsController do
it 'returns a forbidden 403 response' do
remove_board_list user: guest, board: board, list: planning
expect(response).to have_http_status(403)
expect(response).to have_gitlab_http_status(403)
end
end
......@@ -212,7 +212,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
generate_default_lists user: user, board: board
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
it 'returns the defaults lists' do
......@@ -228,7 +228,7 @@ describe Boards::ListsController do
generate_default_lists user: user, board: board
expect(response).to have_http_status(422)
expect(response).to have_gitlab_http_status(422)
end
end
......@@ -236,7 +236,7 @@ describe Boards::ListsController do
it 'returns a forbidden 403 response' do
generate_default_lists user: guest, board: board
expect(response).to have_http_status(403)
expect(response).to have_gitlab_http_status(403)
end
end
......
......@@ -32,7 +32,7 @@ describe Dashboard::MilestonesController do
it 'shows milestone page' do
view_milestone
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
end
end
......@@ -18,19 +18,19 @@ describe Dashboard::TodosController do
get :index, project_id: unauthorized_project.id
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
it 'renders 404 when given project does not exists' do
get :index, project_id: 999
expect(response).to have_http_status(404)
expect(response).to have_gitlab_http_status(404)
end
it 'renders 200 when filtering for "any project" todos' do
get :index, project_id: ''
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
it 'renders 200 when user has access on given project' do
......@@ -38,7 +38,7 @@ describe Dashboard::TodosController do
get :index, project_id: authorized_project.id
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
end
......@@ -61,7 +61,7 @@ describe Dashboard::TodosController do
get :index, page: last_page
expect(assigns(:todos).current_page).to eq(last_page)
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
end
it 'does not redirect to external sites when provided a host field' do
......@@ -104,7 +104,7 @@ describe Dashboard::TodosController do
patch :restore, id: todo.id
expect(todo.reload).to be_pending
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to eq({ "count" => "1", "done_count" => "0" })
end
end
......@@ -118,7 +118,7 @@ describe Dashboard::TodosController do
todos.each do |todo|
expect(todo.reload).to be_pending
end
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to eq({ 'count' => '2', 'done_count' => '0' })
end
end
......
......@@ -8,7 +8,7 @@ describe Groups::GroupMembersController do
it 'renders index with 200 status code' do
get :index, group_id: group
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template(:index)
end