FEATURE: add /conduct as an alias for /guidelines

FEATURE: add /conduct as an alias for /guidelines
diff --git a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 b/app/assets/javascripts/discourse/routes/app-route-map.js.es6
index 30dd8fc..1e2e6ad 100644
--- a/app/assets/javascripts/discourse/routes/app-route-map.js.es6
+++ b/app/assets/javascripts/discourse/routes/app-route-map.js.es6
@@ -181,6 +181,7 @@ export default function() {
   this.route("privacy", { path: "/privacy" });
   this.route("guidelines", { path: "/guidelines" });
   this.route("rules", { path: "/rules" });
+  this.route("conduct", { path: "/conduct" });
 
   this.route("new-topic", { path: "/new-topic" });
   this.route("new-message", { path: "/new-message" });
diff --git a/app/assets/javascripts/discourse/routes/conduct.js.es6 b/app/assets/javascripts/discourse/routes/conduct.js.es6
new file mode 100644
index 0000000..c3eb757
--- /dev/null
+++ b/app/assets/javascripts/discourse/routes/conduct.js.es6
@@ -0,0 +1,3 @@
+import staticRouteBuilder from "discourse/lib/static-route-builder";
+
+export default staticRouteBuilder("conduct");
diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb
index 43b4a85..bd6b2e5 100644
--- a/app/controllers/static_controller.rb
+++ b/app/controllers/static_controller.rb
@@ -12,7 +12,7 @@ class StaticController < ApplicationController
 
   def show
     return redirect_to(path '/') if current_user && (params[:id] == 'login' || params[:id] == 'signup')
-    if SiteSetting.login_required? && current_user.nil? && ['faq', 'guidelines', 'rules'].include?(params[:id])
+    if SiteSetting.login_required? && current_user.nil? && ['faq', 'guidelines'].include?(params[:id])
       return redirect_to path('/login')
     end
 
@@ -31,7 +31,7 @@ class StaticController < ApplicationController
     end
 
     # The /guidelines route ALWAYS shows our FAQ, ignoring the faq_url site setting.
-    @page = 'faq' if @page == 'guidelines' || @page == 'rules'
+    @page = 'faq' if @page == 'guidelines'
 
     # Don't allow paths like ".." or "/" or anything hacky like that
     @page.gsub!(/[^a-z0-9\_\-]/, '')
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 74c6ad1..c9c0c7d 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -231,6 +231,7 @@ en:
     privacy: "Privacy"
     tos: "Terms of Service"
     rules: "Rules"
+    conduct: "Code of Conduct"
     mobile_view: "Mobile View"
     desktop_view: "Desktop View"
     you: "You"
diff --git a/config/routes.rb b/config/routes.rb
index c46c943..a99df27 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -329,13 +329,15 @@ Discourse::Application.routes.draw do
   get "login" => "static#show", id: "login", constraints: { format: /(json|html)/ }
   get "password-reset" => "static#show", id: "password_reset", constraints: { format: /(json|html)/ }
   get "faq" => "static#show", id: "faq", constraints: { format: /(json|html)/ }
-  get "guidelines" => "static#show", id: "guidelines", as: 'guidelines', constraints: { format: /(json|html)/ }
-  get "rules" => "static#show", id: "rules", as: 'rules', constraints: { format: /(json|html)/ }
   get "tos" => "static#show", id: "tos", as: 'tos', constraints: { format: /(json|html)/ }
   get "privacy" => "static#show", id: "privacy", as: 'privacy', constraints: { format: /(json|html)/ }
   get "signup" => "static#show", id: "signup", constraints: { format: /(json|html)/ }
   get "login-preferences" => "static#show", id: "login", constraints: { format: /(json|html)/ }
 
+  %w{guidelines rules conduct}.each do |faq_alias|
+    get faq_alias => "static#show", id: "guidelines", as: faq_alias, constraints: { format: /(json|html)/ }
+  end
+
   get "my/*path", to: 'users#my_redirect'
   get "user_preferences" => "users#user_preferences_redirect"
 
diff --git a/spec/requests/static_controller_spec.rb b/spec/requests/static_controller_spec.rb
index 37a0f4c..b3613be 100644
--- a/spec/requests/static_controller_spec.rb
+++ b/spec/requests/static_controller_spec.rb
@@ -164,7 +164,7 @@ describe StaticController do
         SiteSetting.login_required = true
       end
 
-      ['faq', 'guidelines', 'rules'].each do |page_name|
+      ['faq', 'guidelines', 'rules', 'conduct'].each do |page_name|
         it "#{page_name} page redirects to login page for anon" do
           get "/#{page_name}"
           expect(response).to redirect_to '/login'
@@ -174,9 +174,7 @@ describe StaticController do
           get "/#{page_name}"
           expect(response).to redirect_to '/login'
         end
-      end
 
-      ['faq', 'guidelines', 'rules'].each do |page_name|
         it "#{page_name} page loads for logged in user" do
           sign_in(Fabricate(:user))

GitHub
sha: 6774b64a

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/different-permalink-name-to-guidelines-failing-internally/104502/4