diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-11-12 21:18:57 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-11-12 21:43:03 +0300 |
commit | 99203bfe23975b8dbbaa5daa613fbc90fd39178f (patch) | |
tree | 77ecf8ef90762f09b85e8cf5003d5c6e080171fd /spec/requests/api/pipelines_spec.rb | |
parent | 5b45cd246373f18bf678dbdecad589733cfec8b0 (diff) |
Destroy pipeline in service
Move all logic for destroying a Pipeline into a service so it's easily
reusable.
Diffstat (limited to 'spec/requests/api/pipelines_spec.rb')
-rw-r--r-- | spec/requests/api/pipelines_spec.rb | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index 68de3068568..e786b7531a9 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -440,34 +440,31 @@ describe API::Pipelines do describe 'DELETE /projects/:id/pipelines/:pipeline_id' do context 'authorized user' do - it 'deletes the pipeline' do - delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) + let(:owner) { project.owner } + + it 'destroys the pipeline' do + delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner) expect(response).to have_gitlab_http_status(204) expect { pipeline.reload }.to raise_error(ActiveRecord::RecordNotFound) end it 'returns 404 when it does not exist' do - delete api("/projects/#{project.id}/pipelines/123456", user) + delete api("/projects/#{project.id}/pipelines/123456", owner) expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Not found' end it 'logs an audit event' do - expect { delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) }.to change { SecurityEvent.count }.by(1) + expect { delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner) }.to change { SecurityEvent.count }.by(1) end context 'when the pipeline has jobs' do - let!(:pipeline) do - create(:ci_pipeline, project: project, sha: project.commit.id, - ref: project.default_branch, user: user) - end - let!(:build) { create(:ci_build, project: project, pipeline: pipeline) } - it 'deletes associated jobs' do - delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) + it 'destroys associated jobs' do + delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner) expect(response).to have_gitlab_http_status(204) expect { build.reload }.to raise_error(ActiveRecord::RecordNotFound) @@ -476,7 +473,7 @@ describe API::Pipelines do end context 'unauthorized user' do - it 'should not return a project pipeline' do + it 'should return a 404' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) expect(response).to have_gitlab_http_status(404) |