Skip to content
Snippets Groups Projects
Commit abca19da authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg
Browse files

Use HTTP matchers if possible

parent e0e32562
No related branches found
No related tags found
No related merge requests found
Showing
with 66 additions and 66 deletions
Loading
Loading
@@ -22,7 +22,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
 
it "doesn't sign us in" do
Loading
Loading
@@ -46,7 +46,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
 
it "doesn't sign us in as the impersonator" do
Loading
Loading
@@ -65,7 +65,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
 
it "doesn't sign us in as the impersonator" do
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ describe Admin::SpamLogsController do
it 'lists all spam logs' do
get :index
 
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
end
end
 
Loading
Loading
@@ -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.status).to eq(200)
expect(response).to have_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.status).to eq(302)
expect(response).to have_http_status(302)
expect(SpamLog.count).to eq(0)
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
Loading
Loading
Loading
Loading
@@ -17,7 +17,7 @@ describe Admin::UsersController do
 
it 'deletes user' do
delete :destroy, id: user.username, format: :json
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
expect { User.find(user.id) }.to raise_exception(ActiveRecord::RecordNotFound)
end
end
Loading
Loading
Loading
Loading
@@ -44,7 +44,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.status).to eq(200)
expect(response).to have_http_status(200)
expect(response.body).to eq("authenticated")
end
end
Loading
Loading
@@ -54,7 +54,7 @@ describe ApplicationController do
it "logs the user in" do
@request.headers['PRIVATE-TOKEN'] = user.private_token
get :index
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
expect(response.body).to eq("authenticated")
end
end
Loading
Loading
@@ -80,7 +80,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.status).to eq(200)
expect(response).to have_http_status(200)
expect(response.body).to eq('authenticated')
end
end
Loading
Loading
@@ -89,7 +89,7 @@ describe ApplicationController do
it "logs the user in" do
@request.headers["PRIVATE-TOKEN"] = personal_access_token.token
get :index
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
expect(response.body).to eq('authenticated')
end
end
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@ describe AutocompleteController do
get(:users, project_id: 'unknown')
end
 
it { expect(response.status).to eq(404) }
it { expect(response).to have_http_status(404) }
end
end
 
Loading
Loading
@@ -58,7 +58,7 @@ describe AutocompleteController do
get(:users, group_id: 'unknown')
end
 
it { expect(response.status).to eq(404) }
it { expect(response).to have_http_status(404) }
end
end
 
Loading
Loading
@@ -114,7 +114,7 @@ describe AutocompleteController do
get(:users, project_id: project.id)
end
 
it { expect(response.status).to eq(404) }
it { expect(response).to have_http_status(404) }
end
 
describe 'GET #users with unknown project' do
Loading
Loading
@@ -122,7 +122,7 @@ describe AutocompleteController do
get(:users, project_id: 'unknown')
end
 
it { expect(response.status).to eq(404) }
it { expect(response).to have_http_status(404) }
end
 
describe 'GET #users with inaccessible group' do
Loading
Loading
@@ -131,7 +131,7 @@ describe AutocompleteController do
get(:users, group_id: user.namespace.id)
end
 
it { expect(response.status).to eq(404) }
it { expect(response).to have_http_status(404) }
end
 
describe 'GET #users with no project' do
Loading
Loading
Loading
Loading
@@ -155,7 +155,7 @@ describe Projects::CommitController do
id: commit.id)
 
expect(response).not_to be_success
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
 
Loading
Loading
@@ -204,7 +204,7 @@ describe Projects::CommitController do
id: master_pickable_commit.id)
 
expect(response).not_to be_success
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
 
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ describe Groups::GroupMembersController do
it 'renders index with group members' do
get :index, group_id: group
 
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
expect(response).to render_template(:index)
end
end
Loading
Loading
@@ -26,7 +26,7 @@ describe Groups::GroupMembersController do
delete :destroy, group_id: group,
id: 42
 
expect(response.status).to eq(403)
expect(response).to have_http_status(403)
end
end
 
Loading
Loading
@@ -48,7 +48,7 @@ describe Groups::GroupMembersController do
delete :destroy, group_id: group,
id: member
 
expect(response.status).to eq(403)
expect(response).to have_http_status(403)
expect(group.users).to include group_user
end
end
Loading
Loading
@@ -89,7 +89,7 @@ describe Groups::GroupMembersController do
it 'returns 403' do
delete :leave, group_id: group
 
expect(response.status).to eq(403)
expect(response).to have_http_status(403)
end
end
 
Loading
Loading
@@ -118,7 +118,7 @@ describe Groups::GroupMembersController do
it 'cannot removes himself from the group' do
delete :leave, group_id: group
 
expect(response.status).to eq(403)
expect(response).to have_http_status(403)
end
end
 
Loading
Loading
@@ -166,7 +166,7 @@ describe Groups::GroupMembersController do
post :approve_access_request, group_id: group,
id: 42
 
