diff options
Diffstat (limited to 'spec/requests/api/runners_spec.rb')
-rw-r--r-- | spec/requests/api/runners_spec.rb | 172 |
1 files changed, 86 insertions, 86 deletions
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index c54487a68fe..70094ef4388 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -32,7 +32,7 @@ describe API::Runners do it 'returns response status and headers' do get api('/runners', user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers end @@ -51,7 +51,7 @@ describe API::Runners do get api('/runners?scope=paused', user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to match_array [ @@ -61,7 +61,7 @@ describe API::Runners do it 'avoids filtering if scope is invalid' do get api('/runners?scope=unknown', user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by type' do @@ -76,7 +76,7 @@ describe API::Runners do it 'does not filter by invalid type' do get api('/runners?type=bogus', user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by status' do @@ -92,7 +92,7 @@ describe API::Runners do it 'does not filter by invalid status' do get api('/runners?status=bogus', user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by tag_list' do @@ -111,7 +111,7 @@ describe API::Runners do it 'does not return runners' do get api('/runners') - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -122,7 +122,7 @@ describe API::Runners do it 'returns response status and headers' do get api('/runners/all', admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers end @@ -141,7 +141,7 @@ describe API::Runners do get api('/runners/all?scope=shared', admin) shared = json_response.all? { |r| r['is_shared'] } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response[0]).to have_key('ip_address') @@ -151,7 +151,7 @@ describe API::Runners do it 'filters runners by scope' do get api('/runners/all?scope=specific', admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to match_array [ @@ -163,7 +163,7 @@ describe API::Runners do it 'avoids filtering if scope is invalid' do get api('/runners/all?scope=unknown', admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by type' do @@ -178,7 +178,7 @@ describe API::Runners do it 'does not filter by invalid type' do get api('/runners/all?type=bogus', admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by status' do @@ -194,7 +194,7 @@ describe API::Runners do it 'does not filter by invalid status' do get api('/runners/all?status=bogus', admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by tag_list' do @@ -213,7 +213,7 @@ describe API::Runners do it 'does not return runners list' do get api('/runners/all', user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end @@ -222,7 +222,7 @@ describe API::Runners do it 'does not return runners' do get api('/runners') - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -233,7 +233,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{shared_runner.id}", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['description']).to eq(shared_runner.description) expect(json_response['maximum_timeout']).to be_nil end @@ -247,7 +247,7 @@ describe API::Runners do expect do delete api("/runners/#{unused_project_runner.id}", admin) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { Ci::Runner.project_type.count }.by(-1) end end @@ -255,7 +255,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{project_runner.id}", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['description']).to eq(project_runner.description) end @@ -269,7 +269,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do get api('/runners/0', admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -278,7 +278,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{project_runner.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['description']).to eq(project_runner.description) end end @@ -287,7 +287,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{shared_runner.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['description']).to eq(shared_runner.description) end end @@ -297,7 +297,7 @@ describe API::Runners do it "does not return project runner's details" do get api("/runners/#{project_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -305,7 +305,7 @@ describe API::Runners do it "does not return project runner's details" do get api("/runners/#{project_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -318,7 +318,7 @@ describe API::Runners do description = shared_runner.description update_runner(shared_runner.id, admin, description: "#{description}_updated") - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.description).to eq("#{description}_updated") end @@ -326,14 +326,14 @@ describe API::Runners do active = shared_runner.active update_runner(shared_runner.id, admin, active: !active) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.active).to eq(!active) end it 'runner tag list' do update_runner(shared_runner.id, admin, tag_list: ['ruby2.1', 'pgsql', 'mysql']) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.tag_list).to include('ruby2.1', 'pgsql', 'mysql') end @@ -342,28 +342,28 @@ describe API::Runners do update_runner(shared_runner.id, admin, tag_list: ['ruby2.1', 'pgsql', 'mysql']) update_runner(shared_runner.id, admin, run_untagged: 'false') - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.run_untagged?).to be(false) end it 'runner unlocked flag' do update_runner(shared_runner.id, admin, locked: 'true') - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.locked?).to be(true) end it 'runner access level' do update_runner(shared_runner.id, admin, access_level: 'ref_protected') - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.ref_protected?).to be_truthy end it 'runner maximum timeout' do update_runner(shared_runner.id, admin, maximum_timeout: 1234) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.reload.maximum_timeout).to eq(1234) end @@ -371,7 +371,7 @@ describe API::Runners do put api("/runners/#{shared_runner.id}", admin) shared_runner.reload - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -390,7 +390,7 @@ describe API::Runners do maximum_timeout: 1234) shared_runner.reload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(shared_runner.description).to eq("#{description}_updated") expect(shared_runner.active).to eq(!active) expect(shared_runner.tag_list).to include('ruby2.1', 'pgsql', 'mysql') @@ -411,7 +411,7 @@ describe API::Runners do update_runner(project_runner.id, admin, description: 'test') project_runner.reload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(project_runner.description).to eq('test') expect(project_runner.description).not_to eq(description) expect(project_runner.ensure_runner_queue_value) @@ -422,7 +422,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do update_runner(0, admin, description: 'test') - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end def update_runner(id, user, args) @@ -435,7 +435,7 @@ describe API::Runners do it 'does not update runner' do put api("/runners/#{shared_runner.id}", user), params: { description: 'test' } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -443,7 +443,7 @@ describe API::Runners do it 'does not update project runner without access to it' do put api("/runners/#{project_runner.id}", user2), params: { description: 'test' } - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'updates project runner with access to it' do @@ -451,7 +451,7 @@ describe API::Runners do put api("/runners/#{project_runner.id}", admin), params: { description: 'test' } project_runner.reload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(project_runner.description).to eq('test') expect(project_runner.description).not_to eq(description) end @@ -462,7 +462,7 @@ describe API::Runners do it 'does not delete project runner' do put api("/runners/#{project_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -474,7 +474,7 @@ describe API::Runners do expect do delete api("/runners/#{shared_runner.id}", admin) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { Ci::Runner.instance_type.count }.by(-1) end @@ -488,7 +488,7 @@ describe API::Runners do expect do delete api("/runners/#{project_runner.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { Ci::Runner.project_type.count }.by(-1) end end @@ -496,7 +496,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do delete api('/runners/0', admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -504,40 +504,40 @@ describe API::Runners do context 'when runner is shared' do it 'does not delete runner' do delete api("/runners/#{shared_runner.id}", user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end context 'when runner is not shared' do it 'does not delete runner without access to it' do delete api("/runners/#{project_runner.id}", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'does not delete project runner with more than one associated project' do delete api("/runners/#{two_projects_runner.id}", user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'deletes project runner for one owned project' do expect do delete api("/runners/#{project_runner.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { Ci::Runner.project_type.count }.by(-1) end it 'does not delete group runner with maintainer access' do delete api("/runners/#{group_runner.id}", group_maintainer) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'deletes group runner with owner access' do expect do delete api("/runners/#{group_runner.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { Ci::Runner.group_type.count }.by(-1) end @@ -551,7 +551,7 @@ describe API::Runners do it 'does not delete project runner' do delete api("/runners/#{project_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -569,7 +569,7 @@ describe API::Runners do it 'return jobs' do get api("/runners/#{shared_runner.id}/jobs", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -581,7 +581,7 @@ describe API::Runners do it 'return jobs' do get api("/runners/#{project_runner.id}/jobs", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -593,7 +593,7 @@ describe API::Runners do it 'return filtered jobs' do get api("/runners/#{project_runner.id}/jobs?status=failed", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -607,7 +607,7 @@ describe API::Runners do it 'return jobs in descending order' do get api("/runners/#{project_runner.id}/jobs?order_by=id", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -620,7 +620,7 @@ describe API::Runners do it 'return jobs sorted in ascending order' do get api("/runners/#{project_runner.id}/jobs?order_by=id&sort=asc", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -634,7 +634,7 @@ describe API::Runners do it 'return 400' do get api("/runners/#{project_runner.id}/jobs?status=non-existing", admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -642,7 +642,7 @@ describe API::Runners do it 'return 400' do get api("/runners/#{project_runner.id}/jobs?order_by=non-existing", admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -650,7 +650,7 @@ describe API::Runners do it 'return 400' do get api("/runners/#{project_runner.id}/jobs?sort=non-existing", admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -659,7 +659,7 @@ describe API::Runners do it 'returns 404' do get api('/runners/0/jobs', admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -670,7 +670,7 @@ describe API::Runners do it 'returns 403' do get api("/runners/#{shared_runner.id}/jobs", user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -678,7 +678,7 @@ describe API::Runners do it 'return jobs' do get api("/runners/#{project_runner.id}/jobs", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -690,7 +690,7 @@ describe API::Runners do it 'return filtered jobs' do get api("/runners/#{project_runner.id}/jobs?status=failed", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) @@ -703,7 +703,7 @@ describe API::Runners do it 'return 400' do get api("/runners/#{project_runner.id}/jobs?status=non-existing", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -712,7 +712,7 @@ describe API::Runners do it 'returns 404' do get api('/runners/0/jobs', user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -721,7 +721,7 @@ describe API::Runners do it 'does not return jobs' do get api("/runners/#{project_runner.id}/jobs", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -729,7 +729,7 @@ describe API::Runners do it 'does not return jobs' do get api("/runners/#{project_runner.id}/jobs") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -739,7 +739,7 @@ describe API::Runners do it 'returns response status and headers' do get api('/runners/all', admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers end @@ -756,7 +756,7 @@ describe API::Runners do it 'filters runners by scope' do get api("/projects/#{project.id}/runners?scope=specific", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to match_array [ @@ -767,7 +767,7 @@ describe API::Runners do it 'avoids filtering if scope is invalid' do get api("/projects/#{project.id}/runners?scope=unknown", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by type' do @@ -782,7 +782,7 @@ describe API::Runners do it 'does not filter by invalid type' do get api("/projects/#{project.id}/runners?type=bogus", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by status' do @@ -798,7 +798,7 @@ describe API::Runners do it 'does not filter by invalid status' do get api("/projects/#{project.id}/runners?status=bogus", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'filters runners by tag_list' do @@ -817,7 +817,7 @@ describe API::Runners do it "does not return project's runners" do get api("/projects/#{project.id}/runners", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -825,7 +825,7 @@ describe API::Runners do it "does not return project's runners" do get api("/projects/#{project.id}/runners") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -838,14 +838,14 @@ describe API::Runners do expect do post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id } end.to change { project.runners.count }.by(+1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end it 'avoids changes when enabling already enabled runner' do expect do post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner.id } end.to change { project.runners.count }.by(0) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'does not enable locked runner' do @@ -855,19 +855,19 @@ describe API::Runners do post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id } end.to change { project.runners.count }.by(0) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'does not enable shared runner' do post api("/projects/#{project.id}/runners", user), params: { runner_id: shared_runner.id } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'does not enable group runner' do post api("/projects/#{project.id}/runners", user), params: { runner_id: group_runner.id } - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end context 'user is admin' do @@ -878,7 +878,7 @@ describe API::Runners do expect do post api("/projects/#{project.id}/runners", admin), params: { runner_id: new_project_runner.id } end.to change { project.runners.count }.by(+1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end end @@ -888,14 +888,14 @@ describe API::Runners do end.to change { project.runners.count }.by(1) expect(shared_runner.reload).not_to be_instance_type - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end end it 'raises an error when no runner_id param is provided' do post api("/projects/#{project.id}/runners", admin) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -905,7 +905,7 @@ describe API::Runners do it 'does not enable runner without access to' do post api("/projects/#{project.id}/runners", user), params: { runner_id: new_project_runner.id } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -913,7 +913,7 @@ describe API::Runners do it 'does not enable runner' do post api("/projects/#{project.id}/runners", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -921,7 +921,7 @@ describe API::Runners do it 'does not enable runner' do post api("/projects/#{project.id}/runners") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -933,7 +933,7 @@ describe API::Runners do expect do delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end.to change { project.runners.count }.by(-1) end @@ -947,14 +947,14 @@ describe API::Runners do expect do delete api("/projects/#{project.id}/runners/#{project_runner.id}", user) end.to change { project.runners.count }.by(0) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end it 'returns 404 is runner is not found' do delete api("/projects/#{project.id}/runners/0", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -962,7 +962,7 @@ describe API::Runners do it "does not disable project's runner" do delete api("/projects/#{project.id}/runners/#{project_runner.id}", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -970,7 +970,7 @@ describe API::Runners do it "does not disable project's runner" do delete api("/projects/#{project.id}/runners/#{project_runner.id}") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end |