summaryrefslogtreecommitdiff
path: root/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-19 22:11:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-19 22:11:55 +0000
commit5a8431feceba47fd8e1804d9aa1b1730606b71d5 (patch)
treee5df8e0ceee60f4af8093f5c4c2f934b8abced05 /spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb
parent4d477238500c347c6553d335d920bedfc5a46869 (diff)
downloadgitlab-ce-5a8431feceba47fd8e1804d9aa1b1730606b71d5.tar.gz
Add latest changes from gitlab-org/gitlab@12-5-stable-ee
Diffstat (limited to 'spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb')
-rw-r--r--spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb48
1 files changed, 33 insertions, 15 deletions
diff --git a/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb b/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb
index a99cd7d6076..745b9133529 100644
--- a/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb
+++ b/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb
@@ -18,30 +18,48 @@ describe Banzai::Filter::InlineMetricsRedactorFilter do
end
context 'with a metrics charts placeholder' do
- let(:input) { %(<div class="js-render-metrics" data-dashboard-url="#{url}"></div>) }
+ shared_examples_for 'a supported metrics dashboard url' do
+ context 'no user is logged in' do
+ it 'redacts the placeholder' do
+ expect(doc.to_s).to be_empty
+ end
+ end
- context 'no user is logged in' do
- it 'redacts the placeholder' do
- expect(doc.to_s).to be_empty
+ context 'the user does not have permission do see charts' do
+ let(:doc) { filter(input, current_user: build(:user)) }
+
+ it 'redacts the placeholder' do
+ expect(doc.to_s).to be_empty
+ end
end
- end
- context 'the user does not have permission do see charts' do
- let(:doc) { filter(input, current_user: build(:user)) }
+ context 'the user has requisite permissions' do
+ let(:user) { create(:user) }
+ let(:doc) { filter(input, current_user: user) }
- it 'redacts the placeholder' do
- expect(doc.to_s).to be_empty
+ it 'leaves the placeholder' do
+ project.add_maintainer(user)
+
+ expect(doc.to_s).to eq input
+ end
end
end
- context 'the user has requisite permissions' do
- let(:user) { create(:user) }
- let(:doc) { filter(input, current_user: user) }
+ let(:input) { %(<div class="js-render-metrics" data-dashboard-url="#{url}"></div>) }
- it 'leaves the placeholder' do
- project.add_maintainer(user)
+ it_behaves_like 'a supported metrics dashboard url'
+
+ context 'for a grafana dashboard' do
+ let(:url) { urls.project_grafana_api_metrics_dashboard_url(project, embedded: true) }
+
+ it_behaves_like 'a supported metrics dashboard url'
+ end
- expect(doc.to_s).to eq input
+ context 'for an internal non-dashboard url' do
+ let(:url) { urls.project_url(project) }
+
+ it 'leaves the placeholder' do
+ expect(doc.to_s).to be_empty
end
end
end