Ensure default metrics embed is cached

This commit is contained in:
Sarah Yasonik 2019-07-31 06:32:47 +00:00 committed by James Lopez
parent af9b1ffa75
commit 74563593b9
2 changed files with 5 additions and 3 deletions

View File

@ -23,7 +23,7 @@ module Metrics
# Returns a new dashboard with only the matching
# metrics from the system dashboard, stripped of groups.
# @return [Hash]
def raw_dashboard
def get_raw_dashboard
panels = panel_groups.each_with_object([]) do |group, panels|
matched_panels = group['panels'].select { |panel| matching_panel?(panel) }

View File

@ -14,14 +14,16 @@ describe Metrics::Dashboard::DefaultEmbedService, :use_clean_rails_memory_store_
end
describe '#get_dashboard' do
let(:service_params) { [project, user, { environment: environment, dashboard_path: nil }] }
let(:service_params) { [project, user, { environment: environment }] }
let(:service_call) { described_class.new(*service_params).get_dashboard }
it_behaves_like 'valid embedded dashboard service response'
it_behaves_like 'raises error for users with insufficient permissions'
it 'caches the unprocessed dashboard for subsequent calls' do
expect(YAML).to receive(:safe_load).once.and_call_original
system_service = Metrics::Dashboard::SystemDashboardService
expect(system_service).to receive(:new).once.and_call_original
described_class.new(*service_params).get_dashboard
described_class.new(*service_params).get_dashboard