From 4fa2f7e82d68c974ecfdb8896f15a5a3aba25828 Mon Sep 17 00:00:00 2001
From: David Yip <yipdw@member.fsf.org>
Date: Sun, 15 Oct 2017 03:17:33 -0500
Subject: [PATCH] Set up /settings/keyword_mutes.  #164.

This should eventually be accessible via the API and the web frontend,
but I find it easier to set up an editing interface using Rails
templates and the like.  We can always take it out if it turns out we
don't need it.
---
 .../settings/keyword_mutes_controller.rb          |  7 +++++++
 app/helpers/settings/keyword_mutes_helper.rb      |  2 ++
 app/views/settings/keyword_mutes/index.html.haml  |  2 ++
 config/locales/en.yml                             |  1 +
 config/navigation.rb                              |  1 +
 config/routes.rb                                  |  1 +
 .../settings/keyword_mutes_controller_spec.rb     |  5 +++++
 .../helpers/settings/keyword_mutes_helper_spec.rb | 15 +++++++++++++++
 8 files changed, 34 insertions(+)
 create mode 100644 app/controllers/settings/keyword_mutes_controller.rb
 create mode 100644 app/helpers/settings/keyword_mutes_helper.rb
 create mode 100644 app/views/settings/keyword_mutes/index.html.haml
 create mode 100644 spec/controllers/settings/keyword_mutes_controller_spec.rb
 create mode 100644 spec/helpers/settings/keyword_mutes_helper_spec.rb

diff --git a/app/controllers/settings/keyword_mutes_controller.rb b/app/controllers/settings/keyword_mutes_controller.rb
new file mode 100644
index 0000000000..ffe94e33a4
--- /dev/null
+++ b/app/controllers/settings/keyword_mutes_controller.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class Settings::KeywordMutesController < ApplicationController
+  layout 'admin'
+
+  before_action :authenticate_user!
+end
diff --git a/app/helpers/settings/keyword_mutes_helper.rb b/app/helpers/settings/keyword_mutes_helper.rb
new file mode 100644
index 0000000000..7b98cd59e0
--- /dev/null
+++ b/app/helpers/settings/keyword_mutes_helper.rb
@@ -0,0 +1,2 @@
+module Settings::KeywordMutesHelper
+end
diff --git a/app/views/settings/keyword_mutes/index.html.haml b/app/views/settings/keyword_mutes/index.html.haml
new file mode 100644
index 0000000000..421fbeba29
--- /dev/null
+++ b/app/views/settings/keyword_mutes/index.html.haml
@@ -0,0 +1,2 @@
+- content_for :page_title do
+  = t('settings.keyword_mutes')
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 45929e97dd..6b4e602bd8 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -491,6 +491,7 @@ en:
     export: Data export
     followers: Authorized followers
     import: Import
+    keyword_mutes: Muted keywords
     notifications: Notifications
     preferences: Preferences
     settings: Settings
diff --git a/config/navigation.rb b/config/navigation.rb
index 50bfbd4801..9fa029b72e 100644
--- a/config/navigation.rb
+++ b/config/navigation.rb
@@ -7,6 +7,7 @@ SimpleNavigation::Configuration.run do |navigation|
     primary.item :settings, safe_join([fa_icon('cog fw'), t('settings.settings')]), settings_profile_url do |settings|
       settings.item :profile, safe_join([fa_icon('user fw'), t('settings.edit_profile')]), settings_profile_url
       settings.item :preferences, safe_join([fa_icon('sliders fw'), t('settings.preferences')]), settings_preferences_url
+      settings.item :keyword_mutes, safe_join([fa_icon('volume-off fw'), t('settings.keyword_mutes')]), settings_keyword_mutes_url
       settings.item :notifications, safe_join([fa_icon('bell fw'), t('settings.notifications')]), settings_notifications_url
       settings.item :password, safe_join([fa_icon('lock fw'), t('auth.change_password')]), edit_user_registration_url, highlights_on: %r{/auth/edit|/settings/delete}
       settings.item :two_factor_authentication, safe_join([fa_icon('mobile fw'), t('settings.two_factor_authentication')]), settings_two_factor_authentication_url, highlights_on: %r{/settings/two_factor_authentication}
diff --git a/config/routes.rb b/config/routes.rb
index 9ed081e508..6869142399 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -66,6 +66,7 @@ Rails.application.routes.draw do
 
   namespace :settings do
     resource :profile, only: [:show, :update]
+    resources :keyword_mutes
     resource :preferences, only: [:show, :update]
     resource :notifications, only: [:show, :update]
     resource :import, only: [:show, :create]
diff --git a/spec/controllers/settings/keyword_mutes_controller_spec.rb b/spec/controllers/settings/keyword_mutes_controller_spec.rb
new file mode 100644
index 0000000000..a8c37a072f
--- /dev/null
+++ b/spec/controllers/settings/keyword_mutes_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Settings::KeywordMutesController, type: :controller do
+
+end
diff --git a/spec/helpers/settings/keyword_mutes_helper_spec.rb b/spec/helpers/settings/keyword_mutes_helper_spec.rb
new file mode 100644
index 0000000000..a19d518ddd
--- /dev/null
+++ b/spec/helpers/settings/keyword_mutes_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the Settings::KeywordMutesHelper. For example:
+#
+# describe Settings::KeywordMutesHelper do
+#   describe "string concat" do
+#     it "concats two strings with spaces" do
+#       expect(helper.concat_strings("this","that")).to eq("this that")
+#     end
+#   end
+# end
+RSpec.describe Settings::KeywordMutesHelper, type: :helper do
+  pending "add some examples to (or delete) #{__FILE__}"
+end