Commit 69d55850 authored by Stan Hu's avatar Stan Hu

Merge branch '32198-banner-alerting-of-project-move-is-showing-up-everywhere' into 'master'

Resolve "Banner alerting of project move is showing up everywhere"

See merge request gitlab-org/gitlab!18985
parents 97af0731 1453d309
......@@ -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
......
---
title: Fix "project or group was moved" alerts showing up in the wrong pages
merge_request: 18985
author:
type: fixed
......@@ -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') }
......
......@@ -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
......
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