environment_entity_spec.rb 1003 Bytes
Newer Older
1 2 3
require 'spec_helper'

describe EnvironmentEntity do
4
  let(:request) { double('request') }
5
  let(:entity) do
6
    described_class.new(environment, request: spy('request'))
7 8 9 10 11 12 13 14 15 16
  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
17
    expect(subject).to include(:id, :name, :state, :environment_path)
18
  end
19

20 21 22 23
  it 'exposes folder path' do
    expect(subject).to include(:folder_path)
  end

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  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
43
end