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