diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /spec/services/metrics/dashboard | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) | |
download | gitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/services/metrics/dashboard')
-rw-r--r-- | spec/services/metrics/dashboard/transient_embed_service_spec.rb | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/spec/services/metrics/dashboard/transient_embed_service_spec.rb b/spec/services/metrics/dashboard/transient_embed_service_spec.rb index fddfbe15281..4982f56cddc 100644 --- a/spec/services/metrics/dashboard/transient_embed_service_spec.rb +++ b/spec/services/metrics/dashboard/transient_embed_service_spec.rb @@ -38,21 +38,7 @@ describe Metrics::Dashboard::TransientEmbedService, :use_clean_rails_memory_stor end describe '#get_dashboard' do - let(:embed_json) do - { - panel_groups: [{ - panels: [{ - type: 'line-graph', - title: 'title', - y_label: 'y_label', - metrics: [{ - query_range: 'up', - label: 'y_label' - }] - }] - }] - }.to_json - end + let(:embed_json) { get_embed_json } let(:service_params) { [project, user, { environment: environment, embedded: 'true', embed_json: embed_json }] } let(:service_call) { described_class.new(*service_params).get_dashboard } @@ -68,5 +54,39 @@ describe Metrics::Dashboard::TransientEmbedService, :use_clean_rails_memory_stor described_class.new(*service_params).get_dashboard described_class.new(*service_params).get_dashboard end + + it 'caches unique requests separately' do + alt_embed_json = get_embed_json('area-chart') + alt_service_params = [project, user, { environment: environment, embedded: 'true', embed_json: alt_embed_json }] + + embed = described_class.new(*service_params).get_dashboard + alt_embed = described_class.new(*alt_service_params).get_dashboard + + expect(embed).not_to eq(alt_embed) + expect(get_type_for_embed(embed)).to eq('line-graph') + expect(get_type_for_embed(alt_embed)).to eq('area-chart') + end + + private + + def get_embed_json(type = 'line-graph') + { + panel_groups: [{ + panels: [{ + type: type, + title: 'title', + y_label: 'y_label', + metrics: [{ + query_range: 'up', + label: 'y_label' + }] + }] + }] + }.to_json + end + + def get_type_for_embed(embed) + embed[:dashboard][:panel_groups][0][:panels][0][:type] + end end end |