2011-10-13 16:55:03 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ProjectToRepository do
|
2011-12-23 17:06:47 +00:00
|
|
|
before(:each) do
|
2012-05-16 16:29:28 +01:00
|
|
|
stub_symlink_methods
|
2012-03-29 21:34:22 +01:00
|
|
|
@platform = FactoryGirl.create(:platform)
|
2014-01-21 04:51:49 +00:00
|
|
|
@first_repo = FactoryGirl.create(:repository, platform_id: @platform.id)
|
|
|
|
@second_repo = FactoryGirl.create(:repository, platform_id: @platform.id)
|
2012-03-29 21:34:22 +01:00
|
|
|
@project = FactoryGirl.create(:project)
|
2011-12-23 17:06:47 +00:00
|
|
|
@first_repo.projects << @project
|
|
|
|
@first_repo.save
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not add the same project in different repositories of same platform' do
|
2014-01-21 04:51:49 +00:00
|
|
|
p2r = @second_repo.project_to_repositories.build project_id: @project.id
|
2011-12-23 17:06:47 +00:00
|
|
|
p2r.should_not be_valid
|
|
|
|
end
|
2013-01-18 15:42:32 +00:00
|
|
|
|
|
|
|
it 'creates task for removing project from repository on destroy' do
|
|
|
|
@first_repo.project_to_repositories.destroy_all
|
|
|
|
queue = @redis_instance.lrange(AbfWorker::BuildListsPublishTaskManager::PROJECTS_FOR_CLEANUP, 0, -1)
|
2013-11-06 13:31:24 +00:00
|
|
|
queue.should have(2).item
|
|
|
|
key = "#{@project.id}-#{@first_repo.id}-#{@platform.id}"
|
|
|
|
queue.should include(key, "testing-#{key}")
|
2013-01-18 15:42:32 +00:00
|
|
|
end
|
2011-10-13 16:55:03 +01:00
|
|
|
end
|