#403: rollback DestroyProjectFromRepositoryJob

This commit is contained in:
Vokhmin Alexey V 2014-06-23 23:29:00 +04:00
parent 9b61b20733
commit 79e210b096
4 changed files with 4 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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