Don't filter dmails from moderators (fix #2757).

This commit is contained in:
evazion
2016-11-12 01:04:09 -06:00
parent b0a0a32173
commit 47f663e002
2 changed files with 11 additions and 1 deletions

View File

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

View File

@@ -38,6 +38,16 @@ class DmailTest < ActiveSupport::TestCase
assert_equal(false, @recipient.has_mail?)
end
should "be ignored when sender is a moderator" do
CurrentUser.scoped(FactoryGirl.create(:moderator_user), "127.0.0.1") do
@dmail = FactoryGirl.create(:dmail, :owner => @recipient, :body => "banned word here", :to => @recipient)
end
assert_equal(false, !!@recipient.dmail_filter.filtered?(@dmail))
assert_equal(false, @dmail.is_read?)
assert_equal(true, @recipient.has_mail?)
end
context "that is empty" do
setup do
@recipient.dmail_filter.update_attributes(:words => " ")