BigW Consortium Gitlab

markdown_render.rb 11.1 KB
Newer Older
1 2 3
# If you need to modify the existing seed repository for your tests,
# it is recommended that you make the changes on the `markdown` branch of the seed project repository,
# which should only be used by tests in this file. See `/spec/factories.rb#project` for more info.
4
class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
5 6
  include SharedAuthentication
  include SharedPaths
7
  include SharedMarkdown
8

9
  step 'I own project "Delta"' do
skv committed
10
    @project = Project.find_by(name: "Delta")
11
    @project ||= create(:project, name: "Delta", namespace: @user.namespace)
12 13 14
    @project.team << [@user, :master]
  end

15
  step 'I should see files from repository in markdown' do
16 17 18
    expect(current_path).to eq namespace_project_tree_path(@project.namespace, @project, "markdown")
    expect(page).to have_content "README.md"
    expect(page).to have_content "CHANGELOG"
19 20
  end

21
  step 'I should see rendered README which contains correct links' do
22 23 24 25 26 27 28
    expect(page).to have_content "Welcome to GitLab GitLab is a free project and repository management application"
    expect(page).to have_link "GitLab API doc"
    expect(page).to have_link "GitLab API website"
    expect(page).to have_link "Rake tasks"
    expect(page).to have_link "backup and restore procedure"
    expect(page).to have_link "GitLab API doc directory"
    expect(page).to have_link "Maintenance"
29 30
  end

31
  step 'I click on Gitlab API in README' do
32 33 34
    click_link "GitLab API doc"
  end

35
  step 'I should see correct document rendered' do
36 37
    expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/README.md")
    expect(page).to have_content "All API requests require authentication"
38 39
  end

40
  step 'I click on Rake tasks in README' do
41 42 43
    click_link "Rake tasks"
  end

44
  step 'I should see correct directory rendered' do
45 46 47
    expect(current_path).to eq namespace_project_tree_path(@project.namespace, @project, "markdown/doc/raketasks")
    expect(page).to have_content "backup_restore.md"
    expect(page).to have_content "maintenance.md"
48 49
  end

50
  step 'I click on GitLab API doc directory in README' do
51 52 53
    click_link "GitLab API doc directory"
  end

54
  step 'I should see correct doc/api directory rendered' do
55 56 57
    expect(current_path).to eq namespace_project_tree_path(@project.namespace, @project, "markdown/doc/api")
    expect(page).to have_content "README.md"
    expect(page).to have_content "users.md"
58 59
  end

60
  step 'I click on Maintenance in README' do
61 62 63
    click_link "Maintenance"
  end

64
  step 'I should see correct maintenance file rendered' do
65 66
    expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/raketasks/maintenance.md")
    expect(page).to have_content "bundle exec rake gitlab:env:info RAILS_ENV=production"
67 68
  end

69
  step 'I click on link "empty" in the README' do
70
    page.within('.readme-holder') do
71 72 73 74
      click_link "empty"
    end
  end

75
  step 'I click on link "id" in the README' do
76
    page.within('.readme-holder') do
77 78 79 80
      click_link "#id"
    end
  end

81
  step 'I navigate to the doc/api/README' do
82
    page.within '.tree-table' do
83 84 85
      click_link "doc"
    end

86
    page.within '.tree-table' do
87 88 89
      click_link "api"
    end

90
    page.within '.tree-table' do
91 92
      click_link "README.md"
    end
93 94
  end

95
  step 'I see correct file rendered' do
96 97 98 99
    expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/README.md")
    expect(page).to have_content "Contents"
    expect(page).to have_link "Users"
    expect(page).to have_link "Rake tasks"
100 101
  end

102
  step 'I click on users in doc/api/README' do
103 104 105
    click_link "Users"
  end

106
  step 'I should see the correct document file' do
107 108
    expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/users.md")
    expect(page).to have_content "Get a list of users."
109 110
  end

111
  step 'I click on raketasks in doc/api/README' do
112 113 114
    click_link "Rake tasks"
  end

115 116
  # Markdown branch

117
  When 'I visit markdown branch' do
