ticket_notification_test.rb 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  1. # encoding: utf-8
  2. require 'test_helper'
  3. class TicketNotificationTest < ActiveSupport::TestCase
  4. # create agent1 & agent2
  5. groups = Group.where(name: 'Users')
  6. roles = Role.where(name: 'Agent')
  7. agent1 = User.create_or_update(
  8. login: 'ticket-notification-agent1@example.com',
  9. firstname: 'Notification',
  10. lastname: 'Agent1',
  11. email: 'ticket-notification-agent1@example.com',
  12. password: 'agentpw',
  13. active: true,
  14. roles: roles,
  15. groups: groups,
  16. preferences: {
  17. locale: 'de-de',
  18. },
  19. updated_by_id: 1,
  20. created_by_id: 1,
  21. )
  22. agent2 = User.create_or_update(
  23. login: 'ticket-notification-agent2@example.com',
  24. firstname: 'Notification',
  25. lastname: 'Agent2',
  26. email: 'ticket-notification-agent2@example.com',
  27. password: 'agentpw',
  28. active: true,
  29. roles: roles,
  30. groups: groups,
  31. preferences: {
  32. locale: 'en-ca',
  33. },
  34. updated_by_id: 1,
  35. created_by_id: 1,
  36. )
  37. Group.create_if_not_exists(
  38. name: 'WithoutAccess',
  39. note: 'Test for notification check.',
  40. updated_by_id: 1,
  41. created_by_id: 1
  42. )
  43. # create customer
  44. roles = Role.where(name: 'Customer')
  45. customer = User.create_or_update(
  46. login: 'ticket-notification-customer@example.com',
  47. firstname: 'Notification',
  48. lastname: 'Customer',
  49. email: 'ticket-notification-customer@example.com',
  50. password: 'agentpw',
  51. active: true,
  52. roles: roles,
  53. groups: groups,
  54. updated_by_id: 1,
  55. created_by_id: 1,
  56. )
  57. test 'ticket notification - to all agents / to explicit agents' do
  58. # create ticket in group
  59. ticket1 = Ticket.create(
  60. title: 'some notification test 1',
  61. group: Group.lookup(name: 'Users'),
  62. customer: agent1,
  63. state: Ticket::State.lookup(name: 'new'),
  64. priority: Ticket::Priority.lookup(name: '2 normal'),
  65. updated_by_id: agent1.id,
  66. created_by_id: agent1.id,
  67. )
  68. Ticket::Article.create(
  69. ticket_id: ticket1.id,
  70. from: 'some_sender@example.com',
  71. to: 'some_recipient@example.com',
  72. subject: 'some subject',
  73. message_id: 'some@id',
  74. body: 'some message',
  75. internal: false,
  76. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  77. type: Ticket::Article::Type.where(name: 'email').first,
  78. updated_by_id: agent1.id,
  79. created_by_id: agent1.id,
  80. )
  81. assert(ticket1)
  82. # execute ticket events
  83. Rails.configuration.webserver_is_active = nil
  84. Observer::Ticket::Notification.transaction
  85. #puts Delayed::Job.all.inspect
  86. Delayed::Worker.new.work_off
  87. # verify notifications to agent1 + agent2
  88. assert_equal(1, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
  89. assert_equal(1, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
  90. # create ticket in group
  91. ticket1 = Ticket.create(
  92. title: 'some notification test 1',
  93. group: Group.lookup(name: 'Users'),
  94. customer: agent1,
  95. state: Ticket::State.lookup(name: 'new'),
  96. priority: Ticket::Priority.lookup(name: '2 normal'),
  97. updated_by_id: agent1.id,
  98. created_by_id: agent1.id,
  99. )
  100. Ticket::Article.create(
  101. ticket_id: ticket1.id,
  102. from: 'some_sender@example.com',
  103. to: 'some_recipient@example.com',
  104. subject: 'some subject',
  105. message_id: 'some@id',
  106. body: 'some message',
  107. internal: false,
  108. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  109. type: Ticket::Article::Type.where(name: 'email').first,
  110. updated_by_id: agent1.id,
  111. created_by_id: agent1.id,
  112. )
  113. assert(ticket1)
  114. # execute ticket events
  115. Rails.configuration.webserver_is_active = true
  116. Observer::Ticket::Notification.transaction
  117. #puts Delayed::Job.all.inspect
  118. Delayed::Worker.new.work_off
  119. # verify notifications to agent1 + agent2
  120. assert_equal(0, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
  121. assert_equal(1, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
  122. end
  123. test 'ticket notification - simple' do
  124. # create ticket in group
  125. ticket1 = Ticket.create(
  126. title: 'some notification test 1',
  127. group: Group.lookup(name: 'Users'),
  128. customer: customer,
  129. state: Ticket::State.lookup(name: 'new'),
  130. priority: Ticket::Priority.lookup(name: '2 normal'),
  131. updated_by_id: customer.id,
  132. created_by_id: customer.id,
  133. )
  134. Ticket::Article.create(
  135. ticket_id: ticket1.id,
  136. from: 'some_sender@example.com',
  137. to: 'some_recipient@example.com',
  138. subject: 'some subject',
  139. message_id: 'some@id',
  140. body: 'some message',
  141. internal: false,
  142. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  143. type: Ticket::Article::Type.where(name: 'email').first,
  144. updated_by_id: customer.id,
  145. created_by_id: customer.id,
  146. )
  147. assert( ticket1, 'ticket created - ticket notification simple' )
  148. # execute ticket events
  149. Rails.configuration.webserver_is_active = true
  150. Observer::Ticket::Notification.transaction
  151. #puts Delayed::Job.all.inspect
  152. Delayed::Worker.new.work_off
  153. # verify notifications to agent1 + agent2
  154. assert_equal(1, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
  155. assert_equal(1, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
  156. # update ticket attributes
  157. ticket1.title = "#{ticket1.title} - #2"
  158. ticket1.priority = Ticket::Priority.lookup(name: '3 high')
  159. ticket1.save
  160. # execute ticket events
  161. Observer::Ticket::Notification.transaction
  162. #puts Delayed::Job.all.inspect
  163. Delayed::Worker.new.work_off
  164. # verify notifications to agent1 + agent2
  165. assert_equal(2, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
  166. assert_equal(2, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
  167. # add article to ticket
  168. Ticket::Article.create(
  169. ticket_id: ticket1.id,
  170. from: 'some person',
  171. subject: 'some note',
  172. body: 'some message',
  173. internal: true,
  174. sender: Ticket::Article::Sender.where(name: 'Agent').first,
  175. type: Ticket::Article::Type.where(name: 'note').first,
  176. updated_by_id: agent1.id,
  177. created_by_id: agent1.id,
  178. )
  179. # execute ticket events
  180. Observer::Ticket::Notification.transaction
  181. #puts Delayed::Job.all.inspect
  182. Delayed::Worker.new.work_off
  183. # verify notifications to not to agent1 but to agent2
  184. assert_equal(2, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
  185. assert_equal(3, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
  186. # update ticket by user
  187. ticket1.owner_id = agent1.id
  188. ticket1.updated_by_id = agent1.id
  189. ticket1.save
  190. Ticket::Article.create(
  191. ticket_id: ticket1.id,
  192. from: 'some person',
  193. subject: 'some note',
  194. body: 'some message',
  195. internal: true,
  196. sender: Ticket::Article::Sender.where(name: 'Agent').first,
  197. type: Ticket::Article::Type.where(name: 'note').first,
  198. updated_by_id: agent1.id,
  199. created_by_id: agent1.id,
  200. )
  201. # execute ticket events
  202. Observer::Ticket::Notification.transaction
  203. #puts Delayed::Job.all.inspect
  204. Delayed::Worker.new.work_off
  205. # verify notifications to not to agent1 but to agent2
  206. assert_equal(2, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
  207. assert_equal(3, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
  208. # create ticket with agent1 as owner
  209. ticket2 = Ticket.create(
  210. title: 'some notification test 2',
  211. group: Group.lookup(name: 'Users'),
  212. customer_id: 2,
  213. owner_id: agent1.id,
  214. state: Ticket::State.lookup(name: 'new'),
  215. priority: Ticket::Priority.lookup(name: '2 normal'),
  216. updated_by_id: agent1.id,
  217. created_by_id: agent1.id,
  218. )
  219. Ticket::Article.create(
  220. ticket_id: ticket2.id,
  221. from: 'some_sender@example.com',
  222. to: 'some_recipient@example.com',
  223. subject: 'some subject',
  224. message_id: 'some@id',
  225. body: 'some message',
  226. internal: false,
  227. sender: Ticket::Article::Sender.where(name: 'Agent').first,
  228. type: Ticket::Article::Type.where(name: 'phone').first,
  229. updated_by_id: agent1.id,
  230. created_by_id: agent1.id,
  231. )
  232. # execute ticket events
  233. Observer::Ticket::Notification.transaction
  234. #puts Delayed::Job.all.inspect
  235. Delayed::Worker.new.work_off
  236. assert(ticket2, 'ticket created')
  237. # verify notifications to no one
  238. assert_equal(0, NotificationFactory.already_sent?(ticket2, agent1, 'email'), ticket2.id)
  239. assert_equal(0, NotificationFactory.already_sent?(ticket2, agent2, 'email'), ticket2.id)
  240. # update ticket
  241. ticket2.title = "#{ticket2.title} - #2"
  242. ticket2.updated_by_id = agent1.id
  243. ticket2.priority = Ticket::Priority.lookup(name: '3 high')
  244. ticket2.save
  245. # execute ticket events
  246. Observer::Ticket::Notification.transaction
  247. #puts Delayed::Job.all.inspect
  248. Delayed::Worker.new.work_off
  249. # verify notifications to no one
  250. assert_equal(0, NotificationFactory.already_sent?(ticket2, agent1, 'email'), ticket2.id)
  251. assert_equal(0, NotificationFactory.already_sent?(ticket2, agent2, 'email'), ticket2.id)
  252. # update ticket
  253. ticket2.title = "#{ticket2.title} - #3"
  254. ticket2.updated_by_id = agent2.id
  255. ticket2.priority = Ticket::Priority.lookup(name: '2 normal')
  256. ticket2.save
  257. # execute ticket events
  258. Observer::Ticket::Notification.transaction
  259. #puts Delayed::Job.all.inspect
  260. Delayed::Worker.new.work_off
  261. # verify notifications to agent1 and not to agent2
  262. assert_equal(1, NotificationFactory.already_sent?(ticket2, agent1, 'email'), ticket2.id)
  263. assert_equal(0, NotificationFactory.already_sent?(ticket2, agent2, 'email'), ticket2.id)
  264. # create ticket with agent2 and agent1 as owner
  265. ticket3 = Ticket.create(
  266. title: 'some notification test 3',
  267. group: Group.lookup(name: 'Users'),
  268. customer_id: 2,
  269. owner_id: agent1.id,
  270. state: Ticket::State.lookup(name: 'new'),
  271. priority: Ticket::Priority.lookup(name: '2 normal'),
  272. updated_by_id: agent2.id,
  273. created_by_id: agent2.id,
  274. )
  275. article_inbound = Ticket::Article.create(
  276. ticket_id: ticket3.id,
  277. from: 'some_sender@example.com',
  278. to: 'some_recipient@example.com',
  279. subject: 'some subject',
  280. message_id: 'some@id',
  281. body: 'some message',
  282. internal: false,
  283. sender: Ticket::Article::Sender.where(name: 'Agent').first,
  284. type: Ticket::Article::Type.where(name: 'phone').first,
  285. updated_by_id: agent2.id,
  286. created_by_id: agent2.id,
  287. )
  288. # execute ticket events
  289. Observer::Ticket::Notification.transaction
  290. #puts Delayed::Job.all.inspect
  291. Delayed::Worker.new.work_off
  292. assert(ticket3, 'ticket created')
  293. # verify notifications to agent1 and not to agent2
  294. assert_equal(1, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
  295. assert_equal(0, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
  296. # update ticket
  297. ticket3.title = "#{ticket3.title} - #2"
  298. ticket3.updated_by_id = agent1.id
  299. ticket3.priority = Ticket::Priority.lookup(name: '3 high')
  300. ticket3.save
  301. # execute ticket events
  302. Observer::Ticket::Notification.transaction
  303. #puts Delayed::Job.all.inspect
  304. Delayed::Worker.new.work_off
  305. # verify notifications to no one
  306. assert_equal(1, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
  307. assert_equal(0, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
  308. # update ticket
  309. ticket3.title = "#{ticket3.title} - #3"
  310. ticket3.updated_by_id = agent2.id
  311. ticket3.priority = Ticket::Priority.lookup(name: '2 normal')
  312. ticket3.save
  313. # execute ticket events
  314. Observer::Ticket::Notification.transaction
  315. #puts Delayed::Job.all.inspect
  316. Delayed::Worker.new.work_off
  317. # verify notifications to agent1 and not to agent2
  318. assert_equal(2, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
  319. assert_equal(0, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
  320. # update article / not notification should be sent
  321. article_inbound.internal = true
  322. article_inbound.save
  323. # execute ticket events
  324. Observer::Ticket::Notification.transaction
  325. #puts Delayed::Job.all.inspect
  326. Delayed::Worker.new.work_off
  327. # verify notifications not to agent1 and not to agent2
  328. assert_equal(2, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
  329. assert_equal(0, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
  330. delete = ticket1.destroy
  331. assert(delete, 'ticket1 destroy')
  332. delete = ticket2.destroy
  333. assert(delete, 'ticket2 destroy')
  334. delete = ticket3.destroy
  335. assert(delete, 'ticket3 destroy')
  336. end
  337. test 'ticket notification - z preferences tests' do
  338. agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
  339. agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
  340. agent1.preferences['notification_config']['matrix']['create']['criteria']['no'] = false
  341. agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
  342. agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
  343. agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = false
  344. agent1.save
  345. agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
  346. agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
  347. agent2.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
  348. agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = false
  349. agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
  350. agent2.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
  351. agent2.save
  352. # create ticket in group
  353. ticket1 = Ticket.create(
  354. title: 'some notification test - z preferences tests 1',
  355. group: Group.lookup(name: 'Users'),
  356. customer: customer,
  357. state: Ticket::State.lookup(name: 'new'),
  358. priority: Ticket::Priority.lookup(name: '2 normal'),
  359. updated_by_id: customer.id,
  360. created_by_id: customer.id,
  361. )
  362. Ticket::Article.create(
  363. ticket_id: ticket1.id,
  364. from: 'some_sender@example.com',
  365. to: 'some_recipient@example.com',
  366. subject: 'some subject',
  367. message_id: 'some@id',
  368. body: 'some message',
  369. internal: false,
  370. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  371. type: Ticket::Article::Type.where(name: 'email').first,
  372. updated_by_id: customer.id,
  373. created_by_id: customer.id,
  374. )
  375. # execute ticket events
  376. Rails.configuration.webserver_is_active = false
  377. Observer::Ticket::Notification.transaction
  378. #puts Delayed::Job.all.inspect
  379. Delayed::Worker.new.work_off
  380. # verify notifications to agent1 + agent2
  381. assert_equal(0, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
  382. assert_equal(1, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
  383. # update ticket attributes
  384. ticket1.title = "#{ticket1.title} - #2"
  385. ticket1.priority = Ticket::Priority.lookup(name: '3 high')
  386. ticket1.save
  387. # execute ticket events
  388. Observer::Ticket::Notification.transaction
  389. #puts Delayed::Job.all.inspect
  390. Delayed::Worker.new.work_off
  391. # verify notifications to agent1 + agent2
  392. assert_equal(0, NotificationFactory.already_sent?(ticket1, agent1, 'email'), ticket1.id)
  393. assert_equal(2, NotificationFactory.already_sent?(ticket1, agent2, 'email'), ticket1.id)
  394. # create ticket in group
  395. ticket2 = Ticket.create(
  396. title: 'some notification test - z preferences tests 2',
  397. group: Group.lookup(name: 'Users'),
  398. customer: customer,
  399. owner: agent1,
  400. state: Ticket::State.lookup(name: 'new'),
  401. priority: Ticket::Priority.lookup(name: '2 normal'),
  402. updated_by_id: customer.id,
  403. created_by_id: customer.id,
  404. )
  405. Ticket::Article.create(
  406. ticket_id: ticket2.id,
  407. from: 'some_sender@example.com',
  408. to: 'some_recipient@example.com',
  409. subject: 'some subject',
  410. message_id: 'some@id',
  411. body: 'some message',
  412. internal: false,
  413. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  414. type: Ticket::Article::Type.where(name: 'email').first,
  415. updated_by_id: customer.id,
  416. created_by_id: customer.id,
  417. )
  418. # execute ticket events
  419. Observer::Ticket::Notification.transaction
  420. #puts Delayed::Job.all.inspect
  421. Delayed::Worker.new.work_off
  422. # verify notifications to agent1 + agent2
  423. assert_equal(1, NotificationFactory.already_sent?(ticket2, agent1, 'email'), ticket2.id)
  424. assert_equal(1, NotificationFactory.already_sent?(ticket2, agent2, 'email'), ticket2.id)
  425. # update ticket attributes
  426. ticket2.title = "#{ticket2.title} - #2"
  427. ticket2.priority = Ticket::Priority.lookup(name: '3 high')
  428. ticket2.save
  429. # execute ticket events
  430. Observer::Ticket::Notification.transaction
  431. #puts Delayed::Job.all.inspect
  432. Delayed::Worker.new.work_off
  433. # verify notifications to agent1 + agent2
  434. assert_equal(2, NotificationFactory.already_sent?(ticket2, agent1, 'email'), ticket2.id)
  435. assert_equal(2, NotificationFactory.already_sent?(ticket2, agent2, 'email'), ticket2.id)
  436. # create ticket in group
  437. ticket3 = Ticket.create(
  438. title: 'some notification test - z preferences tests 3',
  439. group: Group.lookup(name: 'Users'),
  440. customer: customer,
  441. owner: agent2,
  442. state: Ticket::State.lookup(name: 'new'),
  443. priority: Ticket::Priority.lookup(name: '2 normal'),
  444. updated_by_id: customer.id,
  445. created_by_id: customer.id,
  446. )
  447. Ticket::Article.create(
  448. ticket_id: ticket3.id,
  449. from: 'some_sender@example.com',
  450. to: 'some_recipient@example.com',
  451. subject: 'some subject',
  452. message_id: 'some@id',
  453. body: 'some message',
  454. internal: false,
  455. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  456. type: Ticket::Article::Type.where(name: 'email').first,
  457. updated_by_id: customer.id,
  458. created_by_id: customer.id,
  459. )
  460. # execute ticket events
  461. Observer::Ticket::Notification.transaction
  462. #puts Delayed::Job.all.inspect
  463. Delayed::Worker.new.work_off
  464. # verify notifications to agent1 + agent2
  465. assert_equal(0, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
  466. assert_equal(1, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
  467. # update ticket attributes
  468. ticket3.title = "#{ticket3.title} - #2"
  469. ticket3.priority = Ticket::Priority.lookup(name: '3 high')
  470. ticket3.save
  471. # execute ticket events
  472. Observer::Ticket::Notification.transaction
  473. #puts Delayed::Job.all.inspect
  474. Delayed::Worker.new.work_off
  475. # verify notifications to agent1 + agent2
  476. assert_equal(0, NotificationFactory.already_sent?(ticket3, agent1, 'email'), ticket3.id)
  477. assert_equal(2, NotificationFactory.already_sent?(ticket3, agent2, 'email'), ticket3.id)
  478. agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
  479. agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
  480. agent1.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
  481. agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
  482. agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
  483. agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
  484. agent1.preferences['notification_config']['group_ids'] = [Group.lookup(name: 'Users').id.to_s]
  485. agent1.save
  486. agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
  487. agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
  488. agent2.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
  489. agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = false
  490. agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
  491. agent2.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
  492. agent1.preferences['notification_config']['group_ids'] = ['-']
  493. agent2.save
  494. # create ticket in group
  495. ticket4 = Ticket.create(
  496. title: 'some notification test - z preferences tests 4',
  497. group: Group.lookup(name: 'Users'),
  498. customer: customer,
  499. state: Ticket::State.lookup(name: 'new'),
  500. priority: Ticket::Priority.lookup(name: '2 normal'),
  501. updated_by_id: customer.id,
  502. created_by_id: customer.id,
  503. )
  504. Ticket::Article.create(
  505. ticket_id: ticket4.id,
  506. from: 'some_sender@example.com',
  507. to: 'some_recipient@example.com',
  508. subject: 'some subject',
  509. message_id: 'some@id',
  510. body: 'some message',
  511. internal: false,
  512. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  513. type: Ticket::Article::Type.where(name: 'email').first,
  514. updated_by_id: customer.id,
  515. created_by_id: customer.id,
  516. )
  517. # execute ticket events
  518. Rails.configuration.webserver_is_active = false
  519. Observer::Ticket::Notification.transaction
  520. #puts Delayed::Job.all.inspect
  521. Delayed::Worker.new.work_off
  522. # verify notifications to agent1 + agent2
  523. assert_equal(1, NotificationFactory.already_sent?(ticket4, agent1, 'email'), ticket4.id)
  524. assert_equal(1, NotificationFactory.already_sent?(ticket4, agent2, 'email'), ticket4.id)
  525. # update ticket attributes
  526. ticket4.title = "#{ticket4.title} - #2"
  527. ticket4.priority = Ticket::Priority.lookup(name: '3 high')
  528. ticket4.save
  529. # execute ticket events
  530. Observer::Ticket::Notification.transaction
  531. #puts Delayed::Job.all.inspect
  532. Delayed::Worker.new.work_off
  533. # verify notifications to agent1 + agent2
  534. assert_equal(2, NotificationFactory.already_sent?(ticket4, agent1, 'email'), ticket4.id)
  535. assert_equal(2, NotificationFactory.already_sent?(ticket4, agent2, 'email'), ticket4.id)
  536. agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
  537. agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
  538. agent1.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
  539. agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
  540. agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
  541. agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
  542. agent1.preferences['notification_config']['group_ids'] = [Group.lookup(name: 'Users').id.to_s]
  543. agent1.save
  544. agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
  545. agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
  546. agent2.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
  547. agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = false
  548. agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
  549. agent2.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
  550. agent2.preferences['notification_config']['group_ids'] = [99]
  551. agent2.save
  552. # create ticket in group
  553. ticket5 = Ticket.create(
  554. title: 'some notification test - z preferences tests 5',
  555. group: Group.lookup(name: 'Users'),
  556. customer: customer,
  557. state: Ticket::State.lookup(name: 'new'),
  558. priority: Ticket::Priority.lookup(name: '2 normal'),
  559. updated_by_id: customer.id,
  560. created_by_id: customer.id,
  561. )
  562. Ticket::Article.create(
  563. ticket_id: ticket5.id,
  564. from: 'some_sender@example.com',
  565. to: 'some_recipient@example.com',
  566. subject: 'some subject',
  567. message_id: 'some@id',
  568. body: 'some message',
  569. internal: false,
  570. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  571. type: Ticket::Article::Type.where(name: 'email').first,
  572. updated_by_id: customer.id,
  573. created_by_id: customer.id,
  574. )
  575. # execute ticket events
  576. Rails.configuration.webserver_is_active = false
  577. Observer::Ticket::Notification.transaction
  578. #puts Delayed::Job.all.inspect
  579. Delayed::Worker.new.work_off
  580. # verify notifications to agent1 + agent2
  581. assert_equal(1, NotificationFactory.already_sent?(ticket5, agent1, 'email'), ticket5.id)
  582. assert_equal(0, NotificationFactory.already_sent?(ticket5, agent2, 'email'), ticket5.id)
  583. # update ticket attributes
  584. ticket5.title = "#{ticket5.title} - #2"
  585. ticket5.priority = Ticket::Priority.lookup(name: '3 high')
  586. ticket5.save
  587. # execute ticket events
  588. Observer::Ticket::Notification.transaction
  589. #puts Delayed::Job.all.inspect
  590. Delayed::Worker.new.work_off
  591. # verify notifications to agent1 + agent2
  592. assert_equal(2, NotificationFactory.already_sent?(ticket5, agent1, 'email'), ticket5.id)
  593. assert_equal(0, NotificationFactory.already_sent?(ticket5, agent2, 'email'), ticket5.id)
  594. agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
  595. agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
  596. agent1.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
  597. agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
  598. agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
  599. agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
  600. agent1.preferences['notification_config']['group_ids'] = [999]
  601. agent1.save
  602. agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
  603. agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
  604. agent2.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
  605. agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
  606. agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
  607. agent2.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
  608. agent2.preferences['notification_config']['group_ids'] = [999]
  609. agent2.save
  610. # create ticket in group
  611. ticket6 = Ticket.create(
  612. title: 'some notification test - z preferences tests 6',
  613. group: Group.lookup(name: 'Users'),
  614. customer: customer,
  615. owner: agent1,
  616. state: Ticket::State.lookup(name: 'new'),
  617. priority: Ticket::Priority.lookup(name: '2 normal'),
  618. updated_by_id: customer.id,
  619. created_by_id: customer.id,
  620. )
  621. Ticket::Article.create(
  622. ticket_id: ticket6.id,
  623. from: 'some_sender@example.com',
  624. to: 'some_recipient@example.com',
  625. subject: 'some subject',
  626. message_id: 'some@id',
  627. body: 'some message',
  628. internal: false,
  629. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  630. type: Ticket::Article::Type.where(name: 'email').first,
  631. updated_by_id: customer.id,
  632. created_by_id: customer.id,
  633. )
  634. # execute ticket events
  635. Rails.configuration.webserver_is_active = false
  636. Observer::Ticket::Notification.transaction
  637. #puts Delayed::Job.all.inspect
  638. Delayed::Worker.new.work_off
  639. # verify notifications to agent1 + agent2
  640. assert_equal(1, NotificationFactory.already_sent?(ticket6, agent1, 'email'), ticket6.id)
  641. assert_equal(1, NotificationFactory.already_sent?(ticket6, agent1, 'online'), ticket6.id)
  642. assert_equal(0, NotificationFactory.already_sent?(ticket6, agent2, 'email'), ticket6.id)
  643. assert_equal(0, NotificationFactory.already_sent?(ticket6, agent2, 'online'), ticket6.id)
  644. # update ticket attributes
  645. ticket6.title = "#{ticket6.title} - #2"
  646. ticket6.priority = Ticket::Priority.lookup(name: '3 high')
  647. ticket6.save
  648. # execute ticket events
  649. Observer::Ticket::Notification.transaction
  650. #puts Delayed::Job.all.inspect
  651. Delayed::Worker.new.work_off
  652. # verify notifications to agent1 + agent2
  653. assert_equal(2, NotificationFactory.already_sent?(ticket6, agent1, 'email'), ticket6.id)
  654. assert_equal(2, NotificationFactory.already_sent?(ticket6, agent1, 'online'), ticket6.id)
  655. assert_equal(0, NotificationFactory.already_sent?(ticket6, agent2, 'email'), ticket6.id)
  656. assert_equal(0, NotificationFactory.already_sent?(ticket6, agent2, 'online'), ticket6.id)
  657. agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
  658. agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
  659. agent1.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
  660. agent1.preferences['notification_config']['matrix']['create']['channel']['email'] = false
  661. agent1.preferences['notification_config']['matrix']['create']['channel']['online'] = true
  662. agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
  663. agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
  664. agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
  665. agent1.preferences['notification_config']['matrix']['update']['channel']['email'] = false
  666. agent1.preferences['notification_config']['matrix']['update']['channel']['online'] = true
  667. agent1.preferences['notification_config']['group_ids'] = [999]
  668. agent1.save
  669. agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
  670. agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
  671. agent2.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
  672. agent2.preferences['notification_config']['matrix']['create']['channel']['email'] = false
  673. agent2.preferences['notification_config']['matrix']['create']['channel']['online'] = true
  674. agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
  675. agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
  676. agent2.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
  677. agent2.preferences['notification_config']['matrix']['update']['channel']['email'] = false
  678. agent2.preferences['notification_config']['matrix']['update']['channel']['online'] = true
  679. agent2.preferences['notification_config']['group_ids'] = [999]
  680. agent2.save
  681. # create ticket in group
  682. ticket7 = Ticket.create(
  683. title: 'some notification test - z preferences tests 7',
  684. group: Group.lookup(name: 'Users'),
  685. customer: customer,
  686. owner: agent1,
  687. state: Ticket::State.lookup(name: 'new'),
  688. priority: Ticket::Priority.lookup(name: '2 normal'),
  689. updated_by_id: customer.id,
  690. created_by_id: customer.id,
  691. )
  692. Ticket::Article.create(
  693. ticket_id: ticket7.id,
  694. from: 'some_sender@example.com',
  695. to: 'some_recipient@example.com',
  696. subject: 'some subject',
  697. message_id: 'some@id',
  698. body: 'some message',
  699. internal: false,
  700. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  701. type: Ticket::Article::Type.where(name: 'email').first,
  702. updated_by_id: customer.id,
  703. created_by_id: customer.id,
  704. )
  705. # execute ticket events
  706. Rails.configuration.webserver_is_active = false
  707. Observer::Ticket::Notification.transaction
  708. #puts Delayed::Job.all.inspect
  709. Delayed::Worker.new.work_off
  710. # verify notifications to agent1 + agent2
  711. assert_equal(0, NotificationFactory.already_sent?(ticket7, agent1, 'email'), ticket7.id)
  712. assert_equal(1, NotificationFactory.already_sent?(ticket7, agent1, 'online'), ticket7.id)
  713. assert_equal(0, NotificationFactory.already_sent?(ticket7, agent2, 'email'), ticket7.id)
  714. assert_equal(0, NotificationFactory.already_sent?(ticket7, agent2, 'online'), ticket7.id)
  715. # update ticket attributes
  716. ticket7.title = "#{ticket7.title} - #2"
  717. ticket7.priority = Ticket::Priority.lookup(name: '3 high')
  718. ticket7.save
  719. # execute ticket events
  720. Observer::Ticket::Notification.transaction
  721. #puts Delayed::Job.all.inspect
  722. Delayed::Worker.new.work_off
  723. # verify notifications to agent1 + agent2
  724. assert_equal(0, NotificationFactory.already_sent?(ticket7, agent1, 'email'), ticket7.id)
  725. assert_equal(2, NotificationFactory.already_sent?(ticket7, agent1, 'online'), ticket7.id)
  726. assert_equal(0, NotificationFactory.already_sent?(ticket7, agent2, 'email'), ticket7.id)
  727. assert_equal(0, NotificationFactory.already_sent?(ticket7, agent2, 'online'), ticket7.id)
  728. end
  729. test 'ticket notification events' do
  730. # create ticket in group
  731. ticket1 = Ticket.create(
  732. title: 'some notification event test 1',
  733. group: Group.lookup(name: 'Users'),
  734. customer: customer,
  735. state: Ticket::State.lookup(name: 'new'),
  736. priority: Ticket::Priority.lookup(name: '2 normal'),
  737. updated_by_id: customer.id,
  738. created_by_id: customer.id,
  739. )
  740. Ticket::Article.create(
  741. ticket_id: ticket1.id,
  742. from: 'some_sender@example.com',
  743. to: 'some_recipient@example.com',
  744. subject: 'some subject',
  745. message_id: 'some@id',
  746. body: 'some message',
  747. internal: false,
  748. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  749. type: Ticket::Article::Type.where(name: 'email').first,
  750. updated_by_id: customer.id,
  751. created_by_id: customer.id,
  752. )
  753. assert(ticket1, 'ticket created')
  754. # execute ticket events
  755. Observer::Ticket::Notification.transaction
  756. # update ticket attributes
  757. ticket1.title = "#{ticket1.title} - #2"
  758. ticket1.priority = Ticket::Priority.lookup(name: '3 high')
  759. ticket1.save
  760. list = EventBuffer.list
  761. list_objects = Observer::Ticket::Notification.get_uniq_changes(list)
  762. assert_equal('some notification event test 1', list_objects[ticket1.id][:changes]['title'][0])
  763. assert_equal('some notification event test 1 - #2', list_objects[ticket1.id][:changes]['title'][1])
  764. assert_not(list_objects[ticket1.id][:changes]['priority'])
  765. assert_equal(2, list_objects[ticket1.id][:changes]['priority_id'][0])
  766. assert_equal(3, list_objects[ticket1.id][:changes]['priority_id'][1])
  767. # update ticket attributes
  768. ticket1.title = "#{ticket1.title} - #3"
  769. ticket1.priority = Ticket::Priority.lookup(name: '1 low')
  770. ticket1.save
  771. list = EventBuffer.list
  772. list_objects = Observer::Ticket::Notification.get_uniq_changes(list)
  773. assert_equal('some notification event test 1', list_objects[ticket1.id][:changes]['title'][0])
  774. assert_equal('some notification event test 1 - #2 - #3', list_objects[ticket1.id][:changes]['title'][1])
  775. assert_not(list_objects[ticket1.id][:changes]['priority'])
  776. assert_equal(2, list_objects[ticket1.id][:changes]['priority_id'][0])
  777. assert_equal(1, list_objects[ticket1.id][:changes]['priority_id'][1])
  778. end
  779. test 'ticket notification template' do
  780. # create ticket in group
  781. ticket1 = Ticket.create(
  782. title: 'some notification template test 1 Bobs\'s resumé',
  783. group: Group.lookup(name: 'Users'),
  784. customer: customer,
  785. state: Ticket::State.lookup(name: 'new'),
  786. priority: Ticket::Priority.lookup(name: '2 normal'),
  787. updated_by_id: customer.id,
  788. created_by_id: customer.id,
  789. )
  790. article = Ticket::Article.create(
  791. ticket_id: ticket1.id,
  792. from: 'some_sender@example.com',
  793. to: 'some_recipient@example.com',
  794. subject: 'some subject',
  795. message_id: 'some@id',
  796. body: "some message\nnewline1 abc\nnewline2",
  797. internal: false,
  798. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  799. type: Ticket::Article::Type.where(name: 'email').first,
  800. updated_by_id: customer.id,
  801. created_by_id: customer.id,
  802. )
  803. assert(ticket1, 'ticket created - ticket notification template')
  804. bg = Observer::Ticket::Notification::BackgroundJob.new(
  805. ticket_id: ticket1.id,
  806. article_id: article.id,
  807. type: 'update',
  808. changes: {
  809. 'priority_id' => [1, 2],
  810. 'pending_time' => [nil, Time.zone.parse('2015-01-11 23:33:47 UTC')],
  811. },
  812. )
  813. # check changed attributes
  814. human_changes = bg.human_changes(agent2, ticket1)
  815. assert( human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute' )
  816. assert( human_changes['Pending till'], 'Check if attributes translated based on ObjectManager::Attribute' )
  817. assert_equal( '1 low', human_changes['Priority'][0] )
  818. assert_equal( '2 normal', human_changes['Priority'][1] )
  819. assert_equal( '', human_changes['Pending till'][0].to_s )
  820. assert_equal( '2015-01-11 23:33:47 UTC', human_changes['Pending till'][1].to_s )
  821. assert_not( human_changes['priority_id'] )
  822. assert_not( human_changes['pending_time'] )
  823. assert_not( human_changes['pending_till'] )
  824. # en notification
  825. result = NotificationFactory.template(
  826. locale: agent2.preferences[:locale],
  827. template: 'ticket_update',
  828. objects: {
  829. ticket: ticket1,
  830. article: article,
  831. recipient: agent2,
  832. changes: human_changes,
  833. }
  834. )
  835. assert_match(/Bobs's resumé/, result[:subject])
  836. assert_match(/Priority/, result[:body])
  837. assert_match(/1 low/, result[:body])
  838. assert_match(/2 normal/, result[:body])
  839. assert_match(/Pending till/, result[:body])
  840. assert_match(/2015-01-11 23:33:47 UTC/, result[:body])
  841. assert_match(/update/, result[:body])
  842. assert_no_match(/pending_till/, result[:body])
  843. assert_no_match(/i18n/, result[:body])
  844. human_changes = bg.human_changes(agent1, ticket1)
  845. assert( human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute' )
  846. assert( human_changes['Pending till'], 'Check if attributes translated based on ObjectManager::Attribute' )
  847. assert_equal( '1 niedrig', human_changes['Priority'][0] )
  848. assert_equal( '2 normal', human_changes['Priority'][1] )
  849. assert_equal( '', human_changes['Pending till'][0].to_s )
  850. assert_equal( '2015-01-11 23:33:47 UTC', human_changes['Pending till'][1].to_s )
  851. assert_not( human_changes['priority_id'] )
  852. assert_not( human_changes['pending_time'] )
  853. assert_not( human_changes['pending_till'] )
  854. # de notification
  855. result = NotificationFactory.template(
  856. locale: agent1.preferences[:locale],
  857. template: 'ticket_update',
  858. objects: {
  859. ticket: ticket1,
  860. article: article,
  861. recipient: agent1,
  862. changes: human_changes,
  863. }
  864. )
  865. assert_match(/Bobs's resumé/, result[:subject])
  866. assert_match(/Priorität/, result[:body])
  867. assert_match(/1 niedrig/, result[:body])
  868. assert_match(/2 normal/, result[:body])
  869. assert_match(/Warten/, result[:body])
  870. assert_match(/2015-01-11 23:33:47 UTC/, result[:body])
  871. assert_match(/aktualis/, result[:body])
  872. assert_no_match(/pending_till/, result[:body])
  873. assert_no_match(/i18n/, result[:body])
  874. bg = Observer::Ticket::Notification::BackgroundJob.new(
  875. ticket_id: ticket1.id,
  876. article_id: article.id,
  877. type: 'update',
  878. changes: {
  879. title: ['some notification template test old 1', 'some notification template test 1 #2'],
  880. priority_id: [2, 3],
  881. },
  882. )
  883. # check changed attributes
  884. human_changes = bg.human_changes(agent1, ticket1)
  885. assert(human_changes['Title'], 'Check if attributes translated based on ObjectManager::Attribute')
  886. assert(human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute')
  887. assert_equal('2 normal', human_changes['Priority'][0])
  888. assert_equal('3 hoch', human_changes['Priority'][1])
  889. assert_equal('some notification template test old 1', human_changes['Title'][0])
  890. assert_equal('some notification template test 1 #2', human_changes['Title'][1])
  891. assert_not(human_changes['priority_id'])
  892. assert_not(human_changes['pending_time'])
  893. assert_not(human_changes['pending_till'])
  894. # de notification
  895. result = NotificationFactory.template(
  896. locale: agent1.preferences[:locale],
  897. template: 'ticket_update',
  898. objects: {
  899. ticket: ticket1,
  900. article: article,
  901. recipient: agent1,
  902. changes: human_changes,
  903. }
  904. )
  905. assert_match(/Bobs's resumé/, result[:subject])
  906. assert_match(/Titel/, result[:body])
  907. assert_no_match(/Title/, result[:body])
  908. assert_match(/some notification template test old 1/, result[:body])
  909. assert_match(/some notification template test 1 #2/, result[:body])
  910. assert_match(/Priorität/, result[:body])
  911. assert_no_match(/Priority/, result[:body])
  912. assert_match(/3 hoch/, result[:body])
  913. assert_match(/2 normal/, result[:body])
  914. assert_match(/aktualisier/, result[:body])
  915. human_changes = bg.human_changes(agent2, ticket1)
  916. # en notification
  917. result = NotificationFactory.template(
  918. locale: agent2.preferences[:locale],
  919. template: 'ticket_update',
  920. objects: {
  921. ticket: ticket1,
  922. article: article,
  923. recipient: agent2,
  924. changes: human_changes,
  925. }
  926. )
  927. assert_match(/Bobs's resumé/, result[:subject])
  928. assert_match(/Title/, result[:body])
  929. assert_match(/some notification template test old 1/, result[:body])
  930. assert_match(/some notification template test 1 #2/, result[:body])
  931. assert_match(/Priority/, result[:body])
  932. assert_match(/3 high/, result[:body])
  933. assert_match(/2 normal/, result[:body])
  934. assert_no_match(/Pending till/, result[:body])
  935. assert_no_match(/2015-01-11 23:33:47 UTC/, result[:body])
  936. assert_match(/update/, result[:body])
  937. assert_no_match(/pending_till/, result[:body])
  938. assert_no_match(/i18n/, result[:body])
  939. end
  940. end