dmails: add tests for automated dmails.

This commit is contained in:
evazion
2017-02-23 22:06:12 -06:00
parent b1af644f67
commit 6704e71377
2 changed files with 35 additions and 2 deletions

View File

@@ -13,7 +13,7 @@ class UserTest < ActiveSupport::TestCase
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "promoting a user" do
setup do
CurrentUser.user = FactoryGirl.create(:moderator_user)
@@ -27,10 +27,16 @@ class UserTest < ActiveSupport::TestCase
assert_equal("You have been promoted to a Gold level account from Member.", @user.feedback.last.body)
end
should "create a dmail" do
should "send an automated dmail to the user" do
bot = FactoryGirl.create(:user)
Danbooru.config.stubs(:system_user).returns(bot)
assert_difference("Dmail.count", 2) do
@user.promote_to!(User::Levels::GOLD)
end
assert(@user.dmails.exists?(from: bot, to: @user, title: "You have been promoted"))
assert(bot.dmails.exists?(from: bot, to: @user, title: "You have been promoted"))
end
end