routing_spec.rb 9.5 KB
Newer Older
Robert Speicher's avatar
Robert Speicher committed
1 2
require 'spec_helper'

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
# 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
    expect(get("/u/User")).to route_to('users#show', username: 'User')
  end

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

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

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

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

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

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

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

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

  it "to Grack" do
55
    expect(get("/gitlab/gitlabhq.git")).to be_routable
Robert Speicher's avatar
Robert Speicher committed
56 57 58
  end
end

59 60 61 62 63 64 65 66 67
#     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
68
    expect(get("/snippets/1/raw")).to route_to('snippets#raw', id: '1')
69 70
  end

Long Nguyen's avatar
Long Nguyen committed
71 72 73 74
  it "to #index" do
    expect(get("/snippets")).to route_to('snippets#index')
  end

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

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

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

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

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

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

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

109 110 111
  it 'to #show' do
    path = '/help/markdown/markdown.md'
    expect(get(path)).to route_to('help#show',
Connor Shea's avatar
Connor Shea committed
112
                                  path: 'markdown/markdown',
113
                                  format: 'md')
Robert Speicher's avatar
Robert Speicher committed
114

115 116
    path = '/help/workflow/protected_branches/protected_branches1.png'
    expect(get(path)).to route_to('help#show',
Connor Shea's avatar
Connor Shea committed
117
                                  path: 'workflow/protected_branches/protected_branches1',
118
                                  format: 'png')
119
    
Connor Shea's avatar
Connor Shea committed
120
    path = '/help/ui'
121
    expect(get(path)).to route_to('help#ui')
122
  end
Robert Speicher's avatar
Robert Speicher committed
123 124 125 126 127 128 129 130 131
end

#             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
132
describe ProfilesController, "routing" do
Robert Speicher's avatar
Robert Speicher committed
133
  it "to #account" do
134
    expect(get("/profile/account")).to route_to('profiles/accounts#show')
Robert Speicher's avatar
Robert Speicher committed
135 136
  end

137 138
  it "to #audit_log" do
    expect(get("/profile/audit_log")).to route_to('profiles#audit_log')
Robert Speicher's avatar
Robert Speicher committed
139 140 141
  end

  it "to #reset_private_token" do
142
    expect(put("/profile/reset_private_token")).to route_to('profiles#reset_private_token')
Robert Speicher's avatar
Robert Speicher committed
143 144 145
  end

  it "to #show" do
146
    expect(get("/profile")).to route_to('profiles#show')
Robert Speicher's avatar
Robert Speicher committed
147
  end
148 149 150 151 152 153 154 155 156
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's avatar
Robert Speicher committed
157

158 159 160
  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's avatar
Robert Speicher committed
161 162 163 164 165 166 167 168 169
  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
170
describe Profiles::KeysController, "routing" do
Robert Speicher's avatar
Robert Speicher committed
171
  it "to #index" do
172
    expect(get("/profile/keys")).to route_to('profiles/keys#index')
Robert Speicher's avatar
Robert Speicher committed
173 174 175
  end

  it "to #create" do
176
    expect(post("/profile/keys")).to route_to('profiles/keys#create')
Robert Speicher's avatar
Robert Speicher committed
177 178 179
  end

  it "to #show" do
180
    expect(get("/profile/keys/1")).to route_to('profiles/keys#show', id: '1')
Robert Speicher's avatar
Robert Speicher committed
181 182 183
  end

  it "to #destroy" do
184
    expect(delete("/profile/keys/1")).to route_to('profiles/keys#destroy', id: '1')
Robert Speicher's avatar
Robert Speicher committed
185
  end
186 187 188

  # get all the ssh-keys of a user
  it "to #get_keys" do
189
    expect(get("/foo.keys")).to route_to('profiles/keys#get_keys', username: 'foo')
190
  end
Robert Speicher's avatar
Robert Speicher committed
191 192
end

193 194 195 196 197
#   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
198
    expect(get("/profile/emails")).to route_to('profiles/emails#index')
199 200 201
  end

  it "to #create" do
202
    expect(post("/profile/emails")).to route_to('profiles/emails#create')
203 204 205
  end

  it "to #destroy" do
206
    expect(delete("/profile/emails/1")).to route_to('profiles/emails#destroy', id: '1')
207 208 209
  end
end

210 211 212
# profile_avatar DELETE /profile/avatar(.:format) profiles/avatars#destroy
describe Profiles::AvatarsController, "routing" do
  it "to #destroy" do
213
    expect(delete("/profile/avatar")).to route_to('profiles/avatars#destroy')
214 215 216
  end
end

217
#                dashboard GET    /dashboard(.:format)                dashboard#show
Robert Speicher's avatar
Robert Speicher committed
218 219 220 221
#         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
222
    expect(get("/dashboard")).to route_to('dashboard/projects#index')
Robert Speicher's avatar
Robert Speicher committed
223 224 225
  end

  it "to #issues" do
226
    expect(get("/dashboard/issues")).to route_to('dashboard#issues')
Robert Speicher's avatar
Robert Speicher committed
227 228 229
  end

  it "to #merge_requests" do
230
    expect(get("/dashboard/merge_requests")).to route_to('dashboard#merge_requests')
Robert Speicher's avatar
Robert Speicher committed
231 232 233
  end
end

Robert Speicher's avatar
Robert Speicher committed
234 235
#                     root        /                                   root#show
describe RootController, 'routing' do
236 237
  it 'to #index' do
    expect(get('/')).to route_to('root#index')
Robert Speicher's avatar
Robert Speicher committed
238 239 240
  end
end

Robert Speicher's avatar
Robert Speicher committed
241 242 243 244 245 246 247 248 249 250 251 252
#        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
GitLab's avatar
GitLab committed
253 254 255

describe "Groups", "routing" do
  it "to #show" do
256
    expect(get("/groups/1")).to route_to('groups#show', id: '1')
GitLab's avatar
GitLab committed
257 258
  end

259
  it "also display group#show on the short path" do
260
    expect(get('/1')).to route_to('namespaces#show', id: '1')
GitLab's avatar
GitLab committed
261 262
  end
end
263 264 265 266 267 268 269 270 271 272

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