Added specs for BuildList.next_build

This commit is contained in:
Vokhmin Alexey V 2014-09-19 01:25:35 +04:00
parent 6b6cb02f0b
commit 6924c9eb66
1 changed files with 42 additions and 0 deletions

View File

@ -15,6 +15,48 @@ describe BuildList do
end end
end end
context '#next_build' do
let!(:build_list) { FactoryGirl.create(:build_list, updated_at: Time.now - 20.seconds) }
it 'returns build list' do
expect_any_instance_of(BuildList).to receive(:delayed_add_job_to_abf_worker_queue)
expect(BuildList.next_build([], [])).to eq build_list
end
context 'filtering build lists by platform' do
it 'returns build list for correct platform' do
expect_any_instance_of(BuildList).to receive(:delayed_add_job_to_abf_worker_queue)
expect(BuildList.next_build([], [build_list.build_for_platform_id])).to eq build_list
end
it 'returns nothing if build list does not in queue' do
expect_any_instance_of(BuildList).to receive(:destroy_from_resque_queue).and_return(0)
expect(BuildList.next_build([], [build_list.build_for_platform_id])).to be_nil
end
it 'returns nothing for wrong platform' do
expect(BuildList.next_build([], [-1])).to be_nil
end
end
context 'filtering build lists by arch' do
it 'returns build list for correct arch' do
expect_any_instance_of(BuildList).to receive(:delayed_add_job_to_abf_worker_queue)
expect(BuildList.next_build([build_list.arch_id], [])).to eq build_list
end
it 'returns nothing if build list does not in queue' do
expect_any_instance_of(BuildList).to receive(:destroy_from_resque_queue).and_return(0)
expect(BuildList.next_build([build_list.arch_id], [])).to be_nil
end
it 'returns nothing for wrong arch' do
expect(BuildList.next_build([-1], [])).to be_nil
end
end
end
context "#notify_users" do context "#notify_users" do
let!(:user) { FactoryGirl.create(:user) } let!(:user) { FactoryGirl.create(:user) }
let!(:build_list) { FactoryGirl.create(:build_list, let!(:build_list) { FactoryGirl.create(:build_list,