gitlab-org--gitlab-foss/spec/lib/gitlab/metrics_dashboard/service_spec.rb

28 lines
901 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2019-04-16 03:01:43 -04:00
require 'spec_helper'
describe Gitlab::MetricsDashboard::Service, :use_clean_rails_memory_store_caching do
2019-04-16 03:15:57 -04:00
let(:project) { build(:project) }
2019-04-16 03:01:43 -04:00
describe 'get_dashboard' do
let(:dashboard_schema) { JSON.parse(fixture_file('lib/gitlab/metrics_dashboard/schemas/dashboard.json')) }
2019-04-16 03:01:43 -04:00
it 'returns a json representation of the environment dashboard' do
result = described_class.new(project).get_dashboard
2019-04-16 03:01:43 -04:00
expect(result.keys).to contain_exactly(:dashboard, :status)
expect(result[:status]).to eq(:success)
expect(JSON::Validator.fully_validate(dashboard_schema, result[:dashboard])).to be_empty
2019-04-16 03:01:43 -04:00
end
it 'caches the dashboard for subsequent calls' do
expect(YAML).to receive(:load_file).once.and_call_original
described_class.new(project).get_dashboard
described_class.new(project).get_dashboard
end
end
end