Vinnie Okada committed
118
    visit namespace_project_tree_path(@project.namespace, @project, "markdown")
119 120
  end

121
  When 'I visit markdown branch "README.md" blob' do
Vinnie Okada committed
122
    visit namespace_project_blob_path(@project.namespace, @project, "markdown/README.md")
123 124 125
  end

  When 'I visit markdown branch "d" tree' do
Vinnie Okada committed
126
    visit namespace_project_tree_path(@project.namespace, @project, "markdown/d")
127 128 129
  end

  When 'I visit markdown branch "d/README.md" blob' do
Vinnie Okada committed
130
    visit namespace_project_blob_path(@project.namespace, @project, "markdown/d/README.md")
131 132
  end

133
  step 'I should see files from repository in markdown branch' do
134 135 136
    expect(current_path).to eq namespace_project_tree_path(@project.namespace, @project, "markdown")
    expect(page).to have_content "README.md"
    expect(page).to have_content "CHANGELOG"
137 138
  end

139
  step 'I see correct file rendered in markdown branch' do
140 141 142 143
    expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/README.md")
    expect(page).to have_content "Contents"
    expect(page).to have_link "Users"
    expect(page).to have_link "Rake tasks"
144 145
  end

146
  step 'I should see correct document rendered for markdown branch' do
147 148
    expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/README.md")
    expect(page).to have_content "All API requests require authentication"
149 150
  end

151
  step 'I should see correct directory rendered for markdown branch' do
152 153 154
    expect(current_path).to eq namespace_project_tree_path(@project.namespace, @project, "markdown/doc/raketasks")
    expect(page).to have_content "backup_restore.md"
    expect(page).to have_content "maintenance.md"
155 156
  end

157
  step 'I should see the users document file in markdown branch' do
158 159
    expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/users.md")
    expect(page).to have_content "Get a list of users."
160 161
  end

162 163
  # Expected link contents

164
  step 'The link with text "empty" should have url "tree/markdown"' do
Vinnie Okada committed
165
    find('a', text: /^empty$/)['href'] == current_host + namespace_project_tree_path(@project.namespace, @project, "markdown")
166 167
  end

168
  step 'The link with text "empty" should have url "blob/markdown/README.md"' do
Vinnie Okada committed
169
    find('a', text: /^empty$/)['href'] == current_host + namespace_project_blob_path(@project.namespace, @project, "markdown/README.md")
170 171
  end

172
  step 'The link with text "empty" should have url "tree/markdown/d"' do
Vinnie Okada committed
173
    find('a', text: /^empty$/)['href'] == current_host + namespace_project_tree_path(@project.namespace, @project, "markdown/d")
174 175
  end

176 177
  step 'The link with text "empty" should have '\
       'url "blob/markdown/d/README.md"' do
Vinnie Okada committed
178
    find('a', text: /^empty$/)['href'] == current_host + namespace_project_blob_path(@project.namespace, @project, "markdown/d/README.md")
179 180
  end

181
  step 'The link with text "ID" should have url "tree/markdownID"' do
