BigW Consortium Gitlab

routing_spec.rb 10 KB
Newer Older
Robert Speicher committed
1 2
require 'spec_helper'

3 4 5 6 7 8 9 10 11
# user                       GET    /u/:username/
# user_groups                GET    /u/:username/groups(.:format)
# user_projects              GET    /u/:username/projects(.:format)
# user_contributed_projects  GET    /u/:username/contributed(.:format)
# user_snippets              GET    /u/:username/snippets(.:format)
# user_calendar              GET    /u/:username/calendar(.:format)
# user_calendar_activities   GET    /u/:username/calendar_activities(.:format)
describe UsersController, "routing" do
  it "to #show" do
12
    allow(User).to receive(:find_by).and_return(true)
13 14

    expect(get("/User")).to route_to('users#show', username: 'User')
15 16 17
  end

  it "to #groups" do
18
    expect(get("/users/User/groups")).to route_to('users#groups', username: 'User')
19 20 21
  end

  it "to #projects" do
22
    expect(get("/users/User/projects")).to route_to('users#projects', username: 'User')
23 24 25
  end

  it "to #contributed" do
26
    expect(get("/users/User/contributed")).to route_to('users#contributed', username: 'User')
27 28 29
  end

  it "to #snippets" do
30
    expect(get("/users/User/snippets")).to route_to('users#snippets', username: 'User')
31 32 33
  end

  it "to #calendar" do
34
    expect(get("/users/User/calendar")).to route_to('users#calendar', username: 'User')
35 36 37
  end

  it "to #calendar_activities" do
38
    expect(get("/users/User/calendar_activities")).to route_to('users#calendar_activities', username: 'User')
39 40 41
  end
end

Robert Speicher committed
42 43 44
# search GET    /search(.:format) search#show
describe SearchController, "routing" do
  it "to #show" do
45
    expect(get("/search")).to route_to('search#show')
Robert Speicher committed
46 47 48
  end
end

49
# gitlab_api /api         API::API
Robert Speicher committed
50 51 52
#            /:path       Grack
describe "Mounted Apps", "routing" do
  it "to API" do
53
    expect(get("/api/issues")).to be_routable
Robert Speicher committed
54 55 56
  end

  it "to Grack" do
57
    expect(get("/gitlab/gitlabhq.git")).to be_routable
Robert Speicher committed
58 59 60
  end
end

61 62 63 64 65 66 67 68 69
#     snippets GET    /snippets(.:format)          snippets#index
#          POST   /snippets(.:format)          snippets#create
#  new_snippet GET    /snippets/new(.:format)      snippets#new
# edit_snippet GET    /snippets/:id/edit(.:format) snippets#edit
#      snippet GET    /snippets/:id(.:format)      snippets#show
#          PUT    /snippets/:id(.:format)      snippets#update
#          DELETE /snippets/:id(.:format)      snippets#destroy
describe SnippetsController, "routing" do
  it "to #raw" do
70
    expect(get("/snippets/1/raw")).to route_to('snippets#raw', id: '1')
71 72
  end

Long Nguyen committed
73 74 75 76
  it "to #index" do
    expect(get("/snippets")).to route_to('snippets#index')
  end

77
  it "to #create" do
78
    expect(post("/snippets")).to route_to('snippets#create')
79 80 81
  end

  it "to #new" do
82
    expect(get("/snippets/new")).to route_to('snippets#new')
83 84 85
  end

  it "to #edit" do
86
    expect(get("/snippets/1/edit")).to route_to('snippets#edit', id: '1')
87 88 89
  end

  it "to #show" do
90
    expect(get("/snippets/1")).to route_to('snippets#show', id: '1')
91 92 93
  end

  it "to #update" do
94
    expect(put("/snippets/1")).to route_to('snippets#update', id: '1')
95 96 97
  end

  it "to #destroy" do
98
    expect(delete("/snippets/1")).to route_to('snippets#destroy', id: '1')
99 100 101
  end
end

102
#            help GET /help(.:format)                 help#index
Connor Shea committed
103
#       help_page GET /help/*path(.:format)           help#show
104 105
#  help_shortcuts GET /help/shortcuts(.:format)       help#shortcuts
#         help_ui GET /help/ui(.:format)              help#ui
106 107 108
describe HelpController, "routing" do
  it "to #index" do
    expect(get("/help")).to route_to('help#index')
Robert Speicher committed
109 110
  end

111
  it 'to #show' do
112
    path = '/help/user/markdown.md'
113
    expect(get(path)).to route_to('help#show',
114
                                  path: 'user/markdown',
115
                                  format: 'md')
Robert Speicher committed
116

117 118
    path = '/help/workflow/protected_branches/protected_branches1.png'
    expect(get(path)).to route_to('help#show',
Connor Shea committed
119
                                  path: 'workflow/protected_branches/protected_branches1',
120
                                  format: 'png')
121

Connor Shea committed
122
    path = '/help/ui'
123
    expect(get(path)).to route_to('help#ui')
124
  end
Robert Speicher committed
125 126
end

127 128 129 130 131 132 133
#                      koding GET    /koding(.:format)                      koding#index
describe KodingController, "routing" do
  it "to #index" do
    expect(get("/koding")).to route_to('koding#index')
  end
end

Robert Speicher committed
134 135 136 137 138 139 140
#             profile_account GET    /profile/account(.:format)             profile#account
#             profile_history GET    /profile/history(.:format)             profile#history
#            profile_password PUT    /profile/password(.:format)            profile#password_update
#               profile_token GET    /profile/token(.:format)               profile#token
# profile_reset_private_token PUT    /profile/reset_private_token(.:format) profile#reset_private_token
#                     profile GET    /profile(.:format)                     profile#show
#              profile_update PUT    /profile/update(.:format)              profile#update
141
describe ProfilesController, "routing" do
Robert Speicher committed
142
  it "to #account" do
143
    expect(get("/profile/account")).to route_to('profiles/accounts#show')
Robert Speicher committed
144 145
  end

146 147
  it "to #audit_log" do
    expect(get("/profile/audit_log")).to route_to('profiles#audit_log')
Robert Speicher committed
148 149 150
  end

  it "to #reset_private_token" do
151
    expect(put("/profile/reset_private_token")).to route_to('profiles#reset_private_token')
Robert Speicher committed
152 153 154
  end

  it "to #show" do
155
    expect(get("/profile")).to route_to('profiles#show')
Robert Speicher committed
156
  end
157 158 159 160 161 162 163 164 165
end

# profile_preferences GET      /profile/preferences(.:format) profiles/preferences#show
#                     PATCH    /profile/preferences(.:format) profiles/preferences#update
#                     PUT      /profile/preferences(.:format) profiles/preferences#update
describe Profiles::PreferencesController, 'routing' do
  it 'to #show' do
    expect(get('/profile/preferences')).to route_to('profiles/preferences#show')
  end
Robert Speicher committed
166

167 168 169
  it 'to #update' do
    expect(put('/profile/preferences')).to   route_to('profiles/preferences#update')
    expect(patch('/profile/preferences')).to route_to('profiles/preferences#update')
Robert Speicher committed
170 171 172 173 174 175 176 177 178
  end
end

#     keys GET    /keys(.:format)          keys#index
#          POST   /keys(.:format)          keys#create
# edit_key GET    /keys/:id/edit(.:format) keys#edit
#      key GET    /keys/:id(.:format)      keys#show
#          PUT    /keys/:id(.:format)      keys#update
#          DELETE /keys/:id(.:format)      keys#destroy
179
describe Profiles::KeysController, "routing" do
Robert Speicher committed
180
  it "to #index" do
181
    expect(get("/profile/keys")).to route_to('profiles/keys#index')
Robert Speicher committed
182 183 184
  end

  it "to #create" do
185
    expect(post("/profile/keys")).to route_to('profiles/keys#create')
Robert Speicher committed
186 187 188
  end

  it "to #show" do
189
    expect(get("/profile/keys/1")).to route_to('profiles/keys#show', id: '1')
Robert Speicher committed
190 191 192
  end

  it "to #destroy" do
193
    expect(delete("/profile/keys/1")).to route_to('profiles/keys#destroy', id: '1')
