diff options
Diffstat (limited to 'spec/serializers/ci/dag_job_entity_spec.rb')
-rw-r--r-- | spec/serializers/ci/dag_job_entity_spec.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/serializers/ci/dag_job_entity_spec.rb b/spec/serializers/ci/dag_job_entity_spec.rb index eaaf39d6bfc..5e2b186186f 100644 --- a/spec/serializers/ci/dag_job_entity_spec.rb +++ b/spec/serializers/ci/dag_job_entity_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Ci::DagJobEntity do +RSpec.describe Ci::DagJobEntity do let_it_be(:request) { double(:request) } let(:job) { create(:ci_build, name: 'dag_job') } @@ -11,10 +11,18 @@ describe Ci::DagJobEntity do describe '#as_json' do subject { entity.as_json } + RSpec.shared_examples "matches schema" do + it "matches schema" do + expect(subject.to_json).to match_schema('entities/dag_job') + end + end + it 'contains the name' do expect(subject[:name]).to eq 'dag_job' end + it_behaves_like "matches schema" + context 'when job is stage scheduled' do it 'contains the name scheduling_type' do expect(subject[:scheduling_type]).to eq 'stage' @@ -23,6 +31,8 @@ describe Ci::DagJobEntity do it 'does not expose needs' do expect(subject).not_to include(:needs) end + + it_behaves_like "matches schema" end context 'when job is dag scheduled' do @@ -32,18 +42,24 @@ describe Ci::DagJobEntity do expect(subject[:scheduling_type]).to eq 'dag' end + it_behaves_like "matches schema" + context 'when job has needs' do let!(:need) { create(:ci_build_need, build: job, name: 'compile') } it 'exposes the array of needs' do expect(subject[:needs]).to eq ['compile'] end + + it_behaves_like "matches schema" end context 'when job has empty needs' do it 'exposes an empty array of needs' do expect(subject[:needs]).to eq [] end + + it_behaves_like "matches schema" end end end |