2015-06-03 07:08:17 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::DestroyService do
|
|
|
|
let!(:user) { create(:user) }
|
|
|
|
let!(:project) { create(:project, namespace: user.namespace) }
|
|
|
|
let!(:path) { project.repository.path_to_repo }
|
|
|
|
let!(:remove_path) { path.sub(/\.git\Z/, "+#{project.id}+deleted.git") }
|
|
|
|
|
|
|
|
context 'Sidekiq inline' do
|
|
|
|
before do
|
|
|
|
# Run sidekiq immediatly to check that renamed repository will be removed
|
|
|
|
Sidekiq::Testing.inline! { destroy_project(project, user, {}) }
|
|
|
|
end
|
|
|
|
|
2015-06-13 18:19:24 -04:00
|
|
|
it { expect(Project.all).not_to include(project) }
|
2015-06-13 18:24:51 -04:00
|
|
|
it { expect(Dir.exists?(path)).to be_falsey }
|
|
|
|
it { expect(Dir.exists?(remove_path)).to be_falsey }
|
2015-06-03 07:08:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'Sidekiq fake' do
|
|
|
|
before do
|
|
|
|
# Dont run sidekiq to check if renamed repository exists
|
|
|
|
Sidekiq::Testing.fake! { destroy_project(project, user, {}) }
|
|
|
|
end
|
|
|
|
|
2015-06-13 18:19:24 -04:00
|
|
|
it { expect(Project.all).not_to include(project) }
|
2015-06-13 18:24:51 -04:00
|
|
|
it { expect(Dir.exists?(path)).to be_falsey }
|
|
|
|
it { expect(Dir.exists?(remove_path)).to be_truthy }
|
2015-06-03 07:08:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy_project(project, user, params)
|
|
|
|
Projects::DestroyService.new(project, user, params).execute
|
|
|
|
end
|
|
|
|
end
|