summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-11-07 22:57:58 +0900
committerShinya Maeda <shinya@gitlab.com>2017-11-07 22:57:58 +0900
commit8029c92e1c81e4c9ab55704bff82cca5ff893a03 (patch)
tree40bfcfe3c73c44c0d7ad978dc5a5e6bf1660b9b4 /spec/requests
parentd8fb903ef7db26566cfacf76ce10e9e7917b8f38 (diff)
downloadgitlab-ce-8029c92e1c81e4c9ab55704bff82cca5ff893a03.tar.gz
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/jobs_spec.rb51
1 files changed, 23 insertions, 28 deletions
diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb
index 327b1176088..2a83213e87a 100644
--- a/spec/requests/api/jobs_spec.rb
+++ b/spec/requests/api/jobs_spec.rb
@@ -500,47 +500,42 @@ describe API::Jobs do
end
describe 'POST /projects/:id/jobs/:job_id/erase' do
- context 'when a master erases a build' do
- before do
- project.add_master(user)
-
- post api("/projects/#{project.id}/jobs/#{job.id}/erase", user)
- end
+ let(:role) { :master }
- context 'job is erasable' do
- let(:job) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline) }
+ before do
+ project.team << [user, role]
- it 'erases job content' do
- expect(response).to have_gitlab_http_status(201)
- expect(job).not_to have_trace
- expect(job.artifacts_file.exists?).to be_falsy
- expect(job.artifacts_metadata.exists?).to be_falsy
- end
+ post api("/projects/#{project.id}/jobs/#{job.id}/erase", user)
+ end
- it 'updates job' do
- job.reload
+ context 'job is erasable' do
+ let(:job) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline) }
- expect(job.erased_at).to be_truthy
- expect(job.erased_by).to eq(user)
- end
+ it 'erases job content' do
+ expect(response).to have_gitlab_http_status(201)
+ expect(job).not_to have_trace
+ expect(job.artifacts_file.exists?).to be_falsy
+ expect(job.artifacts_metadata.exists?).to be_falsy
end
- context 'job is not erasable' do
- let(:job) { create(:ci_build, :trace, project: project, pipeline: pipeline) }
+ it 'updates job' do
+ job.reload
- it 'responds with forbidden' do
- expect(response).to have_gitlab_http_status(403)
- end
+ expect(job.erased_at).to be_truthy
+ expect(job.erased_by).to eq(user)
end
end
- context 'when a developer erases a build' do
- before do
- project.add_developer(user)
+ context 'job is not erasable' do
+ let(:job) { create(:ci_build, :trace, project: project, pipeline: pipeline) }
- post api("/projects/#{project.id}/jobs/#{job.id}/erase", user)
+ it 'responds with forbidden' 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