gitlab-org--gitlab-foss/spec/routing/routing_spec.rb

308 lines
11 KiB
Ruby
Raw Normal View History

2012-09-16 04:21:46 -04:00
require 'spec_helper'
# 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
allow_any_instance_of(UserUrlConstrainer).to receive(:matches?).and_return(true)
expect(get("/User")).to route_to('users#show', username: 'User')
end
it "to #groups" do
expect(get("/users/User/groups")).to route_to('users#groups', username: 'User')
end
it "to #projects" do
expect(get("/users/User/projects")).to route_to('users#projects', username: 'User')
end
it "to #contributed" do
expect(get("/users/User/contributed")).to route_to('users#contributed', username: 'User')
end
it "to #snippets" do
expect(get("/users/User/snippets")).to route_to('users#snippets', username: 'User')
end
it "to #calendar" do
expect(get("/users/User/calendar")).to route_to('users#calendar', username: 'User')
end
it "to #calendar_activities" do
expect(get("/users/User/calendar_activities")).to route_to('users#calendar_activities', username: 'User')
end
end
2012-09-16 04:21:46 -04:00
# search GET /search(.:format) search#show
describe SearchController, "routing" do
it "to #show" do
expect(get("/search")).to route_to('search#show')
2012-09-16 04:21:46 -04:00
end
end
# gitlab_api /api API::API
2012-09-16 04:21:46 -04:00
# /:path Grack
describe "Mounted Apps", "routing" do
it "to API" do
expect(get("/api/issues")).to be_routable
2012-09-16 04:21:46 -04:00
end
it "to Grack" do
expect(get("/gitlab/gitlabhq.git")).to be_routable
2012-09-16 04:21:46 -04:00
end
end
# 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
expect(get("/snippets/1/raw")).to route_to('snippets#raw', id: '1')
end
2016-05-08 04:27:33 -04:00
it "to #index" do
expect(get("/snippets")).to route_to('snippets#index')
end
it "to #create" do
expect(post("/snippets")).to route_to('snippets#create')
end
it "to #new" do
expect(get("/snippets/new")).to route_to('snippets#new')
end
it "to #edit" do
expect(get("/snippets/1/edit")).to route_to('snippets#edit', id: '1')
end
it "to #show" do
expect(get("/snippets/1")).to route_to('snippets#show', id: '1')
end
it "to #update" do
expect(put("/snippets/1")).to route_to('snippets#update', id: '1')
end
it "to #destroy" do
expect(delete("/snippets/1")).to route_to('snippets#destroy', id: '1')
end
end
# help GET /help(.:format) help#index
2016-07-11 18:11:33 -04:00
# help_page GET /help/*path(.:format) help#show
# help_shortcuts GET /help/shortcuts(.:format) help#shortcuts
# help_ui GET /help/ui(.:format) help#ui
describe HelpController, "routing" do
it "to #index" do
expect(get("/help")).to route_to('help#index')
2012-09-16 04:21:46 -04:00
end
it 'to #show' do
2016-08-25 10:19:14 -04:00
path = '/help/user/markdown.md'
expect(get(path)).to route_to('help#show',
2016-08-25 10:19:14 -04:00
path: 'user/markdown',
format: 'md')
2012-09-16 04:21:46 -04:00
path = '/help/workflow/protected_branches/protected_branches1.png'
expect(get(path)).to route_to('help#show',
2016-07-11 18:11:33 -04:00
path: 'workflow/protected_branches/protected_branches1',
format: 'png')
Support integration with Koding (online IDE) Koding: #index: landing page for Koding integration If enabled it will provide a link to open remote Koding instance url for now we are also providing the sneak preview video for how integration works in detail. Repository: check whether .koding.yml file exists on repository Projects: landing page: show Run in IDE (Koding) button if repo has stack file Projects: MR: show Run in IDE Koding button if repo has stack file on active branch ProjectHelpers: add_koding_stack: stack generator for provided project With this helper we will auto-generate the required stack template for a given project. For the feature we can request this base template from the running Koding instance on integration. Currently this will provide users to create a t2.nano instance on aws and it'll automatically configures the instance for basic requirements. Projects: empty state and landing page provide shortcuts to create stack projects_helper: use branch on checkout and provide an entry point This ${var.koding_queryString_branch} will be replaced with the branch provided in query string which will allow us to use same stack template for different branches of the same repository. ref: https://github.com/koding/koding/pull/8597/commits/b8c0e43c4c24bf132670aa8a3cfb0d634acfd09b projects_helper: provide sha info in query string to use existing vms With this change we'll be able to query existing vms on Koding side based on the commit id that they've created. ref: https://github.com/koding/koding/pull/8597/commits/1d630fadf31963fa6ccd3bed92e526761a30a343 Integration: Docs: Koding documentation added Disable /koding route if integration is disabled Use application settings to enable Koding Projects_helper: better indentation with strip_heredoc usage Projects_helper: return koding_url as is if there is no project provided current_settings: set koding_enabled: false by default Koding_Controller: to render not_found once integration is disabled Dashboard_specs: update spec for Koding enabled case Projects_Helper: make repo dynamic ref: https://github.com/koding/koding/pull/8597/commits/4d615242f45aaea4c4986be84ecc612b0bb1514c Updated documentation to have right format
2016-07-25 23:59:39 -04:00
2016-07-11 18:11:33 -04:00
path = '/help/ui'
expect(get(path)).to route_to('help#ui')
2012-12-08 05:42:38 -05:00
end
2012-09-16 04:21:46 -04:00
end
Support integration with Koding (online IDE) Koding: #index: landing page for Koding integration If enabled it will provide a link to open remote Koding instance url for now we are also providing the sneak preview video for how integration works in detail. Repository: check whether .koding.yml file exists on repository Projects: landing page: show Run in IDE (Koding) button if repo has stack file Projects: MR: show Run in IDE Koding button if repo has stack file on active branch ProjectHelpers: add_koding_stack: stack generator for provided project With this helper we will auto-generate the required stack template for a given project. For the feature we can request this base template from the running Koding instance on integration. Currently this will provide users to create a t2.nano instance on aws and it'll automatically configures the instance for basic requirements. Projects: empty state and landing page provide shortcuts to create stack projects_helper: use branch on checkout and provide an entry point This ${var.koding_queryString_branch} will be replaced with the branch provided in query string which will allow us to use same stack template for different branches of the same repository. ref: https://github.com/koding/koding/pull/8597/commits/b8c0e43c4c24bf132670aa8a3cfb0d634acfd09b projects_helper: provide sha info in query string to use existing vms With this change we'll be able to query existing vms on Koding side based on the commit id that they've created. ref: https://github.com/koding/koding/pull/8597/commits/1d630fadf31963fa6ccd3bed92e526761a30a343 Integration: Docs: Koding documentation added Disable /koding route if integration is disabled Use application settings to enable Koding Projects_helper: better indentation with strip_heredoc usage Projects_helper: return koding_url as is if there is no project provided current_settings: set koding_enabled: false by default Koding_Controller: to render not_found once integration is disabled Dashboard_specs: update spec for Koding enabled case Projects_Helper: make repo dynamic ref: https://github.com/koding/koding/pull/8597/commits/4d615242f45aaea4c4986be84ecc612b0bb1514c Updated documentation to have right format
2016-07-25 23:59:39 -04:00
# koding GET /koding(.:format) koding#index
describe KodingController, "routing" do
it "to #index" do
expect(get("/koding")).to route_to('koding#index')
end
end
2012-09-16 04:21:46 -04:00
# 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
describe ProfilesController, "routing" do
2012-09-16 04:21:46 -04:00
it "to #account" do
expect(get("/profile/account")).to route_to('profiles/accounts#show')
2012-09-16 04:21:46 -04:00
end
2015-07-03 07:54:50 -04:00
it "to #audit_log" do
expect(get("/profile/audit_log")).to route_to('profiles#audit_log')
2012-09-16 04:21:46 -04:00
end
it "to #reset_private_token" do
expect(put("/profile/reset_private_token")).to route_to('profiles#reset_private_token')
2012-09-16 04:21:46 -04:00
end
it "to #show" do
expect(get("/profile")).to route_to('profiles#show')
2012-09-16 04:21:46 -04:00
end
2015-06-05 14:00:21 -04:00
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
2012-09-16 04:21:46 -04:00
2015-06-05 14:00:21 -04:00
it 'to #update' do
expect(put('/profile/preferences')).to route_to('profiles/preferences#update')
expect(patch('/profile/preferences')).to route_to('profiles/preferences#update')
2012-09-16 04:21:46 -04:00
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
describe Profiles::KeysController, "routing" do
2012-09-16 04:21:46 -04:00
it "to #index" do
expect(get("/profile/keys")).to route_to('profiles/keys#index')
2012-09-16 04:21:46 -04:00
end
it "to #create" do
expect(post("/profile/keys")).to route_to('profiles/keys#create')
2012-09-16 04:21:46 -04:00
end
it "to #show" do
expect(get("/profile/keys/1")).to route_to('profiles/keys#show', id: '1')
2012-09-16 04:21:46 -04:00
end
it "to #destroy" do
expect(delete("/profile/keys/1")).to route_to('profiles/keys#destroy', id: '1')
2012-09-16 04:21:46 -04:00
end
2014-02-06 04:12:59 -05:00
# get all the ssh-keys of a user
it "to #get_keys" do
allow_any_instance_of(UserUrlConstrainer).to receive(:matches?).and_return(true)
expect(get("/foo.keys")).to route_to('profiles/keys#get_keys', username: 'foo')
2014-02-06 04:12:59 -05:00
end
2012-09-16 04:21:46 -04:00
end
# 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
expect(get("/profile/emails")).to route_to('profiles/emails#index')
end
it "to #create" do
expect(post("/profile/emails")).to route_to('profiles/emails#create')
end
it "to #destroy" do
expect(delete("/profile/emails/1")).to route_to('profiles/emails#destroy', id: '1')
end
end
# profile_avatar DELETE /profile/avatar(.:format) profiles/avatars#destroy
describe Profiles::AvatarsController, "routing" do
it "to #destroy" do
expect(delete("/profile/avatar")).to route_to('profiles/avatars#destroy')
end
end
2013-01-27 06:20:23 -05:00
# dashboard GET /dashboard(.:format) dashboard#show
2012-09-16 04:21:46 -04:00
# 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
expect(get("/dashboard")).to route_to('dashboard/projects#index')
2012-09-16 04:21:46 -04:00
end
it "to #issues" do
expect(get("/dashboard/issues")).to route_to('dashboard#issues')
2012-09-16 04:21:46 -04:00
end
it "to #merge_requests" do
expect(get("/dashboard/merge_requests")).to route_to('dashboard#merge_requests')
2012-09-16 04:21:46 -04:00
end
end
# root / root#show
describe RootController, 'routing' do
it 'to #index' do
expect(get('/')).to route_to('root#index')
end
end
2012-09-16 04:21:46 -04:00
# 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
2014-04-13 11:46:41 -04:00
describe "Groups", "routing" do
let(:name) { 'complex.group-namegit' }
before { allow_any_instance_of(GroupUrlConstrainer).to receive(:matches?).and_return(true) }
2014-04-13 11:46:41 -04:00
it "to #show" do
expect(get("/groups/#{name}")).to route_to('groups#show', id: name)
2014-04-13 11:46:41 -04:00
end
it "also supports nested groups" do
expect(get("/#{name}/#{name}")).to route_to('groups#show', id: "#{name}/#{name}")
end
it "also display group#show on the short path" do
expect(get("/#{name}")).to route_to('groups#show', id: name)
2014-04-13 11:46:41 -04:00
end
it "to #activity" do
expect(get("/groups/#{name}/activity")).to route_to('groups#activity', id: name)
end
it "to #issues" do
expect(get("/groups/#{name}/issues")).to route_to('groups#issues', id: name)
end
it "to #members" do
expect(get("/groups/#{name}/group_members")).to route_to('groups/group_members#index', group_id: name)
end
it "also display group#show with slash in the path" do
expect(get('/group/subgroup')).to route_to('groups#show', id: 'group/subgroup')
end
2014-04-13 11:46:41 -04:00
end
2016-05-10 19:19:16 -04:00
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