summaryrefslogtreecommitdiff
path: root/spec/models/ci/processable_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 12:09:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 12:09:03 +0000
commit5366964a10484c2783a646b35a6da9eece01b242 (patch)
tree4a5a7a289d44e63d96a50a6a64db6e16b871f19c /spec/models/ci/processable_spec.rb
parent733befe96ad19f5a02e442c4a9cc8059d3aabbda (diff)
downloadgitlab-ce-5366964a10484c2783a646b35a6da9eece01b242.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/ci/processable_spec.rb')
-rw-r--r--spec/models/ci/processable_spec.rb25
1 files changed, 25 insertions, 0 deletions
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