fixes #2418 (includes hiding deleted dmails and allowing filtering on user name)

This commit is contained in:
r888888888
2015-07-07 16:47:23 -07:00
parent 4a24fe5074
commit 67e46f6e5c
9 changed files with 121 additions and 8 deletions

View File

@@ -1,7 +1,43 @@
require 'test_helper'
class DmailFilterTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
def setup
super
@receiver = FactoryGirl.create(:user)
@sender = FactoryGirl.create(:user)
end
def create_dmail(body, title)
CurrentUser.scoped(@sender, "127.0.0.1") do
Dmail.create_split(:to_id => @receiver.id, :body => body, :title => title)
end
end
context "a dmail filter for a word" do
setup do
@dmail_filter = @receiver.create_dmail_filter(:words => "banned")
end
should "filter on that word in the body" do
create_dmail("banned", "okay")
assert_equal(true, @receiver.dmails.last.is_deleted?)
end
should "filter on that word in the title" do
create_dmail("okay", "banned")
assert_equal(true, @receiver.dmails.last.is_deleted?)
end
end
context "a dmail filter for a user name" do
setup do
@dmail_filter = @receiver.create_dmail_filter(:words => @sender.name)
end
should "filter on the sender" do
create_dmail("okay", "okay")
assert_equal(true, @receiver.dmails.last.is_deleted?)
end
end
end