diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-26 09:06:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-26 09:06:35 +0300 |
commit | 71c6369c63c3b0576c79f2c9b4ba977aded8de7a (patch) | |
tree | 591bacb9183098ed90a2afabccd517f9b79b9d87 | |
parent | 693cbd0f88c279cf1dbf4997dd8914c720cdd32c (diff) |
Add latest changes from gitlab-org/gitlab@master
5 files changed, 43 insertions, 2 deletions
diff --git a/app/controllers/concerns/routable_actions.rb b/app/controllers/concerns/routable_actions.rb index 45f9888a040..1b2e6461dee 100644 --- a/app/controllers/concerns/routable_actions.rb +++ b/app/controllers/concerns/routable_actions.rb @@ -47,7 +47,7 @@ module RoutableActions canonical_path = routable.full_path if canonical_path != requested_full_path - if canonical_path.casecmp(requested_full_path) != 0 + if !request.xhr? && request.format.html? && canonical_path.casecmp(requested_full_path) != 0 flash[:notice] = "#{routable.class.to_s.titleize} '#{requested_full_path}' was moved to '#{canonical_path}'. Please update any links and bookmarks that may still have the old path." end diff --git a/changelogs/unreleased/32198-banner-alerting-of-project-move-is-showing-up-everywhere.yml b/changelogs/unreleased/32198-banner-alerting-of-project-move-is-showing-up-everywhere.yml new file mode 100644 index 00000000000..a6d211d59ca --- /dev/null +++ b/changelogs/unreleased/32198-banner-alerting-of-project-move-is-showing-up-everywhere.yml @@ -0,0 +1,5 @@ +--- +title: Fix "project or group was moved" alerts showing up in the wrong pages +merge_request: 18985 +author: +type: fixed diff --git a/doc/user/project/milestones/index.md b/doc/user/project/milestones/index.md index 105854ccd33..03f524f5582 100644 --- a/doc/user/project/milestones/index.md +++ b/doc/user/project/milestones/index.md @@ -107,7 +107,7 @@ Not all features in the project milestone view are available in the group milest | Feature | Project milestone view | Group milestone view | |--------------------------------------|:----------------------:|:--------------------:| -| Title an description | ✓ | ✓ | +| Title and description | ✓ | ✓ | | Issues assigned to milestone | ✓ | | | Merge requests assigned to milestone | ✓ | | | Participants and labels used | ✓ | | diff --git a/spec/controllers/groups/milestones_controller_spec.rb b/spec/controllers/groups/milestones_controller_spec.rb index e0a3605d50a..4f4f9e5143b 100644 --- a/spec/controllers/groups/milestones_controller_spec.rb +++ b/spec/controllers/groups/milestones_controller_spec.rb @@ -314,6 +314,24 @@ describe Groups::MilestonesController do expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group)) end + context 'with an AJAX request' do + it 'redirects to the canonical path but does not set flash message' do + get :merge_requests, params: { group_id: redirect_route.path, id: title }, xhr: true + + expect(response).to redirect_to(merge_requests_group_milestone_path(group.to_param, title)) + expect(controller).not_to set_flash[:notice] + end + end + + context 'with JSON format' do + it 'redirects to the canonical path but does not set flash message' do + get :merge_requests, params: { group_id: redirect_route.path, id: title }, format: :json + + expect(response).to redirect_to(merge_requests_group_milestone_path(group.to_param, title, format: :json)) + expect(controller).not_to set_flash[:notice] + end + end + context 'when the old group path is a substring of the scheme or host' do let(:redirect_route) { group.redirect_routes.create(path: 'http') } diff --git a/spec/controllers/projects/labels_controller_spec.rb b/spec/controllers/projects/labels_controller_spec.rb index ff089df37f7..aee017b211a 100644 --- a/spec/controllers/projects/labels_controller_spec.rb +++ b/spec/controllers/projects/labels_controller_spec.rb @@ -204,6 +204,24 @@ describe Projects::LabelsController do expect(response).to redirect_to(project_labels_path(project)) expect(controller).to set_flash[:notice].to(project_moved_message(redirect_route, project)) end + + context 'with an AJAX request' do + it 'redirects to the canonical path but does not set flash message' do + get :index, params: { namespace_id: project.namespace, project_id: project.to_param + 'old' }, xhr: true + + expect(response).to redirect_to(project_labels_path(project)) + expect(controller).not_to set_flash[:notice] + end + end + + context 'with JSON format' do + it 'redirects to the canonical path but does not set flash message' do + get :index, params: { namespace_id: project.namespace, project_id: project.to_param + 'old' }, format: :json + + expect(response).to redirect_to(project_labels_path(project, format: :json)) + expect(controller).not_to set_flash[:notice] + end + end end end end |