diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/serializers/ci/dag_job_group_entity_spec.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) | |
download | gitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/serializers/ci/dag_job_group_entity_spec.rb')
-rw-r--r-- | spec/serializers/ci/dag_job_group_entity_spec.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/serializers/ci/dag_job_group_entity_spec.rb b/spec/serializers/ci/dag_job_group_entity_spec.rb new file mode 100644 index 00000000000..a25723894fd --- /dev/null +++ b/spec/serializers/ci/dag_job_group_entity_spec.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Ci::DagJobGroupEntity do + let_it_be(:request) { double(:request) } + let_it_be(:pipeline) { create(:ci_pipeline) } + let_it_be(:stage) { create(:ci_stage, pipeline: pipeline) } + + let(:group) { Ci::Group.new(pipeline.project, stage, name: 'test', jobs: jobs) } + let(:entity) { described_class.new(group, request: request) } + + describe '#as_json' do + subject { entity.as_json } + + context 'when group contains 1 job' do + let(:job) { create(:ci_build, stage: stage, pipeline: pipeline, name: 'test') } + let(:jobs) { [job] } + + it 'exposes a name' do + expect(subject.fetch(:name)).to eq 'test' + end + + it 'exposes the size' do + expect(subject.fetch(:size)).to eq 1 + end + + it 'exposes the jobs' do + exposed_jobs = subject.fetch(:jobs) + + expect(exposed_jobs.size).to eq 1 + expect(exposed_jobs.first.fetch(:name)).to eq 'test' + end + end + + context 'when group contains multiple parallel jobs' do + let(:job_1) { create(:ci_build, stage: stage, pipeline: pipeline, name: 'test 1/2') } + let(:job_2) { create(:ci_build, stage: stage, pipeline: pipeline, name: 'test 2/2') } + let(:jobs) { [job_1, job_2] } + + it 'exposes a name' do + expect(subject.fetch(:name)).to eq 'test' + end + + it 'exposes the size' do + expect(subject.fetch(:size)).to eq 2 + end + + it 'exposes the jobs' do + exposed_jobs = subject.fetch(:jobs) + + expect(exposed_jobs.size).to eq 2 + expect(exposed_jobs.first.fetch(:name)).to eq 'test 1/2' + expect(exposed_jobs.last.fetch(:name)).to eq 'test 2/2' + end + end + end +end |