diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 09:40:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 09:40:42 +0000 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /spec/support_specs/helpers/html_escaped_helpers_spec.rb | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) | |
download | gitlab-ce-ee664acb356f8123f4f6b00b73c1e1cf0866c7fb.tar.gz |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'spec/support_specs/helpers/html_escaped_helpers_spec.rb')
-rw-r--r-- | spec/support_specs/helpers/html_escaped_helpers_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/support_specs/helpers/html_escaped_helpers_spec.rb b/spec/support_specs/helpers/html_escaped_helpers_spec.rb index 337f7ecc659..77ca6231881 100644 --- a/spec/support_specs/helpers/html_escaped_helpers_spec.rb +++ b/spec/support_specs/helpers/html_escaped_helpers_spec.rb @@ -40,4 +40,33 @@ RSpec.describe HtmlEscapedHelpers do specify { expect(actual_match).to eq(expected_match) } end end + + describe '#ensure_no_html_escaped_tags!' do + subject { |example| described_class.ensure_no_html_escaped_tags!(content, example) } + + context 'when content contains HTML escaped chars' do + let(:content) { 'See <a href="">Link</a>' } + + it 'raises an exception' do + parts = [ + 'The following string contains HTML escaped tags:', + 'See «<a» href="">Link</a>', + 'This check can be disabled via:', + %(it "raises an exception", :skip_html_escaped_tags_check do) + ] + + regexp = Regexp.new(parts.join('.*'), Regexp::MULTILINE) + + expect { subject }.to raise_error(regexp) + end + end + + context 'when content does not contain HTML escaped tags' do + let(:content) { 'See <a href="">Link</a>' } + + it 'does not raise anything' do + expect(subject).to be_nil + end + end + end end |