41 lines
1.3 KiB
Ruby
41 lines
1.3 KiB
Ruby
|
require 'spec_helper'
|
||
|
|
||
|
describe EnvironmentStatusEntity do
|
||
|
let(:user) { create(:user) }
|
||
|
let(:request) { double('request') }
|
||
|
|
||
|
let(:deployment) { create(:deployment, :review_app) }
|
||
|
let(:environment) { deployment.environment}
|
||
|
let(:project) { deployment.project }
|
||
|
let(:merge_request) { create(:merge_request, :deployed_review_app, deployment: deployment) }
|
||
|
|
||
|
let(:environment_status) { EnvironmentStatus.new(environment, merge_request) }
|
||
|
let(:entity) { described_class.new(environment_status, request: request) }
|
||
|
|
||
|
subject { entity.as_json }
|
||
|
|
||
|
before do
|
||
|
allow(request).to receive(:current_user).and_return(user)
|
||
|
end
|
||
|
|
||
|
it { is_expected.to include(:id) }
|
||
|
it { is_expected.to include(:name) }
|
||
|
it { is_expected.to include(:url) }
|
||
|
it { is_expected.to include(:external_url) }
|
||
|
it { is_expected.to include(:external_url_formatted) }
|
||
|
it { is_expected.to include(:deployed_at) }
|
||
|
it { is_expected.to include(:deployed_at_formatted) }
|
||
|
|
||
|
it { is_expected.not_to include(:stop_url) }
|
||
|
it { is_expected.not_to include(:metrics_url) }
|
||
|
it { is_expected.not_to include(:metrics_monitoring_url) }
|
||
|
|
||
|
context 'when the user is project maintainer' do
|
||
|
before do
|
||
|
project.add_maintainer(user)
|
||
|
end
|
||
|
|
||
|
it { is_expected.to include(:stop_url) }
|
||
|
end
|
||
|
end
|