Added specs for BuildList.next_build
This commit is contained in:
parent
6b6cb02f0b
commit
6924c9eb66
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue