diff options
Diffstat (limited to 'spec/serializers/ci')
-rw-r--r-- | spec/serializers/ci/dag_job_group_entity_spec.rb | 6 | ||||
-rw-r--r-- | spec/serializers/ci/dag_pipeline_entity_spec.rb | 6 | ||||
-rw-r--r-- | spec/serializers/ci/dag_stage_entity_spec.rb | 4 | ||||
-rw-r--r-- | spec/serializers/ci/job_entity_spec.rb | 8 | ||||
-rw-r--r-- | spec/serializers/ci/job_serializer_spec.rb | 32 |
5 files changed, 16 insertions, 40 deletions
diff --git a/spec/serializers/ci/dag_job_group_entity_spec.rb b/spec/serializers/ci/dag_job_group_entity_spec.rb index 5a75c04efe5..b654b21f583 100644 --- a/spec/serializers/ci/dag_job_group_entity_spec.rb +++ b/spec/serializers/ci/dag_job_group_entity_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Ci::DagJobGroupEntity do subject { entity.as_json } context 'when group contains 1 job' do - let(:job) { create(:ci_build, stage: stage, pipeline: pipeline, name: 'test') } + let(:job) { create(:ci_build, stage_id: stage.id, pipeline: pipeline, name: 'test') } let(:jobs) { [job] } it 'exposes a name' do @@ -38,8 +38,8 @@ RSpec.describe Ci::DagJobGroupEntity do 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(:job_1) { create(:ci_build, stage_id: stage.id, pipeline: pipeline, name: 'test 1/2') } + let(:job_2) { create(:ci_build, stage_id: stage.id, pipeline: pipeline, name: 'test 2/2') } let(:jobs) { [job_1, job_2] } it 'exposes a name' do diff --git a/spec/serializers/ci/dag_pipeline_entity_spec.rb b/spec/serializers/ci/dag_pipeline_entity_spec.rb index 31a0dc5c048..548fd247743 100644 --- a/spec/serializers/ci/dag_pipeline_entity_spec.rb +++ b/spec/serializers/ci/dag_pipeline_entity_spec.rb @@ -43,9 +43,9 @@ RSpec.describe Ci::DagPipelineEntity do end context 'when pipeline has parallel jobs, DAG needs and GenericCommitStatus' do - let!(:stage_build) { create(:ci_stage_entity, name: 'build', position: 1, pipeline: pipeline) } - let!(:stage_test) { create(:ci_stage_entity, name: 'test', position: 2, pipeline: pipeline) } - let!(:stage_deploy) { create(:ci_stage_entity, name: 'deploy', position: 3, pipeline: pipeline) } + let!(:stage_build) { create(:ci_stage, name: 'build', position: 1, pipeline: pipeline) } + let!(:stage_test) { create(:ci_stage, name: 'test', position: 2, pipeline: pipeline) } + let!(:stage_deploy) { create(:ci_stage, name: 'deploy', position: 3, pipeline: pipeline) } let!(:job_build_1) { create(:ci_build, name: 'build 1', stage: 'build', pipeline: pipeline) } let!(:job_build_2) { create(:ci_build, name: 'build 2', stage: 'build', pipeline: pipeline) } diff --git a/spec/serializers/ci/dag_stage_entity_spec.rb b/spec/serializers/ci/dag_stage_entity_spec.rb index 0262ccdac68..3530a5e2bae 100644 --- a/spec/serializers/ci/dag_stage_entity_spec.rb +++ b/spec/serializers/ci/dag_stage_entity_spec.rb @@ -6,10 +6,10 @@ RSpec.describe Ci::DagStageEntity do let_it_be(:pipeline) { create(:ci_pipeline) } let_it_be(:request) { double(:request) } - let(:stage) { build(:ci_stage, pipeline: pipeline, name: 'test') } + let(:stage) { create(:ci_stage, pipeline: pipeline, name: 'test') } let(:entity) { described_class.new(stage, request: request) } - let!(:job) { create(:ci_build, :success, pipeline: pipeline) } + let!(:job) { create(:ci_build, :success, pipeline: pipeline, stage_id: stage.id) } describe '#as_json' do subject { entity.as_json } diff --git a/spec/serializers/ci/job_entity_spec.rb b/spec/serializers/ci/job_entity_spec.rb index 05b9e38444c..174d9a0aadb 100644 --- a/spec/serializers/ci/job_entity_spec.rb +++ b/spec/serializers/ci/job_entity_spec.rb @@ -52,6 +52,14 @@ RSpec.describe Ci::JobEntity do expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip end + it 'contains queued_at' do + expect(subject).to include :queued_at + end + + it 'contains queued_duration' do + expect(subject).to include :queued_duration + end + context 'when job is retryable' do before do job.update!(status: :failed) diff --git a/spec/serializers/ci/job_serializer_spec.rb b/spec/serializers/ci/job_serializer_spec.rb index d47c9fdbf24..5f889a10f3d 100644 --- a/spec/serializers/ci/job_serializer_spec.rb +++ b/spec/serializers/ci/job_serializer_spec.rb @@ -28,36 +28,4 @@ RSpec.describe Ci::JobSerializer do end end end - - describe '#represent_status' do - context 'for a failed build' do - let(:resource) { create(:ci_build, :failed) } - let(:status) { resource.detailed_status(double('user')) } - - subject { serializer.represent_status(resource) } - - it 'serializes only status' do - expect(subject[:text]).to eq(status.text) - expect(subject[:label]).to eq('failed') - expect(subject[:tooltip]).to eq('failed - (unknown failure)') - expect(subject[:icon]).to eq(status.icon) - expect(subject[:favicon]).to match_asset_path("/assets/ci_favicons/#{status.favicon}.png") - end - end - - context 'for any other type of build' do - let(:resource) { create(:ci_build, :success) } - let(:status) { resource.detailed_status(double('user')) } - - subject { serializer.represent_status(resource) } - - it 'serializes only status' do - expect(subject[:text]).to eq(status.text) - expect(subject[:label]).to eq('passed') - expect(subject[:tooltip]).to eq('passed') - expect(subject[:icon]).to eq(status.icon) - expect(subject[:favicon]).to match_asset_path("/assets/ci_favicons/#{status.favicon}.png") - end - end - end end |