user_mail_delivery_failed_test.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. require 'test_helper'
  2. class UserMailDeliveryFailedTest < ActiveSupport::TestCase
  3. setup do
  4. UserInfo.current_user_id = 1
  5. roles = Role.where(name: 'Customer')
  6. @customer1 = User.create_or_update(
  7. login: 'user-mail-delivery-failed-customer1@example.com',
  8. firstname: 'UserOutOfOffice',
  9. lastname: 'Customer1',
  10. email: 'user-mail-delivery-failed-customer1@example.com',
  11. password: 'agentpw',
  12. active: true,
  13. roles: roles,
  14. )
  15. end
  16. test 'check reset of mail_delivery_failed' do
  17. @customer1.preferences[:mail_delivery_failed] = true
  18. @customer1.preferences[:mail_delivery_failed_data] = Time.zone.now
  19. @customer1.save!
  20. @customer1.reload
  21. assert_equal(@customer1.preferences[:mail_delivery_failed], true)
  22. assert(@customer1.preferences[:mail_delivery_failed_data])
  23. @customer1.email = 'new-user-mail-delivery-failed-customer1@example.com'
  24. @customer1.save!
  25. @customer1.reload
  26. assert_not(@customer1.preferences[:mail_delivery_failed], true)
  27. assert(@customer1.preferences[:mail_delivery_failed_data])
  28. end
  29. end