Commit abca19da authored by Z.J. van de Weg's avatar Z.J. van de Weg

Use HTTP matchers if possible

parent e0e32562
...@@ -22,7 +22,7 @@ describe Admin::ImpersonationsController do ...@@ -22,7 +22,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do it "responds with status 404" do
delete :destroy delete :destroy
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "doesn't sign us in" do it "doesn't sign us in" do
...@@ -46,7 +46,7 @@ describe Admin::ImpersonationsController do ...@@ -46,7 +46,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do it "responds with status 404" do
delete :destroy delete :destroy
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "doesn't sign us in as the impersonator" do it "doesn't sign us in as the impersonator" do
...@@ -65,7 +65,7 @@ describe Admin::ImpersonationsController do ...@@ -65,7 +65,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do it "responds with status 404" do
delete :destroy delete :destroy
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "doesn't sign us in as the impersonator" do it "doesn't sign us in as the impersonator" do
......
...@@ -14,7 +14,7 @@ describe Admin::SpamLogsController do ...@@ -14,7 +14,7 @@ describe Admin::SpamLogsController do
it 'lists all spam logs' do it 'lists all spam logs' do
get :index get :index
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -22,14 +22,14 @@ describe Admin::SpamLogsController do ...@@ -22,14 +22,14 @@ describe Admin::SpamLogsController do
it 'removes only the spam log when removing log' 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 { delete :destroy, id: first_spam.id }.to change { SpamLog.count }.by(-1)
expect(User.find(user.id)).to be_truthy expect(User.find(user.id)).to be_truthy
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it 'removes user and his spam logs when removing the user' do it 'removes user and his spam logs when removing the user' do
delete :destroy, id: first_spam.id, remove_user: true delete :destroy, id: first_spam.id, remove_user: true
expect(flash[:notice]).to eq "User #{user.username} was successfully removed." 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(SpamLog.count).to eq(0)
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound) expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end end
......
...@@ -17,7 +17,7 @@ describe Admin::UsersController do ...@@ -17,7 +17,7 @@ describe Admin::UsersController do
it 'deletes user' do it 'deletes user' do
delete :destroy, id: user.username, format: :json 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) expect { User.find(user.id) }.to raise_exception(ActiveRecord::RecordNotFound)
end end
end end
......
...@@ -44,7 +44,7 @@ describe ApplicationController do ...@@ -44,7 +44,7 @@ describe ApplicationController do
context "when the 'private_token' param is populated with the private token" do context "when the 'private_token' param is populated with the private token" do
it "logs the user in" do it "logs the user in" do
get :index, private_token: user.private_token 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") expect(response.body).to eq("authenticated")
end end
end end
...@@ -54,7 +54,7 @@ describe ApplicationController do ...@@ -54,7 +54,7 @@ describe ApplicationController do
it "logs the user in" do it "logs the user in" do
@request.headers['PRIVATE-TOKEN'] = user.private_token @request.headers['PRIVATE-TOKEN'] = user.private_token
get :index get :index
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(response.body).to eq("authenticated") expect(response.body).to eq("authenticated")
end end
end end
...@@ -80,7 +80,7 @@ describe ApplicationController do ...@@ -80,7 +80,7 @@ describe ApplicationController do
context "when the 'personal_access_token' param is populated with the personal access token" do context "when the 'personal_access_token' param is populated with the personal access token" do
it "logs the user in" do it "logs the user in" do
get :index, private_token: personal_access_token.token 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') expect(response.body).to eq('authenticated')
end end
end end
...@@ -89,7 +89,7 @@ describe ApplicationController do ...@@ -89,7 +89,7 @@ describe ApplicationController do
it "logs the user in" do it "logs the user in" do
@request.headers["PRIVATE-TOKEN"] = personal_access_token.token @request.headers["PRIVATE-TOKEN"] = personal_access_token.token
get :index get :index
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(response.body).to eq('authenticated') expect(response.body).to eq('authenticated')
end end
end end
......
...@@ -29,7 +29,7 @@ describe AutocompleteController do ...@@ -29,7 +29,7 @@ describe AutocompleteController do
get(:users, project_id: 'unknown') get(:users, project_id: 'unknown')
end end
it { expect(response.status).to eq(404) } it { expect(response).to have_http_status(404) }
end end
end end
...@@ -58,7 +58,7 @@ describe AutocompleteController do ...@@ -58,7 +58,7 @@ describe AutocompleteController do
get(:users, group_id: 'unknown') get(:users, group_id: 'unknown')
end end
it { expect(response.status).to eq(404) } it { expect(response).to have_http_status(404) }
end end
end end
...@@ -114,7 +114,7 @@ describe AutocompleteController do ...@@ -114,7 +114,7 @@ describe AutocompleteController do
get(:users, project_id: project.id) get(:users, project_id: project.id)
end end
it { expect(response.status).to eq(404) } it { expect(response).to have_http_status(404) }
end end
describe 'GET #users with unknown project' do describe 'GET #users with unknown project' do
...@@ -122,7 +122,7 @@ describe AutocompleteController do ...@@ -122,7 +122,7 @@ describe AutocompleteController do
get(:users, project_id: 'unknown') get(:users, project_id: 'unknown')
end end
it { expect(response.status).to eq(404) } it { expect(response).to have_http_status(404) }
end end
describe 'GET #users with inaccessible group' do describe 'GET #users with inaccessible group' do
...@@ -131,7 +131,7 @@ describe AutocompleteController do ...@@ -131,7 +131,7 @@ describe AutocompleteController do
get(:users, group_id: user.namespace.id) get(:users, group_id: user.namespace.id)
end end
it { expect(response.status).to eq(404) } it { expect(response).to have_http_status(404) }
end end
describe 'GET #users with no project' do describe 'GET #users with no project' do
......
...@@ -155,7 +155,7 @@ describe Projects::CommitController do ...@@ -155,7 +155,7 @@ describe Projects::CommitController do
id: commit.id) id: commit.id)
expect(response).not_to be_success expect(response).not_to be_success
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -204,7 +204,7 @@ describe Projects::CommitController do ...@@ -204,7 +204,7 @@ describe Projects::CommitController do
id: master_pickable_commit.id) id: master_pickable_commit.id)
expect(response).not_to be_success expect(response).not_to be_success
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
......
...@@ -13,7 +13,7 @@ describe Groups::GroupMembersController do ...@@ -13,7 +13,7 @@ describe Groups::GroupMembersController do
it 'renders index with group members' do it 'renders index with group members' do
get :index, group_id: group get :index, group_id: group
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(response).to render_template(:index) expect(response).to render_template(:index)
end end
end end
...@@ -26,7 +26,7 @@ describe Groups::GroupMembersController do ...@@ -26,7 +26,7 @@ describe Groups::GroupMembersController do
delete :destroy, group_id: group, delete :destroy, group_id: group,
id: 42 id: 42
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
...@@ -48,7 +48,7 @@ describe Groups::GroupMembersController do ...@@ -48,7 +48,7 @@ describe Groups::GroupMembersController do
delete :destroy, group_id: group, delete :destroy, group_id: group,
id: member id: member
expect(response.status).to eq(403) expect(response).to have_http_status(403)
expect(group.users).to include group_user expect(group.users).to include group_user
end end
end end
...@@ -89,7 +89,7 @@ describe Groups::GroupMembersController do ...@@ -89,7 +89,7 @@ describe Groups::GroupMembersController do
it 'returns 403' do it 'returns 403' do
delete :leave, group_id: group delete :leave, group_id: group
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
...@@ -118,7 +118,7 @@ describe Groups::GroupMembersController do ...@@ -118,7 +118,7 @@ describe Groups::GroupMembersController do
it 'cannot removes himself from the group' do it 'cannot removes himself from the group' do
delete :leave, group_id: group delete :leave, group_id: group
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
...@@ -166,7 +166,7 @@ describe Groups::GroupMembersController do ...@@ -166,7 +166,7 @@ describe Groups::GroupMembersController do
post :approve_access_request, group_id: group, post :approve_access_request, group_id: group,
id: 42 id: 42
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
...@@ -188,7 +188,7 @@ describe Groups::GroupMembersController do ...@@ -188,7 +188,7 @@ describe Groups::GroupMembersController do
post :approve_access_request, group_id: group, post :approve_access_request, group_id: group,
id: member id: member
expect(response.status).to eq(403) expect(response).to have_http_status(403)
expect(group.users).not_to include group_requester expect(group.users).not_to include group_requester
end end
end end
......
...@@ -65,21 +65,21 @@ describe HealthCheckController do ...@@ -65,21 +65,21 @@ describe HealthCheckController do
it 'supports passing the token in the header' do it 'supports passing the token in the header' do
request.headers['TOKEN'] = token request.headers['TOKEN'] = token
get :index 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.content_type).to eq 'text/plain'
expect(response.body).to include('The server is on fire') expect(response.body).to include('The server is on fire')
end end
it 'supports failure plaintest response' do it 'supports failure plaintest response' do
get :index, token: token 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.content_type).to eq 'text/plain'
expect(response.body).to include('The server is on fire') expect(response.body).to include('The server is on fire')
end end
it 'supports failure json response' do it 'supports failure json response' do
get :index, token: token, format: :json 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(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false expect(json_response['healthy']).to be false
expect(json_response['message']).to include('The server is on fire') expect(json_response['message']).to include('The server is on fire')
...@@ -87,7 +87,7 @@ describe HealthCheckController do ...@@ -87,7 +87,7 @@ describe HealthCheckController do
it 'supports failure xml response' do it 'supports failure xml response' do
get :index, token: token, format: :xml 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(response.content_type).to eq 'application/xml'
expect(xml_response['healthy']).to be false expect(xml_response['healthy']).to be false
expect(xml_response['message']).to include('The server is on fire') expect(xml_response['message']).to include('The server is on fire')
...@@ -95,7 +95,7 @@ describe HealthCheckController do ...@@ -95,7 +95,7 @@ describe HealthCheckController do
it 'supports failure responses for specific checks' do it 'supports failure responses for specific checks' do
get :index, token: token, checks: 'email', format: :json 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(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false expect(json_response['healthy']).to be false
expect(json_response['message']).to include('Email is on fire') expect(json_response['message']).to include('Email is on fire')
......
...@@ -15,7 +15,7 @@ describe InvitesController do ...@@ -15,7 +15,7 @@ describe InvitesController do
get :accept, id: token get :accept, id: token
member.reload member.reload
expect(response.status).to eq(302) expect(response).to have_http_status(302)
expect(member.user).to eq(user) expect(member.user).to eq(user)
expect(flash[:notice]).to include 'You have been granted' expect(flash[:notice]).to include 'You have been granted'
end end
...@@ -26,7 +26,7 @@ describe InvitesController do ...@@ -26,7 +26,7 @@ describe InvitesController do
get :decline, id: token get :decline, id: token
expect{member.reload}.to raise_error ActiveRecord::RecordNotFound 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' expect(flash[:notice]).to include 'You have declined the invitation to join'
end end
end end
......
...@@ -86,7 +86,7 @@ describe NamespacesController do ...@@ -86,7 +86,7 @@ describe NamespacesController do
it "responds with status 404" do it "responds with status 404" do
get :show, id: group.path get :show, id: group.path
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -102,7 +102,7 @@ describe NamespacesController do ...@@ -102,7 +102,7 @@ describe NamespacesController do
it "responds with status 404" do it "responds with status 404" do
get :show, id: "doesntexist" get :show, id: "doesntexist"
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
......
...@@ -60,7 +60,7 @@ describe NotificationSettingsController do ...@@ -60,7 +60,7 @@ describe NotificationSettingsController do
project: { id: private_project.id }, project: { id: private_project.id },
notification_setting: { level: :participating } notification_setting: { level: :participating }
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -118,7 +118,7 @@ describe NotificationSettingsController do ...@@ -118,7 +118,7 @@ describe NotificationSettingsController do
id: notification_setting, id: notification_setting,
notification_setting: { level: :participating } notification_setting: { level: :participating }
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
......
...@@ -12,7 +12,7 @@ describe Oauth::ApplicationsController do ...@@ -12,7 +12,7 @@ describe Oauth::ApplicationsController do
it 'shows list of applications' do it 'shows list of applications' do
get :index get :index
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it 'redirects back to profile page if OAuth applications are disabled' do it 'redirects back to profile page if OAuth applications are disabled' do
...@@ -21,7 +21,7 @@ describe Oauth::ApplicationsController do ...@@ -21,7 +21,7 @@ describe Oauth::ApplicationsController do
get :index get :index
expect(response.status).to eq(302) expect(response).to have_http_status(302)
expect(response).to redirect_to(profile_path) expect(response).to redirect_to(profile_path)
end end
end end
......
...@@ -13,7 +13,7 @@ describe Profiles::AccountsController do ...@@ -13,7 +13,7 @@ describe Profiles::AccountsController do
delete :unlink, provider: 'saml' delete :unlink, provider: 'saml'
updated_user = User.find(user.id) 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.size).to eq(1)
expect(updated_user.identities).to include(identity) expect(updated_user.identities).to include(identity)
end end
......
...@@ -103,7 +103,7 @@ describe Projects::BranchesController do ...@@ -103,7 +103,7 @@ describe Projects::BranchesController do
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
project_id: project.to_param project_id: project.to_param
expect(response.status).to eq(303) expect(response).to have_http_status(303)
end end
end end
...@@ -121,24 +121,24 @@ describe Projects::BranchesController do ...@@ -121,24 +121,24 @@ describe Projects::BranchesController do
context "valid branch name, valid source" do context "valid branch name, valid source" do
let(:branch) { "feature" } let(:branch) { "feature" }
it { expect(response.status).to eq(200) } it { expect(response).to have_http_status(200) }
end end
context "valid branch name with unencoded slashes" do context "valid branch name with unencoded slashes" do
let(:branch) { "improve/awesome" } let(:branch) { "improve/awesome" }
it { expect(response.status).to eq(200) } it { expect(response).to have_http_status(200) }
end end
context "valid branch name with encoded slashes" do context "valid branch name with encoded slashes" do
let(:branch) { "improve%2Fawesome" } let(:branch) { "improve%2Fawesome" }
it { expect(response.status).to eq(200) } it { expect(response).to have_http_status(200) }
end end
context "invalid branch name, valid ref" do context "invalid branch name, valid ref" do
let(:branch) { "no-branch" } let(:branch) { "no-branch" }
it { expect(response.status).to eq(404) } it { expect(response).to have_http_status(404) }
end end
end end
end end
...@@ -14,7 +14,7 @@ describe Projects::IssuesController do ...@@ -14,7 +14,7 @@ describe Projects::IssuesController do
it "returns index" do it "returns index" do
get :index, namespace_id: project.namespace.path, project_id: project.path 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 end
it "return 301 if request path doesn't match project path" do it "return 301 if request path doesn't match project path" do
...@@ -28,7 +28,7 @@ describe Projects::IssuesController do ...@@ -28,7 +28,7 @@ describe Projects::IssuesController do
project.save project.save
get :index, namespace_id: project.namespace.path, project_id: project.path 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
it "returns 404 when external issue tracker is enabled" do it "returns 404 when external issue tracker is enabled" do
...@@ -36,7 +36,7 @@ describe Projects::IssuesController do ...@@ -36,7 +36,7 @@ describe Projects::IssuesController do
allow(project).to receive(:default_issues_tracker?).and_return(false) allow(project).to receive(:default_issues_tracker?).and_return(false)
get :index, namespace_id: project.namespace.path, project_id: project.path 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
end end
...@@ -248,7 +248,7 @@ describe Projects::IssuesController do ...@@ -248,7 +248,7 @@ describe Projects::IssuesController do
before { sign_in(user) } before { sign_in(user) }
it "rejects a developer to destroy an issue" do it "rejects a developer to destroy an issue" do
delete :destroy, namespace_id: project.namespace.path, project_id: project.path, id: issue.iid 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
end end
...@@ -262,7 +262,7 @@ describe Projects::IssuesController do ...@@ -262,7 +262,7 @@ describe Projects::IssuesController do
it "deletes the issue" do it "deletes the issue" do
delete :destroy, namespace_id: project.namespace.path, project_id: project.path, id: issue.iid 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 expect(controller).to set_flash[:notice].to(/The issue was successfully deleted\./).now
end end
end end
...@@ -280,7 +280,7 @@ describe Projects::IssuesController do ...@@ -280,7 +280,7 @@ describe Projects::IssuesController do
project_id: project.path, id: issue.iid, name: "thumbsup") project_id: project.path, id: issue.iid, name: "thumbsup")
end.to change { issue.award_emoji.count }.by(1) 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 end
end end
...@@ -284,7 +284,7 @@ describe Projects::MergeRequestsController do ...@@ -284,7 +284,7 @@ describe Projects::MergeRequestsController do
it "denies access to users unless they're admin or project owner" 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 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 end
context "when the user is owner" do context "when the user is owner" do
...@@ -297,7 +297,7 @@ describe Projects::MergeRequestsController do ...@@ -297,7 +297,7 @@ describe Projects::MergeRequestsController do
it "deletes the merge request" do it "deletes the merge request" do
delete :destroy, namespace_id: project.namespace.path, project_id: project.path, id: merge_request.iid 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 expect(controller).to set_flash[:notice].to(/The merge request was successfully deleted\./).now
end end
end end
......
...@@ -18,7 +18,7 @@ describe Projects::NotesController do ...@@ -18,7 +18,7 @@ describe Projects::NotesController do
project_id: project.path, id: note.id, name: "thumbsup") project_id: project.path, id: note.id, name: "thumbsup")
end.to change { note.award_emoji.count }.by(1) end.to change { note.award_emoji.count }.by(1)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it "removes the already awarded emoji" do it "removes the already awarded emoji" do
...@@ -30,7 +30,7 @@ describe Projects::NotesController do ...@@ -30,7 +30,7 @@ describe Projects::NotesController do
project_id: project.path, id: note.id, name: "thumbsup") project_id: project.path, id: note.id, name: "thumbsup")
end.to change { AwardEmoji.count }.by(-1) end.to change { AwardEmoji.count }.by(-1)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -58,7 +58,7 @@ describe Projects::ProjectMembersController do ...@@ -58,7 +58,7 @@ describe Projects::ProjectMembersController do
get :index, namespace_id: project.namespace, project_id: project get :index, namespace_id: project.namespace, project_id: project
end end
it { expect(response.status).to eq(200) } it { expect(response).to have_http_status(200) }
end end
end end
...@@ -71,7 +71,7 @@ describe Projects::ProjectMembersController do ...@@ -71,7 +71,7 @@ describe Projects::ProjectMembersController do
project_id: project, project_id: project,
id: 42 id: 42
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -94,7 +94,7 @@ describe Projects::ProjectMembersController do ...@@ -94,7 +94,7 @@ describe Projects::ProjectMembersController do
project_id: project, project_id: project,
id: member id: member
expect(response.status).to eq(404) expect(response).to have_http_status(404)
expect(project.users).to include team_user expect(project.users).to include team_user
end end
end end
...@@ -139,7 +139,7 @@ describe Projects::ProjectMembersController do ...@@ -139,7 +139,7 @@ describe Projects::ProjectMembersController do
delete :leave, namespace_id: project.namespace, delete :leave, namespace_id: project.namespace,
project_id: project project_id: project
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
...@@ -171,7 +171,7 @@ describe Projects::ProjectMembersController do ...@@ -171,7 +171,7 @@ describe Projects::ProjectMembersController do
delete :leave, namespace_id: project.namespace, delete :leave, namespace_id: project.namespace,
project_id: project project_id: project
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
...@@ -224,7 +224,7 @@ describe Projects::ProjectMembersController do ...@@ -224,7 +224,7 @@ describe Projects::ProjectMembersController do
project_id: project, project_id: project,
id: 42 id: 42
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -247,7 +247,7 @@ describe Projects::ProjectMembersController do ...@@ -247,7 +247,7 @@ describe Projects::ProjectMembersController do
project_id: project, project_id: project,
id: member id: member
expect(response.status).to eq(404) expect(response).to have_http_status(404)
expect(project.users).not_to include team_requester expect(project.users).not_to include team_requester
end end
end end
......
...@@ -13,7 +13,7 @@ describe Projects::RawController do ...@@ -13,7 +13,7 @@ describe Projects::RawController do
project_id: public_project.to_param, project_id: public_project.to_param,
id: id) 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-Type']).to eq('text/plain; charset=utf-8')
expect(response.header['Content-Disposition']). expect(response.header['Content-Disposition']).
to eq("inline") to eq("inline")
...@@ -30,7 +30,7 @@ describe Projects::RawController do ...@@ -30,7 +30,7 @@ describe Projects::RawController do
project_id: public_project.to_param, project_id: public_project.to_param,
id: id) 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['Content-Type']).to eq('image/jpeg')
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-blob:") expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-blob:")
end end
...@@ -54,7 +54,7 @@ describe Projects::RawController do ...@@ -54,7 +54,7 @@ describe Projects::RawController do
project_id: public_project.to_param, project_id: public_project.to_param,
id: id) id: id)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -65,7 +65,7 @@ describe Projects::RawController do ...@@ -65,7 +65,7 @@ describe Projects::RawController do
project_id: public_project.to_param, project_id: public_project.to_param,
id: id) id: id)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
......
...@@ -36,7 +36,7 @@ describe Projects::RepositoriesController do ...@@ -36,7 +36,7 @@ describe Projects::RepositoriesController do
it "renders Not Found" do it "renders Not Found" do
get :archive, namespace_id: project.namespace.path, project_id: project.path, ref: "master", format: "zip" 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 end
end end
......
...@@ -19,7 +19,7 @@ describe Projects::SnippetsController do ...@@ -19,7 +19,7 @@ describe Projects::SnippetsController do
get :index, namespace_id: project.namespace.path, project_id: project.path get :index, namespace_id: project.namespace.path, project_id: project.path
expect(assigns(:snippets)).not_to include(project_snippet) expect(assigns(:snippets)).not_to include(project_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -30,7 +30,7 @@ describe Projects::SnippetsController do ...@@ -30,7 +30,7 @@ describe Projects::SnippetsController do
get :index, namespace_id: project.namespace.path, project_id: project.path get :index, namespace_id: project.namespace.path, project_id: project.path
expect(assigns(:snippets)).to include(project_snippet) expect(assigns(:snippets)).to include(project_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -41,7 +41,7 @@ describe Projects::SnippetsController do ...@@ -41,7 +41,7 @@ describe Projects::SnippetsController do
get :index, namespace_id: project.namespace.path, project_id: project.path get :index, namespace_id: project.namespace.path, project_id: project.path
expect(assigns(:snippets)).to include(project_snippet) expect(assigns(:snippets)).to include(project_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -56,7 +56,7 @@ describe Projects::SnippetsController do ...@@ -56,7 +56,7 @@ describe Projects::SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get action, namespace_id: project.namespace.path, project_id: project.path, id: project_snippet.to_param get action, namespace_id: project.namespace.path, project_id: project.path, id: project_snippet.to_param
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -67,7 +67,7 @@ describe Projects::SnippetsController do ...@@ -67,7 +67,7 @@ describe Projects::SnippetsController do
get action, namespace_id: project.namespace.path, project_id: project.path, id: project_snippet.to_param get action, namespace_id: project.namespace.path, project_id: project.path, id: project_snippet.to_param
expect(assigns(:snippet)).to eq(project_snippet) expect(assigns(:snippet)).to eq(project_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -78,7 +78,7 @@ describe Projects::SnippetsController do ...@@ -78,7 +78,7 @@ describe Projects::SnippetsController do
get action, namespace_id: project.namespace.path, project_id: project.path, id: project_snippet.to_param get action, namespace_id: project.namespace.path, project_id: project.path, id: project_snippet.to_param
expect(assigns(:snippet)).to eq(project_snippet) expect(assigns(:snippet)).to eq(project_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -88,7 +88,7 @@ describe Projects::SnippetsController do ...@@ -88,7 +88,7 @@ describe Projects::SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get action, namespace_id: project.namespace.path, project_id: project.path, id: 42 get action, namespace_id: project.namespace.path, project_id: project.path, id: 42
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -98,7 +98,7 @@ describe Projects::SnippetsController do ...@@ -98,7 +98,7 @@ describe Projects::SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get action, namespace_id: project.namespace.path, project_id: project.path, id: 42 get action, namespace_id: project.namespace.path, project_id: project.path, id: 42
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
......
...@@ -22,7 +22,7 @@ describe Projects::TodosController do ...@@ -22,7 +22,7 @@ describe Projects::TodosController do
issuable_type: 'issue') issuable_type: 'issue')
end.to change { user.todos.count }.by(1) end.to change { user.todos.count }.by(1)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -36,7 +36,7 @@ describe Projects::TodosController do ...@@ -36,7 +36,7 @@ describe Projects::TodosController do
issuable_type: 'issue') issuable_type: 'issue')
end.to change { user.todos.count }.by(0) end.to change { user.todos.count }.by(0)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it 'should not create todo for issue when user not logged in' do it 'should not create todo for issue when user not logged in' do
...@@ -47,7 +47,7 @@ describe Projects::TodosController do ...@@ -47,7 +47,7 @@ describe Projects::TodosController do
issuable_type: 'issue') issuable_type: 'issue')
end.to change { user.todos.count }.by(0) end.to change { user.todos.count }.by(0)
expect(response.status).to eq(302) expect(response).to have_http_status(302)
end end
end end
end end
...@@ -69,7 +69,7 @@ describe Projects::TodosController do ...@@ -69,7 +69,7 @@ describe Projects::TodosController do
issuable_type: 'merge_request') issuable_type: 'merge_request')
end.to change { user.todos.count }.by(1) end.to change { user.todos.count }.by(1)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -83,7 +83,7 @@ describe Projects::TodosController do ...@@ -83,7 +83,7 @@ describe Projects::TodosController do
issuable_type: 'merge_request') issuable_type: 'merge_request')
end.to change { user.todos.count }.by(0) end.to change { user.todos.count }.by(0)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it 'should not create todo for merge request user has no access to' do it 'should not create todo for merge request user has no access to' do
...@@ -94,7 +94,7 @@ describe Projects::TodosController do ...@@ -94,7 +94,7 @@ describe Projects::TodosController do
issuable_type: 'merge_request') issuable_type: 'merge_request')
end.to change { user.todos.count }.by(0) end.to change { user.todos.count }.by(0)
expect(response.status).to eq(302) expect(response).to have_http_status(302)
end end
end end
end end
......
...@@ -64,7 +64,7 @@ describe Projects::TreeController do ...@@ -64,7 +64,7 @@ describe Projects::TreeController do
context "valid SHA commit ID with path" do context "valid SHA commit ID with path" do
let(:id) { '6d39438/.gitignore' } let(:id) { '6d39438/.gitignore' }
it { expect(response.status).to eq(302) } it { expect(response).to have_http_status(302) }
end end
end end
......
...@@ -18,7 +18,7 @@ describe Projects::UploadsController do ...@@ -18,7 +18,7 @@ describe Projects::UploadsController do
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
project_id: project.to_param, project_id: project.to_param,
format: :json format: :json
expect(response.status).to eq(422) expect(response).to have_http_status(422)
end end
end end
...@@ -79,7 +79,7 @@ describe Projects::UploadsController do ...@@ -79,7 +79,7 @@ describe Projects::UploadsController do
it "responds with status 200" do it "responds with status 200" do
go go
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -87,7 +87,7 @@ describe Projects::UploadsController do ...@@ -87,7 +87,7 @@ describe Projects::UploadsController do
it "responds with status 404" do it "responds with status 404" do
go go
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -106,7 +106,7 @@ describe Projects::UploadsController do ...@@ -106,7 +106,7 @@ describe Projects::UploadsController do
it "responds with status 200" do it "responds with status 200" do
go go
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -114,7 +114,7 @@ describe Projects::UploadsController do ...@@ -114,7 +114,7 @@ describe Projects::UploadsController do
it "responds with status 404" do it "responds with status 404" do
go go
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -140,7 +140,7 @@ describe Projects::UploadsController do ...@@ -140,7 +140,7 @@ describe Projects::UploadsController do
it "responds with status 200" do it "responds with status 200" do
go go
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -192,7 +192,7 @@ describe Projects::UploadsController do ...@@ -192,7 +192,7 @@ describe Projects::UploadsController do
it "responds with status 200" do it "responds with status 200" do
go go
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -224,7 +224,7 @@ describe Projects::UploadsController do ...@@ -224,7 +224,7 @@ describe Projects::UploadsController do
it "responds with status 200" do it "responds with status 200" do
go go
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -232,7 +232,7 @@ describe Projects::UploadsController do ...@@ -232,7 +232,7 @@ describe Projects::UploadsController do
it "responds with status 404" do it "responds with status 404" do
go go
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -253,7 +253,7 @@ describe Projects::UploadsController do ...@@ -253,7 +253,7 @@ describe Projects::UploadsController do
it "responds with status 200" do it "responds with status 200" do
go go
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -261,7 +261,7 @@ describe Projects::UploadsController do ...@@ -261,7 +261,7 @@ describe Projects::UploadsController do
it "responds with status 404" do it "responds with status 404" do
go go
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -270,7 +270,7 @@ describe Projects::UploadsController do ...@@ -270,7 +270,7 @@ describe Projects::UploadsController do
it "responds with status 404" do it "responds with status 404" do
go go
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
......
...@@ -77,7 +77,7 @@ describe ProjectsController do ...@@ -77,7 +77,7 @@ describe ProjectsController do
get :show, namespace_id: public_project.namespace.path, id: public_project.path get :show, namespace_id: public_project.namespace.path, id: public_project.path
expect(assigns(:project)).to eq(public_project) expect(assigns(:project)).to eq(public_project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -101,7 +101,7 @@ describe ProjectsController do ...@@ -101,7 +101,7 @@ describe ProjectsController do
get :show, namespace_id: public_project.namespace.path, id: public_project.path.upcase get :show, namespace_id: public_project.namespace.path, id: public_project.path.upcase
expect(assigns(:project)).to eq(other_project) expect(assigns(:project)).to eq(other_project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -146,7 +146,7 @@ describe ProjectsController do ...@@ -146,7 +146,7 @@ describe ProjectsController do
expect(project.repository.path).to include(new_path) expect(project.repository.path).to include(new_path)
expect(assigns(:repository).path).to eq(project.repository.path) expect(assigns(:repository).path).to eq(project.repository.path)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -161,7 +161,7 @@ describe ProjectsController do ...@@ -161,7 +161,7 @@ describe ProjectsController do
delete :destroy, namespace_id: project.namespace.path, id: project.path delete :destroy, namespace_id: project.namespace.path, id: project.path
expect { Project.find(orig_id) }.to raise_error(ActiveRecord::RecordNotFound) expect { Project.find(orig_id) }.to raise_error(ActiveRecord::RecordNotFound)
expect(response.status).to eq(302) expect(response).to have_http_status(302)
expect(response).to redirect_to(dashboard_projects_path) expect(response).to redirect_to(dashboard_projects_path)
end end
end end
...@@ -234,7 +234,7 @@ describe ProjectsController do ...@@ -234,7 +234,7 @@ describe ProjectsController do
delete(:remove_fork, delete(:remove_fork,
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
id: project.to_param, format: :js) id: project.to_param, format: :js)
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
......
...@@ -19,7 +19,7 @@ describe SnippetsController do ...@@ -19,7 +19,7 @@ describe SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get :show, id: other_personal_snippet.to_param get :show, id: other_personal_snippet.to_param
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -28,7 +28,7 @@ describe SnippetsController do ...@@ -28,7 +28,7 @@ describe SnippetsController do
get :show, id: personal_snippet.to_param get :show, id: personal_snippet.to_param
expect(assigns(:snippet)).to eq(personal_snippet) expect(assigns(:snippet)).to eq(personal_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -54,7 +54,7 @@ describe SnippetsController do ...@@ -54,7 +54,7 @@ describe SnippetsController do
get :show, id: personal_snippet.to_param get :show, id: personal_snippet.to_param
expect(assigns(:snippet)).to eq(personal_snippet) expect(assigns(:snippet)).to eq(personal_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -79,7 +79,7 @@ describe SnippetsController do ...@@ -79,7 +79,7 @@ describe SnippetsController do
get :show, id: personal_snippet.to_param get :show, id: personal_snippet.to_param
expect(assigns(:snippet)).to eq(personal_snippet) expect(assigns(:snippet)).to eq(personal_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -88,7 +88,7 @@ describe SnippetsController do ...@@ -88,7 +88,7 @@ describe SnippetsController do
get :show, id: personal_snippet.to_param get :show, id: personal_snippet.to_param
expect(assigns(:snippet)).to eq(personal_snippet) expect(assigns(:snippet)).to eq(personal_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -102,7 +102,7 @@ describe SnippetsController do ...@@ -102,7 +102,7 @@ describe SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get :show, id: 'doesntexist' get :show, id: 'doesntexist'
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -110,7 +110,7 @@ describe SnippetsController do ...@@ -110,7 +110,7 @@ describe SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get :show, id: 'doesntexist' get :show, id: 'doesntexist'
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -134,7 +134,7 @@ describe SnippetsController do ...@@ -134,7 +134,7 @@ describe SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get :raw, id: other_personal_snippet.to_param get :raw, id: other_personal_snippet.to_param
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -143,7 +143,7 @@ describe SnippetsController do ...@@ -143,7 +143,7 @@ describe SnippetsController do
get :raw, id: personal_snippet.to_param get :raw, id: personal_snippet.to_param
expect(assigns(:snippet)).to eq(personal_snippet) expect(assigns(:snippet)).to eq(personal_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -169,7 +169,7 @@ describe SnippetsController do ...@@ -169,7 +169,7 @@ describe SnippetsController do
get :raw, id: personal_snippet.to_param get :raw, id: personal_snippet.to_param
expect(assigns(:snippet)).to eq(personal_snippet) expect(assigns(:snippet)).to eq(personal_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -194,7 +194,7 @@ describe SnippetsController do ...@@ -194,7 +194,7 @@ describe SnippetsController do
get :raw, id: personal_snippet.to_param get :raw, id: personal_snippet.to_param
expect(assigns(:snippet)).to eq(personal_snippet) expect(assigns(:snippet)).to eq(personal_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -203,7 +203,7 @@ describe SnippetsController do ...@@ -203,7 +203,7 @@ describe SnippetsController do
get :raw, id: personal_snippet.to_param get :raw, id: personal_snippet.to_param
expect(assigns(:snippet)).to eq(personal_snippet) expect(assigns(:snippet)).to eq(personal_snippet)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -217,7 +217,7 @@ describe SnippetsController do ...@@ -217,7 +217,7 @@ describe SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get :raw, id: 'doesntexist' get :raw, id: 'doesntexist'
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -225,7 +225,7 @@ describe SnippetsController do ...@@ -225,7 +225,7 @@ describe SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get :raw, id: 'doesntexist' get :raw, id: 'doesntexist'
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
......
...@@ -26,7 +26,7 @@ describe UploadsController do ...@@ -26,7 +26,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "user", mounted_as: "avatar", id: user.id, filename: "image.png" get :show, model: "user", mounted_as: "avatar", id: user.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -35,7 +35,7 @@ describe UploadsController do ...@@ -35,7 +35,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "user", mounted_as: "avatar", id: user.id, filename: "image.png" get :show, model: "user", mounted_as: "avatar", id: user.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -52,7 +52,7 @@ describe UploadsController do ...@@ -52,7 +52,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png" get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -64,7 +64,7 @@ describe UploadsController do ...@@ -64,7 +64,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png" get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -109,7 +109,7 @@ describe UploadsController do ...@@ -109,7 +109,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png" get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -118,7 +118,7 @@ describe UploadsController do ...@@ -118,7 +118,7 @@ describe UploadsController do
it "responds with status 404" do it "responds with status 404" do
get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png" get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png"
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -133,7 +133,7 @@ describe UploadsController do ...@@ -133,7 +133,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png" get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -145,7 +145,7 @@ describe UploadsController do ...@@ -145,7 +145,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png" get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -181,7 +181,7 @@ describe UploadsController do ...@@ -181,7 +181,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png" get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -190,7 +190,7 @@ describe UploadsController do ...@@ -190,7 +190,7 @@ describe UploadsController do
it "responds with status 404" do it "responds with status 404" do
get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png" get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png"
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -210,7 +210,7 @@ describe UploadsController do ...@@ -210,7 +210,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png" get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -222,7 +222,7 @@ describe UploadsController do ...@@ -222,7 +222,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png" get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -267,7 +267,7 @@ describe UploadsController do ...@@ -267,7 +267,7 @@ describe UploadsController do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png" get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png"
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -276,7 +276,7 @@ describe UploadsController do ...@@ -276,7 +276,7 @@ describe UploadsController do
it "responds with status 404" do it "responds with status 404" do
get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png" get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png"
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
......
...@@ -33,7 +33,7 @@ describe UsersController do ...@@ -33,7 +33,7 @@ describe UsersController do
it 'renders the show template' do it 'renders the show template' do
get :show, username: user.username get :show, username: user.username
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(response).to render_template('show') expect(response).to render_template('show')
end end
end end
...@@ -47,7 +47,7 @@ describe UsersController do ...@@ -47,7 +47,7 @@ describe UsersController do
context 'when logged out' do context 'when logged out' do
it 'renders 404' do it 'renders 404' do
get :show, username: user.username get :show, username: user.username
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -56,7 +56,7 @@ describe UsersController do ...@@ -56,7 +56,7 @@ describe UsersController do
it 'renders show' do it 'renders show' do
get :show, username: user.username get :show, username: user.username
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(response).to render_template('show') expect(response).to render_template('show')
end end
end end
...@@ -121,7 +121,7 @@ describe UsersController do ...@@ -121,7 +121,7 @@ describe UsersController do
context 'format html' do context 'format html' do
it 'renders snippets page' do it 'renders snippets page' do
get :snippets, username: user.username get :snippets, username: user.username
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(response).to render_template('show') expect(response).to render_template('show')
end end
end end
...@@ -129,7 +129,7 @@ describe UsersController do ...@@ -129,7 +129,7 @@ describe UsersController do
context 'format json' do context 'format json' do
it 'response with snippets json data' do it 'response with snippets json data' do
get :snippets, username: user.username, format: :json get :snippets, username: user.username, format: :json
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(JSON.parse(response.body)).to have_key('html') expect(JSON.parse(response.body)).to have_key('html')
end end
end end
......
...@@ -17,7 +17,7 @@ describe API::API, api: true do ...@@ -17,7 +17,7 @@ describe API::API, api: true do
it "returns an array of award_emoji" do it "returns an array of award_emoji" do
get api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user) get api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['name']).to eq(award_emoji.name) expect(json_response.first['name']).to eq(award_emoji.name)
end end
...@@ -25,7 +25,7 @@ describe API::API, api: true do ...@@ -25,7 +25,7 @@ describe API::API, api: true do
it "should return a 404 error when issue id not found" do it "should return a 404 error when issue id not found" do
get api("/projects/#{project.id}/issues/12345/award_emoji", user) get api("/projects/#{project.id}/issues/12345/award_emoji", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -33,7 +33,7 @@ describe API::API, api: true do ...@@ -33,7 +33,7 @@ describe API::API, api: true do
it "returns an array of award_emoji" do it "returns an array of award_emoji" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji", user) get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['name']).to eq(downvote.name) expect(json_response.first['name']).to eq(downvote.name)
end end
...@@ -45,7 +45,7 @@ describe API::API, api: true do ...@@ -45,7 +45,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji", user1) get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji", user1)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -56,7 +56,7 @@ describe API::API, api: true do ...@@ -56,7 +56,7 @@ describe API::API, api: true do
it 'returns an array of award emoji' do it 'returns an array of award emoji' do
get api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user) get api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['name']).to eq(rocket.name) expect(json_response.first['name']).to eq(rocket.name)
end end
...@@ -68,7 +68,7 @@ describe API::API, api: true do ...@@ -68,7 +68,7 @@ describe API::API, api: true do
it "returns the award emoji" do it "returns the award emoji" do
get api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/#{award_emoji.id}", user) get api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/#{award_emoji.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['name']).to eq(award_emoji.name) expect(json_response['name']).to eq(award_emoji.name)
expect(json_response['awardable_id']).to eq(issue.id) expect(json_response['awardable_id']).to eq(issue.id)
expect(json_response['awardable_type']).to eq("Issue") expect(json_response['awardable_type']).to eq("Issue")
...@@ -77,7 +77,7 @@ describe API::API, api: true do ...@@ -77,7 +77,7 @@ describe API::API, api: true do
it "returns a 404 error if the award is not found" do it "returns a 404 error if the award is not found" do
get api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/12345", user) get api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/12345", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -85,7 +85,7 @@ describe API::API, api: true do ...@@ -85,7 +85,7 @@ describe API::API, api: true do
it 'returns the award emoji' do it 'returns the award emoji' do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user) get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['name']).to eq(downvote.name) expect(json_response['name']).to eq(downvote.name)
expect(json_response['awardable_id']).to eq(merge_request.id) expect(json_response['awardable_id']).to eq(merge_request.id)
expect(json_response['awardable_type']).to eq("MergeRequest") expect(json_response['awardable_type']).to eq("MergeRequest")
...@@ -98,7 +98,7 @@ describe API::API, api: true do ...@@ -98,7 +98,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user1) get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user1)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -109,7 +109,7 @@ describe API::API, api: true do ...@@ -109,7 +109,7 @@ describe API::API, api: true do
it 'returns an award emoji' do it 'returns an award emoji' do
get api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji/#{rocket.id}", user) get api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji/#{rocket.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).not_to be_an Array expect(json_response).not_to be_an Array
expect(json_response['name']).to eq(rocket.name) expect(json_response['name']).to eq(rocket.name)
end end
...@@ -120,7 +120,7 @@ describe API::API, api: true do ...@@ -120,7 +120,7 @@ describe API::API, api: true do
it "creates a new award emoji" do it "creates a new award emoji" do
post api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user), name: 'blowfish' post api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user), name: 'blowfish'
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['name']).to eq('blowfish') expect(json_response['name']).to eq('blowfish')
expect(json_response['user']['username']).to eq(user.username) expect(json_response['user']['username']).to eq(user.username)
end end
...@@ -128,13 +128,13 @@ describe API::API, api: true do ...@@ -128,13 +128,13 @@ describe API::API, api: true do
it "should return a 400 bad request error if the name is not given" do it "should return a 400 bad request error if the name is not given" do
post api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user) post api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 401 unauthorized error if the user is not authenticated" do it "should return a 401 unauthorized error if the user is not authenticated" do
post api("/projects/#{project.id}/issues/#{issue.id}/award_emoji"), name: 'thumbsup' post api("/projects/#{project.id}/issues/#{issue.id}/award_emoji"), name: 'thumbsup'
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -145,7 +145,7 @@ describe API::API, api: true do ...@@ -145,7 +145,7 @@ describe API::API, api: true do
post api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user), name: 'rocket' post api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user), name: 'rocket'
end.to change { note.award_emoji.count }.from(0).to(1) end.to change { note.award_emoji.count }.from(0).to(1)
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['user']['username']).to eq(user.username) expect(json_response['user']['username']).to eq(user.username)
end end
end end
...@@ -157,13 +157,13 @@ describe API::API, api: true do ...@@ -157,13 +157,13 @@ describe API::API, api: true do
delete api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/#{award_emoji.id}", user) delete api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/#{award_emoji.id}", user)
end.to change { issue.award_emoji.count }.from(1).to(0) end.to change { issue.award_emoji.count }.from(1).to(0)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it 'returns a 404 error when the award emoji can not be found' do it 'returns a 404 error when the award emoji can not be found' do
delete api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/12345", user) delete api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/12345", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -173,13 +173,13 @@ describe API::API, api: true do ...@@ -173,13 +173,13 @@ describe API::API, api: true do
delete api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user) delete api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user)
end.to change { merge_request.award_emoji.count }.from(1).to(0) end.to change { merge_request.award_emoji.count }.from(1).to(0)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it 'returns a 404 error when note id not found' do it 'returns a 404 error when note id not found' do
delete api("/projects/#{project.id}/merge_requests/#{merge_request.id}/notes/12345", user) delete api("/projects/#{project.id}/merge_requests/#{merge_request.id}/notes/12345", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -192,7 +192,7 @@ describe API::API, api: true do ...@@ -192,7 +192,7 @@ describe API::API, api: true do
delete api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji/#{rocket.id}", user) delete api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji/#{rocket.id}", user)
end.to change { note.award_emoji.count }.from(1).to(0) end.to change { note.award_emoji.count }.from(1).to(0)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -17,7 +17,7 @@ describe API::API, api: true do ...@@ -17,7 +17,7 @@ describe API::API, api: true do
project.repository.expire_cache project.repository.expire_cache
get api("/projects/#{project.id}/repository/branches", user) get api("/projects/#{project.id}/repository/branches", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
branch_names = json_response.map { |x| x['name'] } branch_names = json_response.map { |x| x['name'] }
expect(branch_names).to match_array(project.repository.branch_names) expect(branch_names).to match_array(project.repository.branch_names)
...@@ -27,7 +27,7 @@ describe API::API, api: true do ...@@ -27,7 +27,7 @@ describe API::API, api: true do
describe "GET /projects/:id/repository/branches/:branch" do describe "GET /projects/:id/repository/branches/:branch" do
it "should return the branch information for a single branch" do it "should return the branch information for a single branch" do
get api("/projects/#{project.id}/repository/branches/#{branch_name}", user) get api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['commit']['id']).to eq(branch_sha) expect(json_response['commit']['id']).to eq(branch_sha)
...@@ -36,19 +36,19 @@ describe API::API, api: true do ...@@ -36,19 +36,19 @@ describe API::API, api: true do
it "should return a 403 error if guest" do it "should return a 403 error if guest" do
get api("/projects/#{project.id}/repository/branches", user2) get api("/projects/#{project.id}/repository/branches", user2)
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
it "should return a 404 error if branch is not available" do it "should return a 404 error if branch is not available" do
get api("/projects/#{project.id}/repository/branches/unknown", user) get api("/projects/#{project.id}/repository/branches/unknown", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
describe "PUT /projects/:id/repository/branches/:branch/protect" do describe "PUT /projects/:id/repository/branches/:branch/protect" do
it "should protect a single branch" do it "should protect a single branch" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user) put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['commit']['id']).to eq(branch_sha) expect(json_response['commit']['id']).to eq(branch_sha)
...@@ -57,25 +57,25 @@ describe API::API, api: true do ...@@ -57,25 +57,25 @@ describe API::API, api: true do
it "should return a 404 error if branch not found" do it "should return a 404 error if branch not found" do
put api("/projects/#{project.id}/repository/branches/unknown/protect", user) put api("/projects/#{project.id}/repository/branches/unknown/protect", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "should return a 403 error if guest" do it "should return a 403 error if guest" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user2) put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user2)
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
it "should return success when protect branch again" do it "should return success when protect branch again" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user) put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user)
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user) put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
describe "PUT /projects/:id/repository/branches/:branch/unprotect" do describe "PUT /projects/:id/repository/branches/:branch/unprotect" do
it "should unprotect a single branch" do it "should unprotect a single branch" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user) put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['commit']['id']).to eq(branch_sha) expect(json_response['commit']['id']).to eq(branch_sha)
...@@ -84,13 +84,13 @@ describe API::API, api: true do ...@@ -84,13 +84,13 @@ describe API::API, api: true do
it "should return success when unprotect branch" do it "should return success when unprotect branch" do
put api("/projects/#{project.id}/repository/branches/unknown/unprotect", user) put api("/projects/#{project.id}/repository/branches/unknown/unprotect", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "should return success when unprotect branch again" do it "should return success when unprotect branch again" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user) put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user) put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -100,7 +100,7 @@ describe API::API, api: true do ...@@ -100,7 +100,7 @@ describe API::API, api: true do
branch_name: 'feature1', branch_name: 'feature1',
ref: branch_sha ref: branch_sha
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['name']).to eq('feature1') expect(json_response['name']).to eq('feature1')
expect(json_response['commit']['id']).to eq(branch_sha) expect(json_response['commit']['id']).to eq(branch_sha)
...@@ -110,14 +110,14 @@ describe API::API, api: true do ...@@ -110,14 +110,14 @@ describe API::API, api: true do
post api("/projects/#{project.id}/repository/branches", user2), post api("/projects/#{project.id}/repository/branches", user2),
branch_name: branch_name, branch_name: branch_name,
ref: branch_sha ref: branch_sha
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
it 'should return 400 if branch name is invalid' do it 'should return 400 if branch name is invalid' do
post api("/projects/#{project.id}/repository/branches", user), post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new design', branch_name: 'new design',
ref: branch_sha ref: branch_sha
expect(response.status).to eq(400) expect(response).to have_http_status(400)
expect(json_response['message']).to eq('Branch name is invalid') expect(json_response['message']).to eq('Branch name is invalid')
end end
...@@ -125,12 +125,12 @@ describe API::API, api: true do ...@@ -125,12 +125,12 @@ describe API::API, api: true do
post api("/projects/#{project.id}/repository/branches", user), post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new_design1', branch_name: 'new_design1',
ref: branch_sha ref: branch_sha
expect(response.status).to eq(201) expect(response).to have_http_status(201)
post api("/projects/#{project.id}/repository/branches", user), post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new_design1', branch_name: 'new_design1',
ref: branch_sha ref: branch_sha
expect(response.status).to eq(400) expect(response).to have_http_status(400)
expect(json_response['message']).to eq('Branch already exists') expect(json_response['message']).to eq('Branch already exists')
end end
...@@ -138,7 +138,7 @@ describe API::API, api: true do ...@@ -138,7 +138,7 @@ describe API::API, api: true do
post api("/projects/#{project.id}/repository/branches", user), post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new_design3', branch_name: 'new_design3',
ref: 'foo' ref: 'foo'
expect(response.status).to eq(400) expect(response).to have_http_status(400)
expect(json_response['message']).to eq('Invalid reference name') expect(json_response['message']).to eq('Invalid reference name')
end end
end end
...@@ -150,25 +150,25 @@ describe API::API, api: true do ...@@ -150,25 +150,25 @@ describe API::API, api: true do
it "should remove branch" do it "should remove branch" do
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user) delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['branch_name']).to eq(branch_name) expect(json_response['branch_name']).to eq(branch_name)
end end
it 'should return 404 if branch not exists' do it 'should return 404 if branch not exists' do
delete api("/projects/#{project.id}/repository/branches/foobar", user) delete api("/projects/#{project.id}/repository/branches/foobar", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "should remove protected branch" do it "should remove protected branch" do
project.protected_branches.create(name: branch_name) project.protected_branches.create(name: branch_name)
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user) delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response.status).to eq(405) expect(response).to have_http_status(405)
expect(json_response['message']).to eq('Protected branch cant be removed') expect(json_response['message']).to eq('Protected branch cant be removed')
end end
it "should not remove HEAD branch" do it "should not remove HEAD branch" do
delete api("/projects/#{project.id}/repository/branches/master", user) delete api("/projects/#{project.id}/repository/branches/master", user)
expect(response.status).to eq(405) expect(response).to have_http_status(405)
expect(json_response['message']).to eq('Cannot remove HEAD branch') expect(json_response['message']).to eq('Cannot remove HEAD branch')
end end
end end
......
...@@ -19,7 +19,7 @@ describe API::API, api: true do ...@@ -19,7 +19,7 @@ describe API::API, api: true do
context 'authorized user' do context 'authorized user' do
it 'should return project builds' do it 'should return project builds' do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
end end
...@@ -32,7 +32,7 @@ describe API::API, api: true do ...@@ -32,7 +32,7 @@ describe API::API, api: true do
let(:query) { 'scope=pending' } let(:query) { 'scope=pending' }
it do it do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
end end
end end
...@@ -41,7 +41,7 @@ describe API::API, api: true do ...@@ -41,7 +41,7 @@ describe API::API, api: true do
let(:query) { 'scope[0]=pending&scope[1]=running' } let(:query) { 'scope[0]=pending&scope[1]=running' }
it do it do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
end end
end end
...@@ -49,7 +49,7 @@ describe API::API, api: true do ...@@ -49,7 +49,7 @@ describe API::API, api: true do
context 'respond 400 when scope contains invalid state' do context 'respond 400 when scope contains invalid state' do
let(:query) { 'scope[0]=pending&scope[1]=unknown_status' } let(:query) { 'scope[0]=pending&scope[1]=unknown_status' }
it { expect(response.status).to eq(400) } it { expect(response).to have_http_status(400) }
end end
end end
...@@ -57,7 +57,7 @@ describe API::API, api: true do ...@@ -57,7 +57,7 @@ describe API::API, api: true do
let(:api_user) { nil } let(:api_user) { nil }
it 'should not return project builds' do it 'should not return project builds' do
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -70,7 +70,7 @@ describe API::API, api: true do ...@@ -70,7 +70,7 @@ describe API::API, api: true do
context 'authorized user' do context 'authorized user' do
it 'should return project builds for specific commit' do it 'should return project builds for specific commit' do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
end end
end end
...@@ -79,7 +79,7 @@ describe API::API, api: true do ...@@ -79,7 +79,7 @@ describe API::API, api: true do
let(:api_user) { nil } let(:api_user) { nil }
it 'should not return project builds' do it 'should not return project builds' do
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -89,7 +89,7 @@ describe API::API, api: true do ...@@ -89,7 +89,7 @@ describe API::API, api: true do
context 'authorized user' do context 'authorized user' do
it 'should return specific build data' do it 'should return specific build data' do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['name']).to eq('test') expect(json_response['name']).to eq('test')
end end
end end
...@@ -98,7 +98,7 @@ describe API::API, api: true do ...@@ -98,7 +98,7 @@ describe API::API, api: true do
let(:api_user) { nil } let(:api_user) { nil }
it 'should not return specific build data' do it 'should not return specific build data' do
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -116,7 +116,7 @@ describe API::API, api: true do ...@@ -116,7 +116,7 @@ describe API::API, api: true do
end end
it 'should return specific build artifacts' do it 'should return specific build artifacts' do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(response.headers).to include(download_headers) expect(response.headers).to include(download_headers)
end end
end end
...@@ -125,13 +125,13 @@ describe API::API, api: true do ...@@ -125,13 +125,13 @@ describe API::API, api: true do
let(:api_user) { nil } let(:api_user) { nil }
it 'should not return specific build artifacts' do it 'should not return specific build artifacts' do
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
it 'should not return build artifacts if not uploaded' do it 'should not return build artifacts if not uploaded' do
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -142,7 +142,7 @@ describe API::API, api: true do ...@@ -142,7 +142,7 @@ describe API::API, api: true do
context 'authorized user' do context 'authorized user' do
it 'should return specific build trace' do it 'should return specific build trace' do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(response.body).to eq(build.trace) expect(response.body).to eq(build.trace)
end end
end end
...@@ -151,7 +151,7 @@ describe API::API, api: true do ...@@ -151,7 +151,7 @@ describe API::API, api: true do
let(:api_user) { nil } let(:api_user) { nil }
it 'should not return specific build trace' do it 'should not return specific build trace' do
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -162,7 +162,7 @@ describe API::API, api: true do ...@@ -162,7 +162,7 @@ describe API::API, api: true do
context 'authorized user' do context 'authorized user' do
context 'user with :update_build persmission' do context 'user with :update_build persmission' do
it 'should cancel running or pending build' do it 'should cancel running or pending build' do
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(project.builds.first.status).to eq('canceled') expect(project.builds.first.status).to eq('canceled')
end end
end end
...@@ -171,7 +171,7 @@ describe API::API, api: true do ...@@ -171,7 +171,7 @@ describe API::API, api: true do
let(:api_user) { user2 } let(:api_user) { user2 }
it 'should not cancel build' do it 'should not cancel build' do
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
end end
...@@ -180,7 +180,7 @@ describe API::API, api: true do ...@@ -180,7 +180,7 @@ describe API::API, api: true do
let(:api_user) { nil } let(:api_user) { nil }
it 'should not cancel build' do it 'should not cancel build' do
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -193,7 +193,7 @@ describe API::API, api: true do ...@@ -193,7 +193,7 @@ describe API::API, api: true do
context 'authorized user' do context 'authorized user' do
context 'user with :update_build permission' do context 'user with :update_build permission' do
it 'should retry non-running build' do it 'should retry non-running build' do
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(project.builds.first.status).to eq('canceled') expect(project.builds.first.status).to eq('canceled')
expect(json_response['status']).to eq('pending') expect(json_response['status']).to eq('pending')
end end
...@@ -203,7 +203,7 @@ describe API::API, api: true do ...@@ -203,7 +203,7 @@ describe API::API, api: true do
let(:api_user) { user2 } let(:api_user) { user2 }
it 'should not retry build' do it 'should not retry build' do
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
end end
...@@ -212,7 +212,7 @@ describe API::API, api: true do ...@@ -212,7 +212,7 @@ describe API::API, api: true do
let(:api_user) { nil } let(:api_user) { nil }
it 'should not retry build' do it 'should not retry build' do
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
......
...@@ -41,7 +41,7 @@ describe API::CommitStatuses, api: true do ...@@ -41,7 +41,7 @@ describe API::CommitStatuses, api: true do
before { get api(get_url, reporter) } before { get api(get_url, reporter) }
it 'returns latest commit statuses' do it 'returns latest commit statuses' do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(statuses_id).to contain_exactly(status3.id, status4.id, status5.id, status6.id) expect(statuses_id).to contain_exactly(status3.id, status4.id, status5.id, status6.id)
...@@ -54,7 +54,7 @@ describe API::CommitStatuses, api: true do ...@@ -54,7 +54,7 @@ describe API::CommitStatuses, api: true do
before { get api(get_url, reporter), all: 1 } before { get api(get_url, reporter), all: 1 }
it 'returns all commit statuses' do it 'returns all commit statuses' do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(statuses_id).to contain_exactly(status1.id, status2.id, expect(statuses_id).to contain_exactly(status1.id, status2.id,
...@@ -67,7 +67,7 @@ describe API::CommitStatuses, api: true do ...@@ -67,7 +67,7 @@ describe API::CommitStatuses, api: true do
before { get api(get_url, reporter), ref: 'develop' } before { get api(get_url, reporter), ref: 'develop' }
it 'returns latest commit statuses for specific ref' do it 'returns latest commit statuses for specific ref' do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(statuses_id).to contain_exactly(status3.id, status5.id) expect(statuses_id).to contain_exactly(status3.id, status5.id)
...@@ -78,7 +78,7 @@ describe API::CommitStatuses, api: true do ...@@ -78,7 +78,7 @@ describe API::CommitStatuses, api: true do
before { get api(get_url, reporter), name: 'coverage' } before { get api(get_url, reporter), name: 'coverage' }
it 'return latest commit statuses for specific name' do it 'return latest commit statuses for specific name' do
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(statuses_id).to contain_exactly(status4.id, status5.id) expect(statuses_id).to contain_exactly(status4.id, status5.id)
...@@ -101,7 +101,7 @@ describe API::CommitStatuses, api: true do ...@@ -101,7 +101,7 @@ describe API::CommitStatuses, api: true do
before { get api(get_url, guest) } before { get api(get_url, guest) }
it "should not return project commits" do it "should not return project commits" do
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
...@@ -109,7 +109,7 @@ describe API::CommitStatuses, api: true do ...@@ -109,7 +109,7 @@ describe API::CommitStatuses, api: true do
before { get api(get_url) } before { get api(get_url) }
it "should not return project commits" do it "should not return project commits" do
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -122,7 +122,7 @@ describe API::CommitStatuses, api: true do ...@@ -122,7 +122,7 @@ describe API::CommitStatuses, api: true do
before { post api(post_url, developer), state: 'success' } before { post api(post_url, developer), state: 'success' }
it 'creates commit status' do it 'creates commit status' do
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['sha']).to eq(commit.id) expect(json_response['sha']).to eq(commit.id)
expect(json_response['status']).to eq('success') expect(json_response['status']).to eq('success')
expect(json_response['name']).to eq('default') expect(json_response['name']).to eq('default')
...@@ -141,7 +141,7 @@ describe API::CommitStatuses, api: true do ...@@ -141,7 +141,7 @@ describe API::CommitStatuses, api: true do
end end
it 'creates commit status' do it 'creates commit status' do
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['sha']).to eq(commit.id) expect(json_response['sha']).to eq(commit.id)
expect(json_response['status']).to eq('success') expect(json_response['status']).to eq('success')
expect(json_response['name']).to eq('coverage') expect(json_response['name']).to eq('coverage')
...@@ -155,7 +155,7 @@ describe API::CommitStatuses, api: true do ...@@ -155,7 +155,7 @@ describe API::CommitStatuses, api: true do
before { post api(post_url, developer), state: 'invalid' } before { post api(post_url, developer), state: 'invalid' }
it 'does not create commit status' do it 'does not create commit status' do
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
end end
...@@ -163,7 +163,7 @@ describe API::CommitStatuses, api: true do ...@@ -163,7 +163,7 @@ describe API::CommitStatuses, api: true do
before { post api(post_url, developer) } before { post api(post_url, developer) }
it 'does not create commit status' do it 'does not create commit status' do
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
end end
...@@ -172,7 +172,7 @@ describe API::CommitStatuses, api: true do ...@@ -172,7 +172,7 @@ describe API::CommitStatuses, api: true do
before { post api(post_url, developer), state: 'running' } before { post api(post_url, developer), state: 'running' }
it 'returns not found error' do it 'returns not found error' do
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -181,7 +181,7 @@ describe API::CommitStatuses, api: true do ...@@ -181,7 +181,7 @@ describe API::CommitStatuses, api: true do
before { post api(post_url, reporter) } before { post api(post_url, reporter) }
it 'should not create commit status' do it 'should not create commit status' do
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
...@@ -189,7 +189,7 @@ describe API::CommitStatuses, api: true do ...@@ -189,7 +189,7 @@ describe API::CommitStatuses, api: true do
before { post api(post_url, guest) } before { post api(post_url, guest) }
it 'should not create commit status' do it 'should not create commit status' do
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
...@@ -197,7 +197,7 @@ describe API::CommitStatuses, api: true do ...@@ -197,7 +197,7 @@ describe API::CommitStatuses, api: true do
before { post api(post_url) } before { post api(post_url) }
it 'should not create commit status' do it 'should not create commit status' do
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
......
...@@ -19,7 +19,7 @@ describe API::API, api: true do ...@@ -19,7 +19,7 @@ describe API::API, api: true do
it "should return project commits" do it "should return project commits" do
get api("/projects/#{project.id}/repository/commits", user) get api("/projects/#{project.id}/repository/commits", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['id']).to eq(project.repository.commit.id) expect(json_response.first['id']).to eq(project.repository.commit.id)
...@@ -29,7 +29,7 @@ describe API::API, api: true do ...@@ -29,7 +29,7 @@ describe API::API, api: true do
context "unauthorized user" do context "unauthorized user" do
it "should not return project commits" do it "should not return project commits" do
get api("/projects/#{project.id}/repository/commits") get api("/projects/#{project.id}/repository/commits")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
...@@ -63,7 +63,7 @@ describe API::API, api: true do ...@@ -63,7 +63,7 @@ describe API::API, api: true do
it "should return an invalid parameter error message" do it "should return an invalid parameter error message" do
get api("/projects/#{project.id}/repository/commits?since=invalid-date", user) get api("/projects/#{project.id}/repository/commits?since=invalid-date", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
expect(json_response['message']).to include "\"since\" must be a timestamp in ISO 8601 format" expect(json_response['message']).to include "\"since\" must be a timestamp in ISO 8601 format"
end end
end end
...@@ -73,26 +73,26 @@ describe API::API, api: true do ...@@ -73,26 +73,26 @@ describe API::API, api: true do
context "authorized user" do context "authorized user" do
it "should return a commit by sha" do it "should return a commit by sha" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['id']).to eq(project.repository.commit.id) expect(json_response['id']).to eq(project.repository.commit.id)
expect(json_response['title']).to eq(project.repository.commit.title) expect(json_response['title']).to eq(project.repository.commit.title)
end end
it "should return a 404 error if not found" do it "should return a 404 error if not found" do
get api("/projects/#{project.id}/repository/commits/invalid_sha", user) get api("/projects/#{project.id}/repository/commits/invalid_sha", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "should return nil for commit without CI" do it "should return nil for commit without CI" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['status']).to be_nil expect(json_response['status']).to be_nil
end end
it "should return status for CI" do it "should return status for CI" do
pipeline = project.ensure_pipeline(project.repository.commit.sha, 'master') pipeline = project.ensure_pipeline(project.repository.commit.sha, 'master')
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['status']).to eq(pipeline.status) expect(json_response['status']).to eq(pipeline.status)
end end
end end
...@@ -100,7 +100,7 @@ describe API::API, api: true do ...@@ -100,7 +100,7 @@ describe API::API, api: true do
context "unauthorized user" do context "unauthorized user" do
it "should not return the selected commit" do it "should not return the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}") get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -111,7 +111,7 @@ describe API::API, api: true do ...@@ -111,7 +111,7 @@ describe API::API, api: true do
it "should return the diff of the selected commit" do it "should return the diff of the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff", user) get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to be >= 1 expect(json_response.length).to be >= 1
...@@ -120,14 +120,14 @@ describe API::API, api: true do ...@@ -120,14 +120,14 @@ describe API::API, api: true do
it "should return a 404 error if invalid commit" do it "should return a 404 error if invalid commit" do
get api("/projects/#{project.id}/repository/commits/invalid_sha/diff", user) get api("/projects/#{project.id}/repository/commits/invalid_sha/diff", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
context "unauthorized user" do context "unauthorized user" do
it "should not return the diff of the selected commit" do it "should not return the diff of the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff") get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -136,7 +136,7 @@ describe API::API, api: true do ...@@ -136,7 +136,7 @@ describe API::API, api: true do
context 'authorized user' do context 'authorized user' do
it 'should return merge_request comments' do it 'should return merge_request comments' do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user) get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(2) expect(json_response.length).to eq(2)
expect(json_response.first['note']).to eq('a comment on a commit') expect(json_response.first['note']).to eq('a comment on a commit')
...@@ -145,14 +145,14 @@ describe API::API, api: true do ...@@ -145,14 +145,14 @@ describe API::API, api: true do
it 'should return a 404 error if merge_request_id not found' do it 'should return a 404 error if merge_request_id not found' do
get api("/projects/#{project.id}/repository/commits/1234ab/comments", user) get api("/projects/#{project.id}/repository/commits/1234ab/comments", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
context 'unauthorized user' do context 'unauthorized user' do
it 'should not return the diff of the selected commit' do it 'should not return the diff of the selected commit' do
get api("/projects/#{project.id}/repository/commits/1234ab/comments") get api("/projects/#{project.id}/repository/commits/1234ab/comments")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -161,7 +161,7 @@ describe API::API, api: true do ...@@ -161,7 +161,7 @@ describe API::API, api: true do
context 'authorized user' do context 'authorized user' do
it 'should return comment' do it 'should return comment' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment' post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment'
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['note']).to eq('My comment') expect(json_response['note']).to eq('My comment')
expect(json_response['path']).to be_nil expect(json_response['path']).to be_nil
expect(json_response['line']).to be_nil expect(json_response['line']).to be_nil
...@@ -170,7 +170,7 @@ describe API::API, api: true do ...@@ -170,7 +170,7 @@ describe API::API, api: true do
it 'should return the inline comment' do it 'should return the inline comment' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment', path: project.repository.commit.diffs.first.new_path, line: 7, line_type: 'new' post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment', path: project.repository.commit.diffs.first.new_path, line: 7, line_type: 'new'
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['note']).to eq('My comment') expect(json_response['note']).to eq('My comment')
expect(json_response['path']).to eq(project.repository.commit.diffs.first.new_path) expect(json_response['path']).to eq(project.repository.commit.diffs.first.new_path)
expect(json_response['line']).to eq(7) expect(json_response['line']).to eq(7)
...@@ -179,19 +179,19 @@ describe API::API, api: true do ...@@ -179,19 +179,19 @@ describe API::API, api: true do
it 'should return 400 if note is missing' do it 'should return 400 if note is missing' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user) post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it 'should return 404 if note is attached to non existent commit' do it 'should return 404 if note is attached to non existent commit' do
post api("/projects/#{project.id}/repository/commits/1234ab/comments", user), note: 'My comment' post api("/projects/#{project.id}/repository/commits/1234ab/comments", user), note: 'My comment'
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
context 'unauthorized user' do context 'unauthorized user' do
it 'should not return the diff of the selected commit' do it 'should not return the diff of the selected commit' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments") post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
......
...@@ -11,21 +11,21 @@ describe API::API, api: true do ...@@ -11,21 +11,21 @@ describe API::API, api: true do
describe "when unauthenticated" do describe "when unauthenticated" do
it "returns authentication success" do it "returns authentication success" do
get api("/user"), access_token: token.token get api("/user"), access_token: token.token
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
describe "when token invalid" do describe "when token invalid" do
it "returns authentication error" do it "returns authentication error" do
get api("/user"), access_token: "123a" get api("/user"), access_token: "123a"
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
describe "authorization by private token" do describe "authorization by private token" do
it "returns authentication success" do it "returns authentication success" do
get api("/user", user) get api("/user", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
end end
...@@ -16,7 +16,7 @@ describe API::API, api: true do ...@@ -16,7 +16,7 @@ describe API::API, api: true do
} }
get api("/projects/#{project.id}/repository/files", user), params get api("/projects/#{project.id}/repository/files", user), params
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['file_path']).to eq(file_path) expect(json_response['file_path']).to eq(file_path)
expect(json_response['file_name']).to eq('popen.rb') expect(json_response['file_name']).to eq('popen.rb')
expect(json_response['last_commit_id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') expect(json_response['last_commit_id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
...@@ -25,7 +25,7 @@ describe API::API, api: true do ...@@ -25,7 +25,7 @@ describe API::API, api: true do
it "should return a 400 bad request if no params given" do it "should return a 400 bad request if no params given" do
get api("/projects/#{project.id}/repository/files", user) get api("/projects/#{project.id}/repository/files", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 404 if such file does not exist" do it "should return a 404 if such file does not exist" do
...@@ -35,7 +35,7 @@ describe API::API, api: true do ...@@ -35,7 +35,7 @@ describe API::API, api: true do
} }
get api("/projects/#{project.id}/repository/files", user), params get api("/projects/#{project.id}/repository/files", user), params
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -51,13 +51,13 @@ describe API::API, api: true do ...@@ -51,13 +51,13 @@ describe API::API, api: true do
it "should create a new file in project repo" do it "should create a new file in project repo" do
post api("/projects/#{project.id}/repository/files", user), valid_params post api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['file_path']).to eq('newfile.rb') expect(json_response['file_path']).to eq('newfile.rb')
end end
it "should return a 400 bad request if no params given" do it "should return a 400 bad request if no params given" do
post api("/projects/#{project.id}/repository/files", user) post api("/projects/#{project.id}/repository/files", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 400 if editor fails to create file" do it "should return a 400 if editor fails to create file" do
...@@ -65,7 +65,7 @@ describe API::API, api: true do ...@@ -65,7 +65,7 @@ describe API::API, api: true do
and_return(false) and_return(false)
post api("/projects/#{project.id}/repository/files", user), valid_params post api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
end end
...@@ -81,13 +81,13 @@ describe API::API, api: true do ...@@ -81,13 +81,13 @@ describe API::API, api: true do
it "should update existing file in project repo" do it "should update existing file in project repo" do
put api("/projects/#{project.id}/repository/files", user), valid_params put api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['file_path']).to eq(file_path) expect(json_response['file_path']).to eq(file_path)
end end
it "should return a 400 bad request if no params given" do it "should return a 400 bad request if no params given" do
put api("/projects/#{project.id}/repository/files", user) put api("/projects/#{project.id}/repository/files", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
end end
...@@ -102,20 +102,20 @@ describe API::API, api: true do ...@@ -102,20 +102,20 @@ describe API::API, api: true do
it "should delete existing file in project repo" do it "should delete existing file in project repo" do
delete api("/projects/#{project.id}/repository/files", user), valid_params delete api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['file_path']).to eq(file_path) expect(json_response['file_path']).to eq(file_path)
end end
it "should return a 400 bad request if no params given" do it "should return a 400 bad request if no params given" do
delete api("/projects/#{project.id}/repository/files", user) delete api("/projects/#{project.id}/repository/files", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 400 if fails to create file" do it "should return a 400 if fails to create file" do
allow_any_instance_of(Repository).to receive(:remove_file).and_return(false) allow_any_instance_of(Repository).to receive(:remove_file).and_return(false)
delete api("/projects/#{project.id}/repository/files", user), valid_params delete api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
end end
...@@ -143,7 +143,7 @@ describe API::API, api: true do ...@@ -143,7 +143,7 @@ describe API::API, api: true do
it "remains unchanged" do it "remains unchanged" do
get api("/projects/#{project.id}/repository/files", user), get_params get api("/projects/#{project.id}/repository/files", user), get_params
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['file_path']).to eq(file_path) expect(json_response['file_path']).to eq(file_path)
expect(json_response['file_name']).to eq(file_path) expect(json_response['file_name']).to eq(file_path)
expect(json_response['content']).to eq(put_params[:content]) expect(json_response['content']).to eq(put_params[:content])
......
...@@ -22,7 +22,7 @@ describe API::API, api: true do ...@@ -22,7 +22,7 @@ describe API::API, api: true do
context 'when authenticated' do context 'when authenticated' do
it 'should fork if user has sufficient access to project' do it 'should fork if user has sufficient access to project' do
post api("/projects/fork/#{project.id}", user2) post api("/projects/fork/#{project.id}", user2)
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['name']).to eq(project.name) expect(json_response['name']).to eq(project.name)
expect(json_response['path']).to eq(project.path) expect(json_response['path']).to eq(project.path)
expect(json_response['owner']['id']).to eq(user2.id) expect(json_response['owner']['id']).to eq(user2.id)
...@@ -32,7 +32,7 @@ describe API::API, api: true do ...@@ -32,7 +32,7 @@ describe API::API, api: true do
it 'should fork if user is admin' do it 'should fork if user is admin' do
post api("/projects/fork/#{project.id}", admin) post api("/projects/fork/#{project.id}", admin)
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['name']).to eq(project.name) expect(json_response['name']).to eq(project.name)
expect(json_response['path']).to eq(project.path) expect(json_response['path']).to eq(project.path)
expect(json_response['owner']['id']).to eq(admin.id) expect(json_response['owner']['id']).to eq(admin.id)
...@@ -42,20 +42,20 @@ describe API::API, api: true do ...@@ -42,20 +42,20 @@ describe API::API, api: true do
it 'should fail on missing project access for the project to fork' do it 'should fail on missing project access for the project to fork' do
post api("/projects/fork/#{project.id}", user3) post api("/projects/fork/#{project.id}", user3)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found') expect(json_response['message']).to eq('404 Project Not Found')
end end
it 'should fail if forked project exists in the user namespace' do it 'should fail if forked project exists in the user namespace' do
post api("/projects/fork/#{project.id}", user) post api("/projects/fork/#{project.id}", user)
expect(response.status).to eq(409) expect(response).to have_http_status(409)
expect(json_response['message']['name']).to eq(['has already been taken']) expect(json_response['message']['name']).to eq(['has already been taken'])
expect(json_response['message']['path']).to eq(['has already been taken']) expect(json_response['message']['path']).to eq(['has already been taken'])
end end
it 'should fail if project to fork from does not exist' do it 'should fail if project to fork from does not exist' do
post api('/projects/fork/424242', user) post api('/projects/fork/424242', user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found') expect(json_response['message']).to eq('404 Project Not Found')
end end
end end
...@@ -63,7 +63,7 @@ describe API::API, api: true do ...@@ -63,7 +63,7 @@ describe API::API, api: true do
context 'when unauthenticated' do context 'when unauthenticated' do
it 'should return authentication error' do it 'should return authentication error' do
post api("/projects/fork/#{project.id}") post api("/projects/fork/#{project.id}")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
expect(json_response['message']).to eq('401 Unauthorized') expect(json_response['message']).to eq('401 Unauthorized')
end end
end end
......
...@@ -31,7 +31,7 @@ describe API::API, api: true do ...@@ -31,7 +31,7 @@ describe API::API, api: true do
it "each user: should return an array of members groups of group3" do it "each user: should return an array of members groups of group3" do
[owner, master, developer, reporter, guest].each do |user| [owner, master, developer, reporter, guest].each do |user|
get api("/groups/#{group_with_members.id}/members", user) get api("/groups/#{group_with_members.id}/members", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(5) expect(json_response.size).to eq(5)
expect(json_response.find { |e| e['id'] == owner.id }['access_level']).to eq(GroupMember::OWNER) expect(json_response.find { |e| e['id'] == owner.id }['access_level']).to eq(GroupMember::OWNER)
...@@ -45,7 +45,7 @@ describe API::API, api: true do ...@@ -45,7 +45,7 @@ describe API::API, api: true do
it 'users not part of the group should get access error' do it 'users not part of the group should get access error' do
get api("/groups/#{group_with_members.id}/members", stranger) get api("/groups/#{group_with_members.id}/members", stranger)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -54,7 +54,7 @@ describe API::API, api: true do ...@@ -54,7 +54,7 @@ describe API::API, api: true do
context "when not a member of the group" do context "when not a member of the group" do
it "should not add guest as member of group_no_members when adding being done by person outside the group" do it "should not add guest as member of group_no_members when adding being done by person outside the group" do
post api("/groups/#{group_no_members.id}/members", reporter), user_id: guest.id, access_level: GroupMember::MASTER post api("/groups/#{group_no_members.id}/members", reporter), user_id: guest.id, access_level: GroupMember::MASTER
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
...@@ -66,7 +66,7 @@ describe API::API, api: true do ...@@ -66,7 +66,7 @@ describe API::API, api: true do
post api("/groups/#{group_no_members.id}/members", owner), user_id: new_user.id, access_level: GroupMember::MASTER post api("/groups/#{group_no_members.id}/members", owner), user_id: new_user.id, access_level: GroupMember::MASTER
end.to change { group_no_members.members.count }.by(1) end.to change { group_no_members.members.count }.by(1)
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['name']).to eq(new_user.name) expect(json_response['name']).to eq(new_user.name)
expect(json_response['access_level']).to eq(GroupMember::MASTER) expect(json_response['access_level']).to eq(GroupMember::MASTER)
end end
...@@ -78,27 +78,27 @@ describe API::API, api: true do ...@@ -78,27 +78,27 @@ describe API::API, api: true do
post api("/groups/#{group_with_members.id}/members", guest), user_id: new_user.id, access_level: GroupMember::MASTER post api("/groups/#{group_with_members.id}/members", guest), user_id: new_user.id, access_level: GroupMember::MASTER
end.not_to change { group_with_members.members.count } end.not_to change { group_with_members.members.count }
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
it "should return error if member already exists" do it "should return error if member already exists" do
post api("/groups/#{group_with_members.id}/members", owner), user_id: master.id, access_level: GroupMember::MASTER post api("/groups/#{group_with_members.id}/members", owner), user_id: master.id, access_level: GroupMember::MASTER
expect(response.status).to eq(409) expect(response).to have_http_status(409)
end end
it "should return a 400 error when user id is not given" do it "should return a 400 error when user id is not given" do
post api("/groups/#{group_no_members.id}/members", owner), access_level: GroupMember::MASTER post api("/groups/#{group_no_members.id}/members", owner), access_level: GroupMember::MASTER
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 400 error when access level is not given" do it "should return a 400 error when access level is not given" do
post api("/groups/#{group_no_members.id}/members", owner), user_id: master.id post api("/groups/#{group_no_members.id}/members", owner), user_id: master.id
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 422 error when access level is not known" do it "should return a 422 error when access level is not known" do
post api("/groups/#{group_no_members.id}/members", owner), user_id: master.id, access_level: 1234 post api("/groups/#{group_no_members.id}/members", owner), user_id: master.id, access_level: 1234
expect(response.status).to eq(422) expect(response).to have_http_status(422)
end end
end end
end end
...@@ -110,7 +110,7 @@ describe API::API, api: true do ...@@ -110,7 +110,7 @@ describe API::API, api: true do
api("/groups/#{group_no_members.id}/members/#{developer.id}", api("/groups/#{group_no_members.id}/members/#{developer.id}",
owner), access_level: GroupMember::MASTER owner), access_level: GroupMember::MASTER
) )
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -122,7 +122,7 @@ describe API::API, api: true do ...@@ -122,7 +122,7 @@ describe API::API, api: true do
access_level: GroupMember::MASTER access_level: GroupMember::MASTER
) )
expect(response.status).to eq(200) expect(response).to have_http_status(200)
get api("/groups/#{group_with_members.id}/members", owner) get api("/groups/#{group_with_members.id}/members", owner)
json_reporter = json_response.find do |e| json_reporter = json_response.find do |e|
...@@ -139,7 +139,7 @@ describe API::API, api: true do ...@@ -139,7 +139,7 @@ describe API::API, api: true do
access_level: GroupMember::MASTER access_level: GroupMember::MASTER
) )
expect(response.status).to eq(403) expect(response).to have_http_status(403)
get api("/groups/#{group_with_members.id}/members", owner) get api("/groups/#{group_with_members.id}/members", owner)
json_developer = json_response.find do |e| json_developer = json_response.find do |e|
...@@ -153,7 +153,7 @@ describe API::API, api: true do ...@@ -153,7 +153,7 @@ describe API::API, api: true do
put( put(
api("/groups/#{group_with_members.id}/members/#{master.id}", owner) api("/groups/#{group_with_members.id}/members/#{master.id}", owner)
) )
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it 'should return a 422 error when access level is not known' do it 'should return a 422 error when access level is not known' do
...@@ -161,7 +161,7 @@ describe API::API, api: true do ...@@ -161,7 +161,7 @@ describe API::API, api: true do
api("/groups/#{group_with_members.id}/members/#{master.id}", owner), api("/groups/#{group_with_members.id}/members/#{master.id}", owner),
access_level: 1234 access_level: 1234
) )
expect(response.status).to eq(422) expect(response).to have_http_status(422)
end end
end end
end end
...@@ -172,7 +172,7 @@ describe API::API, api: true do ...@@ -172,7 +172,7 @@ describe API::API, api: true do
random_user = create(:user) random_user = create(:user)
delete api("/groups/#{group_with_members.id}/members/#{owner.id}", random_user) delete api("/groups/#{group_with_members.id}/members/#{owner.id}", random_user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -182,17 +182,17 @@ describe API::API, api: true do ...@@ -182,17 +182,17 @@ describe API::API, api: true do
delete api("/groups/#{group_with_members.id}/members/#{guest.id}", owner) delete api("/groups/#{group_with_members.id}/members/#{guest.id}", owner)
end.to change { group_with_members.members.count }.by(-1) end.to change { group_with_members.members.count }.by(-1)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it "should return a 404 error when user id is not known" do it "should return a 404 error when user id is not known" do
delete api("/groups/#{group_with_members.id}/members/1328", owner) delete api("/groups/#{group_with_members.id}/members/1328", owner)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "should not allow guest to modify group members" do it "should not allow guest to modify group members" do
delete api("/groups/#{group_with_members.id}/members/#{master.id}", guest) delete api("/groups/#{group_with_members.id}/members/#{master.id}", guest)
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
end end
......
This diff is collapsed.
...@@ -11,7 +11,7 @@ describe API::API, api: true do ...@@ -11,7 +11,7 @@ describe API::API, api: true do
it do it do
get api("/internal/check"), secret_token: secret_token get api("/internal/check"), secret_token: secret_token
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['api_version']).to eq(API::API.version) expect(json_response['api_version']).to eq(API::API.version)
end end
end end
...@@ -23,7 +23,7 @@ describe API::API, api: true do ...@@ -23,7 +23,7 @@ describe API::API, api: true do
it do it do
get api("/internal/broadcast_message"), secret_token: secret_token get api("/internal/broadcast_message"), secret_token: secret_token
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["message"]).to eq(broadcast_message.message) expect(json_response["message"]).to eq(broadcast_message.message)
end end
end end
...@@ -32,7 +32,7 @@ describe API::API, api: true do ...@@ -32,7 +32,7 @@ describe API::API, api: true do
it do it do
get api("/internal/broadcast_message"), secret_token: secret_token get api("/internal/broadcast_message"), secret_token: secret_token
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_empty expect(json_response).to be_empty
end end
end end
...@@ -42,7 +42,7 @@ describe API::API, api: true do ...@@ -42,7 +42,7 @@ describe API::API, api: true do
it do it do
get(api("/internal/discover"), key_id: key.id, secret_token: secret_token) get(api("/internal/discover"), key_id: key.id, secret_token: secret_token)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['name']).to eq(user.name) expect(json_response['name']).to eq(user.name)
end end
...@@ -61,7 +61,7 @@ describe API::API, api: true do ...@@ -61,7 +61,7 @@ describe API::API, api: true do
push(key, project_wiki) push(key, project_wiki)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_truthy expect(json_response["status"]).to be_truthy
end end
end end
...@@ -70,7 +70,7 @@ describe API::API, api: true do ...@@ -70,7 +70,7 @@ describe API::API, api: true do
it do it do
pull(key, project) pull(key, project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_truthy expect(json_response["status"]).to be_truthy
end end
end end
...@@ -79,7 +79,7 @@ describe API::API, api: true do ...@@ -79,7 +79,7 @@ describe API::API, api: true do
it do it do
push(key, project) push(key, project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_truthy expect(json_response["status"]).to be_truthy
end end
end end
...@@ -94,7 +94,7 @@ describe API::API, api: true do ...@@ -94,7 +94,7 @@ describe API::API, api: true do
it do it do
pull(key, project) pull(key, project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey expect(json_response["status"]).to be_falsey
end end
end end
...@@ -103,7 +103,7 @@ describe API::API, api: true do ...@@ -103,7 +103,7 @@ describe API::API, api: true do
it do it do
push(key, project) push(key, project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey expect(json_response["status"]).to be_falsey
end end
end end
...@@ -120,7 +120,7 @@ describe API::API, api: true do ...@@ -120,7 +120,7 @@ describe API::API, api: true do
it do it do
pull(key, personal_project) pull(key, personal_project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey expect(json_response["status"]).to be_falsey
end end
end end
...@@ -129,7 +129,7 @@ describe API::API, api: true do ...@@ -129,7 +129,7 @@ describe API::API, api: true do
it do it do
push(key, personal_project) push(key, personal_project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey expect(json_response["status"]).to be_falsey
end end
end end
...@@ -147,7 +147,7 @@ describe API::API, api: true do ...@@ -147,7 +147,7 @@ describe API::API, api: true do
it do it do
pull(key, project) pull(key, project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_truthy expect(json_response["status"]).to be_truthy
end end
end end
...@@ -156,7 +156,7 @@ describe API::API, api: true do ...@@ -156,7 +156,7 @@ describe API::API, api: true do
it do it do
push(key, project) push(key, project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey expect(json_response["status"]).to be_falsey
end end
end end
...@@ -173,7 +173,7 @@ describe API::API, api: true do ...@@ -173,7 +173,7 @@ describe API::API, api: true do
it do it do
archive(key, project) archive(key, project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_truthy expect(json_response["status"]).to be_truthy
end end
end end
...@@ -182,7 +182,7 @@ describe API::API, api: true do ...@@ -182,7 +182,7 @@ describe API::API, api: true do
it do it do
archive(key, project) archive(key, project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey expect(json_response["status"]).to be_falsey
end end
end end
...@@ -192,7 +192,7 @@ describe API::API, api: true do ...@@ -192,7 +192,7 @@ describe API::API, api: true do
it do it do
pull(key, OpenStruct.new(path_with_namespace: 'gitlab/notexists')) pull(key, OpenStruct.new(path_with_namespace: 'gitlab/notexists'))
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey expect(json_response["status"]).to be_falsey
end end
end end
...@@ -201,7 +201,7 @@ describe API::API, api: true do ...@@ -201,7 +201,7 @@ describe API::API, api: true do
it do it do
pull(OpenStruct.new(id: 0), project) pull(OpenStruct.new(id: 0), project)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey expect(json_response["status"]).to be_falsey
end end
end end
......
This diff is collapsed.
...@@ -14,14 +14,14 @@ describe API::API, api: true do ...@@ -14,14 +14,14 @@ describe API::API, api: true do
context 'when unauthenticated' do context 'when unauthenticated' do
it 'should return authentication error' do it 'should return authentication error' do
get api("/keys/#{key.id}") get api("/keys/#{key.id}")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
context 'when authenticated' do context 'when authenticated' do
it 'should return 404 for non-existing key' do it 'should return 404 for non-existing key' do
get api('/keys/999999', admin) get api('/keys/999999', admin)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
end end
...@@ -29,7 +29,7 @@ describe API::API, api: true do ...@@ -29,7 +29,7 @@ describe API::API, api: true do
user.keys << key user.keys << key
user.save user.save
get api("/keys/#{key.id}", admin) get api("/keys/#{key.id}", admin)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['title']).to eq(key.title) expect(json_response['title']).to eq(key.title)
expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['id']).to eq(user.id)
expect(json_response['user']['username']).to eq(user.username) expect(json_response['user']['username']).to eq(user.username)
......
This diff is collapsed.
...@@ -23,7 +23,7 @@ describe API::Licenses, api: true do ...@@ -23,7 +23,7 @@ describe API::Licenses, api: true do
it 'returns a list of available license templates' do it 'returns a list of available license templates' do
get api('/licenses') get api('/licenses')
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(15) expect(json_response.size).to eq(15)
expect(json_response.map { |l| l['key'] }).to include('agpl-3.0') expect(json_response.map { |l| l['key'] }).to include('agpl-3.0')
...@@ -34,7 +34,7 @@ describe API::Licenses, api: true do ...@@ -34,7 +34,7 @@ describe API::Licenses, api: true do
it 'returns a list of available popular license templates' do it 'returns a list of available popular license templates' do
get api('/licenses?popular=1') get api('/licenses?popular=1')
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(3) expect(json_response.size).to eq(3)
expect(json_response.map { |l| l['key'] }).to include('apache-2.0') expect(json_response.map { |l| l['key'] }).to include('apache-2.0')
...@@ -116,7 +116,7 @@ describe API::Licenses, api: true do ...@@ -116,7 +116,7 @@ describe API::Licenses, api: true do
let(:license_type) { 'muth-over9000' } let(:license_type) { 'muth-over9000' }
it 'returns a 404' do it 'returns a 404' do
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
end end
......
This diff is collapsed.
...@@ -12,20 +12,20 @@ describe API::API, api: true do ...@@ -12,20 +12,20 @@ describe API::API, api: true do
describe 'GET /projects/:id/milestones' do describe 'GET /projects/:id/milestones' do
it 'should return project milestones' do it 'should return project milestones' do
get api("/projects/#{project.id}/milestones", user) get api("/projects/#{project.id}/milestones", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(milestone.title) expect(json_response.first['title']).to eq(milestone.title)
end end
it 'should return a 401 error if user not authenticated' do it 'should return a 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones") get api("/projects/#{project.id}/milestones")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
it 'returns an array of active milestones' do it 'returns an array of active milestones' do
get api("/projects/#{project.id}/milestones?state=active", user) get api("/projects/#{project.id}/milestones?state=active", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
expect(json_response.first['id']).to eq(milestone.id) expect(json_response.first['id']).to eq(milestone.id)
...@@ -34,7 +34,7 @@ describe API::API, api: true do ...@@ -34,7 +34,7 @@ describe API::API, api: true do
it 'returns an array of closed milestones' do it 'returns an array of closed milestones' do
get api("/projects/#{project.id}/milestones?state=closed", user) get api("/projects/#{project.id}/milestones?state=closed", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
expect(json_response.first['id']).to eq(closed_milestone.id) expect(json_response.first['id']).to eq(closed_milestone.id)
...@@ -44,7 +44,7 @@ describe API::API, api: true do ...@@ -44,7 +44,7 @@ describe API::API, api: true do
describe 'GET /projects/:id/milestones/:milestone_id' do describe 'GET /projects/:id/milestones/:milestone_id' do
it 'should return a project milestone by id' do it 'should return a project milestone by id' do
get api("/projects/#{project.id}/milestones/#{milestone.id}", user) get api("/projects/#{project.id}/milestones/#{milestone.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['title']).to eq(milestone.title) expect(json_response['title']).to eq(milestone.title)
expect(json_response['iid']).to eq(milestone.iid) expect(json_response['iid']).to eq(milestone.iid)
end end
...@@ -60,19 +60,19 @@ describe API::API, api: true do ...@@ -60,19 +60,19 @@ describe API::API, api: true do
it 'should return 401 error if user not authenticated' do it 'should return 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones/#{milestone.id}") get api("/projects/#{project.id}/milestones/#{milestone.id}")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
it 'should return a 404 error if milestone id not found' do it 'should return a 404 error if milestone id not found' do
get api("/projects/#{project.id}/milestones/1234", user) get api("/projects/#{project.id}/milestones/1234", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
describe 'POST /projects/:id/milestones' do describe 'POST /projects/:id/milestones' do
it 'should create a new project milestone' do it 'should create a new project milestone' do
post api("/projects/#{project.id}/milestones", user), title: 'new milestone' post api("/projects/#{project.id}/milestones", user), title: 'new milestone'
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['title']).to eq('new milestone') expect(json_response['title']).to eq('new milestone')
expect(json_response['description']).to be_nil expect(json_response['description']).to be_nil
end end
...@@ -80,14 +80,14 @@ describe API::API, api: true do ...@@ -80,14 +80,14 @@ describe API::API, api: true do
it 'should create a new project milestone with description and due date' do it 'should create a new project milestone with description and due date' do
post api("/projects/#{project.id}/milestones", user), post api("/projects/#{project.id}/milestones", user),
title: 'new milestone', description: 'release', due_date: '2013-03-02' title: 'new milestone', description: 'release', due_date: '2013-03-02'
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['description']).to eq('release') expect(json_response['description']).to eq('release')
expect(json_response['due_date']).to eq('2013-03-02') expect(json_response['due_date']).to eq('2013-03-02')
end end
it 'should return a 400 error if title is missing' do it 'should return a 400 error if title is missing' do
post api("/projects/#{project.id}/milestones", user) post api("/projects/#{project.id}/milestones", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
end end
...@@ -95,14 +95,14 @@ describe API::API, api: true do ...@@ -95,14 +95,14 @@ describe API::API, api: true do
it 'should update a project milestone' do it 'should update a project milestone' do
put api("/projects/#{project.id}/milestones/#{milestone.id}", user), put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
title: 'updated title' title: 'updated title'
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['title']).to eq('updated title') expect(json_response['title']).to eq('updated title')
end end
it 'should return a 404 error if milestone id not found' do it 'should return a 404 error if milestone id not found' do
put api("/projects/#{project.id}/milestones/1234", user), put api("/projects/#{project.id}/milestones/1234", user),
title: 'updated title' title: 'updated title'
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -110,7 +110,7 @@ describe API::API, api: true do ...@@ -110,7 +110,7 @@ describe API::API, api: true do
it 'should update a project milestone' do it 'should update a project milestone' do
put api("/projects/#{project.id}/milestones/#{milestone.id}", user), put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
state_event: 'close' state_event: 'close'
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['state']).to eq('closed') expect(json_response['state']).to eq('closed')
end end
...@@ -131,14 +131,14 @@ describe API::API, api: true do ...@@ -131,14 +131,14 @@ describe API::API, api: true do
end end
it 'should return project issues for a particular milestone' do it 'should return project issues for a particular milestone' do
get api("/projects/#{project.id}/milestones/#{milestone.id}/issues", user) get api("/projects/#{project.id}/milestones/#{milestone.id}/issues", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['milestone']['title']).to eq(milestone.title) expect(json_response.first['milestone']['title']).to eq(milestone.title)
end end
it 'should return a 401 error if user not authenticated' do it 'should return a 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones/#{milestone.id}/issues") get api("/projects/#{project.id}/milestones/#{milestone.id}/issues")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
describe 'confidential issues' do describe 'confidential issues' do
...@@ -155,7 +155,7 @@ describe API::API, api: true do ...@@ -155,7 +155,7 @@ describe API::API, api: true do
it 'returns confidential issues to team members' do it 'returns confidential issues to team members' do
get api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", user) get api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(2) expect(json_response.size).to eq(2)
expect(json_response.map { |issue| issue['id'] }).to include(issue.id, confidential_issue.id) expect(json_response.map { |issue| issue['id'] }).to include(issue.id, confidential_issue.id)
...@@ -167,7 +167,7 @@ describe API::API, api: true do ...@@ -167,7 +167,7 @@ describe API::API, api: true do
get api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", member) get api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", member)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
expect(json_response.map { |issue| issue['id'] }).to include(issue.id) expect(json_response.map { |issue| issue['id'] }).to include(issue.id)
...@@ -176,7 +176,7 @@ describe API::API, api: true do ...@@ -176,7 +176,7 @@ describe API::API, api: true do
it 'does not return confidential issues to regular users' do it 'does not return confidential issues to regular users' do
get api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", create(:user)) get api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", create(:user))
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
expect(json_response.map { |issue| issue['id'] }).to include(issue.id) expect(json_response.map { |issue| issue['id'] }).to include(issue.id)
......
...@@ -11,14 +11,14 @@ describe API::API, api: true do ...@@ -11,14 +11,14 @@ describe API::API, api: true do
context "when unauthenticated" do context "when unauthenticated" do
it "should return authentication error" do it "should return authentication error" do
get api("/namespaces") get api("/namespaces")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
context "when authenticated as admin" do context "when authenticated as admin" do
it "admin: should return an array of all namespaces" do it "admin: should return an array of all namespaces" do
get api("/namespaces", admin) get api("/namespaces", admin)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(Namespace.count) expect(json_response.length).to eq(Namespace.count)
...@@ -26,7 +26,7 @@ describe API::API, api: true do ...@@ -26,7 +26,7 @@ describe API::API, api: true do
it "admin: should return an array of matched namespaces" do it "admin: should return an array of matched namespaces" do
get api("/namespaces?search=#{group1.name}", admin) get api("/namespaces?search=#{group1.name}", admin)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -36,7 +36,7 @@ describe API::API, api: true do ...@@ -36,7 +36,7 @@ describe API::API, api: true do
context "when authenticated as a regular user" do context "when authenticated as a regular user" do
it "user: should return an array of namespaces" do it "user: should return an array of namespaces" do
get api("/namespaces", user) get api("/namespaces", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
...@@ -44,7 +44,7 @@ describe API::API, api: true do ...@@ -44,7 +44,7 @@ describe API::API, api: true do
it "admin: should return an array of matched namespaces" do it "admin: should return an array of matched namespaces" do
get api("/namespaces?search=#{user.username}", user) get api("/namespaces?search=#{user.username}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
......
This diff is collapsed.
...@@ -22,7 +22,7 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -22,7 +22,7 @@ describe API::API, 'ProjectHooks', api: true do
context "authorized user" do context "authorized user" do
it "should return project hooks" do it "should return project hooks" do
get api("/projects/#{project.id}/hooks", user) get api("/projects/#{project.id}/hooks", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.count).to eq(1) expect(json_response.count).to eq(1)
...@@ -40,7 +40,7 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -40,7 +40,7 @@ describe API::API, 'ProjectHooks', api: true do
context "unauthorized user" do context "unauthorized user" do
it "should not access project hooks" do it "should not access project hooks" do
get api("/projects/#{project.id}/hooks", user3) get api("/projects/#{project.id}/hooks", user3)
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
end end
...@@ -49,7 +49,7 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -49,7 +49,7 @@ describe API::API, 'ProjectHooks', api: true do
context "authorized user" do context "authorized user" do
it "should return a project hook" do it "should return a project hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user) get api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['url']).to eq(hook.url) expect(json_response['url']).to eq(hook.url)
expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['issues_events']).to eq(hook.issues_events)
expect(json_response['push_events']).to eq(hook.push_events) expect(json_response['push_events']).to eq(hook.push_events)
...@@ -61,20 +61,20 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -61,20 +61,20 @@ describe API::API, 'ProjectHooks', api: true do
it "should return a 404 error if hook id is not available" do it "should return a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user) get api("/projects/#{project.id}/hooks/1234", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
context "unauthorized user" do context "unauthorized user" do
it "should not access an existing hook" do it "should not access an existing hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user3) get api("/projects/#{project.id}/hooks/#{hook.id}", user3)
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
it "should return a 404 error if hook id is not available" do it "should return a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user) get api("/projects/#{project.id}/hooks/1234", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -83,7 +83,7 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -83,7 +83,7 @@ describe API::API, 'ProjectHooks', api: true do
expect do expect do
post api("/projects/#{project.id}/hooks", user), url: "http://example.com", issues_events: true post api("/projects/#{project.id}/hooks", user), url: "http://example.com", issues_events: true
end.to change {project.hooks.count}.by(1) end.to change {project.hooks.count}.by(1)
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['url']).to eq('http://example.com') expect(json_response['url']).to eq('http://example.com')
expect(json_response['issues_events']).to eq(true) expect(json_response['issues_events']).to eq(true)
expect(json_response['push_events']).to eq(true) expect(json_response['push_events']).to eq(true)
...@@ -96,12 +96,12 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -96,12 +96,12 @@ describe API::API, 'ProjectHooks', api: true do
it "should return a 400 error if url not given" do it "should return a 400 error if url not given" do
post api("/projects/#{project.id}/hooks", user) post api("/projects/#{project.id}/hooks", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 422 error if url not valid" do it "should return a 422 error if url not valid" do
post api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com" post api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com"
expect(response.status).to eq(422) expect(response).to have_http_status(422)
end end
end end
...@@ -109,7 +109,7 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -109,7 +109,7 @@ describe API::API, 'ProjectHooks', api: true do
it "should update an existing project hook" do it "should update an existing project hook" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), put api("/projects/#{project.id}/hooks/#{hook.id}", user),
url: 'http://example.org', push_events: false url: 'http://example.org', push_events: false
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['url']).to eq('http://example.org') expect(json_response['url']).to eq('http://example.org')
expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['issues_events']).to eq(hook.issues_events)
expect(json_response['push_events']).to eq(false) expect(json_response['push_events']).to eq(false)
...@@ -121,17 +121,17 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -121,17 +121,17 @@ describe API::API, 'ProjectHooks', api: true do
it "should return 404 error if hook id not found" do it "should return 404 error if hook id not found" do
put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org' put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org'
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "should return 400 error if url is not given" do it "should return 400 error if url is not given" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user) put api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 422 error if url is not valid" do it "should return a 422 error if url is not valid" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com' put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com'
expect(response.status).to eq(422) expect(response).to have_http_status(422)
end end
end end
...@@ -140,22 +140,22 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -140,22 +140,22 @@ describe API::API, 'ProjectHooks', api: true do
expect do expect do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user) delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
end.to change {project.hooks.count}.by(-1) end.to change {project.hooks.count}.by(-1)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it "should return success when deleting hook" do it "should return success when deleting hook" do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user) delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it "should return a 404 error when deleting non existent hook" do it "should return a 404 error when deleting non existent hook" do
delete api("/projects/#{project.id}/hooks/42", user) delete api("/projects/#{project.id}/hooks/42", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "should return a 405 error if hook id not given" do it "should return a 405 error if hook id not given" do
delete api("/projects/#{project.id}/hooks", user) delete api("/projects/#{project.id}/hooks", user)
expect(response.status).to eq(405) expect(response).to have_http_status(405)
end end
it "shold return a 404 if a user attempts to delete project hooks he/she does not own" do it "shold return a 404 if a user attempts to delete project hooks he/she does not own" do
...@@ -164,7 +164,7 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -164,7 +164,7 @@ describe API::API, 'ProjectHooks', api: true do
other_project.team << [test_user, :master] other_project.team << [test_user, :master]
delete api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user) delete api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
expect(WebHook.exists?(hook.id)).to be_truthy expect(WebHook.exists?(hook.id)).to be_truthy
end end
end end
......
...@@ -15,7 +15,7 @@ describe API::API, api: true do ...@@ -15,7 +15,7 @@ describe API::API, api: true do
it "should return project team members" do it "should return project team members" do
get api("/projects/#{project.id}/members", user) get api("/projects/#{project.id}/members", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.count).to eq(2) expect(json_response.count).to eq(2)
expect(json_response.map { |u| u['username'] }).to include user.username expect(json_response.map { |u| u['username'] }).to include user.username
...@@ -23,7 +23,7 @@ describe API::API, api: true do ...@@ -23,7 +23,7 @@ describe API::API, api: true do
it "finds team members with query string" do it "finds team members with query string" do
get api("/projects/#{project.id}/members", user), query: user.username get api("/projects/#{project.id}/members", user), query: user.username
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.count).to eq(1) expect(json_response.count).to eq(1)
expect(json_response.first['username']).to eq(user.username) expect(json_response.first['username']).to eq(user.username)
...@@ -31,7 +31,7 @@ describe API::API, api: true do ...@@ -31,7 +31,7 @@ describe API::API, api: true do
it "should return a 404 error if id not found" do it "should return a 404 error if id not found" do
get api("/projects/9999/members", user) get api("/projects/9999/members", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -40,14 +40,14 @@ describe API::API, api: true do ...@@ -40,14 +40,14 @@ describe API::API, api: true do
it "should return project team member" do it "should return project team member" do
get api("/projects/#{project.id}/members/#{user.id}", user) get api("/projects/#{project.id}/members/#{user.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['username']).to eq(user.username) expect(json_response['username']).to eq(user.username)
expect(json_response['access_level']).to eq(ProjectMember::MASTER) expect(json_response['access_level']).to eq(ProjectMember::MASTER)
end end
it "should return a 404 error if user id not found" do it "should return a 404 error if user id not found" do
get api("/projects/#{project.id}/members/1234", user) get api("/projects/#{project.id}/members/1234", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
...@@ -57,7 +57,7 @@ describe API::API, api: true do ...@@ -57,7 +57,7 @@ describe API::API, api: true do
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER
end.to change { ProjectMember.count }.by(1) end.to change { ProjectMember.count }.by(1)
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['username']).to eq(user2.username) expect(json_response['username']).to eq(user2.username)
expect(json_response['access_level']).to eq(ProjectMember::DEVELOPER) expect(json_response['access_level']).to eq(ProjectMember::DEVELOPER)
end end
...@@ -70,24 +70,24 @@ describe API::API, api: true do ...@@ -70,24 +70,24 @@ describe API::API, api: true do
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER
end.not_to change { ProjectMember.count } end.not_to change { ProjectMember.count }
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['username']).to eq(user2.username) expect(json_response['username']).to eq(user2.username)
expect(json_response['access_level']).to eq(ProjectMember::DEVELOPER) expect(json_response['access_level']).to eq(ProjectMember::DEVELOPER)
end end
it "should return a 400 error when user id is not given" do it "should return a 400 error when user id is not given" do
post api("/projects/#{project.id}/members", user), access_level: ProjectMember::MASTER post api("/projects/#{project.id}/members", user), access_level: ProjectMember::MASTER
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 400 error when access level is not given" do it "should return a 400 error when access level is not given" do
post api("/projects/#{project.id}/members", user), user_id: user2.id post api("/projects/#{project.id}/members", user), user_id: user2.id
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 422 error when access level is not known" do it "should return a 422 error when access level is not known" do
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: 1234 post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: 1234
expect(response.status).to eq(422) expect(response).to have_http_status(422)
end end
end end
...@@ -96,24 +96,24 @@ describe API::API, api: true do ...@@ -96,24 +96,24 @@ describe API::API, api: true do
it "should update project team member" do it "should update project team member" do
put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: ProjectMember::MASTER put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: ProjectMember::MASTER
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['username']).to eq(user3.username) expect(json_response['username']).to eq(user3.username)
expect(json_response['access_level']).to eq(ProjectMember::MASTER) expect(json_response['access_level']).to eq(ProjectMember::MASTER)
end end
it "should return a 404 error if user_id is not found" do it "should return a 404 error if user_id is not found" do
put api("/projects/#{project.id}/members/1234", user), access_level: ProjectMember::MASTER put api("/projects/#{project.id}/members/1234", user), access_level: ProjectMember::MASTER
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "should return a 400 error when access level is not given" do it "should return a 400 error when access level is not given" do
put api("/projects/#{project.id}/members/#{user3.id}", user) put api("/projects/#{project.id}/members/#{user3.id}", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
it "should return a 422 error when access level is not known" do it "should return a 422 error when access level is not known" do
put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: 123 put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: 123
expect(response.status).to eq(422) expect(response).to have_http_status(422)
end end
end end
...@@ -134,20 +134,20 @@ describe API::API, api: true do ...@@ -134,20 +134,20 @@ describe API::API, api: true do
expect do expect do
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
end.not_to change { ProjectMember.count } end.not_to change { ProjectMember.count }
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it "should return 200 if team member already removed" do it "should return 200 if team member already removed" do
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it "should return 200 OK when the user was not member" do it "should return 200 OK when the user was not member" do
expect do expect do
delete api("/projects/#{project.id}/members/1000000", user) delete api("/projects/#{project.id}/members/1000000", user)
end.to change { ProjectMember.count }.by(0) end.to change { ProjectMember.count }.by(0)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['id']).to eq(1000000) expect(json_response['id']).to eq(1000000)
expect(json_response['message']).to eq('Access revoked') expect(json_response['message']).to eq('Access revoked')
end end
...@@ -158,7 +158,7 @@ describe API::API, api: true do ...@@ -158,7 +158,7 @@ describe API::API, api: true do
delete api("/projects/#{project.id}/members/#{user3.id}", user3) delete api("/projects/#{project.id}/members/#{user3.id}", user3)
end.to change { ProjectMember.count }.by(-1) end.to change { ProjectMember.count }.by(-1)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['id']).to eq(project_member2.id) expect(json_response['id']).to eq(project_member2.id)
end end
end end
......
...@@ -27,7 +27,7 @@ describe API::API, api: true do ...@@ -27,7 +27,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/snippets/", user) get api("/projects/#{project.id}/snippets/", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response.size).to eq(3) expect(json_response.size).to eq(3)
expect(json_response.map{ |snippet| snippet['id']} ).to include(public_snippet.id, internal_snippet.id, private_snippet.id) expect(json_response.map{ |snippet| snippet['id']} ).to include(public_snippet.id, internal_snippet.id, private_snippet.id)
end end
...@@ -38,7 +38,7 @@ describe API::API, api: true do ...@@ -38,7 +38,7 @@ describe API::API, api: true do
create(:project_snippet, :private, project: project) create(:project_snippet, :private, project: project)
get api("/projects/#{project.id}/snippets/", user) get api("/projects/#{project.id}/snippets/", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response.size).to eq(0) expect(json_response.size).to eq(0)
end end
end end
...@@ -56,7 +56,7 @@ describe API::API, api: true do ...@@ -56,7 +56,7 @@ describe API::API, api: true do
post api("/projects/#{project.id}/snippets/", admin), params post api("/projects/#{project.id}/snippets/", admin), params
expect(response.status).to eq(201) expect(response).to have_http_status(201)
snippet = ProjectSnippet.find(json_response['id']) snippet = ProjectSnippet.find(json_response['id'])
expect(snippet.content).to eq(params[:code]) expect(snippet.content).to eq(params[:code])
expect(snippet.title).to eq(params[:title]) expect(snippet.title).to eq(params[:title])
...@@ -73,7 +73,7 @@ describe API::API, api: true do ...@@ -73,7 +73,7 @@ describe API::API, api: true do
put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), code: new_content put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), code: new_content
expect(response.status).to eq(200) expect(response).to have_http_status(200)
snippet.reload snippet.reload
expect(snippet.content).to eq(new_content) expect(snippet.content).to eq(new_content)
end end
...@@ -86,7 +86,7 @@ describe API::API, api: true do ...@@ -86,7 +86,7 @@ describe API::API, api: true do
delete api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin) delete api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
...@@ -97,7 +97,7 @@ describe API::API, api: true do ...@@ -97,7 +97,7 @@ describe API::API, api: true do
get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin) get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(response.content_type).to eq 'text/plain' expect(response.content_type).to eq 'text/plain'
expect(response.body).to eq(snippet.content) expect(response.body).to eq(snippet.content)
end end
......
This diff is collapsed.
...@@ -18,7 +18,7 @@ describe API::API, api: true do ...@@ -18,7 +18,7 @@ describe API::API, api: true do
it "should return project commits" do it "should return project commits" do
get api("/projects/#{project.id}/repository/tree", user) get api("/projects/#{project.id}/repository/tree", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['name']).to eq('encoding') expect(json_response.first['name']).to eq('encoding')
...@@ -28,7 +28,7 @@ describe API::API, api: true do ...@@ -28,7 +28,7 @@ describe API::API, api: true do
it 'should return a 404 for unknown ref' do it 'should return a 404 for unknown ref' do
get api("/projects/#{project.id}/repository/tree?ref_name=foo", user) get api("/projects/#{project.id}/repository/tree?ref_name=foo", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
expect(json_response).to be_an Object expect(json_response).to be_an Object
json_response['message'] == '404 Tree Not Found' json_response['message'] == '404 Tree Not Found'
...@@ -38,7 +38,7 @@ describe API::API, api: true do ...@@ -38,7 +38,7 @@ describe API::API, api: true do
context "unauthorized user" do context "unauthorized user" do
it "should not return project commits" do it "should not return project commits" do
get api("/projects/#{project.id}/repository/tree") get api("/projects/#{project.id}/repository/tree")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
end end
end end
...@@ -46,41 +46,41 @@ describe API::API, api: true do ...@@ -46,41 +46,41 @@ describe API::API, api: true do
describe "GET /projects/:id/repository/blobs/:sha" do describe "GET /projects/:id/repository/blobs/:sha" do
it "should get the raw file contents" do it "should get the raw file contents" do
get api("/projects/#{project.id}/repository/blobs/master?filepath=README.md", user) get api("/projects/#{project.id}/repository/blobs/master?filepath=README.md", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it "should return 404 for invalid branch_name" do it "should return 404 for invalid branch_name" do
get api("/projects/#{project.id}/repository/blobs/invalid_branch_name?filepath=README.md", user) get api("/projects/#{project.id}/repository/blobs/invalid_branch_name?filepath=README.md", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "should return 404 for invalid file" do it "should return 404 for invalid file" do
get api("/projects/#{project.id}/repository/blobs/master?filepath=README.invalid", user) get api("/projects/#{project.id}/repository/blobs/master?filepath=README.invalid", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
it "should return a 400 error if filepath is missing" do it "should return a 400 error if filepath is missing" do
get api("/projects/#{project.id}/repository/blobs/master", user) get api("/projects/#{project.id}/repository/blobs/master", user)
expect(response.status).to eq(400) expect(response).to have_http_status(400)
end end
end end
describe "GET /projects/:id/repository/commits/:sha/blob" do describe "GET /projects/:id/repository/commits/:sha/blob" do
it "should get the raw file contents" do it "should get the raw file contents" do
get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.md", user) get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.md", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
end end
describe "GET /projects/:id/repository/raw_blobs/:sha" do describe "GET /projects/:id/repository/raw_blobs/:sha" do
it "should get the raw file contents" do it "should get the raw file contents" do
get api("/projects/#{project.id}/repository/raw_blobs/#{sample_blob.oid}", user) get api("/projects/#{project.id}/repository/raw_blobs/#{sample_blob.oid}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it 'should return a 404 for unknown blob' do it 'should return a 404 for unknown blob' do
get api("/projects/#{project.id}/repository/raw_blobs/123456", user) get api("/projects/#{project.id}/repository/raw_blobs/123456", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
expect(json_response).to be_an Object expect(json_response).to be_an Object
json_response['message'] == '404 Blob Not Found' json_response['message'] == '404 Blob Not Found'
...@@ -91,7 +91,7 @@ describe API::API, api: true do ...@@ -91,7 +91,7 @@ describe API::API, api: true do
it "should get the archive" do it "should get the archive" do
get api("/projects/#{project.id}/repository/archive", user) get api("/projects/#{project.id}/repository/archive", user)
repo_name = project.repository.name.gsub("\.git", "") repo_name = project.repository.name.gsub("\.git", "")
expect(response.status).to eq(200) expect(response).to have_http_status(200)
type, params = workhorse_send_data type, params = workhorse_send_data
expect(type).to eq('git-archive') expect(type).to eq('git-archive')
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.tar.gz/) expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.tar.gz/)
...@@ -100,7 +100,7 @@ describe API::API, api: true do ...@@ -100,7 +100,7 @@ describe API::API, api: true do
it "should get the archive.zip" do it "should get the archive.zip" do
get api("/projects/#{project.id}/repository/archive.zip", user) get api("/projects/#{project.id}/repository/archive.zip", user)
repo_name = project.repository.name.gsub("\.git", "") repo_name = project.repository.name.gsub("\.git", "")
expect(response.status).to eq(200) expect(response).to have_http_status(200)
type, params = workhorse_send_data type, params = workhorse_send_data
expect(type).to eq('git-archive') expect(type).to eq('git-archive')
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.zip/) expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.zip/)
...@@ -109,7 +109,7 @@ describe API::API, api: true do ...@@ -109,7 +109,7 @@ describe API::API, api: true do
it "should get the archive.tar.bz2" do it "should get the archive.tar.bz2" do
get api("/projects/#{project.id}/repository/archive.tar.bz2", user) get api("/projects/#{project.id}/repository/archive.tar.bz2", user)
repo_name = project.repository.name.gsub("\.git", "") repo_name = project.repository.name.gsub("\.git", "")
expect(response.status).to eq(200) expect(response).to have_http_status(200)
type, params = workhorse_send_data type, params = workhorse_send_data
expect(type).to eq('git-archive') expect(type).to eq('git-archive')
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.tar.bz2/) expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.tar.bz2/)
...@@ -117,28 +117,28 @@ describe API::API, api: true do ...@@ -117,28 +117,28 @@ describe API::API, api: true do
it "should return 404 for invalid sha" do it "should return 404 for invalid sha" do
get api("/projects/#{project.id}/repository/archive/?sha=xxx", user) get api("/projects/#{project.id}/repository/archive/?sha=xxx", user)
expect(response.status).to eq(404) expect(response).to have_http_status(404)
end end
end end
describe 'GET /projects/:id/repository/compare' do describe 'GET /projects/:id/repository/compare' do
it "should compare branches" do it "should compare branches" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'feature' get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'feature'
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['commits']).to be_present expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present expect(json_response['diffs']).to be_present
end end
it "should compare tags" do it "should compare tags" do
get api("/projects/#{project.id}/repository/compare", user), from: 'v1.0.0', to: 'v1.1.0' get api("/projects/#{project.id}/repository/compare", user), from: 'v1.0.0', to: 'v1.1.0'
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['commits']).to be_present expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present expect(json_response['diffs']).to be_present
end end
it "should compare commits" do it "should compare commits" do
get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.id, to: sample_commit.parent_id get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.id, to: sample_commit.parent_id
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['commits']).to be_empty expect(json_response['commits']).to be_empty
expect(json_response['diffs']).to be_empty expect(json_response['diffs']).to be_empty
expect(json_response['compare_same_ref']).to be_falsey expect(json_response['compare_same_ref']).to be_falsey
...@@ -146,14 +146,14 @@ describe API::API, api: true do ...@@ -146,14 +146,14 @@ describe API::API, api: true do
it "should compare commits in reverse order" do it "should compare commits in reverse order" do
get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.parent_id, to: sample_commit.id get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.parent_id, to: sample_commit.id
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['commits']).to be_present expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present expect(json_response['diffs']).to be_present
end end
it "should compare same refs" do it "should compare same refs" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'master' get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'master'
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['commits']).to be_empty expect(json_response['commits']).to be_empty
expect(json_response['diffs']).to be_empty expect(json_response['diffs']).to be_empty
expect(json_response['compare_same_ref']).to be_truthy expect(json_response['compare_same_ref']).to be_truthy
...@@ -163,7 +163,7 @@ describe API::API, api: true do ...@@ -163,7 +163,7 @@ describe API::API, api: true do
describe 'GET /projects/:id/repository/contributors' do describe 'GET /projects/:id/repository/contributors' do
it 'should return valid data' do it 'should return valid data' do
get api("/projects/#{project.id}/repository/contributors", user) get api("/projects/#{project.id}/repository/contributors", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
contributor = json_response.first contributor = json_response.first
expect(contributor['email']).to eq('dmitriy.zaporozhets@gmail.com') expect(contributor['email']).to eq('dmitriy.zaporozhets@gmail.com')
......
This diff is collapsed.
...@@ -14,7 +14,7 @@ describe API::API, api: true do ...@@ -14,7 +14,7 @@ describe API::API, api: true do
it "should update #{service} settings" do it "should update #{service} settings" do
put api("/projects/#{project.id}/services/#{dashed_service}", user), service_attrs put api("/projects/#{project.id}/services/#{dashed_service}", user), service_attrs
expect(response.status).to eq(200) expect(response).to have_http_status(200)
end end
it "should return if required fields missing" do it "should return if required fields missing" do
...@@ -45,7 +45,7 @@ describe API::API, api: true do ...@@ -45,7 +45,7 @@ describe API::API, api: true do
it "should delete #{service}" do it "should delete #{service}" do
delete api("/projects/#{project.id}/services/#{dashed_service}", user) delete api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
project.send(service_method).reload project.send(service_method).reload
expect(project.send(service_method).activated?).to be_falsey expect(project.send(service_method).activated?).to be_falsey
end end
...@@ -64,20 +64,20 @@ describe API::API, api: true do ...@@ -64,20 +64,20 @@ describe API::API, api: true do
it 'should return authentication error when unauthenticated' do it 'should return authentication error when unauthenticated' do
get api("/projects/#{project.id}/services/#{dashed_service}") get api("/projects/#{project.id}/services/#{dashed_service}")
expect(response.status).to eq(401) expect(response).to have_http_status(401)
end end
it "should return all properties of service #{service} when authenticated as admin" do it "should return all properties of service #{service} when authenticated as admin" do
get api("/projects/#{project.id}/services/#{dashed_service}", admin) get api("/projects/#{project.id}/services/#{dashed_service}", admin)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list.map) expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list.map)
end end
it "should return properties of service #{service} other than passwords when authenticated as project owner" do it "should return properties of service #{service} other than passwords when authenticated as project owner" do
get api("/projects/#{project.id}/services/#{dashed_service}", user) get api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list_without_passwords) expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list_without_passwords)
end end
...@@ -85,7 +85,7 @@ describe API::API, api: true do ...@@ -85,7 +85,7 @@ describe API::API, api: true do
project.team << [user2, :developer] project.team << [user2, :developer]
get api("/projects/#{project.id}/services/#{dashed_service}", user2) get api("/projects/#{project.id}/services/#{dashed_service}", user2)
expect(response.status).to eq(403) expect(response).to have_http_status(403)
end end
end end
......
...@@ -9,7 +9,7 @@ describe API::API, api: true do ...@@ -9,7 +9,7 @@ describe API::API, api: true do
context "when valid password" do context "when valid password" do
it "should return private token" do it "should return private token" do
post api("/session"), email: user.email, password: '12345678' post api("/session"), email: user.email, password: '12345678'
expect(response.status).to eq(201) expect(response).to have_http_status(201)
expect(json_response['email']).to eq(user.email) expect(json_response['email']).to eq(user.email)
expect(json_response['private_token']).to eq(user.private_token) expect(json_response['private_token']).to eq(user.private_token)
...@@ -48,7 +48,7 @@ describe API::API, api: true do ...@@ -48,7 +48,7 @@ describe API::API, api: true do
context "when invalid password" do context "when invalid password" do
it "should return authentication error" do it "should return authentication error" do
post api("/session"), email: user.email, password: '123' post api("/session"), email: user.email, password: '123'
expect(response.status).to eq(401) expect(response).to have_http_status(401)
expect(json_response['email']).to be_nil expect(json_response['email']).to be_nil
expect(json_response['private_token']).to be_nil expect(json_response['private_token']).to be_nil
...@@ -58,7 +58,7 @@ describe API::API, api: true do ...@@ -58,7 +58,7 @@ describe API::API, api: true do
context "when empty password" do context "when empty password" do
it "should return authentication error" do it "should return authentication error" do
post api("/session"), email: user.email post api("/session"), email: user.email
expect(response.status).to eq(401) expect(response).to have_http_status(401)
expect(json_response['email']).to be_nil expect(json_response['email']).to be_nil
expect(json_response['private_token']).to be_nil expect(json_response['private_token']).to be_nil
...@@ -68,7 +68,7 @@ describe API::API, api: true do ...@@ -68,7 +68,7 @@ describe API::API, api: true do
context "when empty name" do context "when empty name" do
it "should return authentication error" do it "should return authentication error" do
post api("/session"), password: user.password post api("/session"), password: user.password
expect(response.status).to eq(401) expect(response).to have_http_status(401)
expect(json_response['email']).to be_nil expect(json_response['email']).to be_nil
expect(json_response['private_token']).to be_nil expect(json_response['private_token']).to be_nil
......
...@@ -10,7 +10,7 @@ describe API::API, 'Settings', api: true do ...@@ -10,7 +10,7 @@ describe API::API, 'Settings', api: true do
describe "GET /application/settings" do describe "GET /application/settings" do
it "should return application settings" do it "should return application settings" do
get api("/application/settings", admin) get api("/application/settings", admin)
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Hash expect(json_response).to be_an Hash
expect(json_response['default_projects_limit']).to eq(42) expect(json_response['default_projects_limit']).to eq(42)
expect(json_response['signin_enabled']).to be_truthy expect(json_response['signin_enabled']).to be_truthy
...@@ -21,7 +21,7 @@ describe API::API, 'Settings', api: true do ...@@ -21,7 +21,7 @@ describe API::API, 'Settings', api: true do
it "should update application settings" do it "should update application settings" do
put api("/application/settings", admin), put api("/application/settings", admin),
default_projects_limit: 3, signin_enabled: false default_projects_limit: 3, signin_enabled: false
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['default_projects_limit']).to eq(3) expect(json_response['default_projects_limit']).to eq(3)
expect(json_response['signin_enabled']).to be_falsey expect(json_response['signin_enabled']).to be_falsey
end end
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -22,7 +22,7 @@ describe API::Templates, api: true do ...@@ -22,7 +22,7 @@ describe API::Templates, api: true do
it 'returns a list of available gitignore templates' do it 'returns a list of available gitignore templates' do
get api('/gitignores') get api('/gitignores')
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to be > 15 expect(json_response.size).to be > 15
end end
...@@ -34,7 +34,7 @@ describe API::Templates, api: true do ...@@ -34,7 +34,7 @@ describe API::Templates, api: true do
it 'returns a list of available gitlab_ci_ymls' do it 'returns a list of available gitlab_ci_ymls' do
get api('/gitlab_ci_ymls') get api('/gitlab_ci_ymls')
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['name']).not_to be_nil expect(json_response.first['name']).not_to be_nil
end end
...@@ -45,7 +45,7 @@ describe API::Templates, api: true do ...@@ -45,7 +45,7 @@ describe API::Templates, api: true do
it 'adds a disclaimer on the top' do it 'adds a disclaimer on the top' do
get api('/gitlab_ci_ymls/Ruby') get api('/gitlab_ci_ymls/Ruby')
expect(response.status).to eq(200) expect(response).to have_http_status(200)
expect(json_response['content']).to start_with("# This file is a template,") expect(json_response['content']).to start_with("# This file is a template,")
end end
end end
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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