Commit 1868b8af authored by Lin Jen-Shin's avatar Lin Jen-Shin

Move the tests to spec/services/projects/destroy_service_spec.rb

parent aaf382d5
......@@ -47,8 +47,9 @@ describe Projects::DestroyService, services: true do
it_behaves_like 'deleting the project'
end
context 'delete with pipeline' do # which has optimistic locking
context 'delete with pipeline and build' do # which has optimistic locking
let!(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, :artifacts, pipeline: pipeline) }
before do
expect(project).to receive(:destroy!).and_call_original
......
require 'spec_helper'
describe ProjectDestroyWorker do
let(:project) { create(:project, pending_delete: true) }
let(:project) { create(:project) }
let(:path) { project.repository.path_to_repo }
subject { ProjectDestroyWorker.new }
describe '#perform' do
context 'with pipelines and builds' do
let!(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, :artifacts, pipeline: pipeline) }
describe "#perform" do
it "deletes the project" do
subject.perform(project.id, project.owner.id, {})
it 'deletes the project along with pipelines and builds' do
subject.perform(project.id, project.owner.id, {})
expect(Project.all).not_to include(project)
expect(Ci::Pipeline.all).not_to include(pipeline)
expect(Ci::Build.all).not_to include(build)
expect(Dir.exist?(path)).to be_falsey
end
expect(Project.all).not_to include(project)
expect(Dir.exist?(path)).to be_falsey
end
it 'deletes the project but skips repo deletion' do
subject.perform(project.id, project.owner.id, { 'skip_repo' => true })
it "deletes the project but skips repo deletion" do
subject.perform(project.id, project.owner.id, { "skip_repo" => true })
expect(Project.all).not_to include(project)
expect(Dir.exist?(path)).to be_truthy
......
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