diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-26 17:49:07 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-11-07 19:52:09 +0100 |
commit | 5dde0536c323d14fef2327a8d553b5f8a8a7b2d0 (patch) | |
tree | bf95d6594a0925aff3b0c3ee3a5302667bcdb168 /spec/routing | |
parent | 5d14337baff9c2ae8091b7b4ab954f8024449a52 (diff) | |
download | gitlab-ce-5dde0536c323d14fef2327a8d553b5f8a8a7b2d0.tar.gz |
Free up `avatar`, `group_members` and `milestones` as paths
Diffstat (limited to 'spec/routing')
-rw-r--r-- | spec/routing/group_routing_spec.rb | 82 | ||||
-rw-r--r-- | spec/routing/routing_spec.rb | 30 |
2 files changed, 71 insertions, 41 deletions
diff --git a/spec/routing/group_routing_spec.rb b/spec/routing/group_routing_spec.rb index 39fbf082b4d..b3e55f5e3c9 100644 --- a/spec/routing/group_routing_spec.rb +++ b/spec/routing/group_routing_spec.rb @@ -1,18 +1,78 @@ require 'spec_helper' -describe 'group routing' do - let!(:existing_group) { create(:group, parent: create(:group, path: 'gitlab-org'), path: 'infra') } - - describe 'GET #labels' do - it 'routes to the correct controller' do - expect(get('/groups/gitlab-org/infra/-/labels')) - .to route_to(group_id: 'gitlab-org/infra', - controller: 'groups/labels', - action: 'index') +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 + + it "to #activity" do + expect(get("/groups/#{group_path}/activity")).to route_to('groups#activity', id: group_path) + end + + it "to #issues" do + expect(get("/groups/#{group_path}/issues")).to route_to('groups#issues', id: group_path) + end + + it "to #members" do + expect(get("/groups/#{group_path}/-/group_members")).to route_to('groups/group_members#index', group_id: group_path) + end + + describe 'legacy redirection' do + shared_examples 'canonical groups route' do |path| + it "#{path} routes to the correct controller" do + expect(get("/groups/#{group_path}/-/#{path}")) + .to route_to(group_id: group_path, + controller: "groups/#{path}", + action: 'index') + end + + it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/#{path}", "/groups/complex.group-namegit/-/#{path}/" do + let(:resource) { create(:group, parent: group, path: path) } + end + end + + describe 'labels' do + it_behaves_like 'canonical groups route', 'labels' + end + + describe 'group_members' do + it_behaves_like 'canonical groups route', 'group_members' end - it_behaves_like 'redirecting a legacy path', '/groups/gitlab-org/infra/labels', '/groups/gitlab-org/infra/-/labels' do - let(:resource) { create(:group, parent: existing_group, path: 'labels') } + 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 + it_behaves_like 'canonical groups route', 'milestones' + + 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 end end end diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index 609481603af..32aa6e5ad52 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -278,36 +278,6 @@ describe "Authentication", "routing" do end end -describe "Groups", "routing" do - let(:name) { 'complex.group-namegit' } - let!(:group) { create(:group, name: name) } - - it "to #show" do - expect(get("/groups/#{name}")).to route_to('groups#show', id: name) - end - - it "also supports nested groups" do - nested_group = create(:group, parent: group) - expect(get("/#{name}/#{nested_group.name}")).to route_to('groups#show', id: "#{name}/#{nested_group.name}") - end - - it "also display group#show on the short path" do - expect(get("/#{name}")).to route_to('groups#show', id: name) - 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 -end - describe HealthCheckController, 'routing' do it 'to #index' do expect(get('/health_check')).to route_to('health_check#index') |