email_process_sender_name_update_if_needed.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. require 'test_helper'
  2. class EmailProcessSenderNameUpdateIfNeeded < ActiveSupport::TestCase
  3. test 'basic' do
  4. email_raw_string = "From: customer@example.com
  5. To: myzammad@example.com
  6. Subject: test sender name update 1
  7. Some Text"
  8. ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
  9. ticket = Ticket.find(ticket_p.id)
  10. article = Ticket::Article.find(article_p.id)
  11. assert_equal('test sender name update 1', ticket.title)
  12. assert_equal('new', ticket.state.name)
  13. assert_equal('Customer', ticket.create_article_sender.name)
  14. assert_equal('Customer', article.sender.name)
  15. assert_equal('customer@example.com', ticket.customer.email)
  16. assert_equal('', ticket.customer.firstname)
  17. assert_equal('', ticket.customer.lastname)
  18. email_raw_string = "From: Max Smith <customer@example.com>
  19. To: myzammad@example.com
  20. Subject: test sender name update 2
  21. Some Text"
  22. ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
  23. ticket = Ticket.find(ticket_p.id)
  24. article = Ticket::Article.find(article_p.id)
  25. assert_equal('test sender name update 2', ticket.title)
  26. assert_equal('new', ticket.state.name)
  27. assert_equal('Customer', ticket.create_article_sender.name)
  28. assert_equal('Customer', article.sender.name)
  29. assert_equal('customer@example.com', ticket.customer.email)
  30. assert_equal('Max', ticket.customer.firstname)
  31. assert_equal('Smith', ticket.customer.lastname)
  32. end
  33. end