Commit 1567a65c authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '6623-extract-ee-specific-files-lines-for-ci-spec-serializers' into 'master'

Resolve "Extract EE specific files/lines for CI spec/serializers"

See merge request gitlab-org/gitlab-ee!10668
parents e4bf12b6 8045cd13
# frozen_string_literal: true
require 'spec_helper'
describe EnvironmentEntity do
include KubernetesHelpers
let(:user) { create(:user) }
let(:environment) { create(:environment) }
before do
environment.project.add_maintainer(user)
end
let(:entity) do
described_class.new(environment, request: double(current_user: user))
end
describe '#as_json' do
subject { entity.as_json }
context 'when deploy_boards are available' do
before do
stub_licensed_features(deploy_board: true)
end
context 'with deployment service ready' do
before do
allow(environment).to receive(:has_terminals?).and_return(true)
allow(environment).to receive(:rollout_status).and_return(kube_deployment_rollout_status)
end
it 'exposes rollout_status' do
expect(subject).to include(:rollout_status)
end
end
end
context 'when deploy_boards are not available' do
before do
allow(environment).to receive(:has_terminals?).and_return(true)
end
it 'does not expose rollout_status' do
expect(subject).not_to include(:rollout_status)
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe PipelineDetailsEntity do
let(:user) { create(:user) }
let(:request) { double('request') }
before do
stub_not_protect_default_branch
allow(request).to receive(:current_user).and_return(user)
end
let(:entity) do
described_class.represent(pipeline, request: request)
end
describe '#as_json' do
subject { entity.as_json }
context 'when pipeline is triggered by other pipeline' do
let(:pipeline) { create(:ci_empty_pipeline) }
before do
create(:ci_sources_pipeline, pipeline: pipeline)
end
it 'contains an information about depedent pipeline' do
expect(subject[:triggered_by]).to be_a(Hash)
expect(subject[:triggered_by][:path]).not_to be_nil
expect(subject[:triggered_by][:details]).not_to be_nil
expect(subject[:triggered_by][:details][:status]).not_to be_nil
expect(subject[:triggered_by][:project]).not_to be_nil
end
end
context 'when pipeline triggered other pipeline' do
let(:pipeline) { create(:ci_empty_pipeline) }
let(:build) { create(:ci_build, pipeline: pipeline) }
before do
create(:ci_sources_pipeline, source_job: build)
create(:ci_sources_pipeline, source_job: build)
end
it 'contains an information about depedent pipeline' do
expect(subject[:triggered]).to be_a(Array)
expect(subject[:triggered].length).to eq(2)
expect(subject[:triggered].first[:path]).not_to be_nil
expect(subject[:triggered].first[:details]).not_to be_nil
expect(subject[:triggered].first[:details][:status]).not_to be_nil
expect(subject[:triggered].first[:project]).not_to be_nil
end
end
end
end
require 'spec_helper'
describe EnvironmentEntity do
include KubernetesHelpers
let(:user) { create(:user) }
let(:environment) { create(:environment) }
let(:request) { double('request') }
let(:entity) do
described_class.new(environment, request: double(current_user: user))
described_class.new(environment, request: spy('request'))
end
let(:environment) { create(:environment) }
subject { entity.as_json }
before do
environment.project.add_maintainer(user)
end
it 'exposes latest deployment' do
expect(subject).to include(:last_deployment)
end
......@@ -48,29 +41,6 @@ describe EnvironmentEntity do
end
end
context 'with deployment service ready' do
before do
stub_licensed_features(deploy_board: true)
allow(environment).to receive(:has_terminals?).and_return(true)
allow(environment).to receive(:rollout_status).and_return(kube_deployment_rollout_status)
end
it 'exposes rollout_status' do
expect(subject).to include(:rollout_status)
end
end
context 'when license does not has the GitLab_DeployBoard add-on' do
before do
stub_licensed_features(deploy_board: false)
allow(environment).to receive(:has_terminals?).and_return(true)
end
it 'does not expose rollout_status' do
expect(subject[:rollout_status_path]).to be_blank
end
end
context 'with deployment platform' do
let(:project) { create(:project, :repository) }
let(:environment) { create(:environment, project: project) }
......
......@@ -136,40 +136,5 @@ describe PipelineDetailsEntity do
expect(subject[:flags][:yaml_errors]).to be false
end
end
context 'when pipeline is triggered by other pipeline' do
let(:pipeline) { create(:ci_empty_pipeline) }
before do
create(:ci_sources_pipeline, pipeline: pipeline)
end
it 'contains an information about depedent pipeline' do
expect(subject[:triggered_by]).to be_a(Hash)
expect(subject[:triggered_by][:path]).not_to be_nil
expect(subject[:triggered_by][:details]).not_to be_nil
expect(subject[:triggered_by][:details][:status]).not_to be_nil
expect(subject[:triggered_by][:project]).not_to be_nil
end
end
context 'when pipeline triggered other pipeline' do
let(:pipeline) { create(:ci_empty_pipeline) }
let(:build) { create(:ci_build, pipeline: pipeline) }
before do
create(:ci_sources_pipeline, source_job: build)
create(:ci_sources_pipeline, source_job: build)
end
it 'contains an information about depedent pipeline' do
expect(subject[:triggered]).to be_a(Array)
expect(subject[:triggered].length).to eq(2)
expect(subject[:triggered].first[:path]).not_to be_nil
expect(subject[:triggered].first[:details]).not_to be_nil
expect(subject[:triggered].first[:details][:status]).not_to be_nil
expect(subject[:triggered].first[:project]).not_to be_nil
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment