BigW Consortium Gitlab

project_routing_spec.rb 30 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
require 'spec_helper'

# Shared examples for a resource inside a Project
#
# By default it tests all the default REST actions: index, create, new, edit,
# show, update, and destroy. You can remove actions by customizing the
# `actions` variable.
#
# It also expects a `controller` variable to be available which defines both
# the path to the resource as well as the controller name.
#
# Examples
#
#   # Default behavior
15
#   it_behaves_like 'RESTful project resources' do
16 17 18 19
#     let(:controller) { 'issues' }
#   end
#
#   # Customizing actions
20
#   it_behaves_like 'RESTful project resources' do
21 22 23
#     let(:actions)    { [:index] }
#     let(:controller) { 'issues' }
#   end
24
shared_examples 'RESTful project resources' do
25 26
  let(:actions) { [:index, :create, :new, :edit, :show, :update, :destroy] }

27
  it 'to #index' do
Vinnie Okada committed
28
    expect(get("/gitlab/gitlabhq/#{controller}")).to route_to("projects/#{controller}#index", namespace_id: 'gitlab', project_id: 'gitlabhq') if actions.include?(:index)
29 30
  end

31
  it 'to #create' do
Vinnie Okada committed
32
    expect(post("/gitlab/gitlabhq/#{controller}")).to route_to("projects/#{controller}#create", namespace_id: 'gitlab', project_id: 'gitlabhq') if actions.include?(:create)
33 34
  end

35
  it 'to #new' do
Vinnie Okada committed
36
    expect(get("/gitlab/gitlabhq/#{controller}/new")).to route_to("projects/#{controller}#new", namespace_id: 'gitlab', project_id: 'gitlabhq') if actions.include?(:new)
37 38
  end

39
  it 'to #edit' do
