From 16a8160e9f1cc2874a39dfd2d6a6abea9bcfead5 Mon Sep 17 00:00:00 2001
From: Connor Shea <connor.james.shea@gmail.com>
Date: Tue, 19 Jul 2016 11:17:14 -0600
Subject: [PATCH] Fix help page paths to make sure shortcuts and the UI help
 page work.

Add a test to make sure the help page UI path doesn't break in the future.

Fix #19972 and #19889.
---
 config/routes.rb                         | 9 ++++-----
 lib/gitlab/gon_helper.rb                 | 2 +-
 spec/controllers/help_controller_spec.rb | 9 +++++++++
 spec/routing/routing_spec.rb             | 7 ++-----
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/config/routes.rb b/config/routes.rb
index be651d8903f..2a9fe30b0e6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -89,11 +89,10 @@ Rails.application.routes.draw do
   mount Grack::AuthSpawner, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\/(info\/lfs|gitlab-lfs)/.match(request.path_info) }, via: [:get, :post, :put]
 
   # Help
-  
-  get 'help'                  => 'help#index'
-  get 'help/*path'            => 'help#show', as: :help_page
-  get 'help/shortcuts'
-  get 'help/ui' => 'help#ui'
+  get 'help'           => 'help#index'
+  get 'help/shortcuts' => 'help#shortcuts'
+  get 'help/ui'        => 'help#ui'
+  get 'help/*path'     => 'help#show', as: :help_page
 
   #
   # Global snippets
diff --git a/lib/gitlab/gon_helper.rb b/lib/gitlab/gon_helper.rb
index d4f12cb1df9..c5a11148d33 100644
--- a/lib/gitlab/gon_helper.rb
+++ b/lib/gitlab/gon_helper.rb
@@ -5,7 +5,7 @@ module Gitlab
       gon.default_avatar_url     = URI::join(Gitlab.config.gitlab.url, ActionController::Base.helpers.image_path('no_avatar.png')).to_s
       gon.max_file_size          = current_application_settings.max_attachment_size
       gon.relative_url_root      = Gitlab.config.gitlab.relative_url_root
-      gon.shortcuts_path         = help_shortcuts_path
+      gon.shortcuts_path         = help_page_path('shortcuts')
       gon.user_color_scheme      = Gitlab::ColorSchemes.for_user(current_user).css_class
       gon.award_menu_url         = emojis_path
 
diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb
index 267d511c2db..347bef1e129 100644
--- a/spec/controllers/help_controller_spec.rb
+++ b/spec/controllers/help_controller_spec.rb
@@ -63,4 +63,13 @@ describe HelpController do
       end
     end
   end
+
+  describe 'GET #ui' do
+    context 'for UI Development Kit' do
+      it 'renders found' do
+        get :ui
+        expect(response).to have_http_status(200)
+      end
+    end
+  end
 end
diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb
index 2c755919456..0a52c1ab933 100644
--- a/spec/routing/routing_spec.rb
+++ b/spec/routing/routing_spec.rb
@@ -116,12 +116,9 @@ describe HelpController, "routing" do
     expect(get(path)).to route_to('help#show',
                                   path: 'workflow/protected_branches/protected_branches1',
                                   format: 'png')
-    path = '/help/shortcuts'
-    expect(get(path)).to route_to('help#show',
-                                  path: 'shortcuts')
+    
     path = '/help/ui'
-    expect(get(path)).to route_to('help#show',
-                                  path: 'ui')
+    expect(get(path)).to route_to('help#ui')
   end
 end
 
-- 
GitLab