diff options
Diffstat (limited to 'spec/requests/api/v3/projects_spec.rb')
-rw-r--r-- | spec/requests/api/v3/projects_spec.rb | 225 |
1 files changed, 113 insertions, 112 deletions
diff --git a/spec/requests/api/v3/projects_spec.rb b/spec/requests/api/v3/projects_spec.rb index cae2c3118da..f62ad747c73 100644 --- a/spec/requests/api/v3/projects_spec.rb +++ b/spec/requests/api/v3/projects_spec.rb @@ -44,14 +44,14 @@ describe API::V3::Projects do context 'when unauthenticated' do it 'returns authentication error' do get v3_api('/projects') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated as regular user' do it 'returns an array of projects' do get v3_api('/projects', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(project.name) expect(json_response.first['owner']['username']).to eq(user.username) @@ -89,11 +89,12 @@ describe API::V3::Projects do path path_with_namespace star_count forks_count created_at last_activity_at + avatar_url ) get v3_api('/projects?simple=true', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first.keys).to match_array expected_keys end @@ -102,7 +103,7 @@ describe API::V3::Projects do context 'and using search' do it 'returns searched project' do get v3_api('/projects', user), { search: project.name } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) end @@ -111,21 +112,21 @@ describe API::V3::Projects do context 'and using the visibility filter' do it 'filters based on private visibility param' do get v3_api('/projects', user), { visibility: 'private' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::PRIVATE).count) end it 'filters based on internal visibility param' do get v3_api('/projects', user), { visibility: 'internal' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::INTERNAL).count) end it 'filters based on public visibility param' do get v3_api('/projects', user), { visibility: 'public' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::PUBLIC).count) end @@ -137,7 +138,7 @@ describe API::V3::Projects do it 'returns archived project' do get v3_api('/projects?archived=true', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(archived_project.id) @@ -146,7 +147,7 @@ describe API::V3::Projects do it 'returns non-archived project' do get v3_api('/projects?archived=false', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(project.id) @@ -155,7 +156,7 @@ describe API::V3::Projects do it 'returns all project' do get v3_api('/projects', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) end @@ -169,7 +170,7 @@ describe API::V3::Projects do it 'returns the correct order when sorted by id' do get v3_api('/projects', user), { order_by: 'id', sort: 'desc' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['id']).to eq(project3.id) end @@ -183,21 +184,21 @@ describe API::V3::Projects do context 'when unauthenticated' do it 'returns authentication error' do get v3_api('/projects/all') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated as regular user' do it 'returns authentication error' do get v3_api('/projects/all', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'when authenticated as admin' do it 'returns an array of all projects' do get v3_api('/projects/all', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response).to satisfy do |response| @@ -212,7 +213,7 @@ describe API::V3::Projects do it "does not include statistics by default" do get v3_api('/projects/all', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first).not_to include('statistics') end @@ -220,7 +221,7 @@ describe API::V3::Projects do it "includes statistics if requested" do get v3_api('/projects/all', admin), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first).to include 'statistics' end @@ -236,14 +237,14 @@ describe API::V3::Projects do context 'when unauthenticated' do it 'returns authentication error' do get v3_api('/projects/owned') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated as project owner' do it 'returns an array of projects the user owns' do get v3_api('/projects/owned', user4) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(project4.name) expect(json_response.first['owner']['username']).to eq(user4.username) @@ -252,7 +253,7 @@ describe API::V3::Projects do it "does not include statistics by default" do get v3_api('/projects/owned', user4) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first).not_to include('statistics') end @@ -270,7 +271,7 @@ describe API::V3::Projects do get v3_api('/projects/owned', user4), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['statistics']).to eq attributes.stringify_keys end @@ -282,7 +283,7 @@ describe API::V3::Projects do it 'returns the visible projects' do get v3_api('/projects/visible', current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(*projects.map(&:id)) end @@ -328,7 +329,7 @@ describe API::V3::Projects do it 'returns the starred projects viewable by the user' do get v3_api('/projects/starred', user3) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, public_project.id) end @@ -340,14 +341,14 @@ describe API::V3::Projects do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) expect { post v3_api('/projects', user2), name: 'foo' } .to change {Project.count}.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'creates new project without path but with name and returns 201' do expect { post v3_api('/projects', user), name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -358,7 +359,7 @@ describe API::V3::Projects do it 'creates new project without name but with path and returns 201' do expect { post v3_api('/projects', user), path: 'foo_project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -369,7 +370,7 @@ describe API::V3::Projects do it 'creates new project name and path and returns 201' do expect { post v3_api('/projects', user), path: 'foo-Project', name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -380,12 +381,12 @@ describe API::V3::Projects do it 'creates last project before reaching project limit' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1) post v3_api('/projects', user2), name: 'foo' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'does not create new project without name or path and return 400' do expect { post v3_api('/projects', user) }.not_to change { Project.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "assigns attributes to project" do @@ -500,7 +501,7 @@ describe API::V3::Projects do it 'does not allow a non-admin to use a restricted visibility level' do post v3_api('/projects', user), @project - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['visibility_level'].first).to( match('restricted by your GitLab administrator') ) @@ -522,14 +523,14 @@ describe API::V3::Projects do it 'should create new project without path and return 201' do expect { post v3_api("/projects/user/#{user.id}", admin), name: 'foo' }.to change {Project.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'responds with 400 on failure and not project' do expect { post v3_api("/projects/user/#{user.id}", admin) } .not_to change { Project.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end @@ -543,7 +544,7 @@ describe API::V3::Projects do post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project.each_pair do |k, v| next if %i[has_external_issue_tracker path].include?(k) expect(json_response[k.to_s]).to eq(v) @@ -554,7 +555,7 @@ describe API::V3::Projects do project = attributes_for(:project, :public) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_truthy expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC) end @@ -563,7 +564,7 @@ describe API::V3::Projects do project = attributes_for(:project, { public: true }) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_truthy expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC) end @@ -572,7 +573,7 @@ describe API::V3::Projects do project = attributes_for(:project, :internal) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_falsey expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL) end @@ -580,7 +581,7 @@ describe API::V3::Projects do it 'sets a project as internal overriding :public' do project = attributes_for(:project, :internal, { public: true }) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_falsey expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL) end @@ -634,7 +635,7 @@ describe API::V3::Projects do it "uploads the file and returns its info" do post v3_api("/projects/#{project.id}/uploads", user), file: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png") - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['alt']).to eq("dk") expect(json_response['url']).to start_with("/uploads/") expect(json_response['url']).to end_with("/dk.png") @@ -648,7 +649,7 @@ describe API::V3::Projects do get v3_api("/projects/#{public_project.id}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(public_project.id) expect(json_response['description']).to eq(public_project.description) expect(json_response['default_branch']).to eq(public_project.default_branch) @@ -667,7 +668,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(project.id) expect(json_response['description']).to eq(project.description) expect(json_response['default_branch']).to eq(project.default_branch) @@ -709,20 +710,20 @@ describe API::V3::Projects do it 'returns a project by path name' do get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(project.name) end it 'returns a 404 error if not found' do get v3_api('/projects/42', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end it 'returns a 404 error if user is not a member' do other_user = create(:user) get v3_api("/projects/#{project.id}", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'handles users with dots' do @@ -730,14 +731,14 @@ describe API::V3::Projects do project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace) get v3_api("/projects/#{CGI.escape(project.full_path)}", dot_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(project.name) end it 'exposes namespace fields' do get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['namespace']).to eq({ 'id' => user.namespace.id, 'name' => user.namespace.name, @@ -755,7 +756,7 @@ describe API::V3::Projects do it 'contains permission information' do get v3_api("/projects", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.first['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MASTER) expect(json_response.first['permissions']['group_access']).to be_nil @@ -767,7 +768,7 @@ describe API::V3::Projects do project.team << [user, :master] get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MASTER) expect(json_response['permissions']['group_access']).to be_nil @@ -782,7 +783,7 @@ describe API::V3::Projects do it 'sets the owner and return 200' do get v3_api("/projects/#{project2.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['group_access']['access_level']) .to eq(Gitlab::Access::OWNER) @@ -802,7 +803,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/events", current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) first_event = json_response.first @@ -835,7 +836,7 @@ describe API::V3::Projects do it 'returns a 404 error if not found' do get v3_api('/projects/42/events', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end @@ -844,7 +845,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/events", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -856,7 +857,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/users", current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -885,7 +886,7 @@ describe API::V3::Projects do it 'returns a 404 error if not found' do get v3_api('/projects/42/users', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end @@ -894,7 +895,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/users", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -904,7 +905,7 @@ describe API::V3::Projects do it 'returns an array of project snippets' do get v3_api("/projects/#{project.id}/snippets", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['title']).to eq(snippet.title) end @@ -913,13 +914,13 @@ describe API::V3::Projects do describe 'GET /projects/:id/snippets/:snippet_id' do it 'returns a project snippet' do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(snippet.title) end it 'returns a 404 error if snippet id not found' do get v3_api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -928,7 +929,7 @@ describe API::V3::Projects do post v3_api("/projects/#{project.id}/snippets", user), title: 'v3_api test', file_name: 'sample.rb', code: 'test', visibility_level: '0' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('v3_api test') end @@ -942,7 +943,7 @@ describe API::V3::Projects do it 'updates an existing project snippet' do put v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user), code: 'updated code' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('example') expect(snippet.reload.content).to eq('updated code') end @@ -950,7 +951,7 @@ describe API::V3::Projects do it 'updates an existing project snippet with new title' do put v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user), title: 'other v3_api test' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('other v3_api test') end end @@ -962,24 +963,24 @@ describe API::V3::Projects do expect do delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user) end.to change { Snippet.count }.by(-1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns 404 when deleting unknown snippet id' do delete v3_api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end describe 'GET /projects/:id/snippets/:snippet_id/raw' do it 'gets a raw project snippet' do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/raw", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns a 404 error if raw project snippet not found' do get v3_api("/projects/#{project.id}/snippets/5555/raw", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -992,13 +993,13 @@ describe API::V3::Projects do it "is not available for non admin users" do post v3_api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'allows project to be forked from an existing project' do expect(project_fork_target.forked?).not_to be_truthy post v3_api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked_project_link).not_to be_nil @@ -1015,7 +1016,7 @@ describe API::V3::Projects do it 'fails if forked_from project which does not exist' do post v3_api("/projects/#{project_fork_target.id}/fork/9999", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'fails with 409 if already forked' do @@ -1023,7 +1024,7 @@ describe API::V3::Projects do project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) post v3_api("/projects/#{project_fork_target.id}/fork/#{new_project_fork_source.id}", admin) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked?).to be_truthy @@ -1033,7 +1034,7 @@ describe API::V3::Projects do describe 'DELETE /projects/:id/fork' do it "is not visible to users outside group" do delete v3_api("/projects/#{project_fork_target.id}/fork", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'when users belong to project group' do @@ -1046,7 +1047,7 @@ describe API::V3::Projects do it 'is forbidden to non-owner users' do delete v3_api("/projects/#{project_fork_target.id}/fork", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'makes forked project unforked' do @@ -1055,7 +1056,7 @@ describe API::V3::Projects do expect(project_fork_target.forked_from_project).not_to be_nil expect(project_fork_target.forked?).to be_truthy delete v3_api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_fork_target.reload expect(project_fork_target.forked_from_project).to be_nil expect(project_fork_target.forked?).not_to be_truthy @@ -1064,7 +1065,7 @@ describe API::V3::Projects do it 'is idempotent if not forked' do expect(project_fork_target.forked_from_project).to be_nil delete v3_api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) expect(project_fork_target.reload.forked_from_project).to be_nil end end @@ -1081,7 +1082,7 @@ describe API::V3::Projects do post v3_api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at end.to change { ProjectGroupLink.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['group_id']).to eq(group.id) expect(json_response['group_access']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['expires_at']).to eq(expires_at.to_s) @@ -1089,18 +1090,18 @@ describe API::V3::Projects do it "returns a 400 error when group id is not given" do post v3_api("/projects/#{project.id}/share", user), group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when access level is not given" do post v3_api("/projects/#{project.id}/share", user), group_id: group.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when sharing is disabled" do project.namespace.update(share_with_group_lock: true) post v3_api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when user cannot read group' do @@ -1108,19 +1109,19 @@ describe API::V3::Projects do post v3_api("/projects/#{project.id}/share", user), group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when group does not exist' do post v3_api("/projects/#{project.id}/share", user), group_id: 1234, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 400 error when wrong params passed" do post v3_api("/projects/#{project.id}/share", user), group_id: group.id, group_access: 1234 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq 'group_access does not have a valid value' end end @@ -1132,26 +1133,26 @@ describe API::V3::Projects do delete v3_api("/projects/#{project.id}/share/#{group.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(project.project_group_links).to be_empty end it 'returns a 400 when group id is not an integer' do delete v3_api("/projects/#{project.id}/share/foo", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when group link does not exist' do delete v3_api("/projects/#{project.id}/share/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when project does not exist' do delete v3_api("/projects/123/share/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1172,7 +1173,7 @@ describe API::V3::Projects do it 'returns project search responses' do get v3_api("/projects/search/#{args[:query]}", current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(args[:results]) json_response.each { |project| expect(project['name']).to match(args[:match_regex] || /.*#{args[:query]}.*/) } @@ -1215,7 +1216,7 @@ describe API::V3::Projects do it 'returns authentication error' do project_param = { name: 'bar' } put v3_api("/projects/#{project.id}"), project_param - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1223,7 +1224,7 @@ describe API::V3::Projects do it 'updates name' do project_param = { name: 'bar' } put v3_api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1232,7 +1233,7 @@ describe API::V3::Projects do it 'updates visibility_level' do project_param = { visibility_level: 20 } put v3_api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1242,7 +1243,7 @@ describe API::V3::Projects do project3.update_attributes({ visibility_level: Gitlab::VisibilityLevel::PUBLIC }) project_param = { public: false } put v3_api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1252,7 +1253,7 @@ describe API::V3::Projects do it 'does not update name to existing name' do project_param = { name: project3.name } put v3_api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['name']).to eq(['has already been taken']) end @@ -1261,14 +1262,14 @@ describe API::V3::Projects do put v3_api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['request_access_enabled']).to eq(false) end it 'updates path & name to existing path & name in different namespace' do project_param = { path: project4.path, name: project4.name } put v3_api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1279,7 +1280,7 @@ describe API::V3::Projects do it 'updates path' do project_param = { path: 'bar' } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1293,7 +1294,7 @@ describe API::V3::Projects do description: 'new description' } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1302,20 +1303,20 @@ describe API::V3::Projects do it 'does not update path to existing path' do project_param = { path: project.path } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['path']).to eq(['has already been taken']) end it 'does not update name' do project_param = { name: 'bar' } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not update visibility_level' do project_param = { visibility_level: 20 } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1329,7 +1330,7 @@ describe API::V3::Projects do description: 'new description', request_access_enabled: true } put v3_api("/projects/#{project.id}", user3), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1339,7 +1340,7 @@ describe API::V3::Projects do it 'archives the project' do post v3_api("/projects/#{project.id}/archive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_truthy end end @@ -1352,7 +1353,7 @@ describe API::V3::Projects do it 'remains archived' do post v3_api("/projects/#{project.id}/archive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_truthy end end @@ -1365,7 +1366,7 @@ describe API::V3::Projects do it 'rejects the action' do post v3_api("/projects/#{project.id}/archive", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1375,7 +1376,7 @@ describe API::V3::Projects do it 'remains unarchived' do post v3_api("/projects/#{project.id}/unarchive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_falsey end end @@ -1388,7 +1389,7 @@ describe API::V3::Projects do it 'unarchives the project' do post v3_api("/projects/#{project.id}/unarchive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_falsey end end @@ -1401,7 +1402,7 @@ describe API::V3::Projects do it 'rejects the action' do post v3_api("/projects/#{project.id}/unarchive", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1411,7 +1412,7 @@ describe API::V3::Projects do it 'stars the project' do expect { post v3_api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['star_count']).to eq(1) end end @@ -1425,7 +1426,7 @@ describe API::V3::Projects do it 'does not modify the star count' do expect { post v3_api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end end @@ -1440,7 +1441,7 @@ describe API::V3::Projects do it 'unstars the project' do expect { delete v3_api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(-1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['star_count']).to eq(0) end end @@ -1449,7 +1450,7 @@ describe API::V3::Projects do it 'does not modify the star count' do expect { delete v3_api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end end @@ -1458,36 +1459,36 @@ describe API::V3::Projects do context 'when authenticated as user' do it 'removes project' do delete v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not remove a project if not an owner' do user3 = create(:user) project.team << [user3, :developer] delete v3_api("/projects/#{project.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not remove a non existing project' do delete v3_api('/projects/1328', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not remove a project not attached to user' do delete v3_api("/projects/#{project.id}", user2) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context 'when authenticated as admin' do it 'removes any existing project' do delete v3_api("/projects/#{project.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not remove a non existing project' do delete v3_api('/projects/1328', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end |