This commit is contained in:
r888888888
2014-12-12 17:32:33 -08:00
parent 7175df2099
commit ad22e42e62
2 changed files with 15 additions and 1 deletions

View File

@@ -11,7 +11,11 @@ class DmailFilter < ActiveRecord::Base
end
def filtered?(dmail)
dmail.from.level <= User::Levels::MODERATOR && (dmail.body =~ regexp || dmail.subject =~ regexp)
dmail.from.level <= User::Levels::MODERATOR && has_filter? && (dmail.body =~ regexp || dmail.subject =~ regexp)
end
def has_filter?
!words.strip.empty?
end
def regexp

View File

@@ -31,6 +31,16 @@ class DmailTest < ActiveSupport::TestCase
@dmail.save
assert(@dmail.is_deleted)
end
context "that is empty" do
setup do
@recipient.dmail_filter.update_attributes(:words => " ")
end
should "not filter everything" do
assert(!@recipient.dmail_filter.filtered?(@dmail))
end
end
end
context "from a banned user" do