Commit 281643a1bfd6f4da88a278bfce20133c80105de5

Authored by Marin Jankovski
1 parent 603e04bc

Add feature spec.

features/project/issues/issues.feature
@@ -68,6 +68,12 @@ Feature: Project Issues @@ -68,6 +68,12 @@ Feature: Project Issues
68 And I leave a comment with a header containing "Comment with a header" 68 And I leave a comment with a header containing "Comment with a header"
69 Then The comment with the header should not have an ID 69 Then The comment with the header should not have an ID
70 70
  71 + @javascript
  72 + Scenario: Blocks inside comments should not build relative links
  73 + Given I visit issue page "Release 0.4"
  74 + And I leave a comment with code block
  75 + Then The code block should be unchanged
  76 +
71 Scenario: Issues on empty project 77 Scenario: Issues on empty project
72 Given empty project "Empty Project" 78 Given empty project "Empty Project"
73 When I visit empty project page 79 When I visit empty project page
features/steps/project/issues.rb
@@ -163,4 +163,16 @@ class ProjectIssues < Spinach::FeatureSteps @@ -163,4 +163,16 @@ class ProjectIssues < Spinach::FeatureSteps
163 project = Project.find_by(name: 'Empty Project') 163 project = Project.find_by(name: 'Empty Project')
164 visit project_issues_path(project) 164 visit project_issues_path(project)
165 end 165 end
  166 +
  167 + step 'I leave a comment with code block' do
  168 + within(".js-main-target-form") do
  169 + fill_in "note[note]", with: "```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```"
  170 + click_button "Add Comment"
  171 + sleep 0.05
  172 + end
  173 + end
  174 +
  175 + step 'The code block should be unchanged' do
  176 + page.should have_content("```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```")
  177 + end
166 end 178 end
lib/redcarpet/render/gitlab_html.rb
@@ -6,8 +6,6 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML @@ -6,8 +6,6 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
6 def initialize(template, options = {}) 6 def initialize(template, options = {})
7 @template = template 7 @template = template
8 @project = @template.instance_variable_get("@project") 8 @project = @template.instance_variable_get("@project")
9 - @ref = @template.instance_variable_get("@ref")  
10 - @request_path = @template.instance_variable_get("@path")  
11 @options = options.dup 9 @options = options.dup
12 super options 10 super options
13 end 11 end
@@ -46,7 +44,9 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML @@ -46,7 +44,9 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
46 end 44 end
47 45
48 def postprocess(full_document) 46 def postprocess(full_document)
49 - full_document = h.create_relative_links(full_document) 47 + unless @template.instance_variable_get("@project_wiki") || @project.nil?
  48 + full_document = h.create_relative_links(full_document)
  49 + end
50 h.gfm(full_document) 50 h.gfm(full_document)
51 end 51 end
52 end 52 end