diff options
Diffstat (limited to 'spec/helpers/environments_helper_spec.rb')
-rw-r--r-- | spec/helpers/environments_helper_spec.rb | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/spec/helpers/environments_helper_spec.rb b/spec/helpers/environments_helper_spec.rb index d316f2b0a0a..89cb0f72277 100644 --- a/spec/helpers/environments_helper_spec.rb +++ b/spec/helpers/environments_helper_spec.rb @@ -45,7 +45,8 @@ RSpec.describe EnvironmentsHelper do 'custom_dashboard_base_path' => Gitlab::Metrics::Dashboard::RepoDashboardFinder::DASHBOARD_ROOT, 'operations_settings_path' => project_settings_operations_path(project), 'can_access_operations_settings' => 'true', - 'panel_preview_endpoint' => project_metrics_dashboards_builder_path(project, format: :json) + 'panel_preview_endpoint' => project_metrics_dashboards_builder_path(project, format: :json), + 'has_managed_prometheus' => 'false' ) end @@ -120,6 +121,52 @@ RSpec.describe EnvironmentsHelper do end end end + + context 'has_managed_prometheus' do + context 'without prometheus service' do + it "doesn't have managed prometheus" do + expect(metrics_data).to include( + 'has_managed_prometheus' => 'false' + ) + end + end + + context 'with prometheus service' do + let_it_be(:prometheus_service) { create(:prometheus_service, project: project) } + + context 'when manual prometheus service is active' do + it "doesn't have managed prometheus" do + prometheus_service.update!(manual_configuration: true) + + expect(metrics_data).to include( + 'has_managed_prometheus' => 'false' + ) + end + end + + context 'when prometheus service is inactive' do + it "doesn't have managed prometheus" do + prometheus_service.update!(manual_configuration: false) + + expect(metrics_data).to include( + 'has_managed_prometheus' => 'false' + ) + end + end + + context 'when a cluster prometheus is available' do + let(:cluster) { create(:cluster, projects: [project]) } + + it 'has managed prometheus' do + create(:clusters_applications_prometheus, :installed, cluster: cluster) + + expect(metrics_data).to include( + 'has_managed_prometheus' => 'true' + ) + end + end + end + end end describe '#custom_metrics_available?' do @@ -144,7 +191,7 @@ RSpec.describe EnvironmentsHelper do it 'returns logs data' do expected_data = { "environment_name": environment.name, - "environments_path": project_environments_path(project, format: :json), + "environments_path": api_v4_projects_environments_path(id: project.id), "environment_id": environment.id, "cluster_applications_documentation_path" => help_page_path('user/clusters/applications.md', anchor: 'elastic-stack'), "clusters_path": project_clusters_path(project, format: :json) |