summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPaco Guzman <pacoguzmanp@gmail.com>2016-07-18 11:02:19 +0200
committerPaco Guzman <pacoguzmanp@gmail.com>2016-07-18 13:11:46 +0200
commit0c2da7f7348095ae6babeee230484f7f9c59ea62 (patch)
treeb600949e434013700786c8e688ad18f6d5d52ebf /spec
parent240a4aa62ab24a8a7b5545dee6bd2cf00ad7596e (diff)
downloadgitlab-ce-0c2da7f7348095ae6babeee230484f7f9c59ea62.tar.gz
Don't parse Rinku returned value to DocFragment when it didn't change the original html string.18593-avoid-parse_html-when-rinku-didnt-do-anything
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/banzai/filter/autolink_filter_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/autolink_filter_spec.rb b/spec/lib/banzai/filter/autolink_filter_spec.rb
index 84c2ddf444e..dca7f997570 100644
--- a/spec/lib/banzai/filter/autolink_filter_spec.rb
+++ b/spec/lib/banzai/filter/autolink_filter_spec.rb
@@ -15,6 +15,16 @@ describe Banzai::Filter::AutolinkFilter, lib: true do
expect(filter(act).to_html).to eq exp
end
+ context 'when the input contains no links' do
+ it 'does not parse_html back the rinku returned value' do
+ act = HTML::Pipeline.parse('<p>This text contains no links to autolink</p>')
+
+ expect_any_instance_of(described_class).not_to receive(:parse_html)
+
+ filter(act).to_html
+ end
+ end
+
context 'Rinku schemes' do
it 'autolinks http' do
doc = filter("See #{link}")
@@ -58,6 +68,16 @@ describe Banzai::Filter::AutolinkFilter, lib: true do
expect(filter(act).to_html).to eq exp
end
end
+
+ context 'when the input contains link' do
+ it 'does parse_html back the rinku returned value' do
+ act = HTML::Pipeline.parse("<p>See #{link}</p>")
+
+ expect_any_instance_of(described_class).to receive(:parse_html).at_least(:once).and_call_original
+
+ filter(act).to_html
+ end
+ end
end
context 'other schemes' do