blob: 554437ecef5097e01fe74b2112efe424a484c260 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::DagStageEntity do
let_it_be(:pipeline) { create(:ci_pipeline) }
let_it_be(:request) { double(:request) }
let(:stage) { create(:ci_stage_entity, pipeline: pipeline, name: 'test') }
let(:entity) { described_class.new(stage, request: request) }
let!(:job) { create(:ci_build, :success, pipeline: pipeline, stage_id: stage.id) }
describe '#as_json' do
subject { entity.as_json }
it 'contains valid name' do
expect(subject[:name]).to eq 'test'
end
it 'contains the job groups' do
expect(subject).to include :groups
expect(subject[:groups]).not_to be_empty
job_group = subject[:groups].first
expect(job_group[:name]).to eq 'test'
expect(job_group[:size]).to eq 1
expect(job_group[:jobs]).not_to be_empty
end
it "matches schema" do
expect(subject.to_json).to match_schema('entities/dag_stage')
end
end
end
|