diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-11-14 10:54:30 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-11-14 10:54:30 +0000 |
commit | 6b01821b0d7c7c624ab86936a7cadb82b3603630 (patch) | |
tree | 22027af01434dddcf507a48a9e12d05b86ff4953 /spec/requests | |
parent | 6b9b516007c8dda88f33e9603a6880e3fc3ff103 (diff) | |
parent | 8029c92e1c81e4c9ab55704bff82cca5ff893a03 (diff) | |
download | gitlab-ce-6b01821b0d7c7c624ab86936a7cadb82b3603630.tar.gz |
Merge branch 'fix/sm/31771-do-not-allow-jobs-to-be-erased-new' into 'master'
Do not allow jobs to be erased
Closes #31771
See merge request gitlab-org/gitlab-ce!15216
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/jobs_spec.rb | 21 | ||||
-rw-r--r-- | spec/requests/api/v3/builds_spec.rb | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb index 1765907c1b4..2a83213e87a 100644 --- a/spec/requests/api/jobs_spec.rb +++ b/spec/requests/api/jobs_spec.rb @@ -500,7 +500,11 @@ describe API::Jobs do end describe 'POST /projects/:id/jobs/:job_id/erase' do + let(:role) { :master } + before do + project.team << [user, role] + post api("/projects/#{project.id}/jobs/#{job.id}/erase", user) end @@ -529,6 +533,23 @@ describe API::Jobs do expect(response).to have_gitlab_http_status(403) end end + + context 'when a developer erases a build' do + let(:role) { :developer } + let(:job) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline, user: owner) } + + context 'when the build was created by the developer' do + let(:owner) { user } + + it { expect(response).to have_gitlab_http_status(201) } + end + + context 'when the build was created by the other' do + let(:owner) { create(:user) } + + it { expect(response).to have_gitlab_http_status(403) } + end + end end describe 'POST /projects/:id/jobs/:job_id/artifacts/keep' do diff --git a/spec/requests/api/v3/builds_spec.rb b/spec/requests/api/v3/builds_spec.rb index 3f58b7ef384..a73bb456b52 100644 --- a/spec/requests/api/v3/builds_spec.rb +++ b/spec/requests/api/v3/builds_spec.rb @@ -408,6 +408,8 @@ describe API::V3::Builds do describe 'POST /projects/:id/builds/:build_id/erase' do before do + project.add_master(user) + post v3_api("/projects/#{project.id}/builds/#{build.id}/erase", user) end |