Commit 181cf350 authored by Sean McGivern's avatar Sean McGivern

Redirect to group boards with params from old path

If using the old path (`/groups/$group/boards/*`), and there is no subgroup
called 'boards', redirect to `/groups/$group/-/boards/*`.

Note that because there is no path matching a group followed by an integer, this
redirect will work for individual boards even if there _is_ a subgroup called
'boards'.
parent 3f4d1f3e
---
title: Redirect to existing group boards using old URL if there is no subgroup called
'boards'
merge_request:
author:
type: fixed
......@@ -89,7 +89,14 @@ constraints(GroupUrlConstrainer.new) do
end
## EE-specific
get :boards, to: redirect('/groups/%{group_id}/-/boards')
legacy_ee_group_boards_redirect = redirect do |params, request|
path = "/groups/#{params[:group_id]}/-/boards"
path << "/#{params[:extra_params]}" if params[:extra_params].present?
path << "?#{request.query_string}" if request.query_string.present?
path
end
get 'boards(/*extra_params)', as: :legacy_ee_group_boards_redirect, to: legacy_ee_group_boards_redirect
end
scope(path: '*id',
......
require 'spec_helper'
describe 'Deprecated boards paths' do
it 'redirects to boards page' do
group = create :group, name: 'gitlabhq'
let!(:group) { create(:group, name: 'gitlabhq') }
get('/groups/gitlabhq/boards')
context 'when no group called boards exists' do
it 'redirects to boards page' do
get('/groups/gitlabhq/boards')
expect(response).to redirect_to(group_boards_path(group))
expect(response).to redirect_to(group_boards_path(group))
end
it 'redirects to the boards page with additional params' do
get('/groups/gitlabhq/boards/1?foo=bar')
expect(response).to redirect_to(group_board_path(group, 1, foo: 'bar'))
end
end
context 'when a group called boards exists', :nested_groups do
before do
create(:group, name: 'boards', parent: group)
end
it 'does not redirect to the main boards page' do
get('/groups/gitlabhq/boards')
expect(response).to have_gitlab_http_status(200)
end
it 'does not redirect to the boards page with additional params' do
get('/groups/gitlabhq/boards/issues')
expect(response).to have_gitlab_http_status(200)
end
it 'redirects to the boards page with additional params if there is no matching route on the subgroup' do
get('/groups/gitlabhq/boards/1?foo=bar')
expect(response).to redirect_to(group_board_path(group, 1, foo: 'bar'))
end
end
end
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