Commit 298e4ece authored by Robert Speicher's avatar Robert Speicher

Merge branch 'regex-find-replace-http-matcher' into 'master'

Use `have_http_status` matcher where possible

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