diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-24 03:07:52 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-24 03:07:52 +0000 |
commit | f12dba53d96f9ba995726257353bf6df374e5aee (patch) | |
tree | 67fc609f26825f347cc79d10108cb4844eb33a23 /spec/models/environment_spec.rb | |
parent | 3888bc4261500c275759683076e07baaf352e5ec (diff) | |
download | gitlab-ce-f12dba53d96f9ba995726257353bf6df374e5aee.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/environment_spec.rb')
-rw-r--r-- | spec/models/environment_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index fe1517e76d3..462e9a56f5c 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -6,6 +6,7 @@ describe Environment, :use_clean_rails_memory_store_caching do include ReactiveCachingHelpers using RSpec::Parameterized::TableSyntax include RepoHelpers + include StubENV let(:project) { create(:project, :repository) } @@ -851,6 +852,52 @@ describe Environment, :use_clean_rails_memory_store_caching do context 'without a monitoring service' do it { is_expected.to be_falsy } end + + context 'when sample metrics are enabled' do + before do + stub_env('USE_SAMPLE_METRICS', 'true') + end + + context 'with no prometheus adapter configured' do + before do + allow(environment.prometheus_adapter).to receive(:configured?).and_return(false) + end + + it { is_expected.to be_truthy } + end + end + end + + describe '#has_sample_metrics?' do + subject { environment.has_metrics? } + + let(:project) { create(:project) } + + context 'when sample metrics are enabled' do + before do + stub_env('USE_SAMPLE_METRICS', 'true') + end + + context 'with no prometheus adapter configured' do + before do + allow(environment.prometheus_adapter).to receive(:configured?).and_return(false) + end + + it { is_expected.to be_truthy } + end + + context 'with the environment stopped' do + before do + environment.stop + end + + it { is_expected.to be_falsy } + end + end + + context 'when sample metrics are not enabled' do + it { is_expected.to be_falsy } + end end context 'when the environment is unavailable' do |