|
296 | 296 | it_behaves_like 'tagged build picker'
|
297 | 297 | end
|
298 | 298 |
|
299 |
| - context 'when runner can not pick untagged jobs' do |
| 299 | + context 'when runner cannot pick untagged jobs' do |
300 | 300 | before { runner.run_untagged = false }
|
301 | 301 |
|
302 |
| - it 'can not handle builds without tags' do |
| 302 | + it 'cannot handle builds without tags' do |
303 | 303 | expect(build.can_be_served?(runner)).to be_falsey
|
304 | 304 | end
|
305 | 305 |
|
306 | 306 | it_behaves_like 'tagged build picker'
|
307 | 307 | end
|
308 | 308 | end
|
| 309 | + |
| 310 | + context 'when runner is locked' do |
| 311 | + before { runner.locked = true } |
| 312 | + |
| 313 | + shared_examples 'locked build picker' do |serve_matching_tags| |
| 314 | + context 'when runner cannot pick untagged jobs' do |
| 315 | + before { runner.run_untagged = false } |
| 316 | + |
| 317 | + it 'cannot handle builds without tags' do |
| 318 | + expect(build.can_be_served?(runner)).to be_falsey |
| 319 | + end |
| 320 | + end |
| 321 | + |
| 322 | + context 'when having runner tags' do |
| 323 | + before { runner.tag_list = ['bb', 'cc'] } |
| 324 | + |
| 325 | + it "#{serve_matching_tags} handle it for matching tags" do |
| 326 | + build.tag_list = ['bb'] |
| 327 | + expected = if serve_matching_tags |
| 328 | + be_truthy |
| 329 | + else |
| 330 | + be_falsey |
| 331 | + end |
| 332 | + expect(build.can_be_served?(runner)).to expected |
| 333 | + end |
| 334 | + |
| 335 | + it 'cannot handle it for builds without matching tags' do |
| 336 | + build.tag_list = ['aa'] |
| 337 | + expect(build.can_be_served?(runner)).to be_falsey |
| 338 | + end |
| 339 | + end |
| 340 | + end |
| 341 | + |
| 342 | + context 'when serving the same project' do |
| 343 | + it 'can handle it' do |
| 344 | + expect(build.can_be_served?(runner)).to be_truthy |
| 345 | + end |
| 346 | + |
| 347 | + it_behaves_like 'locked build picker', true |
| 348 | + end |
| 349 | + |
| 350 | + context 'serving a different project' do |
| 351 | + before { runner.runner_projects.destroy_all } |
| 352 | + |
| 353 | + it 'cannot handle it' do |
| 354 | + expect(build.can_be_served?(runner)).to be_falsey |
| 355 | + end |
| 356 | + |
| 357 | + it_behaves_like 'locked build picker', false |
| 358 | + end |
| 359 | + end |
309 | 360 | end
|
310 | 361 |
|
311 | 362 | describe '#has_tags?' do
|
|
0 commit comments