expect(response.status).to eq(403)
expect(response).to have_http_status(403)
end
end
 
Loading
Loading
@@ -188,7 +188,7 @@ describe Groups::GroupMembersController do
post :approve_access_request, group_id: group,
id: member
 
expect(response.status).to eq(403)
expect(response).to have_http_status(403)
expect(group.users).not_to include group_requester
end
end
Loading
Loading
Loading
Loading
@@ -65,21 +65,21 @@ describe HealthCheckController do
it 'supports passing the token in the header' do
request.headers['TOKEN'] = token
get :index
expect(response.status).to eq(500)
expect(response).to have_http_status(500)
expect(response.content_type).to eq 'text/plain'
expect(response.body).to include('The server is on fire')
end
 
it 'supports failure plaintest response' do
get :index, token: token
expect(response.status).to eq(500)
expect(response).to have_http_status(500)
expect(response.content_type).to eq 'text/plain'
expect(response.body).to include('The server is on fire')
end
 
it 'supports failure json response' do
get :index, token: token, format: :json
expect(response.status).to eq(500)
expect(response).to have_http_status(500)
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')
Loading
Loading
@@ -87,7 +87,7 @@ describe HealthCheckController do
 
it 'supports failure xml response' do
get :index, token: token, format: :xml
expect(response.status).to eq(500)
expect(response).to have_http_status(500)
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')
Loading
Loading
@@ -95,7 +95,7 @@ describe HealthCheckController do
 
it 'supports failure responses for specific checks' do
get :index, token: token, checks: 'email', format: :json
expect(response.status).to eq(500)
expect(response).to have_http_status(500)
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')
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ describe InvitesController do
get :accept, id: token
member.reload
 
expect(response.status).to eq(302)
expect(response).to have_http_status(302)
expect(member.user).to eq(user)
expect(flash[:notice]).to include 'You have been granted'
end
Loading
Loading
@@ -26,7 +26,7 @@ describe InvitesController do
get :decline, id: token
expect{member.reload}.to raise_error ActiveRecord::RecordNotFound
 
expect(response.status).to eq(302)
expect(response).to have_http_status(302)
expect(flash[:notice]).to include 'You have declined the invitation to join'
end
end
Loading
Loading
Loading
Loading
@@ -86,7 +86,7 @@ describe NamespacesController do
it "responds with status 404" do
get :show, id: group.path
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
end
Loading
Loading
@@ -102,7 +102,7 @@ describe NamespacesController do
it "responds with status 404" do
get :show, id: "doesntexist"
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
 
Loading
Loading
Loading
Loading
@@ -60,7 +60,7 @@ describe NotificationSettingsController do
project: { id: private_project.id },
notification_setting: { level: :participating }
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
end
Loading
Loading
@@ -118,7 +118,7 @@ describe NotificationSettingsController do
id: notification_setting,
notification_setting: { level: :participating }
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
end
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ describe Oauth::ApplicationsController do
it 'shows list of applications' do
get :index
 
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
end
 
it 'redirects back to profile page if OAuth applications are disabled' do
Loading
Loading
@@ -21,7 +21,7 @@ describe Oauth::ApplicationsController do
 
get :index
 
expect(response.status).to eq(302)
expect(response).to have_http_status(302)
expect(response).to redirect_to(profile_path)
end
end
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ describe Profiles::AccountsController do
delete :unlink, provider: 'saml'
updated_user = User.find(user.id)
 
expect(response.status).to eq(302)
expect(response).to have_http_status(302)
expect(updated_user.identities.size).to eq(1)
expect(updated_user.identities).to include(identity)
end
Loading
Loading
Loading
Loading
@@ -103,7 +103,7 @@ describe Projects::BranchesController do
namespace_id: project.namespace.to_param,
project_id: project.to_param
 
expect(response.status).to eq(303)
expect(response).to have_http_status(303)
end
end
 
Loading
Loading
@@ -121,24 +121,24 @@ describe Projects::BranchesController do
context "valid branch name, valid source" do
let(:branch) { "feature" }
 
it { expect(response.status).to eq(200) }
it { expect(response).to have_http_status(200) }
end
 
context "valid branch name with unencoded slashes" do
let(:branch) { "improve/awesome" }
 
it { expect(response.status).to eq(200) }
it { expect(response).to have_http_status(200) }
end
 
context "valid branch name with encoded slashes" do
let(:branch) { "improve%2Fawesome" }
 
it { expect(response.status).to eq(200) }
it { expect(response).to have_http_status(200) }
end
context "invalid branch name, valid ref" do
let(:branch) { "no-branch" }
 
it { expect(response.status).to eq(404) }
it { expect(response).to have_http_status(404) }
end
end
end
Loading
Loading
@@ -14,7 +14,7 @@ describe Projects::IssuesController do
it "returns index" do
get :index, namespace_id: project.namespace.path, project_id: project.path
 
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
end
 
it "return 301 if request path doesn't match project path" do
Loading
Loading
@@ -28,7 +28,7 @@ describe Projects::IssuesController do
project.save
 
get :index, namespace_id: project.namespace.path, project_id: project.path
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
 
it "returns 404 when external issue tracker is enabled" do
Loading
Loading
@@ -36,7 +36,7 @@ describe Projects::IssuesController do
allow(project).to receive(:default_issues_tracker?).and_return(false)
 
get :index, namespace_id: project.namespace.path, project_id: project.path
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
 
Loading
Loading
@@ -248,7 +248,7 @@ describe Projects::IssuesController do
before { sign_in(user) }
it "rejects a developer to destroy an issue" do
delete :destroy, namespace_id: project.namespace.path, project_id: project.path, id: issue.iid
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
 
Loading
Loading
@@ -262,7 +262,7 @@ describe Projects::IssuesController do
it "deletes the issue" do
delete :destroy, namespace_id: project.namespace.path, project_id: project.path, id: issue.iid
 
expect(response.status).to eq(302)
expect(response).to have_http_status(302)
expect(controller).to set_flash[:notice].to(/The issue was successfully deleted\./).now
end
end
Loading
Loading
@@ -280,7 +280,7 @@ describe Projects::IssuesController do
project_id: project.path, id: issue.iid, name: "thumbsup")
end.to change { issue.award_emoji.count }.by(1)
 
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
end
end
end
Loading
Loading
@@ -284,7 +284,7 @@ describe Projects::MergeRequestsController do
it "denies access to users unless they're admin or project owner" do
delete :destroy, namespace_id: project.namespace.path, project_id: project.path, id: merge_request.iid
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
 
context "when the user is owner" do
Loading
Loading
@@ -297,7 +297,7 @@ describe Projects::MergeRequestsController do
it "deletes the merge request" do
delete :destroy, namespace_id: project.namespace.path, project_id: project.path, id: merge_request.iid
 
expect(response.status).to eq(302)
expect(response).to have_http_status(302)
expect(controller).to set_flash[:notice].to(/The merge request was successfully deleted\./).now
end
end
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ describe Projects::NotesController do
project_id: project.path, id: note.id, name: "thumbsup")
end.to change { note.award_emoji.count }.by(1)
 
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
end
 
it "removes the already awarded emoji" do
Loading
Loading
@@ -30,7 +30,7 @@ describe Projects::NotesController do
project_id: project.path, id: note.id, name: "thumbsup")
end.to change { AwardEmoji.count }.by(-1)
 
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
end
end
end
Loading
Loading
@@ -58,7 +58,7 @@ describe Projects::ProjectMembersController do
get :index, namespace_id: project.namespace, project_id: project
end
 
it { expect(response.status).to eq(200) }
it { expect(response).to have_http_status(200) }
end
end
 
Loading
Loading
@@ -71,7 +71,7 @@ describe Projects::ProjectMembersController do
project_id: project,
id: 42
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
 
Loading
Loading
@@ -94,7 +94,7 @@ describe Projects::ProjectMembersController do
project_id: project,
id: member
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
expect(project.users).to include team_user
end
end
Loading
Loading
@@ -139,7 +139,7 @@ describe Projects::ProjectMembersController do
delete :leave, namespace_id: project.namespace,
project_id: project
 
expect(response.status).to eq(403)
expect(response).to have_http_status(403)
end
end
 
Loading
Loading
@@ -171,7 +171,7 @@ describe Projects::ProjectMembersController do
delete :leave, namespace_id: project.namespace,
project_id: project
 
expect(response.status).to eq(403)
expect(response).to have_http_status(403)
end
end
 
Loading
Loading
@@ -224,7 +224,7 @@ describe Projects::ProjectMembersController do
project_id: project,
id: 42
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
 
Loading
Loading
@@ -247,7 +247,7 @@ describe Projects::ProjectMembersController do
project_id: project,
id: member
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
expect(project.users).not_to include team_requester
end
end
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ describe Projects::RawController do
project_id: public_project.to_param,
id: id)
 
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
expect(response.header['Content-Disposition']).
to eq("inline")
Loading
Loading
@@ -30,7 +30,7 @@ describe Projects::RawController do
project_id: public_project.to_param,
id: id)
 
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
expect(response.header['Content-Type']).to eq('image/jpeg')
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-blob:")
end
Loading
Loading
@@ -54,7 +54,7 @@ describe Projects::RawController do
project_id: public_project.to_param,
id: id)
 
expect(response.status).to eq(200)
expect(response).to have_http_status(200)
end
end
 
Loading
Loading
@@ -65,7 +65,7 @@ describe Projects::RawController do
project_id: public_project.to_param,
id: id)
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
end
end
Loading
Loading
Loading
Loading
@@ -36,7 +36,7 @@ describe Projects::RepositoriesController do
it "renders Not Found" do
get :archive, namespace_id: project.namespace.path, project_id: project.path, ref: "master", format: "zip"
 
expect(response.status).to eq(404)
expect(response).to have_http_status(404)
end
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