diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-17 00:08:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-17 00:08:00 +0300 |
commit | 69d6d3ca2013e97cfd2d89449669ea7bf475f4e9 (patch) | |
tree | 2cc4227ebfc52b7603691f06b0b8e09e030e8428 /spec/lib/banzai | |
parent | 01fdcf49b1553c22ae116fe96cedd7b91d02225c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/banzai')
-rw-r--r-- | spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb | 26 |
1 files changed, 22 insertions, 4 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 745b9133529..e2615ea5069 100644 --- a/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb +++ b/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb @@ -55,11 +55,29 @@ describe Banzai::Filter::InlineMetricsRedactorFilter do it_behaves_like 'a supported metrics dashboard url' end - context 'for an internal non-dashboard url' do - let(:url) { urls.project_url(project) } + context 'the user has requisite permissions' do + let(:user) { create(:user) } + let(:doc) { filter(input, current_user: user) } - it 'leaves the placeholder' do - expect(doc.to_s).to be_empty + before do + project.add_maintainer(user) + end + + 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 + + context 'with over 100 embeds' do + let(:embed) { %(<div class="js-render-metrics" data-dashboard-url="#{url}"></div>) } + let(:input) { embed * 150 } + + it 'redacts ill-advised embeds' do + expect(doc.to_s.length).to eq(embed.length * 100) + end end end end |