Robert Speicher committed
194
  end
195 196 197

  # get all the ssh-keys of a user
  it "to #get_keys" do
198
    expect(get("/foo.keys")).to route_to('profiles/keys#get_keys', username: 'foo')
199
  end
Robert Speicher committed
200 201
end

202 203 204 205 206
#   emails GET    /emails(.:format)        emails#index
#          POST   /keys(.:format)          emails#create
#          DELETE /keys/:id(.:format)      keys#destroy
describe Profiles::EmailsController, "routing" do
  it "to #index" do
207
    expect(get("/profile/emails")).to route_to('profiles/emails#index')
208 209 210
  end

  it "to #create" do
211
    expect(post("/profile/emails")).to route_to('profiles/emails#create')
212 213 214
  end

  it "to #destroy" do
215
    expect(delete("/profile/emails/1")).to route_to('profiles/emails#destroy', id: '1')
216 217 218
  end
end

219 220 221
# profile_avatar DELETE /profile/avatar(.:format) profiles/avatars#destroy
describe Profiles::AvatarsController, "routing" do
  it "to #destroy" do
222
    expect(delete("/profile/avatar")).to route_to('profiles/avatars#destroy')
223 224 225
  end
end

226
#                dashboard GET    /dashboard(.:format)                dashboard#show
Robert Speicher committed
227 228 229 230
#         dashboard_issues GET    /dashboard/issues(.:format)         dashboard#issues
# dashboard_merge_requests GET    /dashboard/merge_requests(.:format) dashboard#merge_requests
describe DashboardController, "routing" do
  it "to #index" do
231
    expect(get("/dashboard")).to route_to('dashboard/projects#index')
Robert Speicher committed
232 233 234
  end

  it "to #issues" do
235
    expect(get("/dashboard/issues")).to route_to('dashboard#issues')
Robert Speicher committed
236 237 238
  end

  it "to #merge_requests" do
239
    expect(get("/dashboard/merge_requests")).to route_to('dashboard#merge_requests')
Robert Speicher committed
240 241 242
  end
end

Robert Speicher committed
243 244
#                     root        /                                   root#show
describe RootController, 'routing' do
245 246
  it 'to #index' do
    expect(get('/')).to route_to('root#index')
Robert Speicher committed
247 248 249
  end
end

Robert Speicher committed
250 251 252 253 254 255 256 257 258 259 260 261
#        new_user_session GET    /users/sign_in(.:format)               devise/sessions#new
#            user_session POST   /users/sign_in(.:format)               devise/sessions#create
#    destroy_user_session DELETE /users/sign_out(.:format)              devise/sessions#destroy
# user_omniauth_authorize        /users/auth/:provider(.:format)        omniauth_callbacks#passthru
#  user_omniauth_callback        /users/auth/:action/callback(.:format) omniauth_callbacks#(?-mix:(?!))
#           user_password POST   /users/password(.:format)              devise/passwords#create
#       new_user_password GET    /users/password/new(.:format)          devise/passwords#new
#      edit_user_password GET    /users/password/edit(.:format)         devise/passwords#edit
#                         PUT    /users/password(.:format)              devise/passwords#update
describe "Authentication", "routing" do
  # pending
end
262 263 264

describe "Groups", "routing" do
  it "to #show" do
265
    expect(get("/groups/1")).to route_to('groups#show', id: '1')
266 267
  end

268
  it "also display group#show on the short path" do
269
    allow(Group).to receive(:find_by).and_return(true)
270 271

    expect(get('/1')).to route_to('groups#show', id: '1')
272
  end
273 274

  it "also display group#show with dot in the path" do
275
    allow(Group).to receive(:find_by).and_return(true)
276 277 278

    expect(get('/group.with.dot')).to route_to('groups#show', id: 'group.with.dot')
  end
279
end
280 281 282 283 284 285 286 287 288 289

describe HealthCheckController, 'routing' do
  it 'to #index' do
    expect(get('/health_check')).to route_to('health_check#index')
  end

  it 'also supports passing checks in the url' do
    expect(get('/health_check/email')).to route_to('health_check#index', checks: 'email')
  end
end