Commit 4b37e477 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'custom-emoji-followup' into 'master'

Add spec for emoji and custom emoji filters for ignored tags

See merge request gitlab-org/gitlab!55305
parents 42f70ce8 ff9ed116
......@@ -18,10 +18,10 @@ RSpec.describe Banzai::Filter::CustomEmojiFilter do
end
it 'ignores non existent custom emoji' do
exp = act = '<p>:foo:</p>'
doc = filter(act)
exp = '<p>:foo:</p>'
doc = filter(exp)
expect(doc.to_html).to match Regexp.escape(exp)
expect(doc.to_html).to eq(exp)
end
it 'correctly uses the custom emoji URL' do
......@@ -77,4 +77,10 @@ RSpec.describe Banzai::Filter::CustomEmojiFilter do
filter('<p>:tanuki: :party-parrot:</p>')
end.not_to exceed_all_query_limit(control_count.count)
end
context 'ancestor tags' do
let(:emoji_name) { ':tanuki:' }
it_behaves_like 'ignored ancestor tags'
end
end
......@@ -117,4 +117,10 @@ RSpec.describe Banzai::Filter::EmojiFilter do
expect(doc.to_html).to match(/^This deserves a <gl-emoji.+>, big time\.\z/)
end
context 'ancestor tags' do
let(:emoji_name) { ':see_no_evil:' }
it_behaves_like 'ignored ancestor tags'
end
end
# frozen_string_literal: true
RSpec.shared_examples 'ignored ancestor tags' do
it 'does not match emoji in a pre tag' do
doc = filter("<p><pre>#{emoji_name}</pre></p>")
expect(doc.css('img').size).to eq 0
end
it 'does not match emoji in code tag' do
doc = filter("<p><code>#{emoji_name} wow</code></p>")
expect(doc.css('img').size).to eq 0
end
it 'does not match emoji in tt tag' do
doc = filter("<p><tt>#{emoji_name} yes!</tt></p>")
expect(doc.css('img').size).to eq 0
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