Commit 8029c92e authored by Shinya Maeda's avatar Shinya Maeda

Reduce changes

parent d8fb903e
...@@ -371,6 +371,8 @@ describe Projects::JobsController do ...@@ -371,6 +371,8 @@ describe Projects::JobsController do
end end
describe 'POST erase' do describe 'POST erase' do
let(:role) { :master }
before do before do
project.team << [user, role] project.team << [user, role]
sign_in(user) sign_in(user)
...@@ -378,8 +380,6 @@ describe Projects::JobsController do ...@@ -378,8 +380,6 @@ describe Projects::JobsController do
post_erase post_erase
end end
let(:role) { :master }
context 'when job is erasable' do context 'when job is erasable' do
let(:job) { create(:ci_build, :erasable, :trace, pipeline: pipeline) } let(:job) { create(:ci_build, :erasable, :trace, pipeline: pipeline) }
......
...@@ -500,47 +500,42 @@ describe API::Jobs do ...@@ -500,47 +500,42 @@ describe API::Jobs do
end end
describe 'POST /projects/:id/jobs/:job_id/erase' do describe 'POST /projects/:id/jobs/:job_id/erase' do
context 'when a master erases a build' do let(:role) { :master }
before do
project.add_master(user)
post api("/projects/#{project.id}/jobs/#{job.id}/erase", user)
end
context 'job is erasable' do before do
let(:job) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline) } project.team << [user, role]
it 'erases job content' do post api("/projects/#{project.id}/jobs/#{job.id}/erase", user)
expect(response).to have_gitlab_http_status(201) end
expect(job).not_to have_trace
expect(job.artifacts_file.exists?).to be_falsy
expect(job.artifacts_metadata.exists?).to be_falsy
end
it 'updates job' do context 'job is erasable' do
job.reload let(:job) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline) }
expect(job.erased_at).to be_truthy it 'erases job content' do
expect(job.erased_by).to eq(user) expect(response).to have_gitlab_http_status(201)
end expect(job).not_to have_trace
expect(job.artifacts_file.exists?).to be_falsy
expect(job.artifacts_metadata.exists?).to be_falsy
end end
context 'job is not erasable' do it 'updates job' do
let(:job) { create(:ci_build, :trace, project: project, pipeline: pipeline) } job.reload
it 'responds with forbidden' do expect(job.erased_at).to be_truthy
expect(response).to have_gitlab_http_status(403) expect(job.erased_by).to eq(user)
end
end end
end end
context 'when a developer erases a build' do context 'job is not erasable' do
before do let(:job) { create(:ci_build, :trace, project: project, pipeline: pipeline) }
project.add_developer(user)
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
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) } let(:job) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline, user: owner) }
context 'when the build was created by the developer' do context 'when the build was created by the developer' do
......
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