2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe EnvironmentEntity do
|
2018-11-18 11:00:15 +05:30
|
|
|
let(:request) { double('request') }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:entity) do
|
2018-11-18 11:00:15 +05:30
|
|
|
described_class.new(environment, request: spy('request'))
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
let(:environment) { create(:environment) }
|
|
|
|
subject { entity.as_json }
|
|
|
|
|
|
|
|
it 'exposes latest deployment' do
|
|
|
|
expect(subject).to include(:last_deployment)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'exposes core elements of environment' do
|
|
|
|
expect(subject).to include(:id, :name, :state, :environment_path)
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it 'exposes folder path' do
|
|
|
|
expect(subject).to include(:folder_path)
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
context 'metrics disabled' do
|
|
|
|
before do
|
|
|
|
allow(environment).to receive(:has_metrics?).and_return(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't expose metrics path" do
|
|
|
|
expect(subject).not_to include(:metrics_path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'metrics enabled' do
|
|
|
|
before do
|
|
|
|
allow(environment).to receive(:has_metrics?).and_return(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'exposes metrics path' do
|
|
|
|
expect(subject).to include(:metrics_path)
|
|
|
|
end
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
context 'with deployment platform' do
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:environment) { create(:environment, project: project) }
|
|
|
|
|
|
|
|
context 'when deployment platform is a cluster' do
|
|
|
|
before do
|
|
|
|
create(:cluster,
|
|
|
|
:provided_by_gcp,
|
|
|
|
:project,
|
|
|
|
environment_scope: '*',
|
|
|
|
projects: [project])
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'includes cluster_type' do
|
2019-02-15 15:39:39 +05:30
|
|
|
expect(subject).to include(:cluster_type)
|
|
|
|
expect(subject[:cluster_type]).to eq('project_type')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|