#403: rollback DestroyProjectFromRepositoryJob
This commit is contained in:
parent
9b61b20733
commit
79e210b096
|
@ -1,10 +1,6 @@
|
||||||
class DestroyProjectFromRepositoryJob
|
class DestroyProjectFromRepositoryJob
|
||||||
@queue = :middle
|
|
||||||
|
|
||||||
def self.perform(project_id, repository_id)
|
|
||||||
project = Project.find(project_id)
|
|
||||||
repository = Repository.find(repository_id)
|
|
||||||
|
|
||||||
|
def self.perform(project, repository)
|
||||||
service = AbfWorkerService::Repository.new(repository)
|
service = AbfWorkerService::Repository.new(repository)
|
||||||
service.destroy_project!(project)
|
service.destroy_project!(project)
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ProjectToRepository < ActiveRecord::Base
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def destroy_project_from_repository
|
def destroy_project_from_repository
|
||||||
Resque.enqueue(DestroyProjectFromRepositoryJob, project_id, repository_id)
|
DestroyProjectFromRepositoryJob.perform(project, repository)
|
||||||
end
|
end
|
||||||
|
|
||||||
def one_project_in_platform_repositories
|
def one_project_in_platform_repositories
|
||||||
|
|
|
@ -6,15 +6,13 @@ describe DestroyProjectFromRepositoryJob do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_symlink_methods
|
stub_symlink_methods
|
||||||
allow(Project).to receive(:find).with(123).and_return(project)
|
|
||||||
allow(Repository).to receive(:find).with(234).and_return(repository)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { DestroyProjectFromRepositoryJob }
|
subject { DestroyProjectFromRepositoryJob }
|
||||||
|
|
||||||
it 'ensures that not raises error' do
|
it 'ensures that not raises error' do
|
||||||
expect do
|
expect do
|
||||||
subject.perform 123, 234
|
subject.perform project, repository
|
||||||
end.to_not raise_exception
|
end.to_not raise_exception
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe ProjectToRepository do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates task for removing project from repository on destroy' do
|
it 'creates task for removing project from repository on destroy' do
|
||||||
expect(Resque).to receive(:enqueue).with(DestroyProjectFromRepositoryJob, project.id, first_repo.id)
|
expect(DestroyProjectFromRepositoryJob).to receive(:perform).with(project, first_repo)
|
||||||
first_repo.project_to_repositories.destroy_all
|
first_repo.project_to_repositories.destroy_all
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue