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 168
  end
end


169 170 171 172 173
#     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
174 175
describe Projects::DeployKeysController, 'routing' do
  it_behaves_like 'RESTful project resources' do
176
    let(:actions)    { [:index, :new, :create] }
177 178 179 180 181 182 183
    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
184 185
describe Projects::ProtectedBranchesController, 'routing' do
  it_behaves_like 'RESTful project resources' do
186 187 188 189 190
    let(:actions)    { [:index, :create, :destroy] }
    let(:controller) { 'protected_branches' }
  end
end

Dmitriy Zaporozhets committed
191 192 193
#    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
194 195
describe Projects::RefsController, 'routing' do
  it 'to #switch' do
Vinnie Okada committed
196
    expect(get('/gitlab/gitlabhq/refs/switch')).to route_to('projects/refs#switch', namespace_id: 'gitlab', project_id: 'gitlabhq')
197 198 199
  end

  it 'to #logs_tree' do
Vinnie Okada committed
200 201 202 203 204 205 206 207 208
    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')
209 210 211
  end
end

212 213
#               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
214 215
#           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
216 217 218 219 220 221 222 223 224 225 226 227
#           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
228 229
describe Projects::MergeRequestsController, 'routing' do
  it 'to #diffs' do
Vinnie Okada committed
230
    expect(get('/gitlab/gitlabhq/merge_requests/1/diffs')).to route_to('projects/merge_requests#diffs', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
231 232
  end

233 234 235 236
  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

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

244 245
  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')
246 247
  end

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

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

256
  it 'to #show' do
Vinnie Okada committed
257 258
    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')
259 260
  end

261
  it_behaves_like 'RESTful project resources' do
262
    let(:controller) { 'merge_requests' }
263
    let(:actions) { [:index, :create, :new, :edit, :show, :update] }
264 265 266 267 268 269 270 271 272 273 274
  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
275 276
describe SnippetsController, 'routing' do
  it 'to #raw' do
Vinnie Okada committed
277
    expect(get('/gitlab/gitlabhq/snippets/1/raw')).to route_to('projects/snippets#raw', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
278 279
  end

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

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

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

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

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

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

304
  it 'to #destroy' do
Vinnie Okada committed
305
    expect(delete('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
306 307 308 309 310 311 312
  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
313 314
describe Projects::HooksController, 'routing' do
  it 'to #test' do
Vinnie Okada committed
315
    expect(get('/gitlab/gitlabhq/hooks/1/test')).to route_to('projects/hooks#test', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
316 317
  end

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

324
# project_commit GET    /:project_id/commit/:id(.:format) commit#show {id: /\h{7,40}/, project_id: /[^\/]+/}
325 326
describe Projects::CommitController, 'routing' do
  it 'to #show' do
327 328 329
    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
330
    expect(get('/gitlab/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5')
331 332 333
  end
end

334 335 336 337
#    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
338 339
describe Projects::CommitsController, 'routing' do
  it_behaves_like 'RESTful project resources' do
340
    let(:actions)    { [:show] }
341 342
    let(:controller) { 'commits' }
  end
343

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

349 350 351 352 353
#     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
354
  it_behaves_like 'RESTful project resources' do
355 356
    let(:actions)    { [:index, :create, :update, :destroy] }
    let(:controller) { 'project_members' }
357 358 359 360 361 362 363 364 365 366
  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
367 368
describe Projects::MilestonesController, 'routing' do
  it_behaves_like 'RESTful project resources' do
369
    let(:controller) { 'milestones' }
370
    let(:actions) { [:index, :create, :new, :edit, :show, :update] }
371 372 373 374
  end
end

# project_labels GET    /:project_id/labels(.:format) labels#index
375 376
describe Projects::LabelsController, 'routing' do
  it 'to #index' do
Vinnie Okada committed
377
    expect(get('/gitlab/gitlabhq/labels')).to route_to('projects/labels#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
378 379 380 381 382 383 384 385 386 387 388 389 390
  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
391 392
describe Projects::IssuesController, 'routing' do
  it 'to #bulk_update' do
Vinnie Okada committed
393
    expect(post('/gitlab/gitlabhq/issues/bulk_update')).to route_to('projects/issues#bulk_update', namespace_id: 'gitlab', project_id: 'gitlabhq')
394 395
  end

396
  it_behaves_like 'RESTful project resources' do
397
    let(:controller) { 'issues' }
398
    let(:actions) { [:index, :create, :new, :edit, :show, :update] }
399 400 401 402 403 404
  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
405 406
describe Projects::NotesController, 'routing' do
  it_behaves_like 'RESTful project resources' do
407 408 409 410
    let(:actions)    { [:index, :create, :destroy] }
    let(:controller) { 'notes' }
  end
end
411

412
# project_blame GET    /:project_id/blame/:id(.:format) blame#show {id: /.+/, project_id: /[^\/]+/}
413 414
describe Projects::BlameController, 'routing' do
  it 'to #show' do
Vinnie Okada committed
415 416
    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')
417 418 419
  end
end

420
# project_blob GET    /:project_id/blob/:id(.:format) blob#show {id: /.+/, project_id: /[^\/]+/}
421 422
describe Projects::BlobController, 'routing' do
  it 'to #show' do
Vinnie Okada committed
423 424 425 426
    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')
427 428 429
  end
end

430
# project_tree GET    /:project_id/tree/:id(.:format) tree#show {id: /.+/, project_id: /[^\/]+/}
431 432
describe Projects::TreeController, 'routing' do
  it 'to #show' do
Vinnie Okada committed
433 434
    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')
435 436 437
  end
end

438 439 440 441 442 443 444 445 446 447 448 449
# 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

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

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

466 467 468
# 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: /[^\/]+/}
469 470
describe Projects::CompareController, 'routing' do
  it 'to #index' do
Vinnie Okada committed
471
    expect(get('/gitlab/gitlabhq/compare')).to route_to('projects/compare#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
472 473
  end

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

478
  it 'to #show' do
Vinnie Okada committed
479 480
    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')
481 482
  end
end
483

484 485
describe Projects::NetworkController, 'routing' do
  it 'to #show' do
Vinnie Okada committed
486 487
    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')
488 489 490
  end
end

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

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

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

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