diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/build_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/ci/processable_spec.rb | 25 | ||||
-rw-r--r-- | spec/models/project_services/youtrack_service_spec.rb | 4 |
3 files changed, 32 insertions, 1 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 65fd9b049d6..4bfb5771bb8 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -762,8 +762,10 @@ describe Ci::Build do let(:needs) { } let!(:final) do + scheduling_type = needs.present? ? :dag : :stage + create(:ci_build, - pipeline: pipeline, name: 'final', + pipeline: pipeline, name: 'final', scheduling_type: scheduling_type, stage_idx: 3, stage: 'deploy', options: { dependencies: dependencies } diff --git a/spec/models/ci/processable_spec.rb b/spec/models/ci/processable_spec.rb index f3d743fc272..1e0544c14c5 100644 --- a/spec/models/ci/processable_spec.rb +++ b/spec/models/ci/processable_spec.rb @@ -120,4 +120,29 @@ describe Ci::Processable do end end end + + describe '.populate_scheduling_type!' do + let!(:build_without_needs) { create(:ci_build, project: project, pipeline: pipeline) } + let!(:build_with_needs) { create(:ci_build, project: project, pipeline: pipeline) } + let!(:needs_relation) { create(:ci_build_need, build: build_with_needs) } + let!(:another_build) { create(:ci_build, project: project) } + + before do + Ci::Processable.update_all(scheduling_type: nil) + end + + it 'populates scheduling_type of processables' do + expect do + pipeline.processables.populate_scheduling_type! + end.to change(pipeline.processables.where(scheduling_type: nil), :count).from(2).to(0) + + expect(build_without_needs.reload.scheduling_type).to eq('stage') + expect(build_with_needs.reload.scheduling_type).to eq('dag') + end + + it 'does not affect processables from other pipelines' do + pipeline.processables.populate_scheduling_type! + expect(another_build.reload.scheduling_type).to be_nil + end + end end diff --git a/spec/models/project_services/youtrack_service_spec.rb b/spec/models/project_services/youtrack_service_spec.rb index dcc40d8f343..0067793f8d8 100644 --- a/spec/models/project_services/youtrack_service_spec.rb +++ b/spec/models/project_services/youtrack_service_spec.rb @@ -37,6 +37,10 @@ describe YoutrackService do it 'does allow project prefix on the reference' do expect(described_class.reference_pattern.match('YT-123')[:issue]).to eq('YT-123') end + + it 'does not allow issue number to be followed by a letter' do + expect(described_class.reference_pattern.match('YT-123A')).to eq(nil) + end end context 'overriding properties' do |