Commit d82c59e5 authored by syasonik's avatar syasonik

Split up redactor shared examples

parent d94f8a61
...@@ -19,12 +19,14 @@ describe Banzai::Filter::InlineMetricsRedactorFilter do ...@@ -19,12 +19,14 @@ describe Banzai::Filter::InlineMetricsRedactorFilter do
context 'with a metrics charts placeholder' do context 'with a metrics charts placeholder' do
let(:input) { %(<div class="js-render-metrics" data-dashboard-url="#{url}"></div>) } let(:input) { %(<div class="js-render-metrics" data-dashboard-url="#{url}"></div>) }
it_behaves_like 'a supported metrics dashboard url' it_behaves_like 'redacts the embed placeholder'
it_behaves_like 'retains the embed placeholder when applicable'
context 'for a grafana dashboard' do context 'for a grafana dashboard' do
let(:url) { urls.project_grafana_api_metrics_dashboard_url(project, embedded: true) } let(:url) { urls.project_grafana_api_metrics_dashboard_url(project, embedded: true) }
it_behaves_like 'a supported metrics dashboard url' it_behaves_like 'redacts the embed placeholder'
it_behaves_like 'retains the embed placeholder when applicable'
end end
context 'the user has requisite permissions' do context 'the user has requisite permissions' do
......
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_examples 'a supported metrics dashboard url' do RSpec.shared_examples 'redacts the embed placeholder' do
context 'no user is logged in' do context 'no user is logged in' do
it 'redacts the placeholder' do it 'redacts the placeholder' do
expect(doc.to_s).to be_empty expect(doc.to_s).to be_empty
...@@ -14,7 +14,9 @@ RSpec.shared_examples 'a supported metrics dashboard url' do ...@@ -14,7 +14,9 @@ RSpec.shared_examples 'a supported metrics dashboard url' do
expect(doc.to_s).to be_empty expect(doc.to_s).to be_empty
end end
end end
end
RSpec.shared_examples 'retains the embed placeholder when applicable' do
context 'the user has requisite permissions' do context 'the user has requisite permissions' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:doc) { filter(input, current_user: user) } let(:doc) { filter(input, current_user: user) }
...@@ -22,7 +24,7 @@ RSpec.shared_examples 'a supported metrics dashboard url' do ...@@ -22,7 +24,7 @@ RSpec.shared_examples 'a supported metrics dashboard url' do
it 'leaves the placeholder' do it 'leaves the placeholder' do
project.add_maintainer(user) project.add_maintainer(user)
expect(doc.to_s).to eq(input) expect(CGI.unescapeHTML(doc.to_s)).to eq(input)
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment