Don't filter dmails from moderators (fix #2757).
This commit is contained in:
@@ -11,7 +11,7 @@ class DmailFilter < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def filtered?(dmail)
|
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
|
end
|
||||||
|
|
||||||
def has_filter?
|
def has_filter?
|
||||||
|
|||||||
@@ -38,6 +38,16 @@ class DmailTest < ActiveSupport::TestCase
|
|||||||
assert_equal(false, @recipient.has_mail?)
|
assert_equal(false, @recipient.has_mail?)
|
||||||
end
|
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
|
context "that is empty" do
|
||||||
setup do
|
setup do
|
||||||
@recipient.dmail_filter.update_attributes(:words => " ")
|
@recipient.dmail_filter.update_attributes(:words => " ")
|
||||||
|
|||||||
Reference in New Issue
Block a user