2017-10-26 10:10:03 -04:00
require 'spec_helper'
2017-10-26 11:49:07 -04:00
describe " Groups " , " routing " do
let ( :group_path ) { 'complex.group-namegit' }
let! ( :group ) { create ( :group , path : group_path ) }
it " to # show " do
expect ( get ( " /groups/ #{ group_path } " ) ) . to route_to ( 'groups#show' , id : group_path )
end
it " also supports nested groups " do
nested_group = create ( :group , parent : group )
expect ( get ( " / #{ group_path } / #{ nested_group . path } " ) ) . to route_to ( 'groups#show' , id : " #{ group_path } / #{ nested_group . path } " )
end
it " also display group # show on the short path " do
expect ( get ( " / #{ group_path } " ) ) . to route_to ( 'groups#show' , id : group_path )
end
2019-03-14 08:55:46 -04:00
it " to # details " do
expect ( get ( " /groups/ #{ group_path } /-/details " ) ) . to route_to ( 'groups#details' , id : group_path )
end
2017-10-26 11:49:07 -04:00
it " to # activity " do
2017-10-27 05:29:51 -04:00
expect ( get ( " /groups/ #{ group_path } /-/activity " ) ) . to route_to ( 'groups#activity' , id : group_path )
2017-10-26 11:49:07 -04:00
end
it " to # issues " do
2017-10-27 05:29:51 -04:00
expect ( get ( " /groups/ #{ group_path } /-/issues " ) ) . to route_to ( 'groups#issues' , id : group_path )
2017-10-26 11:49:07 -04:00
end
it " to # members " do
expect ( get ( " /groups/ #{ group_path } /-/group_members " ) ) . to route_to ( 'groups/group_members#index' , group_id : group_path )
end
2017-10-27 05:29:51 -04:00
it " to # labels " do
expect ( get ( " /groups/ #{ group_path } /-/labels " ) ) . to route_to ( 'groups/labels#index' , group_id : group_path )
end
2017-10-26 11:49:07 -04:00
2017-10-27 05:29:51 -04:00
it " to # milestones " do
expect ( get ( " /groups/ #{ group_path } /-/milestones " ) ) . to route_to ( 'groups/milestones#index' , group_id : group_path )
end
2017-10-26 11:49:07 -04:00
2017-10-27 05:29:51 -04:00
describe 'legacy redirection' do
2017-10-26 11:49:07 -04:00
describe 'labels' do
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/labels " , " /groups/complex.group-namegit/-/labels " do
2017-10-27 05:29:51 -04:00
let ( :resource ) { create ( :group , parent : group , path : 'labels' ) }
end
2017-11-16 12:12:45 -05:00
context 'when requesting JSON' do
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/labels.json " , " /groups/complex.group-namegit/-/labels.json " do
let ( :resource ) { create ( :group , parent : group , path : 'labels' ) }
end
end
2017-10-26 11:49:07 -04:00
end
describe 'group_members' do
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/group_members " , " /groups/complex.group-namegit/-/group_members " do
2017-10-27 05:29:51 -04:00
let ( :resource ) { create ( :group , parent : group , path : 'group_members' ) }
end
2017-10-26 10:10:03 -04:00
end
2017-10-26 11:49:07 -04:00
describe 'avatar' do
it 'routes to the avatars controller' do
expect ( delete ( " /groups/ #{ group_path } /-/avatar " ) )
. to route_to ( group_id : group_path ,
controller : 'groups/avatars' ,
action : 'destroy' )
end
end
describe 'milestones' do
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/milestones " , " /groups/complex.group-namegit/-/milestones " do
2017-10-27 05:29:51 -04:00
let ( :resource ) { create ( :group , parent : group , path : 'milestones' ) }
end
2017-10-26 11:49:07 -04:00
context 'nested routes' do
include RSpec :: Rails :: RequestExampleGroup
let ( :milestone ) { create ( :milestone , group : group ) }
it 'redirects the nested routes' do
request = get ( " /groups/ #{ group_path } /milestones/ #{ milestone . id } /merge_requests " )
expect ( request ) . to redirect_to ( " /groups/ #{ group_path } /-/milestones/ #{ milestone . id } /merge_requests " )
end
end
2017-11-07 07:04:46 -05:00
context 'with a query string' do
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/milestones?hello=world " , " /groups/complex.group-namegit/-/milestones?hello=world " do
2017-11-07 07:04:46 -05:00
let ( :resource ) { create ( :group , parent : group , path : 'milestones' ) }
end
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/milestones?milestones=/milestones " , " /groups/complex.group-namegit/-/milestones?milestones=/milestones " do
2017-11-07 07:04:46 -05:00
let ( :resource ) { create ( :group , parent : group , path : 'milestones' ) }
end
end
2017-10-26 10:10:03 -04:00
end
2017-10-27 05:29:51 -04:00
describe 'edit' do
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/edit " , " /groups/complex.group-namegit/-/edit " do
2017-10-27 05:29:51 -04:00
let ( :resource ) do
pending ( 'still rejected because of the wildcard reserved word' )
create ( :group , parent : group , path : 'edit' )
end
end
end
describe 'issues' do
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/issues " , " /groups/complex.group-namegit/-/issues " do
2017-10-27 05:29:51 -04:00
let ( :resource ) { create ( :group , parent : group , path : 'issues' ) }
end
end
describe 'merge_requests' do
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/merge_requests " , " /groups/complex.group-namegit/-/merge_requests " do
2017-10-27 05:29:51 -04:00
let ( :resource ) { create ( :group , parent : group , path : 'merge_requests' ) }
end
end
describe 'projects' do
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/projects " , " /groups/complex.group-namegit/-/projects " do
2017-10-27 05:29:51 -04:00
let ( :resource ) { create ( :group , parent : group , path : 'projects' ) }
end
end
describe 'activity' do
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/complex.group-namegit/activity " , " /groups/complex.group-namegit/-/activity " do
2017-10-27 05:29:51 -04:00
let ( :resource ) { create ( :group , parent : group , path : 'activity' ) }
end
2017-11-16 12:12:45 -05:00
it_behaves_like 'redirecting a legacy path' , " /groups/activity/activity " , " /groups/activity/-/activity " do
2017-10-27 05:29:51 -04:00
let! ( :parent ) { create ( :group , path : 'activity' ) }
let ( :resource ) { create ( :group , parent : parent , path : 'activity' ) }
end
end
2019-04-26 00:11:47 -04:00
describe 'subgroup "boards"' do
it 'shows group show page' do
allow ( Group ) . to receive ( :find_by_full_path ) . with ( 'gitlabhq/boards' , any_args ) . and_return ( true )
expect ( get ( '/groups/gitlabhq/boards' ) ) . to route_to ( 'groups#show' , id : 'gitlabhq/boards' )
end
it 'shows boards index page' do
allow ( Group ) . to receive ( :find_by_full_path ) . with ( 'gitlabhq' , any_args ) . and_return ( true )
expect ( get ( '/groups/gitlabhq/-/boards' ) ) . to route_to ( 'groups/boards#index' , group_id : 'gitlabhq' )
end
end
2017-10-26 10:10:03 -04:00
end
end