Commit f7b2740c authored by Ryan Cobb's avatar Ryan Cobb

Expect metric_data key

parent b9839862
......@@ -32,10 +32,20 @@ module EE
override :project_metrics_data
def project_metrics_data(project)
ee_project_metrics_data = {}
ee_project_metrics_data['logs_path'] = project_logs_path(project) if can?(current_user, :read_pod_logs, project)
ee_metrics_data = {}
ee_metrics_data['logs_path'] = project_logs_path(project) if can?(current_user, :read_pod_logs, project)
super.merge(ee_project_metrics_data)
super.merge(ee_metrics_data)
end
override :project_and_environment_metrics_data
def project_and_environment_metrics_data(project, environment)
ee_metrics_data = {}
# overwrites project_metrics_data logs_path if environment is available
ee_metrics_data['logs_path'] = project_logs_path(project, environment_name: environment.name) if can?(current_user, :read_pod_logs, project)
super.merge(ee_metrics_data)
end
end
end
......@@ -191,7 +191,7 @@ RSpec.shared_examples 'cluster metrics' do
get :metrics_dashboard, params: metrics_params, format: :json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.keys).to contain_exactly('dashboard', 'status')
expect(json_response.keys).to contain_exactly('dashboard', 'status', 'metrics_data')
end
it 'is the default dashboard' do
......
......@@ -54,7 +54,7 @@ describe MetricsDashboard do
it 'returns the specified dashboard' do
expect(json_response['dashboard']['dashboard']).to eq('Environment metrics')
expect(json_response).not_to have_key('all_dashboards')
expect(json_response).not_to have_key('metrics_data')
expect(json_response).to have_key('metrics_data')
end
end
......
......@@ -131,10 +131,11 @@ describe Projects::GrafanaApiController do
get :metrics_dashboard, params: params
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({
expect(json_response).to include ({
'dashboard' => '{}',
'status' => 'success'
})
expect(json_response).to include('metrics_data')
end
end
......
......@@ -352,7 +352,7 @@ describe Projects::Prometheus::AlertsController do
get :metrics_dashboard, params: request_params(id: metric.id, environment_id: alert.environment.id), format: :json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.keys).to contain_exactly('dashboard', 'status')
expect(json_response.keys).to contain_exactly('dashboard', 'status', 'metrics_data')
end
it 'is the correct embed' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment