diff options
Diffstat (limited to 'spec/features/markdown')
-rw-r--r-- | spec/features/markdown/copy_as_gfm_spec.rb | 288 | ||||
-rw-r--r-- | spec/features/markdown/gitlab_flavored_markdown_spec.rb | 28 | ||||
-rw-r--r-- | spec/features/markdown/markdown_spec.rb | 186 | ||||
-rw-r--r-- | spec/features/markdown/math_spec.rb | 16 | ||||
-rw-r--r-- | spec/features/markdown/mermaid_spec.rb | 8 |
5 files changed, 233 insertions, 293 deletions
diff --git a/spec/features/markdown/copy_as_gfm_spec.rb b/spec/features/markdown/copy_as_gfm_spec.rb index 60ddb02da2c..4a881a203bd 100644 --- a/spec/features/markdown/copy_as_gfm_spec.rb +++ b/spec/features/markdown/copy_as_gfm_spec.rb @@ -1,6 +1,6 @@ -require 'spec_helper' +require "spec_helper" -describe 'Copy as GFM', :js do +describe "Copy as GFM", :js do include MarkupHelper include RepoHelpers include ActionView::Helpers::JavaScriptHelper @@ -9,7 +9,7 @@ describe 'Copy as GFM', :js do sign_in(create(:admin)) end - describe 'Copying rendered GFM' do + describe "Copying rendered GFM" do before do @feat = MarkdownFeature.new @@ -25,16 +25,14 @@ describe 'Copy as GFM', :js do # by verifying (`html_to_gfm(gfm_to_html(gfm)) == gfm`) for a number of examples of GFM for every filter, using the `verify` helper. # These are all in a single `it` for performance reasons. - it 'works', :aggregate_failures do + it "works", :aggregate_failures do verify( - 'nesting', - - '> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**' + "nesting", + "> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**" ) verify( - 'a real world example from the gitlab-ce README', - + "a real world example from the gitlab-ce README", <<~GFM # GitLab @@ -68,8 +66,8 @@ describe 'Copy as GFM', :js do GFM ) - aggregate_failures('an accidentally selected empty element') do - gfm = '# Heading1' + aggregate_failures("an accidentally selected empty element") do + gfm = "# Heading1" html = <<~HTML <h1>Heading1</h1> @@ -85,8 +83,8 @@ describe 'Copy as GFM', :js do expect(output_gfm.strip).to eq(gfm.strip) end - aggregate_failures('an accidentally selected other element') do - gfm = 'Test comment with **Markdown!**' + aggregate_failures("an accidentally selected other element") do + gfm = "Test comment with **Markdown!**" html = <<~HTML <li class="note"> @@ -105,21 +103,18 @@ describe 'Copy as GFM', :js do end verify( - 'InlineDiffFilter', - - '{-Deleted text-}', - '{+Added text+}' + "InlineDiffFilter", + "{-Deleted text-}", + "{+Added text+}" ) verify( - 'TaskListFilter', - + "TaskListFilter", <<~GFM, * [ ] Unchecked task * [x] Checked task GFM - <<~GFM 1. [ ] Unchecked ordered task @@ -128,8 +123,7 @@ describe 'Copy as GFM', :js do ) verify( - 'ReferenceFilter', - + "ReferenceFilter", # issue reference @feat.issue.to_reference, # full issue reference @@ -137,22 +131,20 @@ describe 'Copy as GFM', :js do # issue URL project_issue_url(@project, @feat.issue), # issue URL with note anchor - project_issue_url(@project, @feat.issue, anchor: 'note_123'), + project_issue_url(@project, @feat.issue, anchor: "note_123"), # issue link "[Issue](#{project_issue_url(@project, @feat.issue)})", # issue link with note anchor - "[Issue](#{project_issue_url(@project, @feat.issue, anchor: 'note_123')})" + "[Issue](#{project_issue_url(@project, @feat.issue, anchor: "note_123")})" ) verify( - 'AutolinkFilter', - - 'https://example.com' + "AutolinkFilter", + "https://example.com" ) verify( - 'TableOfContentsFilter', - + "TableOfContentsFilter", <<~GFM, [[_TOC_]] @@ -160,34 +152,28 @@ describe 'Copy as GFM', :js do ## Heading 2 GFM - pipeline: :wiki, project_wiki: @project.wiki ) verify( - 'EmojiFilter', - - ':thumbsup:' + "EmojiFilter", + ":thumbsup:" ) verify( - 'ImageLinkFilter', - - '' + "ImageLinkFilter", + "" ) verify( - 'VideoLinkFilter', - - '' + "VideoLinkFilter", + "" ) verify( - 'MathFilter: math as converted from GFM to HTML', - + "MathFilter: math as converted from GFM to HTML", '$`c = \pm\sqrt{a^2 + b^2}`$', - # math block <<~GFM ```math @@ -196,7 +182,7 @@ describe 'Copy as GFM', :js do GFM ) - aggregate_failures('MathFilter: math as transformed from HTML to KaTeX') do + aggregate_failures("MathFilter: math as transformed from HTML to KaTeX") do gfm = '$`c = \pm\sqrt{a^2 + b^2}`$' html = <<~HTML @@ -308,8 +294,7 @@ describe 'Copy as GFM', :js do end verify( - 'MermaidFilter: mermaid as converted from GFM to HTML', - + "MermaidFilter: mermaid as converted from GFM to HTML", <<~GFM ```mermaid graph TD; @@ -318,7 +303,7 @@ describe 'Copy as GFM', :js do GFM ) - aggregate_failures('MermaidFilter: mermaid as transformed from HTML to SVG') do + aggregate_failures("MermaidFilter: mermaid as transformed from HTML to SVG") do gfm = <<~GFM ```mermaid graph TD; @@ -403,8 +388,7 @@ describe 'Copy as GFM', :js do end verify( - 'SuggestionFilter: suggestion as converted from GFM to HTML', - + "SuggestionFilter: suggestion as converted from GFM to HTML", <<~GFM ```suggestion New @@ -413,7 +397,7 @@ describe 'Copy as GFM', :js do GFM ) - aggregate_failures('SuggestionFilter: suggestion as transformed from HTML to Vue component') do + aggregate_failures("SuggestionFilter: suggestion as transformed from HTML to Vue component") do gfm = <<~GFM ```suggestion New @@ -465,50 +449,38 @@ describe 'Copy as GFM', :js do end verify( - 'SanitizationFilter', - + "SanitizationFilter", <<~GFM - <sub>sub</sub> - - <dl> - <dt>dt</dt> - <dt>dt</dt> - <dd>dd</dd> - <dd>dd</dd> - - <dt>dt</dt> - <dt>dt</dt> - <dd>dd</dd> - <dd>dd</dd> - </dl> - - <kbd>kbd</kbd> - - <q>q</q> - - <samp>samp</samp> - - <var>var</var> - - <abbr title="HyperText "Markup" Language">HTML</abbr> - - <details> - <summary>summary></summary> - - details - </details> + <sub>sub</sub> + <dl> + <dt>dt</dt> + <dt>dt</dt> + <dd>dd</dd> + <dd>dd</dd> + <dt>dt</dt> + <dt>dt</dt> + <dd>dd</dd> + <dd>dd</dd> + </dl> + <kbd>kbd</kbd> + <q>q</q> + <samp>samp</samp> + <var>var</var> + <abbr title="HyperText "Markup" Language">HTML</abbr> + <details> + <summary>summary></summary> + details + </details> GFM ) verify( - 'SanitizationFilter', - + "SanitizationFilter", <<~GFM, ``` Plain text ``` GFM - <<~GFM, ```ruby def foo @@ -516,7 +488,6 @@ describe 'Copy as GFM', :js do end ``` GFM - <<~GFM Foo @@ -527,28 +498,20 @@ describe 'Copy as GFM', :js do ) verify( - 'MarkdownFilter', - + "MarkdownFilter", "Line with two spaces at the end \nto insert a linebreak", - - '`code`', - '`` code with ` ticks ``', - - '> Quote', - + "`code`", + "`` code with ` ticks ``", + "> Quote", # multiline quote <<~GFM, > Multiline Quote > > With multiple paragraphs GFM - - '', - - '# Heading with no anchor link', - - '[Link](https://example.com)', - + "", + "# Heading with no anchor link", + "[Link](https://example.com)", <<~GFM, * List item @@ -575,7 +538,6 @@ describe 'Copy as GFM', :js do > Blockquote GFM - <<~GFM, 1. Ordered list item @@ -602,22 +564,16 @@ describe 'Copy as GFM', :js do --- GFM - - '# Heading', - '## Heading', - '### Heading', - '#### Heading', - '##### Heading', - '###### Heading', - - '**Bold**', - - '*Italics*', - - '~~Strikethrough~~', - - '---', - + "# Heading", + "## Heading", + "### Heading", + "#### Heading", + "##### Heading", + "###### Heading", + "**Bold**", + "*Italics*", + "~~Strikethrough~~", + "---", # table <<~GFM, | Centered | Right | Left | @@ -643,7 +599,7 @@ describe 'Copy as GFM', :js do aggregate_failures(label) do gfms.each do |gfm| - html = gfm_to_html(gfm, markdown_options).gsub(/\A
|
\z/, '') + html = gfm_to_html(gfm, markdown_options).gsub(/\A
|
\z/, "") output_gfm = html_to_gfm(html) expect(output_gfm.strip).to eq(gfm.strip) end @@ -656,73 +612,66 @@ describe 'Copy as GFM', :js do end end - describe 'Copying code' do + describe "Copying code" do let(:project) { create(:project, :repository) } - context 'from a diff' do - shared_examples 'copying code from a diff' do - context 'selecting one word of text' do - it 'copies as inline code' do + context "from a diff" do + shared_examples "copying code from a diff" do + context "selecting one word of text" do + it "copies as inline code" do verify( '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"] .line .no', - - '`RuntimeError`', - + "`RuntimeError`", target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]' ) end end - context 'selecting one line of text' do - it 'copies as inline code' do + context "selecting one line of text" do + it "copies as inline code" do verify( '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]', - '`raise RuntimeError, "System commands must be given as an array of strings"`', - target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]' ) end end - context 'selecting multiple lines of text' do - it 'copies as a code block' do + context "selecting multiple lines of text" do + it "copies as a code block" do verify( '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]', - <<~GFM, ```ruby raise RuntimeError, "System commands must be given as an array of strings" end ``` GFM - target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]' ) end end end - context 'inline diff' do + context "inline diff" do before do - visit project_commit_path(project, sample_commit.id, view: 'inline') + visit project_commit_path(project, sample_commit.id, view: "inline") end - it_behaves_like 'copying code from a diff' + it_behaves_like "copying code from a diff" end - context 'parallel diff' do + context "parallel diff" do before do - visit project_commit_path(project, sample_commit.id, view: 'parallel') + visit project_commit_path(project, sample_commit.id, view: "parallel") end - it_behaves_like 'copying code from a diff' + it_behaves_like "copying code from a diff" - context 'selecting code on the left' do - it 'copies as a code block' do + context "selecting code on the left" do + it "copies as a code block" do verify( '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]', - <<~GFM, ```ruby unless cmd.is_a?(Array) @@ -730,17 +679,15 @@ describe 'Copy as GFM', :js do end ``` GFM - target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"].left-side' ) end end - context 'selecting code on the right' do - it 'copies as a code block' do + context "selecting code on the right" do + it "copies as a code block" do verify( '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]', - <<~GFM, ```ruby unless cmd.is_a?(Array) @@ -748,7 +695,6 @@ describe 'Copy as GFM', :js do end ``` GFM - target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"].right-side' ) end @@ -756,37 +702,34 @@ describe 'Copy as GFM', :js do end end - context 'from a blob' do + context "from a blob" do before do - visit project_blob_path(project, File.join('master', 'files/ruby/popen.rb')) + visit project_blob_path(project, File.join("master", "files/ruby/popen.rb")) wait_for_requests end - context 'selecting one word of text' do - it 'copies as inline code' do + context "selecting one word of text" do + it "copies as inline code" do verify( '.line[id="LC9"] .no', - - '`RuntimeError`' + "`RuntimeError`" ) end end - context 'selecting one line of text' do - it 'copies as inline code' do + context "selecting one line of text" do + it "copies as inline code" do verify( '.line[id="LC9"]', - '`raise RuntimeError, "System commands must be given as an array of strings"`' ) end end - context 'selecting multiple lines of text' do - it 'copies as a code block' do + context "selecting multiple lines of text" do + it "copies as a code block" do verify( '.line[id="LC9"], .line[id="LC10"]', - <<~GFM, ```ruby raise RuntimeError, "System commands must be given as an array of strings" @@ -798,37 +741,34 @@ describe 'Copy as GFM', :js do end end - context 'from a GFM code block' do + context "from a GFM code block" do before do - visit project_blob_path(project, File.join('markdown', 'doc/api/users.md')) + visit project_blob_path(project, File.join("markdown", "doc/api/users.md")) wait_for_requests end - context 'selecting one word of text' do - it 'copies as inline code' do + context "selecting one word of text" do + it "copies as inline code" do verify( '.line[id="LC27"] .s2', - '`"bio"`' ) end end - context 'selecting one line of text' do - it 'copies as inline code' do + context "selecting one line of text" do + it "copies as inline code" do verify( '.line[id="LC27"]', - '`"bio": null,`' ) end end - context 'selecting multiple lines of text' do - it 'copies as a code block with the correct language' do + context "selecting multiple lines of text" do + it "copies as a code block with the correct language" do verify( '.line[id="LC27"], .line[id="LC28"]', - <<~GFM, ```json "bio": null, @@ -842,7 +782,7 @@ describe 'Copy as GFM', :js do def verify(selector, gfm, target: nil) html = html_for_selector(selector) - output_gfm = html_to_gfm(html, 'transformCodeSelection', target: target) + output_gfm = html_to_gfm(html, "transformCodeSelection", target: target) wait_for_requests expect(output_gfm.strip).to eq(gfm.strip) end @@ -859,7 +799,7 @@ describe 'Copy as GFM', :js do page.evaluate_script(js) end - def html_to_gfm(html, transformer = 'transformGFMSelection', target: nil) + def html_to_gfm(html, transformer = "transformGFMSelection", target: nil) js = <<~JS (function(html) { // Setting it off so the import already starts @@ -889,8 +829,8 @@ describe 'Copy as GFM', :js do JS page.execute_script(js) - loop until page.evaluate_script('window.gfmCopytestRes !== null') + loop until page.evaluate_script("window.gfmCopytestRes !== null") - page.evaluate_script('window.gfmCopytestRes') + page.evaluate_script("window.gfmCopytestRes") end end diff --git a/spec/features/markdown/gitlab_flavored_markdown_spec.rb b/spec/features/markdown/gitlab_flavored_markdown_spec.rb index 6997ca48427..7109e87a67d 100644 --- a/spec/features/markdown/gitlab_flavored_markdown_spec.rb +++ b/spec/features/markdown/gitlab_flavored_markdown_spec.rb @@ -1,11 +1,11 @@ -require 'spec_helper' +require "spec_helper" describe "GitLab Flavored Markdown" do let(:user) { create(:user) } let(:project) { create(:project) } let(:issue) { create(:issue, project: project) } let(:fred) do - create(:user, name: 'fred') do |user| + create(:user, name: "fred") do |user| project.add_maintainer(user) end end @@ -25,7 +25,7 @@ describe "GitLab Flavored Markdown" do end it "renders title in commits#index" do - visit project_commits_path(project, 'master', limit: 1) + visit project_commits_path(project, "master", limit: 1) expect(page).to have_link(issue.to_reference) end @@ -52,15 +52,15 @@ describe "GitLab Flavored Markdown" do describe "for issues", :js do before do @other_issue = create(:issue, - author: user, - assignees: [user], - project: project) + author: user, + assignees: [user], + project: project) @issue = create(:issue, - author: user, - assignees: [user], - project: project, - title: "fix #{@other_issue.to_reference}", - description: "ask #{fred.to_reference} for details") + author: user, + assignees: [user], + project: project, + title: "fix #{@other_issue.to_reference}", + description: "ask #{fred.to_reference} for details") @note = create(:note_on_issue, noteable: @issue, project: @issue.project, note: "Hello world") end @@ -107,9 +107,9 @@ describe "GitLab Flavored Markdown" do describe "for milestones" do before do @milestone = create(:milestone, - project: project, - title: "fix #{issue.to_reference}", - description: "ask #{fred.to_reference} for details") + project: project, + title: "fix #{issue.to_reference}", + description: "ask #{fred.to_reference} for details") end it "renders title in milestones#index" do diff --git a/spec/features/markdown/markdown_spec.rb b/spec/features/markdown/markdown_spec.rb index 8815643ca96..bc915b93417 100644 --- a/spec/features/markdown/markdown_spec.rb +++ b/spec/features/markdown/markdown_spec.rb @@ -1,5 +1,5 @@ -require 'spec_helper' -require 'erb' +require "spec_helper" +require "erb" # This feature spec is intended to be a comprehensive exercising of all of # GitLab's non-standard Markdown parsing and the integration thereof. @@ -24,7 +24,7 @@ require 'erb' # # See the MarkdownFeature class for setup details. -describe 'GitLab Markdown', :aggregate_failures do +describe "GitLab Markdown", :aggregate_failures do include Capybara::Node::Matchers include MarkupHelper include MarkdownMatchers @@ -32,8 +32,8 @@ describe 'GitLab Markdown', :aggregate_failures do # Sometimes it can be useful to see the parsed output of the Markdown document # for debugging. Call this method to write the output to # `tmp/capybara/<filename>.html`. - def write_markdown(filename = 'markdown_spec') - File.open(Rails.root.join("tmp/capybara/#{filename}.html"), 'w') do |file| + def write_markdown(filename = "markdown_spec") + File.open(Rails.root.join("tmp/capybara/#{filename}.html"), "w") do |file| file.puts @html end end @@ -43,103 +43,103 @@ describe 'GitLab Markdown', :aggregate_failures do end # Shared behavior that all pipelines should exhibit - shared_examples 'all pipelines' do - it 'includes extensions' do - aggregate_failures 'does not parse emphasis inside of words' do - expect(doc.to_html).not_to match('foo<em>bar</em>baz') + shared_examples "all pipelines" do + it "includes extensions" do + aggregate_failures "does not parse emphasis inside of words" do + expect(doc.to_html).not_to match("foo<em>bar</em>baz") end - aggregate_failures 'parses table Markdown' do + aggregate_failures "parses table Markdown" do expect(doc).to have_selector('th:contains("Header")') expect(doc).to have_selector('th:contains("Row")') expect(doc).to have_selector('th:contains("Example")') end - aggregate_failures 'allows Markdown in tables' do + aggregate_failures "allows Markdown in tables" do expect(doc.at_css('td:contains("Baz")').children.to_html) - .to eq '<strong>Baz</strong>' + .to eq "<strong>Baz</strong>" end - aggregate_failures 'parses fenced code blocks' do - expect(doc).to have_selector('pre.code.highlight.js-syntax-highlight.c') - expect(doc).to have_selector('pre.code.highlight.js-syntax-highlight.python') + aggregate_failures "parses fenced code blocks" do + expect(doc).to have_selector("pre.code.highlight.js-syntax-highlight.c") + expect(doc).to have_selector("pre.code.highlight.js-syntax-highlight.python") end - aggregate_failures 'parses mermaid code block' do - expect(doc).to have_selector('pre[lang=mermaid] > code.js-render-mermaid') + aggregate_failures "parses mermaid code block" do + expect(doc).to have_selector("pre[lang=mermaid] > code.js-render-mermaid") end - aggregate_failures 'parses strikethroughs' do + aggregate_failures "parses strikethroughs" do expect(doc).to have_selector(%{del:contains("and this text doesn't")}) end end - it 'includes SanitizationFilter' do - aggregate_failures 'permits b elements' do + it "includes SanitizationFilter" do + aggregate_failures "permits b elements" do expect(doc).to have_selector('b:contains("b tag")') end - aggregate_failures 'permits em elements' do + aggregate_failures "permits em elements" do expect(doc).to have_selector('em:contains("em tag")') end - aggregate_failures 'permits code elements' do + aggregate_failures "permits code elements" do expect(doc).to have_selector('code:contains("code tag")') end - aggregate_failures 'permits kbd elements' do + aggregate_failures "permits kbd elements" do expect(doc).to have_selector('kbd:contains("s")') end - aggregate_failures 'permits strike elements' do - expect(doc).to have_selector('strike:contains(Emoji)') + aggregate_failures "permits strike elements" do + expect(doc).to have_selector("strike:contains(Emoji)") end - aggregate_failures 'permits img elements' do + aggregate_failures "permits img elements" do expect(doc).to have_selector('img[data-src*="smile.png"]') end - aggregate_failures 'permits br elements' do - expect(doc).to have_selector('br') + aggregate_failures "permits br elements" do + expect(doc).to have_selector("br") end - aggregate_failures 'permits hr elements' do - expect(doc).to have_selector('hr') + aggregate_failures "permits hr elements" do + expect(doc).to have_selector("hr") end - aggregate_failures 'permits span elements' do + aggregate_failures "permits span elements" do expect(doc).to have_selector('span:contains("span tag")') end - aggregate_failures 'permits details elements' do + aggregate_failures "permits details elements" do expect(doc).to have_selector('details:contains("Hiding the details")') end - aggregate_failures 'permits summary elements' do + aggregate_failures "permits summary elements" do expect(doc).to have_selector('details summary:contains("collapsible")') end - aggregate_failures 'permits align attribute in th elements' do - expect(doc.at_css('th:contains("Header")')['align']).to eq 'center' - expect(doc.at_css('th:contains("Row")')['align']).to eq 'right' - expect(doc.at_css('th:contains("Example")')['align']).to eq 'left' + aggregate_failures "permits align attribute in th elements" do + expect(doc.at_css('th:contains("Header")')["align"]).to eq "center" + expect(doc.at_css('th:contains("Row")')["align"]).to eq "right" + expect(doc.at_css('th:contains("Example")')["align"]).to eq "left" end - aggregate_failures 'permits align attribute in td elements' do - expect(doc.at_css('td:contains("Foo")')['align']).to eq 'center' - expect(doc.at_css('td:contains("Bar")')['align']).to eq 'right' - expect(doc.at_css('td:contains("Baz")')['align']).to eq 'left' + aggregate_failures "permits align attribute in td elements" do + expect(doc.at_css('td:contains("Foo")')["align"]).to eq "center" + expect(doc.at_css('td:contains("Bar")')["align"]).to eq "right" + expect(doc.at_css('td:contains("Baz")')["align"]).to eq "left" end - aggregate_failures 'permits superscript elements' do - expect(doc).to have_selector('sup', count: 2) + aggregate_failures "permits superscript elements" do + expect(doc).to have_selector("sup", count: 2) end - aggregate_failures 'permits subscript elements' do - expect(doc).to have_selector('sub', count: 3) + aggregate_failures "permits subscript elements" do + expect(doc).to have_selector("sub", count: 3) end - aggregate_failures 'removes `rel` attribute from links' do + aggregate_failures "removes `rel` attribute from links" do expect(doc).not_to have_selector('a[rel="bookmark"]') end @@ -148,52 +148,52 @@ describe 'GitLab Markdown', :aggregate_failures do end end - describe 'Escaping' do - it 'escapes non-tag angle brackets' do - table = doc.css('table').last.at_css('tbody') - expect(table.at_xpath('.//tr[1]/td[3]').inner_html).to eq '1 < 3 & 5' + describe "Escaping" do + it "escapes non-tag angle brackets" do + table = doc.css("table").last.at_css("tbody") + expect(table.at_xpath(".//tr[1]/td[3]").inner_html).to eq "1 < 3 & 5" end end - describe 'Edge Cases' do - it 'allows markup inside link elements' do + describe "Edge Cases" do + it "allows markup inside link elements" do aggregate_failures do expect(doc.at_css('a[href="#link-emphasis"]').to_html) - .to eq %{<a href="#link-emphasis"><em>text</em></a>} + .to eq %(<a href="#link-emphasis"><em>text</em></a>) expect(doc.at_css('a[href="#link-strong"]').to_html) - .to eq %{<a href="#link-strong"><strong>text</strong></a>} + .to eq %(<a href="#link-strong"><strong>text</strong></a>) expect(doc.at_css('a[href="#link-code"]').to_html) - .to eq %{<a href="#link-code"><code>text</code></a>} + .to eq %(<a href="#link-code"><code>text</code></a>) end end end - it 'includes ExternalLinkFilter' do - aggregate_failures 'adds nofollow to external link' do + it "includes ExternalLinkFilter" do + aggregate_failures "adds nofollow to external link" do link = doc.at_css('a:contains("Google")') - expect(link.attr('rel')).to include('nofollow') + expect(link.attr("rel")).to include("nofollow") end - aggregate_failures 'adds noreferrer to external link' do + aggregate_failures "adds noreferrer to external link" do link = doc.at_css('a:contains("Google")') - expect(link.attr('rel')).to include('noreferrer') + expect(link.attr("rel")).to include("noreferrer") end - aggregate_failures 'adds _blank to target attribute for external links' do + aggregate_failures "adds _blank to target attribute for external links" do link = doc.at_css('a:contains("Google")') - expect(link.attr('target')).to match('_blank') + expect(link.attr("target")).to match("_blank") end - aggregate_failures 'ignores internal link' do + aggregate_failures "ignores internal link" do link = doc.at_css('a:contains("GitLab Root")') - expect(link.attr('rel')).not_to match 'nofollow' - expect(link.attr('target')).not_to match '_blank' + expect(link.attr("rel")).not_to match "nofollow" + expect(link.attr("target")).not_to match "_blank" end end end @@ -206,31 +206,31 @@ describe 'GitLab Markdown', :aggregate_failures do @group = @feat.group end - context 'default pipeline' do + context "default pipeline" do before do @html = markdown(@feat.raw_markdown) end - it_behaves_like 'all pipelines' + it_behaves_like "all pipelines" - it 'includes custom filters' do - aggregate_failures 'RelativeLinkFilter' do + it "includes custom filters" do + aggregate_failures "RelativeLinkFilter" do expect(doc).to parse_relative_links end - aggregate_failures 'EmojiFilter' do + aggregate_failures "EmojiFilter" do expect(doc).to parse_emoji end - aggregate_failures 'TableOfContentsFilter' do + aggregate_failures "TableOfContentsFilter" do expect(doc).to create_header_links end - aggregate_failures 'AutolinkFilter' do + aggregate_failures "AutolinkFilter" do expect(doc).to create_autolinks end - aggregate_failures 'all reference filters' do + aggregate_failures "all reference filters" do expect(doc).to reference_users expect(doc).to reference_issues expect(doc).to reference_merge_requests @@ -241,57 +241,57 @@ describe 'GitLab Markdown', :aggregate_failures do expect(doc).to reference_milestones end - aggregate_failures 'TaskListFilter' do + aggregate_failures "TaskListFilter" do expect(doc).to parse_task_lists end - aggregate_failures 'InlineDiffFilter' do + aggregate_failures "InlineDiffFilter" do expect(doc).to parse_inline_diffs end - aggregate_failures 'VideoLinkFilter' do + aggregate_failures "VideoLinkFilter" do expect(doc).to parse_video_links end - aggregate_failures 'ColorFilter' do + aggregate_failures "ColorFilter" do expect(doc).to parse_colors end end end - context 'wiki pipeline' do + context "wiki pipeline" do before do @project_wiki = @feat.project_wiki @project_wiki_page = @feat.project_wiki_page - path = 'images/example.jpg' + path = "images/example.jpg" gitaly_wiki_file = Gitlab::GitalyClient::WikiFile.new(path: path) expect(@project_wiki).to receive(:find_file).with(path).and_return(Gitlab::Git::WikiFile.new(gitaly_wiki_file)) - allow(@project_wiki).to receive(:wiki_base_path) { '/namespace1/gitlabhq/wikis' } + allow(@project_wiki).to receive(:wiki_base_path) { "/namespace1/gitlabhq/wikis" } - @html = markdown(@feat.raw_markdown, { pipeline: :wiki, project_wiki: @project_wiki, page_slug: @project_wiki_page.slug }) + @html = markdown(@feat.raw_markdown, {pipeline: :wiki, project_wiki: @project_wiki, page_slug: @project_wiki_page.slug}) end - it_behaves_like 'all pipelines' + it_behaves_like "all pipelines" - it 'includes custom filters' do - aggregate_failures 'RelativeLinkFilter' do + it "includes custom filters" do + aggregate_failures "RelativeLinkFilter" do expect(doc).not_to parse_relative_links end - aggregate_failures 'EmojiFilter' do + aggregate_failures "EmojiFilter" do expect(doc).to parse_emoji end - aggregate_failures 'TableOfContentsFilter' do + aggregate_failures "TableOfContentsFilter" do expect(doc).to create_header_links end - aggregate_failures 'AutolinkFilter' do + aggregate_failures "AutolinkFilter" do expect(doc).to create_autolinks end - aggregate_failures 'all reference filters' do + aggregate_failures "all reference filters" do expect(doc).to reference_users expect(doc).to reference_issues expect(doc).to reference_merge_requests @@ -302,23 +302,23 @@ describe 'GitLab Markdown', :aggregate_failures do expect(doc).to reference_milestones end - aggregate_failures 'TaskListFilter' do + aggregate_failures "TaskListFilter" do expect(doc).to parse_task_lists end - aggregate_failures 'GollumTagsFilter' do + aggregate_failures "GollumTagsFilter" do expect(doc).to parse_gollum_tags end - aggregate_failures 'InlineDiffFilter' do + aggregate_failures "InlineDiffFilter" do expect(doc).to parse_inline_diffs end - aggregate_failures 'VideoLinkFilter' do + aggregate_failures "VideoLinkFilter" do expect(doc).to parse_video_links end - aggregate_failures 'ColorFilter' do + aggregate_failures "ColorFilter" do expect(doc).to parse_colors end end diff --git a/spec/features/markdown/math_spec.rb b/spec/features/markdown/math_spec.rb index 16ad0d456be..a5e56cb7628 100644 --- a/spec/features/markdown/math_spec.rb +++ b/spec/features/markdown/math_spec.rb @@ -1,9 +1,9 @@ -require 'spec_helper' +require "spec_helper" -describe 'Math rendering', :js do +describe "Math rendering", :js do let!(:project) { create(:project, :public) } - it 'renders inline and display math correctly' do + it "renders inline and display math correctly" do description = <<~MATH This math is inline $`a^2+b^2=c^2`$. @@ -17,11 +17,11 @@ describe 'Math rendering', :js do visit project_issue_path(project, issue) - expect(page).to have_selector('.katex .mord.mathdefault', text: 'b') - expect(page).to have_selector('.katex-display .mord.mathdefault', text: 'b') + expect(page).to have_selector(".katex .mord.mathdefault", text: "b") + expect(page).to have_selector(".katex-display .mord.mathdefault", text: "b") end - it 'only renders non XSS links' do + it "only renders non XSS links" do description = <<~MATH This link is valid $`\\href{javascript:alert('xss');}{xss}`$. @@ -32,7 +32,7 @@ describe 'Math rendering', :js do visit project_issue_path(project, issue) - expect(page).to have_selector('.katex-error', text: "\href{javascript:alert('xss');}{xss}") - expect(page).to have_selector('.katex-html a', text: 'Gitlab') + expect(page).to have_selector(".katex-error", text: "\href{javascript:alert('xss');}{xss}") + expect(page).to have_selector(".katex-html a", text: "Gitlab") end end diff --git a/spec/features/markdown/mermaid_spec.rb b/spec/features/markdown/mermaid_spec.rb index 7008b361394..477f134835b 100644 --- a/spec/features/markdown/mermaid_spec.rb +++ b/spec/features/markdown/mermaid_spec.rb @@ -1,7 +1,7 @@ -require 'spec_helper' +require "spec_helper" -describe 'Mermaid rendering', :js do - it 'renders Mermaid diagrams correctly' do +describe "Mermaid rendering", :js do + it "renders Mermaid diagrams correctly" do description = <<~MERMAID ```mermaid graph TD; @@ -18,7 +18,7 @@ describe 'Mermaid rendering', :js do visit project_issue_path(project, issue) %w[A B C D].each do |label| - expect(page).to have_selector('svg text', text: label) + expect(page).to have_selector("svg text", text: label) end end end |