gitlab-org--gitlab-foss/spec/serializers/environment_entity_spec.rb
Kamil Trzciński 4efd18d7e1 Merge branch '29943-environment-folder' into 'security-9-5'
Do not use `location.pathname` when accessing environments folders

See merge request !2147
2017-09-07 20:22:16 -04:00

42 lines
957 B
Ruby

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
expect(subject).to include(:id, :name, :state, :environment_path)
end
it 'exposes folder path' do
expect(subject).to include(:folder_path)
end
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
end