fixes #2326
This commit is contained in:
@@ -196,11 +196,12 @@ class Dmail < ActiveRecord::Base
|
|||||||
def auto_delete_if_filtered
|
def auto_delete_if_filtered
|
||||||
if owner_id != CurrentUser.user.id && to.dmail_filter.try(:filtered?, self)
|
if owner_id != CurrentUser.user.id && to.dmail_filter.try(:filtered?, self)
|
||||||
self.is_deleted = true
|
self.is_deleted = true
|
||||||
|
self.is_read = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_recipient
|
def update_recipient
|
||||||
unless is_deleted
|
unless is_deleted?
|
||||||
to.update_attribute(:has_mail, true)
|
to.update_attribute(:has_mail, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,7 +29,14 @@ class DmailTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
should "autodelete if it has a banned word" do
|
should "autodelete if it has a banned word" do
|
||||||
@dmail.save
|
@dmail.save
|
||||||
assert(@dmail.is_deleted)
|
assert_equal(true, @dmail.is_deleted?)
|
||||||
|
assert_equal(true, @dmail.is_read?)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "not update the recipient's has_mail if filtered" do
|
||||||
|
@dmail.save
|
||||||
|
@recipient.reload
|
||||||
|
assert_equal(false, @recipient.has_mail?)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "that is empty" do
|
context "that is empty" do
|
||||||
|
|||||||
Reference in New Issue
Block a user