2019-09-30 21:07:59 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
describe Metrics::Dashboard::DefaultEmbedService, :use_clean_rails_memory_store_caching do
|
2019-09-30 21:07:59 +05:30
|
|
|
include MetricsDashboardHelpers
|
|
|
|
|
|
|
|
set(:project) { build(:project) }
|
|
|
|
set(:user) { create(:user) }
|
|
|
|
set(:environment) { create(:environment, project: project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#get_dashboard' do
|
2019-10-12 21:52:04 +05:30
|
|
|
let(:service_params) { [project, user, { environment: environment }] }
|
2019-09-30 21:07:59 +05:30
|
|
|
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
|
2019-10-12 21:52:04 +05:30
|
|
|
system_service = Metrics::Dashboard::SystemDashboardService
|
|
|
|
|
|
|
|
expect(system_service).to receive(:new).once.and_call_original
|
2019-09-30 21:07:59 +05:30
|
|
|
|
|
|
|
described_class.new(*service_params).get_dashboard
|
|
|
|
described_class.new(*service_params).get_dashboard
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when called with a non-system dashboard' do
|
|
|
|
let(:dashboard_path) { 'garbage/dashboard/path' }
|
|
|
|
|
|
|
|
it_behaves_like 'valid embedded dashboard service response'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|