diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2018-03-05 23:02:26 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2018-03-05 23:02:26 +0300 |
commit | b53356546dc54a6674eda8fa2d4f730a70f77206 (patch) | |
tree | 35e655f82b3f80039cded957b866ba16629eb2b5 /spec/models/environment_spec.rb | |
parent | 5ceec83a0154e513480a9bb08e252371bf7886c6 (diff) |
Check if prometheus_adapter is properly called
Diffstat (limited to 'spec/models/environment_spec.rb')
-rw-r--r-- | spec/models/environment_spec.rb | 32 |
1 files changed, 3 insertions, 29 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 8c052888b04..ceb570ac777 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -623,36 +623,10 @@ describe Environment do end describe '#prometheus_adapter' do - let(:cluster) { create(:cluster, :provided_by_user, environment_scope: '*', projects: [project]) } + it 'calls prometheus adapter service' do + expect_any_instance_of(Prometheus::AdapterService).to receive(:prometheus_adapter) - context 'prometheus service can execute queries' do - let(:prometheus_service) { double(:prometheus_service, can_query?: true) } - - before do - allow(environment.project).to receive(:find_or_initialize_service).with('prometheus').and_return prometheus_service - end - - it 'return prometheus service as prometheus adapter' do - expect(environment.prometheus_adapter).to eq(prometheus_service) - end - end - - context "prometheus service can't execute queries" do - let(:prometheus_service) { double(:prometheus_service, can_query?: false) } - - context 'with cluster with prometheus installed' do - let!(:prometheus) { create(:clusters_applications_prometheus, :installed, cluster: cluster) } - - it 'returns application handling all environments' do - expect(environment.prometheus_adapter).to eq(prometheus) - end - end - - context 'with cluster without prometheus installed' do - it 'returns nil' do - expect(environment.prometheus_adapter).to be_nil - end - end + subject.prometheus_adapter end end end |