From 429b02a5d512a96c09fb95df23742a1a0313da80 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 9 Jan 2017 17:08:24 +0800 Subject: [PATCH] oops fix specs. --- lib/validators/censored_words_validator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/validators/censored_words_validator.rb b/lib/validators/censored_words_validator.rb index b5727c53390..3d3c3685264 100644 --- a/lib/validators/censored_words_validator.rb +++ b/lib/validators/censored_words_validator.rb @@ -1,11 +1,11 @@ class CensoredWordsValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) - if value =~ /#{SiteSetting.censored_words}/i + if !SiteSetting.censored_words.blank? && value =~ /#{SiteSetting.censored_words}/i record.errors.add( attribute, :contains_censored_words, censored_words: SiteSetting.censored_words ) - elsif value =~ /#{SiteSetting.censored_pattern}/i + elsif !SiteSetting.censored_pattern.blank? && value =~ /#{SiteSetting.censored_pattern}/i record.errors.add( attribute, :matches_censored_pattern, censored_pattern: SiteSetting.censored_pattern