2011-10-13 16:55:03 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ProjectToRepository do
|
2014-06-19 20:35:53 +01:00
|
|
|
let(:platform) { FactoryGirl.create(:platform) }
|
|
|
|
let(:first_repo) { FactoryGirl.create(:repository, platform: platform) }
|
|
|
|
let(:second_repo) { FactoryGirl.create(:repository, platform: platform) }
|
|
|
|
let(:project) { FactoryGirl.create(:project) }
|
|
|
|
|
|
|
|
before do
|
2012-05-16 16:29:28 +01:00
|
|
|
stub_symlink_methods
|
2014-06-19 20:35:53 +01:00
|
|
|
first_repo.projects << project
|
|
|
|
first_repo.save
|
2011-12-23 17:06:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not add the same project in different repositories of same platform' do
|
2014-06-19 20:35:53 +01:00
|
|
|
p2r = second_repo.project_to_repositories.build project: project
|
|
|
|
expect(p2r).to_not be_valid
|
2011-12-23 17:06:47 +00:00
|
|
|
end
|
2013-01-18 15:42:32 +00:00
|
|
|
|
|
|
|
it 'creates task for removing project from repository on destroy' do
|
2014-06-23 20:29:00 +01:00
|
|
|
expect(DestroyProjectFromRepositoryJob).to receive(:perform).with(project, first_repo)
|
2014-06-19 20:35:53 +01:00
|
|
|
first_repo.project_to_repositories.destroy_all
|
2013-01-18 15:42:32 +00:00
|
|
|
end
|
2011-10-13 16:55:03 +01:00
|
|
|
end
|