diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-10 06:07:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-10 06:07:25 +0300 |
commit | 4a6dacc8662ed65c0b83a3715e4eb05a78168db1 (patch) | |
tree | 04aced9d7d60c1213db9d5152158afe02126599f /spec/lib/banzai/pipeline | |
parent | 070ac34d473978dc27ea2878ed1cf17865e24e9a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/banzai/pipeline')
-rw-r--r-- | spec/lib/banzai/pipeline/full_pipeline_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/banzai/pipeline/plain_markdown_pipeline_spec.rb | 25 |
2 files changed, 14 insertions, 13 deletions
diff --git a/spec/lib/banzai/pipeline/full_pipeline_spec.rb b/spec/lib/banzai/pipeline/full_pipeline_spec.rb index 1a0f5a53a23..0a86d795056 100644 --- a/spec/lib/banzai/pipeline/full_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/full_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Banzai::Pipeline::FullPipeline do +RSpec.describe Banzai::Pipeline::FullPipeline, feature_category: :team_planning do describe 'References' do let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project) } diff --git a/spec/lib/banzai/pipeline/plain_markdown_pipeline_spec.rb b/spec/lib/banzai/pipeline/plain_markdown_pipeline_spec.rb index 536f2a67415..e2a36e58cf7 100644 --- a/spec/lib/banzai/pipeline/plain_markdown_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/plain_markdown_pipeline_spec.rb @@ -2,24 +2,25 @@ require 'spec_helper' -RSpec.describe Banzai::Pipeline::PlainMarkdownPipeline do +RSpec.describe Banzai::Pipeline::PlainMarkdownPipeline, feature_category: :team_planning do using RSpec::Parameterized::TableSyntax describe 'backslash escapes', :aggregate_failures do let_it_be(:project) { create(:project, :public) } let_it_be(:issue) { create(:issue, project: project) } - it 'converts all reference punctuation to literals' do - reference_chars = Banzai::Filter::MarkdownPreEscapeFilter::REFERENCE_CHARACTERS - markdown = reference_chars.split('').map { |char| char.prepend("\\") }.join - punctuation = Banzai::Filter::MarkdownPreEscapeFilter::REFERENCE_CHARACTERS.split('') - punctuation = punctuation.delete_if { |char| char == '&' } - punctuation << '&' + it 'converts all escapable punctuation to literals' do + markdown = Banzai::Filter::MarkdownPreEscapeFilter::ESCAPABLE_CHARS.pluck(:escaped).join result = described_class.call(markdown, project: project) output = result[:output].to_html - punctuation.each { |char| expect(output).to include("<span>#{char}</span>") } + Banzai::Filter::MarkdownPreEscapeFilter::ESCAPABLE_CHARS.pluck(:char).each do |char| + char = '&' if char == '&' + + expect(output).to include("<span>#{char}</span>") + end + expect(result[:escaped_literals]).to be_truthy end @@ -33,12 +34,12 @@ RSpec.describe Banzai::Pipeline::PlainMarkdownPipeline do end.compact reference_chars.all? do |char| - Banzai::Filter::MarkdownPreEscapeFilter::REFERENCE_CHARACTERS.include?(char) + Banzai::Filter::MarkdownPreEscapeFilter::TARGET_CHARS.include?(char) end end - it 'does not convert non-reference punctuation to spans' do - markdown = %q(\"\'\*\+\,\-\.\/\:\;\<\=\>\?\[\]\_\`\{\|\}) + %q[\(\)\\\\] + it 'does not convert non-reference/latex punctuation to spans' do + markdown = %q(\"\'\*\+\,\-\.\/\:\;\<\=\>\?\[\]\`\|) + %q[\(\)\\\\] result = described_class.call(markdown, project: project) output = result[:output].to_html @@ -55,7 +56,7 @@ RSpec.describe Banzai::Pipeline::PlainMarkdownPipeline do expect(result[:escaped_literals]).to be_falsey end - describe 'backslash escapes do not work in code blocks, code spans, autolinks, or raw HTML' do + describe 'backslash escapes are untouched in code blocks, code spans, autolinks, or raw HTML' do where(:markdown, :expected) do %q(`` \@\! ``) | %q(<code>\@\!</code>) %q( \@\!) | %Q(<code>\\@\\!\n</code>) |