#403: rollback DestroyProjectFromRepositoryJob
This commit is contained in:
parent
9b61b20733
commit
79e210b096
|
@ -1,10 +1,6 @@
|
|||
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.destroy_project!(project)
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ class ProjectToRepository < ActiveRecord::Base
|
|||
protected
|
||||
|
||||
def destroy_project_from_repository
|
||||
Resque.enqueue(DestroyProjectFromRepositoryJob, project_id, repository_id)
|
||||
DestroyProjectFromRepositoryJob.perform(project, repository)
|
||||
end
|
||||
|
||||
def one_project_in_platform_repositories
|
||||
|
|
|
@ -6,15 +6,13 @@ describe DestroyProjectFromRepositoryJob do
|
|||
|
||||
before do
|
||||
stub_symlink_methods
|
||||
allow(Project).to receive(:find).with(123).and_return(project)
|
||||
allow(Repository).to receive(:find).with(234).and_return(repository)
|
||||
end
|
||||
|
||||
subject { DestroyProjectFromRepositoryJob }
|
||||
|
||||
it 'ensures that not raises error' do
|
||||
expect do
|
||||
subject.perform 123, 234
|
||||
subject.perform project, repository
|
||||
end.to_not raise_exception
|
||||
end
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ describe ProjectToRepository do
|
|||
end
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue