From 0d9e80c3ddedb5b56165dffa6cb248ee49091abf Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 24 Jan 2017 15:40:01 +0200 Subject: [PATCH] Fix 500 error for Group#web_url method if nested group Signed-off-by: Dmitriy Zaporozhets --- config/routes/group.rb | 6 ++---- spec/models/group_spec.rb | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/routes/group.rb b/config/routes/group.rb index 776c31c9dac..60a1175fe80 100644 --- a/config/routes/group.rb +++ b/config/routes/group.rb @@ -19,13 +19,11 @@ end scope(path: 'groups/*id', controller: :groups, - constraints: { id: Gitlab::Regex.namespace_route_regex }) do + constraints: { id: Gitlab::Regex.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 - -# Must be last route in this file -get 'groups/*id' => 'groups#show', as: :group_canonical, constraints: { id: Gitlab::Regex.namespace_route_regex } diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 45fe927202b..63ffdf70958 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -269,6 +269,12 @@ describe Group, models: true do it 'returns the canonical URL' do expect(group.web_url).to include("groups/#{group.name}") end + + context 'nested group' do + let(:nested_group) { create(:group, :nested) } + + it { expect(nested_group.web_url).to include("groups/#{nested_group.full_path}") } + end end describe 'nested group' do -- GitLab