2016-11-04 12:23:06 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe EnvironmentEntity do
|
|
|
|
let(:entity) do
|
|
|
|
described_class.new(environment, request: double)
|
|
|
|
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
|
2016-11-17 15:08:05 +00:00
|
|
|
expect(subject).to include(:id, :name, :state, :environment_path)
|
2016-11-04 12:23:06 +00:00
|
|
|
end
|
2017-03-31 09:20:11 +00:00
|
|
|
|
|
|
|
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
|
2016-11-04 12:23:06 +00:00
|
|
|
end
|