Commit a441e7a7 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'backort_routes_group_routes_from_ee' into 'master'

Backport EE changes to group routes

Closes gitlab-ee#3794

See merge request gitlab-org/gitlab-ce!14973
parents 08a8a3f9 ee1b89ae
...@@ -4,7 +4,19 @@ resources :groups, only: [:index, :new, :create] do ...@@ -4,7 +4,19 @@ resources :groups, only: [:index, :new, :create] do
post :preview_markdown post :preview_markdown
end end
scope(path: 'groups/*group_id', constraints(GroupUrlConstrainer.new) do
scope(path: 'groups/*id',
controller: :groups,
constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ }) do
get :edit, as: :edit_group
get :issues, as: :issues_group
get :merge_requests, as: :merge_requests_group
get :projects, as: :projects_group
get :activity, as: :activity_group
get '/', action: :show, as: :group_canonical
end
scope(path: 'groups/*group_id',
module: :groups, module: :groups,
as: :group, as: :group,
constraints: { group_id: Gitlab::PathRegex.full_namespace_route_regex }) do constraints: { group_id: Gitlab::PathRegex.full_namespace_route_regex }) do
...@@ -35,20 +47,8 @@ scope(path: 'groups/*group_id', ...@@ -35,20 +47,8 @@ scope(path: 'groups/*group_id',
resources :children, only: [:index] resources :children, only: [:index]
end end
end end
scope(path: 'groups/*id',
controller: :groups,
constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ }) do
get :edit, as: :edit_group
get :issues, as: :issues_group
get :merge_requests, as: :merge_requests_group
get :projects, as: :projects_group
get :activity, as: :activity_group
get '/', action: :show, as: :group_canonical
end
constraints(GroupUrlConstrainer.new) do
scope(path: '*id', scope(path: '*id',
as: :group, as: :group,
constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ }, constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ },
......
...@@ -285,17 +285,15 @@ end ...@@ -285,17 +285,15 @@ end
describe "Groups", "routing" do describe "Groups", "routing" do
let(:name) { 'complex.group-namegit' } let(:name) { 'complex.group-namegit' }
let!(:group) { create(:group, name: name) }
before do
allow_any_instance_of(GroupUrlConstrainer).to receive(:matches?).and_return(true)
end
it "to #show" do it "to #show" do
expect(get("/groups/#{name}")).to route_to('groups#show', id: name) expect(get("/groups/#{name}")).to route_to('groups#show', id: name)
end end
it "also supports nested groups" do it "also supports nested groups" do
expect(get("/#{name}/#{name}")).to route_to('groups#show', id: "#{name}/#{name}") nested_group = create(:group, parent: group)
expect(get("/#{name}/#{nested_group.name}")).to route_to('groups#show', id: "#{name}/#{nested_group.name}")
end end
it "also display group#show on the short path" do it "also display group#show on the short path" do
...@@ -313,10 +311,6 @@ describe "Groups", "routing" do ...@@ -313,10 +311,6 @@ describe "Groups", "routing" do
it "to #members" do it "to #members" do
expect(get("/groups/#{name}/group_members")).to route_to('groups/group_members#index', group_id: name) expect(get("/groups/#{name}/group_members")).to route_to('groups/group_members#index', group_id: name)
end 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
end end
describe HealthCheckController, 'routing' do describe HealthCheckController, 'routing' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment