Commit 877aa5458627d42d03a7f204d02db9d326af006c

Authored by Robert Speicher
1 parent beb5e1bd

Rename gitlab_flavored_markdown_spec to gitlab_markdown_helper_spec

spec/helpers/gitlab_flavored_markdown_spec.rb
@@ -1,232 +0,0 @@ @@ -1,232 +0,0 @@
1 -require "spec_helper"  
2 -  
3 -describe GitlabMarkdownHelper do  
4 - before do  
5 - @project = Factory(:project)  
6 - @commit = @project.repo.commits.first.parents.first  
7 - @commit = CommitDecorator.decorate(Commit.new(@commit))  
8 - @other_project = Factory :project, path: "OtherPath", code: "OtherCode"  
9 - @fake_user = Factory :user, name: "fred"  
10 - end  
11 -  
12 - describe "#gfm" do  
13 - it "should return text if @project is not set" do  
14 - @project = nil  
15 -  
16 - gfm("foo").should == "foo"  
17 - end  
18 -  
19 - describe "referencing a commit" do  
20 - it "should link using a full id" do  
21 - gfm("Reverts changes from #{@commit.id}").should == "Reverts changes from #{link_to @commit.id, project_commit_path(@project, id: @commit.id), title: "Commit: #{@commit.author_name} - #{@commit.title}", class: "gfm gfm-commit "}"  
22 - end  
23 -  
24 - it "should link using a short id" do  
25 - gfm("Backported from #{@commit.id[0, 6]}").should == "Backported from #{link_to @commit.id[0, 6], project_commit_path(@project, id: @commit.id), title: "Commit: #{@commit.author_name} - #{@commit.title}", class: "gfm gfm-commit "}"  
26 - end  
27 -  
28 - it "should link with adjecent text" do  
29 - gfm("Reverted (see #{@commit.id})").should == "Reverted (see #{link_to @commit.id, project_commit_path(@project, id: @commit.id), title: "Commit: #{@commit.author_name} - #{@commit.title}", class: "gfm gfm-commit "})"  
30 - end  
31 -  
32 - it "should not link with an invalid id" do  
33 - gfm("What happened in 12345678?").should == "What happened in 12345678?"  
34 - end  
35 - end  
36 -  
37 - describe "referencing a team member" do  
38 - it "should link using a simple name" do  
39 - user = Factory :user, name: "barry"  
40 - @project.users << user  
41 - member = @project.users_projects.where(user_id: user).first  
42 -  
43 - gfm("@#{user.name} you are right").should == "#{link_to "@#{user.name}", project_team_member_path(@project, member), class: "gfm gfm-team_member "} you are right"  
44 - end  
45 -  
46 - it "should link using a name with dots" do  
47 - user = Factory :user, name: "alphA.Beta"  
48 - @project.users << user  
49 - member = @project.users_projects.where(user_id: user).first  
50 -  
51 - gfm("@#{user.name} you are right").should == "#{link_to "@#{user.name}", project_team_member_path(@project, member), class: "gfm gfm-team_member "} you are right"  
52 - end  
53 -  
54 - it "should link using name with underscores" do  
55 - user = Factory :user, name: "ping_pong_king"  
56 - @project.users << user  
57 - member = @project.users_projects.where(user_id: user).first  
58 -  
59 - gfm("@#{user.name} you are right").should == "#{link_to "@#{user.name}", project_team_member_path(@project, member), class: "gfm gfm-team_member "} you are right"  
60 - end  
61 -  
62 - it "should link with adjecent text" do  
63 - user = Factory.create(:user, name: "ace")  
64 - @project.users << user  
65 - member = @project.users_projects.where(user_id: user).first  
66 -  
67 - gfm("Mail the Admin (@#{user.name})").should == "Mail the Admin (#{link_to "@#{user.name}", project_team_member_path(@project, member), class: "gfm gfm-team_member "})"  
68 - end  
69 -  
70 - it "should add styles" do  
71 - user = Factory :user, name: "barry"  
72 - @project.users << user  
73 - gfm("@#{user.name} you are right").should have_selector(".gfm.gfm-team_member")  
74 - end  
75 -  
76 - it "should not link using a bogus name" do  
77 - gfm("What hapened to @foo?").should == "What hapened to @foo?"  
78 - end  
79 - end  
80 -  
81 - describe "referencing an issue" do  
82 - before do  
83 - @issue = Factory :issue, assignee: @fake_user, author: @fake_user, project: @project  
84 - @invalid_issue = Factory :issue, assignee: @fake_user, author: @fake_user, project: @other_project  
85 - end  
86 -  
87 - it "should link using a correct id" do  
88 - gfm("Fixes ##{@issue.id}").should == "Fixes #{link_to "##{@issue.id}", project_issue_path(@project, @issue), title: "Issue: #{@issue.title}", class: "gfm gfm-issue "}"  
89 - end  
90 -  
91 - it "should link with adjecent text" do  
92 - gfm("This has already been discussed (see ##{@issue.id})").should == "This has already been discussed (see #{link_to "##{@issue.id}", project_issue_path(@project, @issue), title: "Issue: #{@issue.title}", class: "gfm gfm-issue "})"  
93 - end  
94 -  
95 - it "should add styles" do  
96 - gfm("Fixes ##{@issue.id}").should have_selector(".gfm.gfm-issue")  
97 - end  
98 -  
99 - it "should not link using an invalid id" do  
100 - gfm("##{@invalid_issue.id} has been marked duplicate of this").should == "##{@invalid_issue.id} has been marked duplicate of this"  
101 - end  
102 - end  
103 -  
104 - describe "referencing a merge request" do  
105 - before do  
106 - @merge_request = Factory :merge_request, assignee: @fake_user, author: @fake_user, project: @project  
107 - @invalid_merge_request = Factory :merge_request, assignee: @fake_user, author: @fake_user, project: @other_project  
108 - end  
109 -  
110 - it "should link using a correct id" do  
111 - gfm("Fixed in !#{@merge_request.id}").should == "Fixed in #{link_to "!#{@merge_request.id}", project_merge_request_path(@project, @merge_request), title: "Merge Request: #{@merge_request.title}", class: "gfm gfm-merge_request "}"  
112 - end  
113 -  
114 - it "should link with adjecent text" do  
115 - gfm("This has been fixed already (see !#{@merge_request.id})").should == "This has been fixed already (see #{link_to "!#{@merge_request.id}", project_merge_request_path(@project, @merge_request), title: "Merge Request: #{@merge_request.title}", class: "gfm gfm-merge_request "})"  
116 - end  
117 -  
118 - it "should add styles" do  
119 - gfm("Fixed in !#{@merge_request.id}").should have_selector(".gfm.gfm-merge_request")  
120 - end  
121 -  
122 - it "should not link using an invalid id" do  
123 - gfm("!#{@invalid_merge_request.id} violates our coding guidelines")  
124 - end  
125 - end  
126 -  
127 - describe "referencing a snippet" do  
128 - before do  
129 - @snippet = Factory.create(:snippet,  
130 - title: "Render asset to string",  
131 - author: @fake_user,  
132 - project: @project)  
133 - end  
134 -  
135 - it "should link using a correct id" do  
136 - gfm("Check out $#{@snippet.id}").should == "Check out #{link_to "$#{@snippet.id}", project_snippet_path(@project, @snippet), title: "Snippet: #{@snippet.title}", class: "gfm gfm-snippet "}"  
137 - end  
138 -  
139 - it "should link with adjecent text" do  
140 - gfm("I have created a snippet for that ($#{@snippet.id})").should == "I have created a snippet for that (#{link_to "$#{@snippet.id}", project_snippet_path(@project, @snippet), title: "Snippet: #{@snippet.title}", class: "gfm gfm-snippet "})"  
141 - end  
142 -  
143 - it "should add styles" do  
144 - gfm("Check out $#{@snippet.id}").should have_selector(".gfm.gfm-snippet")  
145 - end  
146 -  
147 - it "should not link using an invalid id" do  
148 - gfm("Don't use $1234").should == "Don't use $1234"  
149 - end  
150 - end  
151 -  
152 - it "should link to multiple things" do  
153 - user = Factory :user, name: "barry"  
154 - @project.users << user  
155 - member = @project.users_projects.where(user_id: user).first  
156 -  
157 - gfm("Let @#{user.name} fix the *mess* in #{@commit.id}").should == "Let #{link_to "@#{user.name}", project_team_member_path(@project, member), class: "gfm gfm-team_member "} fix the *mess* in #{link_to @commit.id, project_commit_path(@project, id: @commit.id), title: "Commit: #{@commit.author_name} - #{@commit.title}", class: "gfm gfm-commit "}"  
158 - end  
159 -  
160 - it "should not trip over other stuff" do  
161 - gfm("_Please_ *stop* 'helping' and all the other b*$#%' you do.").should == "_Please_ *stop* 'helping' and all the other b*$#%' you do."  
162 - end  
163 -  
164 - it "should not touch HTML entities" do  
165 - gfm("We&#39;ll accept good pull requests.").should == "We&#39;ll accept good pull requests."  
166 - end  
167 -  
168 - it "should forward HTML options to links" do  
169 - gfm("fixed in #{@commit.id}", class: "foo").should have_selector("a.foo")  
170 - end  
171 - end  
172 -  
173 - describe "#link_to_gfm" do  
174 - let(:issue1) { Factory :issue, assignee: @fake_user, author: @fake_user, project: @project }  
175 - let(:issue2) { Factory :issue, assignee: @fake_user, author: @fake_user, project: @project }  
176 -  
177 - it "should handle references nested in links with all the text" do  
178 - link_to_gfm("This should finally fix ##{issue1.id} and ##{issue2.id} for real", project_commit_path(@project, id: @commit.id)).should == "#{link_to "This should finally fix ", project_commit_path(@project, id: @commit.id)}#{link_to "##{issue1.id}", project_issue_path(@project, issue1), title: "Issue: #{issue1.title}", class: "gfm gfm-issue "}#{link_to " and ", project_commit_path(@project, id: @commit.id)}#{link_to "##{issue2.id}", project_issue_path(@project, issue2), title: "Issue: #{issue2.title}", class: "gfm gfm-issue "}#{link_to " for real", project_commit_path(@project, id: @commit.id)}"  
179 - end  
180 -  
181 - it "should forward HTML options" do  
182 - link_to_gfm("This should finally fix ##{issue1.id} for real", project_commit_path(@project, id: @commit.id), class: "foo").should have_selector(".foo")  
183 - end  
184 - end  
185 -  
186 - describe "#markdown" do  
187 - before do  
188 - @issue = Factory :issue, assignee: @fake_user, author: @fake_user, project: @project  
189 - @merge_request = Factory :merge_request, assignee: @fake_user, author: @fake_user, project: @project  
190 - @note = Factory.create(:note,  
191 - note: "Screenshot of the new feature",  
192 - project: @project,  
193 - noteable_id: @commit.id,  
194 - noteable_type: "Commit",  
195 - attachment: "screenshot123.jpg")  
196 - @snippet = Factory.create(:snippet,  
197 - title: "Render asset to string",  
198 - author: @fake_user,  
199 - project: @project)  
200 -  
201 - @other_user = Factory :user, name: "bill"  
202 - @project.users << @other_user  
203 - @member = @project.users_projects.where(user_id: @other_user).first  
204 - end  
205 -  
206 - it "should handle references in paragraphs" do  
207 - markdown("\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. #{@commit.id} Nam pulvinar sapien eget odio adipiscing at faucibus orci vestibulum.\n").should == "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. #{link_to @commit.id, project_commit_path(@project, id: @commit.id), title: "Commit: #{@commit.author_name} - #{@commit.title}", class: "gfm gfm-commit "} Nam pulvinar sapien eget odio adipiscing at faucibus orci vestibulum.</p>\n"  
208 - end  
209 -  
210 - it "should handle references in headers" do  
211 - markdown("\n# Working around ##{@issue.id} for now\n## Apply !#{@merge_request.id}").should == "<h1 id=\"toc_0\">Working around #{link_to "##{@issue.id}", project_issue_path(@project, @issue), title: "Issue: #{@issue.title}", class: "gfm gfm-issue "} for now</h1>\n\n<h2 id=\"toc_1\">Apply #{link_to "!#{@merge_request.id}", project_merge_request_path(@project, @merge_request), title: "Merge Request: #{@merge_request.title}", class: "gfm gfm-merge_request "}</h2>\n"  
212 - end  
213 -  
214 - it "should handle references in lists" do  
215 - markdown("\n* dark: ##{@issue.id}\n* light by @#{@other_user.name}\n").should == "<ul>\n<li>dark: #{link_to "##{@issue.id}", project_issue_path(@project, @issue), title: "Issue: #{@issue.title}", class: "gfm gfm-issue "}</li>\n<li>light by #{link_to "@#{@other_user.name}", project_team_member_path(@project, @member), class: "gfm gfm-team_member "}</li>\n</ul>\n"  
216 - end  
217 -  
218 - it "should handle references in <em>" do  
219 - markdown("Apply _!#{@merge_request.id}_ ASAP").should == "<p>Apply <em>#{link_to "!#{@merge_request.id}", project_merge_request_path(@project, @merge_request), title: "Merge Request: #{@merge_request.title}", class: "gfm gfm-merge_request "}</em> ASAP</p>\n"  
220 - end  
221 -  
222 - it "should leave code blocks untouched" do  
223 - markdown("\n some code from $#{@snippet.id}\n here too\n").should == "<div class=\"highlight\"><pre><span class=\"n\">some</span> <span class=\"n\">code</span> <span class=\"n\">from</span> $#{@snippet.id}\n<span class=\"n\">here</span> <span class=\"n\">too</span>\n</pre>\n</div>\n"  
224 -  
225 - markdown("\n```\nsome code from $#{@snippet.id}\nhere too\n```\n").should == "<div class=\"highlight\"><pre><span class=\"n\">some</span> <span class=\"n\">code</span> <span class=\"n\">from</span> $#{@snippet.id}\n<span class=\"n\">here</span> <span class=\"n\">too</span>\n</pre>\n</div>\n"  
226 - end  
227 -  
228 - it "should leave inline code untouched" do  
229 - markdown("\nDon't use `$#{@snippet.id}` here.\n").should == "<p>Don&#39;t use <code>$#{@snippet.id}</code> here.</p>\n"  
230 - end  
231 - end  
232 -end  
spec/helpers/gitlab_markdown_helper_spec.rb 0 → 100644
@@ -0,0 +1,232 @@ @@ -0,0 +1,232 @@
  1 +require "spec_helper"
  2 +
  3 +describe GitlabMarkdownHelper do
  4 + before do
  5 + @project = Factory(:project)
  6 + @commit = @project.repo.commits.first.parents.first
  7 + @commit = CommitDecorator.decorate(Commit.new(@commit))
  8 + @other_project = Factory :project, path: "OtherPath", code: "OtherCode"
  9 + @fake_user = Factory :user, name: "fred"
  10 + end
  11 +
  12 + describe "#gfm" do
  13 + it "should return text if @project is not set" do
  14 + @project = nil
  15 +
  16 + gfm("foo").should == "foo"
  17 + end
  18 +
  19 + describe "referencing a commit" do
  20 + it "should link using a full id" do
  21 + gfm("Reverts changes from #{@commit.id}").should == "Reverts changes from #{link_to @commit.id, project_commit_path(@project, id: @commit.id), title: "Commit: #{@commit.author_name} - #{@commit.title}", class: "gfm gfm-commit "}"
  22 + end
  23 +
  24 + it "should link using a short id" do
  25 + gfm("Backported from #{@commit.id[0, 6]}").should == "Backported from #{link_to @commit.id[0, 6], project_commit_path(@project, id: @commit.id), title: "Commit: #{@commit.author_name} - #{@commit.title}", class: "gfm gfm-commit "}"
  26 + end
  27 +
  28 + it "should link with adjecent text" do
  29 + gfm("Reverted (see #{@commit.id})").should == "Reverted (see #{link_to @commit.id, project_commit_path(@project, id: @commit.id), title: "Commit: #{@commit.author_name} - #{@commit.title}", class: "gfm gfm-commit "})"
  30 + end
  31 +
  32 + it "should not link with an invalid id" do
  33 + gfm("What happened in 12345678?").should == "What happened in 12345678?"
  34 + end
  35 + end
  36 +
  37 + describe "referencing a team member" do
  38 + it "should link using a simple name" do
  39 + user = Factory :user, name: "barry"
  40 + @project.users << user
  41 + member = @project.users_projects.where(user_id: user).first
  42 +
  43 + gfm("@#{user.name} you are right").should == "#{link_to "@#{user.name}", project_team_member_path(@project, member), class: "gfm gfm-team_member "} you are right"
  44 + end
  45 +
  46 + it "should link using a name with dots" do
  47 + user = Factory :user, name: "alphA.Beta"
  48 + @project.users << user
  49 + member = @project.users_projects.where(user_id: user).first
  50 +
  51 + gfm("@#{user.name} you are right").should == "#{link_to "@#{user.name}", project_team_member_path(@project, member), class: "gfm gfm-team_member "} you are right"
  52 + end
  53 +
  54 + it "should link using name with underscores" do
  55 + user = Factory :user, name: "ping_pong_king"
  56 + @project.users << user
  57 + member = @project.users_projects.where(user_id: user).first
  58 +
  59 + gfm("@#{user.name} you are right").should == "#{link_to "@#{user.name}", project_team_member_path(@project, member), class: "gfm gfm-team_member "} you are right"
  60 + end
  61 +
  62 + it "should link with adjecent text" do
  63 + user = Factory.create(:user, name: "ace")
  64 + @project.users << user
  65 + member = @project.users_projects.where(user_id: user).first
  66 +
  67 + gfm("Mail the Admin (@#{user.name})").should == "Mail the Admin (#{link_to "@#{user.name}", project_team_member_path(@project, member), class: "gfm gfm-team_member "})"
  68 + end
  69 +
  70 + it "should add styles" do
  71 + user = Factory :user, name: "barry"
  72 + @project.users << user
  73 + gfm("@#{user.name} you are right").should have_selector(".gfm.gfm-team_member")
  74 + end
  75 +
  76 + it "should not link using a bogus name" do
  77 + gfm("What hapened to @foo?").should == "What hapened to @foo?"
  78 + end
  79 + end
  80 +
  81 + describe "referencing an issue" do
  82 + before do
  83 + @issue = Factory :issue, assignee: @fake_user, author: @fake_user, project: @project
  84 + @invalid_issue = Factory :issue, assignee: @fake_user, author: @fake_user, project: @other_project
  85 + end
  86 +
  87 + it "should link using a correct id" do
  88 + gfm("Fixes ##{@issue.id}").should == "Fixes #{link_to "##{@issue.id}", project_issue_path(@project, @issue), title: "Issue: #{@issue.title}", class: "gfm gfm-issue "}"
  89 + end
  90 +
  91 + it "should link with adjecent text" do
  92 + gfm("This has already been discussed (see ##{@issue.id})").should == "This has already been discussed (see #{link_to "##{@issue.id}", project_issue_path(@project, @issue), title: "Issue: #{@issue.title}", class: "gfm gfm-issue "})"
  93 + end
  94 +
  95 + it "should add styles" do
  96 + gfm("Fixes ##{@issue.id}").should have_selector(".gfm.gfm-issue")
  97 + end
  98 +
  99 + it "should not link using an invalid id" do
  100 + gfm("##{@invalid_issue.id} has been marked duplicate of this").should == "##{@invalid_issue.id} has been marked duplicate of this"
  101 + end
  102 + end
  103 +
  104 + describe "referencing a merge request" do
  105 + before do
  106 + @merge_request = Factory :merge_request, assignee: @fake_user, author: @fake_user, project: @project
  107 + @invalid_merge_request = Factory :merge_request, assignee: @fake_user, author: @fake_user, project: @other_project
  108 + end
  109 +
  110 + it "should link using a correct id" do
  111 + gfm("Fixed in !#{@merge_request.id}").should == "Fixed in #{link_to "!#{@merge_request.id}", project_merge_request_path(@project, @merge_request), title: "Merge Request: #{@merge_request.title}", class: "gfm gfm-merge_request "}"
  112 + end
  113 +
  114 + it "should link with adjecent text" do
  115 + gfm("This has been fixed already (see !#{@merge_request.id})").should == "This has been fixed already (see #{link_to "!#{@merge_request.id}", project_merge_request_path(@project, @merge_request), title: "Merge Request: #{@merge_request.title}", class: "gfm gfm-merge_request "})"
  116 + end
  117 +
  118 + it "should add styles" do
  119 + gfm("Fixed in !#{@merge_request.id}").should have_selector(".gfm.gfm-merge_request")
  120 + end
  121 +
  122 + it "should not link using an invalid id" do
  123 + gfm("!#{@invalid_merge_request.id} violates our coding guidelines")
  124 + end
  125 + end
  126 +
  127 + describe "referencing a snippet" do
  128 + before do
  129 + @snippet = Factory.create(:snippet,
  130 + title: "Render asset to string",
  131 + author: @fake_user,
  132 + project: @project)
  133 + end
  134 +
  135 + it "should link using a correct id" do
  136 + gfm("Check out $#{@snippet.id}").should == "Check out #{link_to "$#{@snippet.id}", project_snippet_path(@project, @snippet), title: "Snippet: #{@snippet.title}", class: "gfm gfm-snippet "}"
  137 + end
  138 +
  139 + it "should link with adjecent text" do
  140 + gfm("I have created a snippet for that ($#{@snippet.id})").should == "I have created a snippet for that (#{link_to "$#{@snippet.id}", project_snippet_path(@project, @snippet), title: "Snippet: #{@snippet.title}", class: "gfm gfm-snippet "})"
  141 + end
  142 +
  143 + it "should add styles" do
  144 + gfm("Check out $#{@snippet.id}").should have_selector(".gfm.gfm-snippet")
  145 + end
  146 +
  147 + it "should not link using an invalid id" do
  148 + gfm("Don't use $1234").should == "Don't use $1234"
  149 + end
  150 + end
  151 +
  152 + it "should link to multiple things" do
  153 + user = Factory :user, name: "barry"
  154 + @project.users << user
  155 + member = @project.users_projects.where(user_id: user).first
  156 +
  157 + gfm("Let @#{user.name} fix the *mess* in #{@commit.id}").should == "Let #{link_to "@#{user.name}", project_team_member_path(@project, member), class: "gfm gfm-team_member "} fix the *mess* in #{link_to @commit.id, project_commit_path(@project, id: @commit.id), title: "Commit: #{@commit.author_name} - #{@commit.title}", class: "gfm gfm-commit "}"
  158 + end
  159 +
  160 + it "should not trip over other stuff" do
  161 + gfm("_Please_ *stop* 'helping' and all the other b*$#%' you do.").should == "_Please_ *stop* 'helping' and all the other b*$#%' you do."
  162 + end
  163 +
  164 + it "should not touch HTML entities" do
  165 + gfm("We&#39;ll accept good pull requests.").should == "We&#39;ll accept good pull requests."
  166 + end
  167 +
  168 + it "should forward HTML options to links" do
  169 + gfm("fixed in #{@commit.id}", class: "foo").should have_selector("a.foo")
  170 + end
  171 + end
  172 +
  173 + describe "#link_to_gfm" do
  174 + let(:issue1) { Factory :issue, assignee: @fake_user, author: @fake_user, project: @project }
  175 + let(:issue2) { Factory :issue, assignee: @fake_user, author: @fake_user, project: @project }
  176 +
  177 + it "should handle references nested in links with all the text" do
  178 + link_to_gfm("This should finally fix ##{issue1.id} and ##{issue2.id} for real", project_commit_path(@project, id: @commit.id)).should == "#{link_to "This should finally fix ", project_commit_path(@project, id: @commit.id)}#{link_to "##{issue1.id}", project_issue_path(@project, issue1), title: "Issue: #{issue1.title}", class: "gfm gfm-issue "}#{link_to " and ", project_commit_path(@project, id: @commit.id)}#{link_to "##{issue2.id}", project_issue_path(@project, issue2), title: "Issue: #{issue2.title}", class: "gfm gfm-issue "}#{link_to " for real", project_commit_path(@project, id: @commit.id)}"
  179 + end
  180 +
  181 + it "should forward HTML options" do
  182 + link_to_gfm("This should finally fix ##{issue1.id} for real", project_commit_path(@project, id: @commit.id), class: "foo").should have_selector(".foo")
  183 + end
  184 + end
  185 +
  186 + describe "#markdown" do
  187 + before do
  188 + @issue = Factory :issue, assignee: @fake_user, author: @fake_user, project: @project
  189 + @merge_request = Factory :merge_request, assignee: @fake_user, author: @fake_user, project: @project
  190 + @note = Factory.create(:note,
  191 + note: "Screenshot of the new feature",
  192 + project: @project,
  193 + noteable_id: @commit.id,
  194 + noteable_type: "Commit",
  195 + attachment: "screenshot123.jpg")
  196 + @snippet = Factory.create(:snippet,
  197 + title: "Render asset to string",
  198 + author: @fake_user,
  199 + project: @project)
  200 +
  201 + @other_user = Factory :user, name: "bill"
  202 + @project.users << @other_user
  203 + @member = @project.users_projects.where(user_id: @other_user).first
  204 + end
  205 +
  206 + it "should handle references in paragraphs" do
  207 + markdown("\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. #{@commit.id} Nam pulvinar sapien eget odio adipiscing at faucibus orci vestibulum.\n").should == "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. #{link_to @commit.id, project_commit_path(@project, id: @commit.id), title: "Commit: #{@commit.author_name} - #{@commit.title}", class: "gfm gfm-commit "} Nam pulvinar sapien eget odio adipiscing at faucibus orci vestibulum.</p>\n"
  208 + end
  209 +
  210 + it "should handle references in headers" do
  211 + markdown("\n# Working around ##{@issue.id} for now\n## Apply !#{@merge_request.id}").should == "<h1 id=\"toc_0\">Working around #{link_to "##{@issue.id}", project_issue_path(@project, @issue), title: "Issue: #{@issue.title}", class: "gfm gfm-issue "} for now</h1>\n\n<h2 id=\"toc_1\">Apply #{link_to "!#{@merge_request.id}", project_merge_request_path(@project, @merge_request), title: "Merge Request: #{@merge_request.title}", class: "gfm gfm-merge_request "}</h2>\n"
  212 + end
  213 +
  214 + it "should handle references in lists" do
  215 + markdown("\n* dark: ##{@issue.id}\n* light by @#{@other_user.name}\n").should == "<ul>\n<li>dark: #{link_to "##{@issue.id}", project_issue_path(@project, @issue), title: "Issue: #{@issue.title}", class: "gfm gfm-issue "}</li>\n<li>light by #{link_to "@#{@other_user.name}", project_team_member_path(@project, @member), class: "gfm gfm-team_member "}</li>\n</ul>\n"
  216 + end
  217 +
  218 + it "should handle references in <em>" do
  219 + markdown("Apply _!#{@merge_request.id}_ ASAP").should == "<p>Apply <em>#{link_to "!#{@merge_request.id}", project_merge_request_path(@project, @merge_request), title: "Merge Request: #{@merge_request.title}", class: "gfm gfm-merge_request "}</em> ASAP</p>\n"
  220 + end
  221 +
  222 + it "should leave code blocks untouched" do
  223 + markdown("\n some code from $#{@snippet.id}\n here too\n").should == "<div class=\"highlight\"><pre><span class=\"n\">some</span> <span class=\"n\">code</span> <span class=\"n\">from</span> $#{@snippet.id}\n<span class=\"n\">here</span> <span class=\"n\">too</span>\n</pre>\n</div>\n"
  224 +
  225 + markdown("\n```\nsome code from $#{@snippet.id}\nhere too\n```\n").should == "<div class=\"highlight\"><pre><span class=\"n\">some</span> <span class=\"n\">code</span> <span class=\"n\">from</span> $#{@snippet.id}\n<span class=\"n\">here</span> <span class=\"n\">too</span>\n</pre>\n</div>\n"
  226 + end
  227 +
  228 + it "should leave inline code untouched" do
  229 + markdown("\nDon't use `$#{@snippet.id}` here.\n").should == "<p>Don&#39;t use <code>$#{@snippet.id}</code> here.</p>\n"
  230 + end
  231 + end
  232 +end