Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /spec/lib/banzai
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/lib/banzai')
-rw-r--r--spec/lib/banzai/filter/emoji_filter_spec.rb14
-rw-r--r--spec/lib/banzai/filter/normalize_source_filter_spec.rb26
-rw-r--r--spec/lib/banzai/pipeline/pre_process_pipeline_spec.rb27
-rw-r--r--spec/lib/banzai/reference_parser/base_parser_spec.rb3
-rw-r--r--spec/lib/banzai/reference_parser/design_parser_spec.rb2
5 files changed, 72 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/emoji_filter_spec.rb b/spec/lib/banzai/filter/emoji_filter_spec.rb
index d78763b6939..9005b4401b7 100644
--- a/spec/lib/banzai/filter/emoji_filter_spec.rb
+++ b/spec/lib/banzai/filter/emoji_filter_spec.rb
@@ -21,6 +21,20 @@ RSpec.describe Banzai::Filter::EmojiFilter do
expect(doc.to_html).to match Regexp.escape(exp)
end
+ it 'ignores unicode versions of trademark, copyright, and registered trademark' do
+ exp = act = '<p>™ © ®</p>'
+ doc = filter(act)
+ expect(doc.to_html).to match Regexp.escape(exp)
+ end
+
+ it 'replaces name versions of trademark, copyright, and registered trademark' do
+ doc = filter('<p>:tm: :copyright: :registered:</p>')
+
+ expect(doc.css('gl-emoji')[0].text).to eq '™'
+ expect(doc.css('gl-emoji')[1].text).to eq '©'
+ expect(doc.css('gl-emoji')[2].text).to eq '®'
+ end
+
it 'correctly encodes the URL' do
doc = filter('<p>:+1:</p>')
expect(doc.css('gl-emoji').first.text).to eq '👍'
diff --git a/spec/lib/banzai/filter/normalize_source_filter_spec.rb b/spec/lib/banzai/filter/normalize_source_filter_spec.rb
new file mode 100644
index 00000000000..8eaeec0e7b0
--- /dev/null
+++ b/spec/lib/banzai/filter/normalize_source_filter_spec.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Banzai::Filter::NormalizeSourceFilter do
+ include FilterSpecHelper
+
+ it 'removes the UTF8 BOM from the beginning of the text' do
+ content = "\xEF\xBB\xBF---"
+
+ output = filter(content)
+
+ expect(output).to match '---'
+ end
+
+ it 'does not remove those characters from anywhere else in the text' do
+ content = <<~MD
+ \xEF\xBB\xBF---
+ \xEF\xBB\xBF---
+ MD
+
+ output = filter(content)
+
+ expect(output).to match "---\n\xEF\xBB\xBF---\n"
+ end
+end
diff --git a/spec/lib/banzai/pipeline/pre_process_pipeline_spec.rb b/spec/lib/banzai/pipeline/pre_process_pipeline_spec.rb
new file mode 100644
index 00000000000..fc74c592867
--- /dev/null
+++ b/spec/lib/banzai/pipeline/pre_process_pipeline_spec.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Banzai::Pipeline::PreProcessPipeline do
+ it 'pre-processes the source text' do
+ markdown = <<~MD
+ \xEF\xBB\xBF---
+ foo: :foo_symbol
+ bar: :bar_symbol
+ ---
+
+ >>>
+ blockquote
+ >>>
+ MD
+
+ result = described_class.call(markdown, {})
+
+ aggregate_failures do
+ expect(result[:output]).not_to include "\xEF\xBB\xBF"
+ expect(result[:output]).not_to include '---'
+ expect(result[:output]).to include "```yaml\nfoo: :foo_symbol\n"
+ expect(result[:output]).to include "> blockquote\n"
+ end
+ end
+end
diff --git a/spec/lib/banzai/reference_parser/base_parser_spec.rb b/spec/lib/banzai/reference_parser/base_parser_spec.rb
index 5ab76b2c68b..18d8418ca23 100644
--- a/spec/lib/banzai/reference_parser/base_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/base_parser_spec.rb
@@ -323,6 +323,9 @@ RSpec.describe Banzai::ReferenceParser::BaseParser do
it 'will not overflow the stack' do
ids = 1.upto(1_000_000).to_a
+ # Avoid executing a large, unnecessary SQL query
+ expect(User).to receive(:where).with(id: ids).and_return(User.none)
+
expect { subject.collection_objects_for_ids(User, ids) }.not_to raise_error
end
end
diff --git a/spec/lib/banzai/reference_parser/design_parser_spec.rb b/spec/lib/banzai/reference_parser/design_parser_spec.rb
index 92d3a4aaad2..a9cb2952c26 100644
--- a/spec/lib/banzai/reference_parser/design_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/design_parser_spec.rb
@@ -29,9 +29,11 @@ RSpec.describe Banzai::ReferenceParser::DesignParser do
let_it_be(:other_project_link) do
design_link(create(:design, :with_versions))
end
+
let_it_be(:public_link) do
design_link(create(:design, :with_versions, issue: create(:issue, project: public_project)))
end
+
let_it_be(:public_but_confidential_link) do
design_link(create(:design, :with_versions, issue: create(:issue, :confidential, project: public_project)))
end