Commit 204964918b4926186026d6d8ff4b8212c280676a
1 parent
0a60b19b
Exists in
master
and in
4 other branches
Add specs for using GFM on a variety pages
Showing
1 changed file
with
241 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,241 @@ |
| 1 | +require 'spec_helper' | |
| 2 | + | |
| 3 | +describe "Gitlab Flavored Markdown" do | |
| 4 | + let(:project) { Factory :project } | |
| 5 | + let(:issue) { Factory :issue, :project => project } | |
| 6 | + let(:merge_request) { Factory :merge_request, :project => project } | |
| 7 | + let(:fred) do | |
| 8 | + u = Factory :user, :name => "fred" | |
| 9 | + project.users << u | |
| 10 | + u | |
| 11 | + end | |
| 12 | + | |
| 13 | + before do | |
| 14 | + # add test branch | |
| 15 | + @branch_name = "gfm-test" | |
| 16 | + r = project.repo | |
| 17 | + i = r.index | |
| 18 | + # add test file | |
| 19 | + @test_file = "gfm_test_file" | |
| 20 | + i.add(@test_file, "foo\nbar\n") | |
| 21 | + # add commit with gfm | |
| 22 | + i.commit("fix ##{issue.id}\n\nask @#{fred.name} for details", :head => @branch_name) | |
| 23 | + | |
| 24 | + # add test tag | |
| 25 | + @tag_name = "gfm-test-tag" | |
| 26 | + r.git.native(:tag, {}, @tag_name, commit.id) | |
| 27 | + end | |
| 28 | + after do | |
| 29 | + # delete test branch and tag | |
| 30 | + project.repo.git.native(:branch, {:D => true}, @branch_name) | |
| 31 | + project.repo.git.native(:tag, {:d => true}, @tag_name) | |
| 32 | + project.repo.gc_auto | |
| 33 | + end | |
| 34 | + | |
| 35 | + let(:commit) { project.commits(@branch_name).first } | |
| 36 | + | |
| 37 | + before do | |
| 38 | + login_as :user | |
| 39 | + project.add_access(@user, :read, :write) | |
| 40 | + end | |
| 41 | + | |
| 42 | + | |
| 43 | + describe "for commits" do | |
| 44 | + it "should render title in commits#index" do | |
| 45 | + visit project_commits_path(project, :ref => @branch_name) | |
| 46 | + | |
| 47 | + page.should have_link("##{issue.id}") | |
| 48 | + end | |
| 49 | + | |
| 50 | + it "should render title in commits#show" do | |
| 51 | + visit project_commit_path(project, :id => commit.id) | |
| 52 | + | |
| 53 | + page.should have_link("##{issue.id}") | |
| 54 | + end | |
| 55 | + | |
| 56 | + it "should render description in commits#show" do | |
| 57 | + visit project_commit_path(project, :id => commit.id) | |
| 58 | + | |
| 59 | + page.should have_link("@#{fred.name}") | |
| 60 | + end | |
| 61 | + | |
| 62 | + it "should render title in refs#tree", :js => true do | |
| 63 | + visit tree_project_ref_path(project, :id => @branch_name) | |
| 64 | + | |
| 65 | + within(".tree_commit") do | |
| 66 | + page.should have_link("##{issue.id}") | |
| 67 | + end | |
| 68 | + end | |
| 69 | + | |
| 70 | + it "should render title in refs#blame" do | |
| 71 | + visit blame_file_project_ref_path(project, :id => @branch_name, :path => @test_file) | |
| 72 | + | |
| 73 | + within(".blame_commit") do | |
| 74 | + page.should have_link("##{issue.id}") | |
| 75 | + end | |
| 76 | + end | |
| 77 | + | |
| 78 | + it "should render title in repositories#branches" do | |
| 79 | + visit branches_project_repository_path(project) | |
| 80 | + | |
| 81 | + page.should have_link("##{issue.id}") | |
| 82 | + end | |
| 83 | + | |
| 84 | + it "should render title in repositories#tags" do | |
| 85 | + visit tags_project_repository_path(project) | |
| 86 | + | |
| 87 | + page.should have_link("##{issue.id}") | |
| 88 | + end | |
| 89 | + end | |
| 90 | + | |
| 91 | + | |
| 92 | + describe "for issues" do | |
| 93 | + before do | |
| 94 | + @other_issue = Factory :issue, | |
| 95 | + :author => @user, | |
| 96 | + :assignee => @user, | |
| 97 | + :project => project | |
| 98 | + @issue = Factory :issue, | |
| 99 | + :author => @user, | |
| 100 | + :assignee => @user, | |
| 101 | + :project => project, | |
| 102 | + :title => "fix ##{@other_issue.id}", | |
| 103 | + :description => "ask @#{fred.name} for details" | |
| 104 | + end | |
| 105 | + | |
| 106 | + it "should render subject in issues#index" do | |
| 107 | + visit project_issues_path(project) | |
| 108 | + | |
| 109 | + page.should have_link("##{@other_issue.id}") | |
| 110 | + end | |
| 111 | + | |
| 112 | + it "should render subject in issues#show" do | |
| 113 | + visit project_issue_path(project, @issue) | |
| 114 | + | |
| 115 | + page.should have_link("##{@other_issue.id}") | |
| 116 | + end | |
| 117 | + | |
| 118 | + it "should render details in issues#show" do | |
| 119 | + visit project_issue_path(project, @issue) | |
| 120 | + | |
| 121 | + page.should have_link("@#{fred.name}") | |
| 122 | + end | |
| 123 | + end | |
| 124 | + | |
| 125 | + | |
| 126 | + describe "for merge requests" do | |
| 127 | + before do | |
| 128 | + @merge_request = Factory :merge_request, | |
| 129 | + :project => project, | |
| 130 | + :title => "fix ##{issue.id}" | |
| 131 | + end | |
| 132 | + | |
| 133 | + it "should render title in merge_requests#index" do | |
| 134 | + visit project_merge_requests_path(project) | |
| 135 | + | |
| 136 | + page.should have_link("##{issue.id}") | |
| 137 | + end | |
| 138 | + | |
| 139 | + it "should render title in merge_requests#show" do | |
| 140 | + visit project_merge_request_path(project, @merge_request) | |
| 141 | + | |
| 142 | + page.should have_link("##{issue.id}") | |
| 143 | + end | |
| 144 | + end | |
| 145 | + | |
| 146 | + | |
| 147 | + describe "for milestones" do | |
| 148 | + before do | |
| 149 | + @milestone = Factory :milestone, | |
| 150 | + :project => project, | |
| 151 | + :title => "fix ##{issue.id}", | |
| 152 | + :description => "ask @#{fred.name} for details" | |
| 153 | + end | |
| 154 | + | |
| 155 | + it "should render title in milestones#index" do | |
| 156 | + visit project_milestones_path(project) | |
| 157 | + | |
| 158 | + page.should have_link("##{issue.id}") | |
| 159 | + end | |
| 160 | + | |
| 161 | + it "should render title in milestones#show" do | |
| 162 | + visit project_milestone_path(project, @milestone) | |
| 163 | + | |
| 164 | + page.should have_link("##{issue.id}") | |
| 165 | + end | |
| 166 | + | |
| 167 | + it "should render description in milestones#show" do | |
| 168 | + visit project_milestone_path(project, @milestone) | |
| 169 | + | |
| 170 | + page.should have_link("@#{fred.name}") | |
| 171 | + end | |
| 172 | + end | |
| 173 | + | |
| 174 | + | |
| 175 | + describe "for notes" do | |
| 176 | + it "should render in commits#show", :js => true do | |
| 177 | + visit project_commit_path(project, :id => commit.id) | |
| 178 | + fill_in "note_note", :with => "see ##{issue.id}" | |
| 179 | + click_button "Add Comment" | |
| 180 | + | |
| 181 | + page.should have_link("##{issue.id}") | |
| 182 | + end | |
| 183 | + | |
| 184 | + it "should render in issue#show", :js => true do | |
| 185 | + visit project_issue_path(project, issue) | |
| 186 | + fill_in "note_note", :with => "see ##{issue.id}" | |
| 187 | + click_button "Add Comment" | |
| 188 | + | |
| 189 | + page.should have_link("##{issue.id}") | |
| 190 | + end | |
| 191 | + | |
| 192 | + it "should render in merge_request#show", :js => true do | |
| 193 | + visit project_merge_request_path(project, merge_request) | |
| 194 | + fill_in "note_note", :with => "see ##{issue.id}" | |
| 195 | + click_button "Add Comment" | |
| 196 | + | |
| 197 | + page.should have_link("##{issue.id}") | |
| 198 | + end | |
| 199 | + | |
| 200 | + it "should render in projects#wall", :js => true do | |
| 201 | + visit wall_project_path(project) | |
| 202 | + fill_in "note_note", :with => "see ##{issue.id}" | |
| 203 | + click_button "Add Comment" | |
| 204 | + | |
| 205 | + page.should have_link("##{issue.id}") | |
| 206 | + end | |
| 207 | + | |
| 208 | + it "should render in wikis#index", :js => true do | |
| 209 | + visit project_wiki_path(project, :index) | |
| 210 | + fill_in "Title", :with => 'Test title' | |
| 211 | + fill_in "Content", :with => '[link test](test)' | |
| 212 | + click_on "Save" | |
| 213 | + | |
| 214 | + fill_in "note_note", :with => "see ##{issue.id}" | |
| 215 | + click_button "Add Comment" | |
| 216 | + | |
| 217 | + page.should have_link("##{issue.id}") | |
| 218 | + end | |
| 219 | + end | |
| 220 | + | |
| 221 | + | |
| 222 | + describe "for wikis" do | |
| 223 | + before do | |
| 224 | + visit project_wiki_path(project, :index) | |
| 225 | + fill_in "Title", :with => "Circumvent ##{issue.id}" | |
| 226 | + fill_in "Content", :with => "# Other pages\n\n* [Foo](foo)\n* [Bar](bar)\n\nAlso look at ##{issue.id} :-)" | |
| 227 | + click_on "Save" | |
| 228 | + end | |
| 229 | + | |
| 230 | + it "should NOT render title in wikis#show" do | |
| 231 | + within(".content h3") do # page title | |
| 232 | + page.should have_content("Circumvent ##{issue.id}") | |
| 233 | + page.should_not have_link("##{issue.id}") | |
| 234 | + end | |
| 235 | + end | |
| 236 | + | |
| 237 | + it "should render content in wikis#show" do | |
| 238 | + page.should have_link("##{issue.id}") | |
| 239 | + end | |
| 240 | + end | |
| 241 | +end | ... | ... |