Vinnie Okada committed
40
    expect(get("/gitlab/gitlabhq/#{controller}/1/edit")).to route_to("projects/#{controller}#edit", namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') if actions.include?(:edit)
41 42
  end

43
  it 'to #show' do
Vinnie Okada committed
44
    expect(get("/gitlab/gitlabhq/#{controller}/1")).to route_to("projects/#{controller}#show", namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') if actions.include?(:show)
45 46
  end

47
  it 'to #update' do
Vinnie Okada committed
48
    expect(put("/gitlab/gitlabhq/#{controller}/1")).to route_to("projects/#{controller}#update", namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') if actions.include?(:update)
49 50
  end

51
  it 'to #destroy' do
Vinnie Okada committed
52
    expect(delete("/gitlab/gitlabhq/#{controller}/1")).to route_to("projects/#{controller}#destroy", namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') if actions.include?(:destroy)
53 54 55
  end
end

56 57 58 59 60 61 62
#                 projects POST   /projects(.:format)     projects#create
#              new_project GET    /projects/new(.:format) projects#new
#            files_project GET    /:id/files(.:format)    projects#files
#             edit_project GET    /:id/edit(.:format)     projects#edit
#                  project GET    /:id(.:format)          projects#show
#                          PUT    /:id(.:format)          projects#update
#                          DELETE /:id(.:format)          projects#destroy
63
# markdown_preview_project POST   /:id/markdown_preview(.:format) projects#markdown_preview
64 65
describe ProjectsController, 'routing' do
  it 'to #create' do
66
    expect(post('/projects')).to route_to('projects#create')
67 68
  end

69
  it 'to #new' do
70
    expect(get('/projects/new')).to route_to('projects#new')
71 72
  end

73
  it 'to #edit' do
Vinnie Okada committed
74
    expect(get('/gitlab/gitlabhq/edit')).to route_to('projects#edit', namespace_id: 'gitlab', id: 'gitlabhq')
75 76
  end

77
  it 'to #autocomplete_sources' do
Vinnie Okada committed
78
    expect(get('/gitlab/gitlabhq/autocomplete_sources')).to route_to('projects#autocomplete_sources', namespace_id: 'gitlab', id: 'gitlabhq')
79 80
  end

81
  it 'to #show' do
Vinnie Okada committed
82
    expect(get('/gitlab/gitlabhq')).to route_to('projects#show', namespace_id: 'gitlab', id: 'gitlabhq')
83
    expect(get('/gitlab/gitlabhq.keys')).to route_to('projects#show', namespace_id: 'gitlab', id: 'gitlabhq.keys')
84 85
  end

86
  it 'to #update' do
Vinnie Okada committed
87
    expect(put('/gitlab/gitlabhq')).to route_to('projects#update', namespace_id: 'gitlab', id: 'gitlabhq')
88 89
  end

90
  it 'to #destroy' do
Vinnie Okada committed
91
    expect(delete('/gitlab/gitlabhq')).to route_to('projects#destroy', namespace_id: 'gitlab', id: 'gitlabhq')
92
  end
93 94

  it 'to #markdown_preview' do
95
    expect(post('/gitlab/gitlabhq/markdown_preview')).to(
Vinnie Okada committed
96
      route_to('projects#markdown_preview', namespace_id: 'gitlab', id: 'gitlabhq')
97 98
    )
  end
99 100
end

101 102 103 104 105 106
#  pages_project_wikis GET    /:project_id/wikis/pages(.:format)       projects/wikis#pages
# history_project_wiki GET    /:project_id/wikis/:id/history(.:format) projects/wikis#history
#        project_wikis POST   /:project_id/wikis(.:format)             projects/wikis#create
#    edit_project_wiki GET    /:project_id/wikis/:id/edit(.:format)    projects/wikis#edit
#         project_wiki GET    /:project_id/wikis/:id(.:format)         projects/wikis#show
#                      DELETE /:project_id/wikis/:id(.:format)         projects/wikis#destroy
107 108
describe Projects::WikisController, 'routing' do
  it 'to #pages' do
Vinnie Okada committed
109
    expect(get('/gitlab/gitlabhq/wikis/pages')).to route_to('projects/wikis#pages', namespace_id: 'gitlab', project_id: 'gitlabhq')
110 111
  end

112
  it 'to #history' do
Vinnie Okada committed
113
    expect(get('/gitlab/gitlabhq/wikis/1/history')).to route_to('projects/wikis#history', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
114 115
  end

116
  it_behaves_like 'RESTful project resources' do
117 118 119 120 121
    let(:actions)    { [:create, :edit, :show, :destroy] }
    let(:controller) { 'wikis' }
  end
end

122 123 124 125
# branches_project_repository GET    /:project_id/repository/branches(.:format) projects/repositories#branches
#     tags_project_repository GET    /:project_id/repository/tags(.:format)     projects/repositories#tags
#  archive_project_repository GET    /:project_id/repository/archive(.:format)  projects/repositories#archive
#     edit_project_repository GET    /:project_id/repository/edit(.:format)     projects/repositories#edit
126 127
describe Projects::RepositoriesController, 'routing' do
  it 'to #archive' do
Vinnie Okada committed
128
    expect(get('/gitlab/gitlabhq/repository/archive')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq')
129 130
  end

131
  it 'to #archive format:zip' do
Vinnie Okada committed
132
    expect(get('/gitlab/gitlabhq/repository/archive.zip')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'zip')
133 134
  end

135
  it 'to #archive format:tar.bz2' do
Vinnie Okada committed
136
    expect(get('/gitlab/gitlabhq/repository/archive.tar.bz2')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'tar.bz2')
137 138
  end

139
  it 'to #show' do
Vinnie Okada committed
140
    expect(get('/gitlab/gitlabhq/repository')).to route_to('projects/repositories#show', namespace_id: 'gitlab', project_id: 'gitlabhq')
141 142 143
  end
end

144 145
describe Projects::BranchesController, 'routing' do
  it 'to #branches' do
Vinnie Okada committed
146 147 148 149 150 151 152
    expect(get('/gitlab/gitlabhq/branches')).to route_to('projects/branches#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
    expect(delete('/gitlab/gitlabhq/branches/feature%2345')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45')
    expect(delete('/gitlab/gitlabhq/branches/feature%2B45')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45')
    expect(delete('/gitlab/gitlabhq/branches/feature@45')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45')
    expect(delete('/gitlab/gitlabhq/branches/feature%2345/foo/bar/baz')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45/foo/bar/baz')
    expect(delete('/gitlab/gitlabhq/branches/feature%2B45/foo/bar/baz')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45/foo/bar/baz')
    expect(delete('/gitlab/gitlabhq/branches/feature@45/foo/bar/baz')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45/foo/bar/baz')
Dmitriy Zaporozhets committed
153 154 155
  end
end

156 157
describe Projects::TagsController, 'routing' do
  it 'to #tags' do
Vinnie Okada committed
158 159 160 161 162 163 164
    expect(get('/gitlab/gitlabhq/tags')).to route_to('projects/tags#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
    expect(delete('/gitlab/gitlabhq/tags/feature%2345')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45')
    expect(delete('/gitlab/gitlabhq/tags/feature%2B45')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45')
    expect(delete('/gitlab/gitlabhq/tags/feature@45')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45')
    expect(delete('/gitlab/gitlabhq/tags/feature%2345/foo/bar/baz')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45/foo/bar/baz')
    expect(delete('/gitlab/gitlabhq/tags/feature%2B45/foo/bar/baz')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45/foo/bar/baz')
    expect(delete('/gitlab/gitlabhq/tags/feature@45/foo/bar/baz')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45/foo/bar/baz')
Dmitriy Zaporozhets committed
165 166 167
  end
end

168 169 170 171 172
#     project_deploy_keys GET    /:project_id/deploy_keys(.:format)          deploy_keys#index
#                         POST   /:project_id/deploy_keys(.:format)          deploy_keys#create
#  new_project_deploy_key GET    /:project_id/deploy_keys/new(.:format)      deploy_keys#new
#      project_deploy_key GET    /:project_id/deploy_keys/:id(.:format)      deploy_keys#show
#                         DELETE /:project_id/deploy_keys/:id(.:format)      deploy_keys#destroy
173 174
describe Projects::DeployKeysController, 'routing' do
  it_behaves_like 'RESTful project resources' do
175
    let(:actions)    { [:index, :new, :create] }
176 177 178 179 180 181 182
    let(:controller) { 'deploy_keys' }
  end
end

# project_protected_branches GET    /:project_id/protected_branches(.:format)     protected_branches#index
#                            POST   /:project_id/protected_branches(.:format)     protected_branches#create
#   project_protected_branch DELETE /:project_id/protected_branches/:id(.:format) protected_branches#destroy
183 184
describe Projects::ProtectedBranchesController, 'routing' do
  it_behaves_like 'RESTful project resources' do
185 186 187 188 189
    let(:actions)    { [:index, :create, :destroy] }
    let(:controller) { 'protected_branches' }
  end
end

Dmitriy Zaporozhets committed
190 191 192
#    switch_project_refs GET    /:project_id/refs/switch(.:format)              refs#switch
#  logs_tree_project_ref GET    /:project_id/refs/:id/logs_tree(.:format)       refs#logs_tree
#  logs_file_project_ref GET    /:project_id/refs/:id/logs_tree/:path(.:format) refs#logs_tree
193 194
describe Projects::RefsController, 'routing' do
  it 'to #switch' do
Vinnie Okada committed
195
    expect(get('/gitlab/gitlabhq/refs/switch')).to route_to('projects/refs#switch', namespace_id: 'gitlab', project_id: 'gitlabhq')
196 197 198
  end

  it 'to #logs_tree' do
Vinnie Okada committed
199 200 201 202 203 204 205 206 207
    expect(get('/gitlab/gitlabhq/refs/stable/logs_tree')).to             route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable')
    expect(get('/gitlab/gitlabhq/refs/feature%2345/logs_tree')).to             route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45')
    expect(get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree')).to             route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45')
    expect(get('/gitlab/gitlabhq/refs/feature@45/logs_tree')).to             route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45')
    expect(get('/gitlab/gitlabhq/refs/stable/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz')
    expect(get('/gitlab/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45', path: 'foo/bar/baz')
    expect(get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45', path: 'foo/bar/baz')
    expect(get('/gitlab/gitlabhq/refs/feature@45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45', path: 'foo/bar/baz')
    expect(get('/gitlab/gitlabhq/refs/stable/logs_tree/files.scss')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'files.scss')
208 209 210
  end
end

211 212
#               diffs_namespace_project_merge_request GET      /:namespace_id/:project_id/merge_requests/:id/diffs(.:format)               projects/merge_requests#diffs
#             commits_namespace_project_merge_request GET      /:namespace_id/:project_id/merge_requests/:id/commits(.:format)             projects/merge_requests#commits
213 214
#           merge_namespace_project_merge_request POST     /:namespace_id/:project_id/merge_requests/:id/merge(.:format)           projects/merge_requests#merge
#     merge_check_namespace_project_merge_request GET      /:namespace_id/:project_id/merge_requests/:id/merge_check(.:format)     projects/merge_requests#merge_check
215 216 217 218 219 220 221 222 223 224 225 226
#           ci_status_namespace_project_merge_request GET      /:namespace_id/:project_id/merge_requests/:id/ci_status(.:format)           projects/merge_requests#ci_status
# toggle_subscription_namespace_project_merge_request POST     /:namespace_id/:project_id/merge_requests/:id/toggle_subscription(.:format) projects/merge_requests#toggle_subscription
#        branch_from_namespace_project_merge_requests GET      /:namespace_id/:project_id/merge_requests/branch_from(.:format)             projects/merge_requests#branch_from
#          branch_to_namespace_project_merge_requests GET      /:namespace_id/:project_id/merge_requests/branch_to(.:format)               projects/merge_requests#branch_to
#    update_branches_namespace_project_merge_requests GET      /:namespace_id/:project_id/merge_requests/update_branches(.:format)         projects/merge_requests#update_branches
#                    namespace_project_merge_requests GET      /:namespace_id/:project_id/merge_requests(.:format)                         projects/merge_requests#index
#                                                     POST     /:namespace_id/:project_id/merge_requests(.:format)                         projects/merge_requests#create
#                 new_namespace_project_merge_request GET      /:namespace_id/:project_id/merge_requests/new(.:format)                     projects/merge_requests#new
#                edit_namespace_project_merge_request GET      /:namespace_id/:project_id/merge_requests/:id/edit(.:format)                projects/merge_requests#edit
#                     namespace_project_merge_request GET      /:namespace_id/:project_id/merge_requests/:id(.:format)                     projects/merge_requests#show
#                                                     PATCH    /:namespace_id/:project_id/merge_requests/:id(.:format)                     projects/merge_requests#update
#                                                     PUT      /:namespace_id/:project_id/merge_requests/:id(.:format)                     projects/merge_requests#update
227 228
describe Projects::MergeRequestsController, 'routing' do
  it 'to #diffs' do
Vinnie Okada committed
229
    expect(get('/gitlab/gitlabhq/merge_requests/1/diffs')).to route_to('projects/merge_requests#diffs', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
230 231
  end

232 233 234 235
  it 'to #commits' do
    expect(get('/gitlab/gitlabhq/merge_requests/1/commits')).to route_to('projects/merge_requests#commits', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
  end

236 237 238
  it 'to #merge' do
    expect(post('/gitlab/gitlabhq/merge_requests/1/merge')).to route_to(
      'projects/merge_requests#merge',
Vinnie Okada committed
239
      namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1'
240
    )
241 242
  end

243 244
  it 'to #merge_check' do
    expect(get('/gitlab/gitlabhq/merge_requests/1/merge_check')).to route_to('projects/merge_requests#merge_check', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
245 246
  end

247
  it 'to #branch_from' do
Vinnie Okada committed
248
    expect(get('/gitlab/gitlabhq/merge_requests/branch_from')).to route_to('projects/merge_requests#branch_from', namespace_id: 'gitlab', project_id: 'gitlabhq')
249 250
  end

251
  it 'to #branch_to' do
Vinnie Okada committed
252
    expect(get('/gitlab/gitlabhq/merge_requests/branch_to')).to route_to('projects/merge_requests#branch_to', namespace_id: 'gitlab', project_id: 'gitlabhq')
253 254
  end

255
  it 'to #show' do
Vinnie Okada committed
256 257
    expect(get('/gitlab/gitlabhq/merge_requests/1.diff')).to route_to('projects/merge_requests#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1', format: 'diff')
    expect(get('/gitlab/gitlabhq/merge_requests/1.patch')).to route_to('projects/merge_requests#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1', format: 'patch')
258 259
  end

260
  it_behaves_like 'RESTful project resources' do
261
    let(:controller) { 'merge_requests' }
262
    let(:actions) { [:index, :create, :new, :edit, :show, :update] }
263 264 265 266 267 268 269 270 271 272 273
  end
end

#  raw_project_snippet GET    /:project_id/snippets/:id/raw(.:format)  snippets#raw
#     project_snippets GET    /:project_id/snippets(.:format)          snippets#index
#                      POST   /:project_id/snippets(.:format)          snippets#create
#  new_project_snippet GET    /:project_id/snippets/new(.:format)      snippets#new
# edit_project_snippet GET    /:project_id/snippets/:id/edit(.:format) snippets#edit
#      project_snippet GET    /:project_id/snippets/:id(.:format)      snippets#show
#                      PUT    /:project_id/snippets/:id(.:format)      snippets#update
#                      DELETE /:project_id/snippets/:id(.:format)      snippets#destroy
274 275
describe SnippetsController, 'routing' do
  it 'to #raw' do
Vinnie Okada committed
276
    expect(get('/gitlab/gitlabhq/snippets/1/raw')).to route_to('projects/snippets#raw', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
277 278
  end

279
  it 'to #index' do
Vinnie Okada committed
280
    expect(get('/gitlab/gitlabhq/snippets')).to route_to('projects/snippets#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
281 282
  end

283
  it 'to #create' do
Vinnie Okada committed
284
    expect(post('/gitlab/gitlabhq/snippets')).to route_to('projects/snippets#create', namespace_id: 'gitlab', project_id: 'gitlabhq')
285 286
  end

287
  it 'to #new' do
Vinnie Okada committed
288
    expect(get('/gitlab/gitlabhq/snippets/new')).to route_to('projects/snippets#new', namespace_id: 'gitlab', project_id: 'gitlabhq')
289 290
  end

291
  it 'to #edit' do
Vinnie Okada committed
292
    expect(get('/gitlab/gitlabhq/snippets/1/edit')).to route_to('projects/snippets#edit', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
293 294
  end

295
  it 'to #show' do
Vinnie Okada committed
296
    expect(get('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
297 298
  end

299
  it 'to #update' do
Vinnie Okada committed
300
    expect(put('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#update', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
301 302
  end

303
  it 'to #destroy' do
Vinnie Okada committed
304
    expect(delete('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
305 306 307 308 309 310 311
  end
end

# test_project_hook GET    /:project_id/hooks/:id/test(.:format) hooks#test
#     project_hooks GET    /:project_id/hooks(.:format)          hooks#index
#                   POST   /:project_id/hooks(.:format)          hooks#create
#      project_hook DELETE /:project_id/hooks/:id(.:format)      hooks#destroy
312 313
describe Projects::HooksController, 'routing' do
  it 'to #test' do
Vinnie Okada committed
314
    expect(get('/gitlab/gitlabhq/hooks/1/test')).to route_to('projects/hooks#test', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
315 316
  end

317
  it_behaves_like 'RESTful project resources' do
318 319 320 321 322
    let(:actions)    { [:index, :create, :destroy] }
    let(:controller) { 'hooks' }
  end
end

323
# project_commit GET    /:project_id/commit/:id(.:format) commit#show {id: /\h{7,40}/, project_id: /[^\/]+/}
324 325
describe Projects::CommitController, 'routing' do
  it 'to #show' do
326 327 328
    expect(get('/gitlab/gitlabhq/commit/4246fbd')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd')
    expect(get('/gitlab/gitlabhq/commit/4246fbd.diff')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd', format: 'diff')
    expect(get('/gitlab/gitlabhq/commit/4246fbd.patch')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd', format: 'patch')
Vinnie Okada committed
329
    expect(get('/gitlab/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5')
330 331 332
  end
end

333 334 335 336
#    patch_project_commit GET    /:project_id/commits/:id/patch(.:format) commits#patch
#         project_commits GET    /:project_id/commits(.:format)           commits#index
#                         POST   /:project_id/commits(.:format)           commits#create
#          project_commit GET    /:project_id/commits/:id(.:format)       commits#show
337 338
describe Projects::CommitsController, 'routing' do
  it_behaves_like 'RESTful project resources' do
339
    let(:actions)    { [:show] }
340 341
    let(:controller) { 'commits' }
  end
342

343
  it 'to #show' do
Vinnie Okada committed
344
    expect(get('/gitlab/gitlabhq/commits/master.atom')).to route_to('projects/commits#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master', format: 'atom')
345
  end
346 347
end

348 349 350 351 352
#     project_project_members GET    /:project_id/project_members(.:format)          project_members#index
#                          POST   /:project_id/project_members(.:format)          project_members#create
#                          PUT    /:project_id/project_members/:id(.:format)      project_members#update
#                          DELETE /:project_id/project_members/:id(.:format)      project_members#destroy
describe Projects::ProjectMembersController, 'routing' do
353
  it_behaves_like 'RESTful project resources' do
354 355
    let(:actions)    { [:index, :create, :update, :destroy] }
    let(:controller) { 'project_members' }
356 357 358 359 360 361 362 363 364 365
  end
end

#     project_milestones GET    /:project_id/milestones(.:format)          milestones#index
#                        POST   /:project_id/milestones(.:format)          milestones#create
#  new_project_milestone GET    /:project_id/milestones/new(.:format)      milestones#new
# edit_project_milestone GET    /:project_id/milestones/:id/edit(.:format) milestones#edit
#      project_milestone GET    /:project_id/milestones/:id(.:format)      milestones#show
#                        PUT    /:project_id/milestones/:id(.:format)      milestones#update
#                        DELETE /:project_id/milestones/:id(.:format)      milestones#destroy
366 367
describe Projects::MilestonesController, 'routing' do
  it_behaves_like 'RESTful project resources' do
368
    let(:controller) { 'milestones' }
369
    let(:actions) { [:index, :create, :new, :edit, :show, :update] }
370 371 372 373
  end
end

# project_labels GET    /:project_id/labels(.:format) labels#index
374 375
describe Projects::LabelsController, 'routing' do
  it 'to #index' do
Vinnie Okada committed
376
    expect(get('/gitlab/gitlabhq/labels')).to route_to('projects/labels#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
377 378 379 380 381 382 383 384 385 386 387 388 389
  end
end

#        sort_project_issues POST   /:project_id/issues/sort(.:format)        issues#sort
# bulk_update_project_issues POST   /:project_id/issues/bulk_update(.:format) issues#bulk_update
#      search_project_issues GET    /:project_id/issues/search(.:format)      issues#search
#             project_issues GET    /:project_id/issues(.:format)             issues#index
#                            POST   /:project_id/issues(.:format)             issues#create
#          new_project_issue GET    /:project_id/issues/new(.:format)         issues#new
#         edit_project_issue GET    /:project_id/issues/:id/edit(.:format)    issues#edit
#              project_issue GET    /:project_id/issues/:id(.:format)         issues#show
#                            PUT    /:project_id/issues/:id(.:format)         issues#update
#                            DELETE /:project_id/issues/:id(.:format)         issues#destroy
390 391
describe Projects::IssuesController, 'routing' do
  it 'to #bulk_update' do
Vinnie Okada committed
392
    expect(post('/gitlab/gitlabhq/issues/bulk_update')).to route_to('projects/issues#bulk_update', namespace_id: 'gitlab', project_id: 'gitlabhq')
393 394
  end

395
  it_behaves_like 'RESTful project resources' do
396
    let(:controller) { 'issues' }
397
    let(:actions) { [:index, :create, :new, :edit, :show, :update] }
398 399 400 401 402 403
  end
end

#         project_notes GET    /:project_id/notes(.:format)         notes#index
#                       POST   /:project_id/notes(.:format)         notes#create
#          project_note DELETE /:project_id/notes/:id(.:format)     notes#destroy
404 405
describe Projects::NotesController, 'routing' do
  it_behaves_like 'RESTful project resources' do
406 407 408 409
    let(:actions)    { [:index, :create, :destroy] }
    let(:controller) { 'notes' }
  end
end
410

411
# project_blame GET    /:project_id/blame/:id(.:format) blame#show {id: /.+/, project_id: /[^\/]+/}
412 413
describe Projects::BlameController, 'routing' do
  it 'to #show' do
Vinnie Okada committed
414 415
    expect(get('/gitlab/gitlabhq/blame/master/app/models/project.rb')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
    expect(get('/gitlab/gitlabhq/blame/master/files.scss')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
416 417 418
  end
end

419
# project_blob GET    /:project_id/blob/:id(.:format) blob#show {id: /.+/, project_id: /[^\/]+/}
420 421
describe Projects::BlobController, 'routing' do
  it 'to #show' do
Vinnie Okada committed
422 423 424 425
    expect(get('/gitlab/gitlabhq/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
    expect(get('/gitlab/gitlabhq/blob/master/app/models/compare.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/compare.rb')
    expect(get('/gitlab/gitlabhq/blob/master/app/models/diff.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/diff.js')
    expect(get('/gitlab/gitlabhq/blob/master/files.scss')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
426 427 428
  end
end

429
# project_tree GET    /:project_id/tree/:id(.:format) tree#show {id: /.+/, project_id: /[^\/]+/}
430 431
describe Projects::TreeController, 'routing' do
  it 'to #show' do
Vinnie Okada committed
432 433
    expect(get('/gitlab/gitlabhq/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
    expect(get('/gitlab/gitlabhq/tree/master/files.scss')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
434 435 436
  end
end

437 438 439 440 441 442 443 444 445 446 447 448
# project_find_file GET /:namespace_id/:project_id/find_file/*id(.:format)  projects/find_file#show {:id=>/.+/, :namespace_id=>/[a-zA-Z.0-9_\-]+/, :project_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/, :format=>/html/}
# project_files     GET /:namespace_id/:project_id/files/*id(.:format)      projects/find_file#list {:id=>/(?:[^.]|\.(?!json$))+/, :namespace_id=>/[a-zA-Z.0-9_\-]+/, :project_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/, :format=>/json/}
describe Projects::FindFileController, 'routing' do
  it 'to #show' do
    expect(get('/gitlab/gitlabhq/find_file/master')).to route_to('projects/find_file#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master')
  end

  it 'to #list' do
    expect(get('/gitlab/gitlabhq/files/master.json')).to route_to('projects/find_file#list', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master', format: 'json')
  end
end

449 450
describe Projects::BlobController, 'routing' do
  it 'to #edit' do
451
    expect(get('/gitlab/gitlabhq/edit/master/app/models/project.rb')).to(
452
      route_to('projects/blob#edit',
Vinnie Okada committed
453
               namespace_id: 'gitlab', project_id: 'gitlabhq',
454 455 456 457
               id: 'master/app/models/project.rb'))
  end

  it 'to #preview' do
458
    expect(post('/gitlab/gitlabhq/preview/master/app/models/project.rb')).to(
459
      route_to('projects/blob#preview',
Vinnie Okada committed
460
               namespace_id: 'gitlab', project_id: 'gitlabhq',
461 462 463 464
               id: 'master/app/models/project.rb'))
  end
end

465 466 467
# project_compare_index GET    /:project_id/compare(.:format)             compare#index {id: /[^\/]+/, project_id: /[^\/]+/}
#                       POST   /:project_id/compare(.:format)             compare#create {id: /[^\/]+/, project_id: /[^\/]+/}
#       project_compare        /:project_id/compare/:from...:to(.:format) compare#show {from: /.+/, to: /.+/, id: /[^\/]+/, project_id: /[^\/]+/}
468 469
describe Projects::CompareController, 'routing' do
  it 'to #index' do
Vinnie Okada committed
470
    expect(get('/gitlab/gitlabhq/compare')).to route_to('projects/compare#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
471 472
  end

473
  it 'to #compare' do
Vinnie Okada committed
474
    expect(post('/gitlab/gitlabhq/compare')).to route_to('projects/compare#create', namespace_id: 'gitlab', project_id: 'gitlabhq')
475 476
  end

477
  it 'to #show' do
Vinnie Okada committed
478 479
    expect(get('/gitlab/gitlabhq/compare/master...stable')).to     route_to('projects/compare#show', namespace_id: 'gitlab', project_id: 'gitlabhq', from: 'master', to: 'stable')
    expect(get('/gitlab/gitlabhq/compare/issue/1234...stable')).to route_to('projects/compare#show', namespace_id: 'gitlab', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable')
480 481
  end
end
482

483 484
describe Projects::NetworkController, 'routing' do
  it 'to #show' do
Vinnie Okada committed
485 486
    expect(get('/gitlab/gitlabhq/network/master')).to route_to('projects/network#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master')
    expect(get('/gitlab/gitlabhq/network/master.json')).to route_to('projects/network#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master', format: 'json')
487 488 489
  end
end

490 491
describe Projects::GraphsController, 'routing' do
  it 'to #show' do
Vinnie Okada committed
492
    expect(get('/gitlab/gitlabhq/graphs/master')).to route_to('projects/graphs#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master')
493 494
  end
end
495

496 497
describe Projects::ForksController, 'routing' do
  it 'to #new' do
498
    expect(get('/gitlab/gitlabhq/forks/new')).to route_to('projects/forks#new', namespace_id: 'gitlab', project_id: 'gitlabhq')
499 500
  end

501
  it 'to #create' do
502
    expect(post('/gitlab/gitlabhq/forks')).to route_to('projects/forks#create', namespace_id: 'gitlab', project_id: 'gitlabhq')
503
  end
504
end
505 506 507 508

# project_avatar DELETE /project/avatar(.:format) projects/avatars#destroy
describe Projects::AvatarsController, 'routing' do
  it 'to #destroy' do
509
    expect(delete('/gitlab/gitlabhq/avatar')).to route_to(
Vinnie Okada committed
510
      'projects/avatars#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq')
511
  end
512
end