#446: updated #destroy_git_repo, added specs
This commit is contained in:
parent
cba5ff2d5e
commit
3239cf388e
|
@ -187,7 +187,7 @@ module Git
|
||||||
def destroy_git_repo
|
def destroy_git_repo
|
||||||
FileUtils.rm_rf path
|
FileUtils.rm_rf path
|
||||||
return unless alias_from_id
|
return unless alias_from_id
|
||||||
unless Project.where.not(id: id).where(alias_from_id: alias_from_id).exists?
|
unless alias_from || Project.where.not(id: id).where(alias_from_id: alias_from_id).exists?
|
||||||
FileUtils.rm_rf alias_path
|
FileUtils.rm_rf alias_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -59,13 +59,26 @@ describe Project do
|
||||||
end.to change(Project, :count).by(-1)
|
end.to change(Project, :count).by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'middle alias node' do
|
it 'alias nodes' do
|
||||||
alias_alias_project # init chain of projects
|
alias_alias_project # init chain of projects
|
||||||
expect do
|
expect do
|
||||||
alias_project.destroy
|
alias_project.destroy
|
||||||
end.to change(Project, :count).by(-1)
|
end.to change(Project, :count).by(-1)
|
||||||
expect{ Grit::Repo.new(root_project.path) }.to_not raise_exception
|
expect{ Grit::Repo.new(root_project.path) }.to_not raise_exception
|
||||||
|
expect{ Grit::Repo.new(alias_alias_project.path) }.to_not raise_exception
|
||||||
expect{ Grit::Repo.new(alias_project.path) }.to raise_exception
|
expect{ Grit::Repo.new(alias_project.path) }.to raise_exception
|
||||||
|
|
||||||
|
expect do
|
||||||
|
alias_alias_project.destroy
|
||||||
|
end.to change(Project, :count).by(-1)
|
||||||
|
expect{ Grit::Repo.new(root_project.path) }.to_not raise_exception
|
||||||
|
expect{ Grit::Repo.new(alias_alias_project.path) }.to raise_exception
|
||||||
|
|
||||||
|
expect do
|
||||||
|
root_project.destroy
|
||||||
|
end.to change(Project, :count).by(-1)
|
||||||
|
expect{ Grit::Repo.new(root_project.path) }.to raise_exception
|
||||||
|
expect{ Grit::Repo.new(root_project.send(:alias_path)) }.to raise_exception
|
||||||
end
|
end
|
||||||
|
|
||||||
pending 'when will be available orphan_strategy: :adopt' do
|
pending 'when will be available orphan_strategy: :adopt' do
|
||||||
|
|
Loading…
Reference in New Issue