Vinnie Okada committed
182
    find('a', text: /^#id$/)['href'] == current_host + namespace_project_tree_path(@project.namespace, @project, "markdown") + '#id'
183 184
  end

185
  step 'The link with text "/ID" should have url "tree/markdownID"' do
Vinnie Okada committed
186
    find('a', text: /^\/#id$/)['href'] == current_host + namespace_project_tree_path(@project.namespace, @project, "markdown") + '#id'
187 188
  end

189 190
  step 'The link with text "README.mdID" '\
       'should have url "blob/markdown/README.mdID"' do
Vinnie Okada committed
191
    find('a', text: /^README.md#id$/)['href'] == current_host + namespace_project_blob_path(@project.namespace, @project, "markdown/README.md") + '#id'
192 193
  end

194 195
  step 'The link with text "d/README.mdID" should have '\
       'url "blob/markdown/d/README.mdID"' do
Vinnie Okada committed
196
    find('a', text: /^d\/README.md#id$/)['href'] == current_host + namespace_project_blob_path(@project.namespace, @project, "d/markdown/README.md") + '#id'
197 198
  end

199
  step 'The link with text "ID" should have url "blob/markdown/README.mdID"' do
Vinnie Okada committed
200
    find('a', text: /^#id$/)['href'] == current_host + namespace_project_blob_path(@project.namespace, @project, "markdown/README.md") + '#id'
201 202
  end

203
  step 'The link with text "/ID" should have url "blob/markdown/README.mdID"' do
Vinnie Okada committed
204
    find('a', text: /^\/#id$/)['href'] == current_host + namespace_project_blob_path(@project.namespace, @project, "markdown/README.md") + '#id'
205 206 207 208
  end

  # Wiki

209
  step 'I go to wiki page' do
210
    click_link "Wiki"
211
    expect(current_path).to eq namespace_project_wiki_path(@project.namespace, @project, "home")
212 213
  end

214
  step 'I add various links to the wiki page' do
Marin Jankovski committed
215
    fill_in "wiki[content]", with: "[test](test)\n[GitLab API doc](api)\n[Rake tasks](raketasks)\n"
216 217 218 219
    fill_in "wiki[message]", with: "Adding links to wiki"
    click_button "Create page"
  end

220
  step 'Wiki page should have added links' do
221 222
    expect(current_path).to eq namespace_project_wiki_path(@project.namespace, @project, "home")
    expect(page).to have_content "test GitLab API doc Rake tasks"
223 224
  end

225 226 227 228 229 230 231 232 233 234
  step 'I add a header to the wiki page' do
    fill_in "wiki[content]", with: "# Wiki header\n"
    fill_in "wiki[message]", with: "Add header to wiki"
    click_button "Create page"
  end

  step 'Wiki header should have correct id and link' do
    header_should_have_correct_id_and_link(1, 'Wiki header', 'wiki-header')
  end

235
  step 'I click on test link' do
236 237 238
    click_link "test"
  end

239
  step 'I see new wiki page named test' do
240
    expect(current_path).to eq  namespace_project_wiki_path(@project.namespace, @project, "test")
241 242 243 244 245

    page.within(:css, ".nav-text") do
      expect(page).to have_content "Test"
      expect(page).to have_content "Edit Page"
    end
246 247 248
  end

  When 'I go back to wiki page home' do
Vinnie Okada committed
249
    visit namespace_project_wiki_path(@project.namespace, @project, "home")
250
    expect(current_path).to eq namespace_project_wiki_path(@project.namespace, @project, "home")
251 252
  end

253
  step 'I click on GitLab API doc link' do
254 255 256
    click_link "GitLab API"
  end

257
  step 'I see Gitlab API document' do
258
    expect(current_path).to eq namespace_project_wiki_path(@project.namespace, @project, "api")
259 260 261 262 263

    page.within(:css, ".nav-text") do
      expect(page).to have_content "Edit"
      expect(page).to have_content "Api"
    end
264 265
  end

266
  step 'I click on Rake tasks link' do
267 268 269
    click_link "Rake tasks"
  end

270
  step 'I see Rake tasks directory' do
271
    expect(current_path).to eq namespace_project_wiki_path(@project.namespace, @project, "raketasks")
272 273 274 275 276

    page.within(:css, ".nav-text") do
      expect(page).to have_content "Edit"
      expect(page).to have_content "Rake"
    end
277
  end
278

279
  step 'I go directory which contains README file' do
Vinnie Okada committed
280
    visit namespace_project_tree_path(@project.namespace, @project, "markdown/doc/api")
281
    expect(current_path).to eq namespace_project_tree_path(@project.namespace, @project, "markdown/doc/api")
282 283
  end

284
  step 'I click on a relative link in README' do
285 286 287
    click_link "Users"
  end

288
  step 'I should see the correct markdown' do
289 290
    expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/users.md")
    expect(page).to have_content "List users"
291
  end
292 293 294 295 296 297 298 299

  step 'Header "Application details" should have correct id and link' do
    header_should_have_correct_id_and_link(2, 'Application details', 'application-details')
  end

  step 'Header "GitLab API" should have correct id and link' do
    header_should_have_correct_id_and_link(1, 'GitLab API', 'gitlab-api')
  end
300
end