email_process_identify_sender_max_test.rb 937 B

12345678910111213141516171819202122232425262728293031323334
  1. require 'test_helper'
  2. class EmailProcessIdentifySenderMax < ActiveSupport::TestCase
  3. test 'text max created recipients per email' do
  4. current_users = User.count
  5. email_raw_string = "From: #{generate_recipient(1)}
  6. To: #{generate_recipient(22)}
  7. Cc: #{generate_recipient(22)}
  8. Subject: test max sender identify
  9. Some Text"
  10. ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
  11. ticket = Ticket.find(ticket_p.id)
  12. assert_equal('test max sender identify', ticket.title)
  13. assert_equal(current_users + 41, User.count)
  14. end
  15. def generate_recipient(count)
  16. recipients = ''
  17. count.times.each do
  18. if recipients.present?
  19. recipients += ', '
  20. end
  21. domain = "#{Time.zone.now.to_i}-#{rand(999_999_999_999_999)}.example.com"
  22. email = "#{Time.zone.now.to_i}-#{rand(999_999_999_999_999)}@#{domain}"
  23. recipients += email
  24. end
  25. recipients
  26. end
  27. end