email_process_bounce_test.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # encoding: utf-8
  2. require 'test_helper'
  3. class EmailProcessBounceTest < ActiveSupport::TestCase
  4. test 'process with bounce check' do
  5. ticket = Ticket.create(
  6. title: 'bounce check',
  7. group: Group.lookup( name: 'Users'),
  8. customer_id: 2,
  9. state: Ticket::State.lookup( name: 'new' ),
  10. priority: Ticket::Priority.lookup( name: '2 normal' ),
  11. updated_by_id: 1,
  12. created_by_id: 1,
  13. )
  14. article = Ticket::Article.create(
  15. ticket_id: ticket.id,
  16. from: 'some_sender@example.com',
  17. to: 'some_recipient@example.com',
  18. subject: 'bounce check',
  19. message_id: '<20150830145601.30.608881@edenhofer.zammad.com>',
  20. body: 'some message bounce check',
  21. internal: false,
  22. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  23. type: Ticket::Article::Type.where(name: 'email').first,
  24. updated_by_id: 1,
  25. created_by_id: 1,
  26. )
  27. travel 1.second
  28. email_raw_string = IO.binread('test/fixtures/mail33-undelivered-mail-returned-to-sender.box')
  29. ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email_raw_string)
  30. assert_equal(ticket.id, ticket_p.id)
  31. assert_equal('new', ticket_p.state.name)
  32. travel_back
  33. ticket.destroy
  34. end
  35. end