From bd1fbe18d65a763f610b6bc4c64f4b447e4495b6 Mon Sep 17 00:00:00 2001
From: Alfredo Sumaran <alfredo@gitlab.com>
Date: Thu, 24 Mar 2016 15:19:43 -0500
Subject: [PATCH] Use strings instead of constants

---
 app/helpers/search_helper.rb | 56 ++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 31 deletions(-)

diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index e6aa21887ec..8a97a74ad73 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -1,11 +1,5 @@
 module SearchHelper
 
-  CAT_SETTINGS = 'Settings'
-  CAT_HELP = 'Help'
-  CAT_CURR_PROJECT = 'Current Project'
-  CAT_GROUPS = 'Groups'
-  CAT_PROJECTS = 'Projects'
-
   def search_autocomplete_opts(term)
     return unless current_user
 
@@ -30,25 +24,25 @@ module SearchHelper
   # Autocomplete results for various settings pages
   def default_autocomplete
     [
-      { category: CAT_SETTINGS, label: "Profile settings", url: profile_path },
-      { category: CAT_SETTINGS, label: "SSH Keys",         url: profile_keys_path },
-      { category: CAT_SETTINGS, label: "Dashboard",        url: root_path },
-      { category: CAT_SETTINGS, label: "Admin Section",    url: admin_root_path },
+      { category: "Settings", label: "Profile settings", url: profile_path },
+      { category: "Settings", label: "SSH Keys",         url: profile_keys_path },
+      { category: "Settings", label: "Dashboard",        url: root_path },
+      { category: "Settings", label: "Admin Section",    url: admin_root_path },
     ]
   end
 
   # Autocomplete results for internal help pages
   def help_autocomplete
     [
-      { category: CAT_HELP, label: "API Help",           url: help_page_path("api", "README") },
-      { category: CAT_HELP, label: "Markdown Help",      url: help_page_path("markdown", "markdown") },
-      { category: CAT_HELP, label: "Permissions Help",   url: help_page_path("permissions", "permissions") },
-      { category: CAT_HELP, label: "Public Access Help", url: help_page_path("public_access", "public_access") },
-      { category: CAT_HELP, label: "Rake Tasks Help",    url: help_page_path("raketasks", "README") },
-      { category: CAT_HELP, label: "SSH Keys Help",      url: help_page_path("ssh", "README") },
-      { category: CAT_HELP, label: "System Hooks Help",  url: help_page_path("system_hooks", "system_hooks") },
-      { category: CAT_HELP, label: "Webhooks Help",      url: help_page_path("web_hooks", "web_hooks") },
-      { category: CAT_HELP, label: "Workflow Help",      url: help_page_path("workflow", "README") },
+      { category: "Help", label: "API Help",           url: help_page_path("api", "README") },
+      { category: "Help", label: "Markdown Help",      url: help_page_path("markdown", "markdown") },
+      { category: "Help", label: "Permissions Help",   url: help_page_path("permissions", "permissions") },
+      { category: "Help", label: "Public Access Help", url: help_page_path("public_access", "public_access") },
+      { category: "Help", label: "Rake Tasks Help",    url: help_page_path("raketasks", "README") },
+      { category: "Help", label: "SSH Keys Help",      url: help_page_path("ssh", "README") },
+      { category: "Help", label: "System Hooks Help",  url: help_page_path("system_hooks", "system_hooks") },
+      { category: "Help", label: "Webhooks Help",      url: help_page_path("web_hooks", "web_hooks") },
+      { category: "Help", label: "Workflow Help",      url: help_page_path("workflow", "README") },
     ]
   end
 
@@ -58,16 +52,16 @@ module SearchHelper
       ref    = @ref || @project.repository.root_ref
 
       [
-        { category: CAT_CURR_PROJECT, label: "Files",          url: namespace_project_tree_path(@project.namespace, @project, ref) },
-        { category: CAT_CURR_PROJECT, label: "Commits",        url: namespace_project_commits_path(@project.namespace, @project, ref) },
-        { category: CAT_CURR_PROJECT, label: "Network",        url: namespace_project_network_path(@project.namespace, @project, ref) },
-        { category: CAT_CURR_PROJECT, label: "Graph",          url: namespace_project_graph_path(@project.namespace, @project, ref) },
-        { category: CAT_CURR_PROJECT, label: "Issues",         url: namespace_project_issues_path(@project.namespace, @project) },
-        { category: CAT_CURR_PROJECT, label: "Merge Requests", url: namespace_project_merge_requests_path(@project.namespace, @project) },
-        { category: CAT_CURR_PROJECT, label: "Milestones",     url: namespace_project_milestones_path(@project.namespace, @project) },
-        { category: CAT_CURR_PROJECT, label: "Snippets",       url: namespace_project_snippets_path(@project.namespace, @project) },
-        { category: CAT_CURR_PROJECT, label: "Members",        url: namespace_project_project_members_path(@project.namespace, @project) },
-        { category: CAT_CURR_PROJECT, label: "Wiki",           url: namespace_project_wikis_path(@project.namespace, @project) },
+        { category: "Current Project", label: "Files",          url: namespace_project_tree_path(@project.namespace, @project, ref) },
+        { category: "Current Project", label: "Commits",        url: namespace_project_commits_path(@project.namespace, @project, ref) },
+        { category: "Current Project", label: "Network",        url: namespace_project_network_path(@project.namespace, @project, ref) },
+        { category: "Current Project", label: "Graph",          url: namespace_project_graph_path(@project.namespace, @project, ref) },
+        { category: "Current Project", label: "Issues",         url: namespace_project_issues_path(@project.namespace, @project) },
+        { category: "Current Project", label: "Merge Requests", url: namespace_project_merge_requests_path(@project.namespace, @project) },
+        { category: "Current Project", label: "Milestones",     url: namespace_project_milestones_path(@project.namespace, @project) },
+        { category: "Current Project", label: "Snippets",       url: namespace_project_snippets_path(@project.namespace, @project) },
+        { category: "Current Project", label: "Members",        url: namespace_project_project_members_path(@project.namespace, @project) },
+        { category: "Current Project", label: "Wiki",           url: namespace_project_wikis_path(@project.namespace, @project) },
       ]
     else
       []
@@ -78,7 +72,7 @@ module SearchHelper
   def groups_autocomplete(term, limit = 5)
     current_user.authorized_groups.search(term).limit(limit).map do |group|
       {
-        category: CAT_GROUPS,
+        category: "Groups",
         id: group.id,
         label: "#{search_result_sanitize(group.name)}",
         url: group_path(group)
@@ -91,7 +85,7 @@ module SearchHelper
     current_user.authorized_projects.search_by_title(term).
       sorted_by_stars.non_archived.limit(limit).map do |p|
       {
-        category: CAT_PROJECTS,
+        category: "Projects",
         id: p.id,
         value: "#{search_result_sanitize(p.name)}",
         label: "#{search_result_sanitize(p.name_with_namespace)}",
-- 
GitLab