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:
Diffstat (limited to 'spec/helpers/markup_helper_spec.rb')
-rw-r--r--spec/helpers/markup_helper_spec.rb66
1 files changed, 3 insertions, 63 deletions
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb
index 8a7a6d003f4..a2e34471324 100644
--- a/spec/helpers/markup_helper_spec.rb
+++ b/spec/helpers/markup_helper_spec.rb
@@ -425,21 +425,21 @@ FooBar
end
it 'delegates to #markdown_unsafe when file name corresponds to Markdown' do
- expect(helper).to receive(:gitlab_markdown?).with('foo.md').and_return(true)
+ expect(Gitlab::MarkupHelper).to receive(:gitlab_markdown?).with('foo.md').and_return(true)
expect(helper).to receive(:markdown_unsafe).and_return('NOEL')
expect(helper.markup('foo.md', content)).to eq('NOEL')
end
it 'delegates to #asciidoc_unsafe when file name corresponds to AsciiDoc' do
- expect(helper).to receive(:asciidoc?).with('foo.adoc').and_return(true)
+ expect(Gitlab::MarkupHelper).to receive(:asciidoc?).with('foo.adoc').and_return(true)
expect(helper).to receive(:asciidoc_unsafe).and_return('NOEL')
expect(helper.markup('foo.adoc', content)).to eq('NOEL')
end
it 'uses passed in rendered content' do
- expect(helper).not_to receive(:gitlab_markdown?)
+ expect(Gitlab::MarkupHelper).not_to receive(:gitlab_markdown?)
expect(helper).not_to receive(:markdown_unsafe)
expect(helper.markup('foo.md', content, rendered: '<p>NOEL</p>')).to eq('<p>NOEL</p>')
@@ -562,20 +562,6 @@ FooBar
shared_examples_for 'common markdown examples' do
let(:project_base) { build(:project, :repository) }
- it 'displays inline code' do
- object = create_object('Text with `inline code`')
- expected = 'Text with <code>inline code</code>'
-
- expect(first_line_in_markdown(object, attribute, 100, project: project)).to match(expected)
- end
-
- it 'truncates the text with multiple paragraphs' do
- object = create_object("Paragraph 1\n\nParagraph 2")
- expected = 'Paragraph 1...'
-
- expect(first_line_in_markdown(object, attribute, 100, project: project)).to match(expected)
- end
-
it 'displays the first line of a code block' do
object = create_object("```\nCode block\nwith two lines\n```")
expected = %r{<pre.+><code><span class="line">Code block\.\.\.</span>\n</code></pre>}
@@ -591,18 +577,6 @@ FooBar
expect(first_line_in_markdown(object, attribute, 150, project: project)).to match(expected)
end
- it 'preserves a link href when link text is truncated' do
- text = 'The quick brown fox jumped over the lazy dog' # 44 chars
- link_url = 'http://example.com/foo/bar/baz' # 30 chars
- input = "#{text}#{text}#{text} #{link_url}" # 163 chars
- expected_link_text = 'http://example...</a>'
-
- object = create_object(input)
-
- expect(first_line_in_markdown(object, attribute, 150, project: project)).to match(link_url)
- expect(first_line_in_markdown(object, attribute, 150, project: project)).to match(expected_link_text)
- end
-
it 'preserves code color scheme' do
object = create_object("```ruby\ndef test\n 'hello world'\nend\n```")
expected = "\n<pre class=\"code highlight js-syntax-highlight language-ruby\">" \
@@ -669,40 +643,6 @@ FooBar
expect(result).to include(html)
end
- it 'truncates Markdown properly' do
- object = create_object("@#{user.username}, can you look at this?\nHello world\n")
- actual = first_line_in_markdown(object, attribute, 100, project: project)
-
- doc = Nokogiri::HTML.parse(actual)
-
- # Make sure we didn't create invalid markup
- expect(doc.errors).to be_empty
-
- # Leading user link
- expect(doc.css('a').length).to eq(1)
- expect(doc.css('a')[0].attr('href')).to eq user_path(user)
- expect(doc.css('a')[0].text).to eq "@#{user.username}"
-
- expect(doc.content).to eq "@#{user.username}, can you look at this?..."
- end
-
- it 'truncates Markdown with emoji properly' do
- object = create_object("foo :wink:\nbar :grinning:")
- actual = first_line_in_markdown(object, attribute, 100, project: project)
-
- doc = Nokogiri::HTML.parse(actual)
-
- # Make sure we didn't create invalid markup
- # But also account for the 2 errors caused by the unknown `gl-emoji` elements
- expect(doc.errors.length).to eq(2)
-
- expect(doc.css('gl-emoji').length).to eq(2)
- expect(doc.css('gl-emoji')[0].attr('data-name')).to eq 'wink'
- expect(doc.css('gl-emoji')[1].attr('data-name')).to eq 'grinning'
-
- expect(doc.content).to eq "foo 😉\nbar 😀"
- end
-
it 'does not post-process truncated text', :request_store do
object = create_object("hello \n\n [Test](README.md)")