FIX: don't downcase watched words on input since it can break the watched_words_regular_expressions setting

This commit is contained in:
Neil Lalonde
2018-01-09 16:51:45 -05:00
parent daad2291ba
commit 8f21c96ea5
3 changed files with 20 additions and 4 deletions

View File

@@ -31,11 +31,12 @@ class WatchedWord < ActiveRecord::Base
scope :by_action, -> { order("action ASC, word ASC") }
def self.normalize_word(w)
w.strip.downcase.squeeze('*')
w.strip.squeeze('*')
end
def self.create_or_update_word(params)
w = find_or_initialize_by(word: normalize_word(params[:word]))
new_word = normalize_word(params[:word])
w = WatchedWord.where("word ILIKE ?", new_word).first || WatchedWord.new(word: new_word)
w.action_key = params[:action_key] if params[:action_key]
w.action = params[:action] if params[:action]
w.save