ticket_selector_test.rb 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'test_helper'
  3. class TicketSelectorTest < ActiveSupport::TestCase
  4. setup do
  5. @group = Group.create_or_update(
  6. name: 'SelectorTest',
  7. updated_at: '2015-02-05 16:37:00',
  8. updated_by_id: 1,
  9. created_by_id: 1,
  10. )
  11. roles = Role.where(name: 'Agent')
  12. @agent1 = User.create_or_update(
  13. login: 'ticket-selector-agent1@example.com',
  14. firstname: 'Notification',
  15. lastname: 'Agent1',
  16. email: 'ticket-selector-agent1@example.com',
  17. password: 'agentpw',
  18. active: true,
  19. roles: roles,
  20. groups: [@group],
  21. updated_at: '2015-02-05 16:37:00',
  22. updated_by_id: 1,
  23. created_by_id: 1,
  24. )
  25. @agent2 = User.create_or_update(
  26. login: 'ticket-selector-agent2@example.com',
  27. firstname: 'Notification',
  28. lastname: 'Agent2',
  29. email: 'ticket-selector-agent2@example.com',
  30. password: 'agentpw',
  31. active: true,
  32. roles: roles,
  33. updated_at: '2015-02-05 16:38:00',
  34. updated_by_id: 1,
  35. created_by_id: 1,
  36. )
  37. roles = Role.where(name: 'Customer')
  38. @organization1 = Organization.create_if_not_exists(
  39. name: 'Selector Org',
  40. updated_at: '2015-02-05 16:37:00',
  41. updated_by_id: 1,
  42. created_by_id: 1,
  43. )
  44. @customer1 = User.create_or_update(
  45. login: 'ticket-selector-customer1@example.com',
  46. firstname: 'Notification',
  47. lastname: 'Customer1',
  48. email: 'ticket-selector-customer1@example.com',
  49. password: 'customerpw',
  50. active: true,
  51. organization_id: @organization1.id,
  52. roles: roles,
  53. updated_at: '2015-02-05 16:37:00',
  54. updated_by_id: 1,
  55. created_by_id: 1,
  56. )
  57. @customer2 = User.create_or_update(
  58. login: 'ticket-selector-customer2@example.com',
  59. firstname: 'Notification',
  60. lastname: 'Customer2',
  61. email: 'ticket-selector-customer2@example.com',
  62. password: 'customerpw',
  63. active: true,
  64. organization_id: nil,
  65. roles: roles,
  66. updated_at: '2015-02-05 16:37:00',
  67. updated_by_id: 1,
  68. created_by_id: 1,
  69. )
  70. Ticket.where(group_id: @group.id).destroy_all
  71. end
  72. test 'ticket create' do
  73. Ticket.destroy_all
  74. ticket1 = Ticket.create!(
  75. title: 'some title1',
  76. group: @group,
  77. customer_id: @customer1.id,
  78. owner_id: @agent1.id,
  79. state: Ticket::State.lookup(name: 'new'),
  80. priority: Ticket::Priority.lookup(name: '2 normal'),
  81. created_at: '2015-02-05 16:37:00',
  82. # updated_at: '2015-02-05 17:37:00',
  83. updated_by_id: 1,
  84. created_by_id: 1,
  85. )
  86. assert(ticket1, 'ticket created')
  87. assert_equal(ticket1.customer.id, @customer1.id)
  88. assert_equal(ticket1.organization.id, @organization1.id)
  89. travel 1.second
  90. ticket2 = Ticket.create!(
  91. title: 'some title2',
  92. group: @group,
  93. customer_id: @customer2.id,
  94. state: Ticket::State.lookup(name: 'new'),
  95. priority: Ticket::Priority.lookup(name: '2 normal'),
  96. created_at: '2015-02-05 16:37:00',
  97. # updated_at: '2015-02-05 17:37:00',
  98. updated_by_id: 1,
  99. created_by_id: 1,
  100. )
  101. assert(ticket2, 'ticket created')
  102. assert_equal(ticket2.customer.id, @customer2.id)
  103. assert_nil(ticket2.organization_id)
  104. travel 1.second
  105. ticket3 = Ticket.create!(
  106. title: 'some title3',
  107. group: @group,
  108. customer_id: @customer2.id,
  109. state: Ticket::State.lookup(name: 'open'),
  110. priority: Ticket::Priority.lookup(name: '2 normal'),
  111. created_at: '2015-02-05 16:37:00',
  112. # updated_at: '2015-02-05 17:37:00',
  113. updated_by_id: 1,
  114. created_by_id: 1,
  115. )
  116. ticket3.update_columns(escalation_at: '2015-02-06 10:00:00')
  117. assert(ticket3, 'ticket created')
  118. assert_equal(ticket3.customer.id, @customer2.id)
  119. assert_nil(ticket3.organization_id)
  120. travel 1.second
  121. # search not matching
  122. condition = {
  123. 'ticket.state_id' => {
  124. operator: 'is',
  125. value: [99],
  126. },
  127. }
  128. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  129. assert_equal(ticket_count, 0)
  130. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  131. assert_equal(ticket_count, 0)
  132. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  133. assert_equal(ticket_count, 0)
  134. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  135. assert_equal(ticket_count, 0)
  136. # search matching with empty value / missing key
  137. condition = {
  138. 'ticket.group_id' => {
  139. operator: 'is',
  140. value: @group.id,
  141. },
  142. 'ticket.state_id' => {
  143. operator: 'is',
  144. },
  145. }
  146. ticket_count, = Ticket.selectors(condition, limit: 10)
  147. assert_nil(ticket_count)
  148. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  149. assert_nil(ticket_count)
  150. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  151. assert_nil(ticket_count)
  152. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  153. assert_nil(ticket_count)
  154. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  155. assert_nil(ticket_count)
  156. # search matching with empty value []
  157. condition = {
  158. 'ticket.group_id' => {
  159. operator: 'is',
  160. value: @group.id,
  161. },
  162. 'ticket.state_id' => {
  163. operator: 'is',
  164. value: [],
  165. },
  166. }
  167. ticket_count, = Ticket.selectors(condition, limit: 10)
  168. assert_nil(ticket_count)
  169. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  170. assert_nil(ticket_count)
  171. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  172. assert_nil(ticket_count)
  173. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  174. assert_nil(ticket_count)
  175. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  176. assert_nil(ticket_count)
  177. # search matching with empty value ''
  178. condition = {
  179. 'ticket.group_id' => {
  180. operator: 'is',
  181. value: @group.id,
  182. },
  183. 'ticket.state_id' => {
  184. operator: 'is',
  185. },
  186. }
  187. ticket_count, = Ticket.selectors(condition, limit: 10)
  188. assert_nil(ticket_count)
  189. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  190. assert_nil(ticket_count)
  191. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  192. assert_nil(ticket_count)
  193. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  194. assert_nil(ticket_count)
  195. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  196. assert_nil(ticket_count)
  197. # search matching
  198. condition = {
  199. 'ticket.group_id' => {
  200. operator: 'is',
  201. value: @group.id,
  202. },
  203. 'ticket.state_id' => {
  204. operator: 'is',
  205. value: [Ticket::State.lookup(name: 'new').id],
  206. },
  207. }
  208. ticket_count, = Ticket.selectors(condition, limit: 10)
  209. assert_equal(ticket_count, 2)
  210. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  211. assert_equal(ticket_count, 2)
  212. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  213. assert_equal(ticket_count, 0)
  214. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  215. assert_equal(ticket_count, 1)
  216. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  217. assert_equal(ticket_count, 1)
  218. condition = {
  219. 'ticket.group_id' => {
  220. operator: 'is',
  221. value: @group.id,
  222. },
  223. 'ticket.state_id' => {
  224. operator: 'is not',
  225. value: [Ticket::State.lookup(name: 'open').id],
  226. },
  227. }
  228. ticket_count, = Ticket.selectors(condition, limit: 10)
  229. assert_equal(ticket_count, 2)
  230. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  231. assert_equal(ticket_count, 2)
  232. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  233. assert_equal(ticket_count, 0)
  234. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  235. assert_equal(ticket_count, 1)
  236. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  237. assert_equal(ticket_count, 1)
  238. condition = {
  239. 'ticket.escalation_at' => {
  240. operator: 'is not',
  241. value: nil,
  242. }
  243. }
  244. ticket_count, = Ticket.selectors(condition, limit: 10)
  245. assert_equal(ticket_count, 1)
  246. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  247. assert_equal(ticket_count, 1)
  248. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  249. assert_equal(ticket_count, 0)
  250. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  251. assert_equal(ticket_count, 0)
  252. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  253. assert_equal(ticket_count, 1)
  254. # search - created_at
  255. condition = {
  256. 'ticket.group_id' => {
  257. operator: 'is',
  258. value: @group.id,
  259. },
  260. 'ticket.created_at' => {
  261. operator: 'after (absolute)', # before (absolute)
  262. value: '2015-02-05T16:00:00.000Z',
  263. },
  264. }
  265. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  266. assert_equal(ticket_count, 3)
  267. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  268. assert_equal(ticket_count, 0)
  269. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  270. assert_equal(ticket_count, 1)
  271. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  272. assert_equal(ticket_count, 2)
  273. condition = {
  274. 'ticket.group_id' => {
  275. operator: 'is',
  276. value: @group.id,
  277. },
  278. 'ticket.created_at' => {
  279. operator: 'after (absolute)', # before (absolute)
  280. value: '2015-02-05T18:00:00.000Z',
  281. },
  282. }
  283. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  284. assert_equal(ticket_count, 0)
  285. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  286. assert_equal(ticket_count, 0)
  287. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  288. assert_equal(ticket_count, 0)
  289. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  290. assert_equal(ticket_count, 0)
  291. condition = {
  292. 'ticket.group_id' => {
  293. operator: 'is',
  294. value: @group.id,
  295. },
  296. 'ticket.created_at' => {
  297. operator: 'before (absolute)',
  298. value: '2015-02-05T18:00:00.000Z',
  299. },
  300. }
  301. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  302. assert_equal(ticket_count, 3)
  303. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  304. assert_equal(ticket_count, 0)
  305. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  306. assert_equal(ticket_count, 1)
  307. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  308. assert_equal(ticket_count, 2)
  309. condition = {
  310. 'ticket.group_id' => {
  311. operator: 'is',
  312. value: @group.id,
  313. },
  314. 'ticket.created_at' => {
  315. operator: 'before (absolute)',
  316. value: '2015-02-05T16:00:00.000Z',
  317. },
  318. }
  319. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  320. assert_equal(ticket_count, 0)
  321. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  322. assert_equal(ticket_count, 0)
  323. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  324. assert_equal(ticket_count, 0)
  325. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  326. assert_equal(ticket_count, 0)
  327. condition = {
  328. 'ticket.group_id' => {
  329. operator: 'is',
  330. value: @group.id,
  331. },
  332. 'ticket.created_at' => {
  333. operator: 'before (relative)',
  334. range: 'day', # minute|hour|day|month|
  335. value: '10',
  336. },
  337. }
  338. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  339. assert_equal(ticket_count, 3)
  340. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  341. assert_equal(ticket_count, 0)
  342. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  343. assert_equal(ticket_count, 1)
  344. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  345. assert_equal(ticket_count, 2)
  346. condition = {
  347. 'ticket.group_id' => {
  348. operator: 'is',
  349. value: @group.id,
  350. },
  351. 'ticket.created_at' => {
  352. operator: 'till (relative)',
  353. range: 'year', # minute|hour|day|month|
  354. value: '10',
  355. },
  356. }
  357. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  358. assert_equal(ticket_count, 3)
  359. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  360. assert_equal(ticket_count, 0)
  361. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  362. assert_equal(ticket_count, 1)
  363. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  364. assert_equal(ticket_count, 2)
  365. condition = {
  366. 'ticket.group_id' => {
  367. operator: 'is',
  368. value: @group.id,
  369. },
  370. 'ticket.created_at' => {
  371. operator: 'within last (relative)',
  372. range: 'year', # minute|hour|day|month|
  373. value: '10',
  374. },
  375. }
  376. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  377. assert_equal(ticket_count, 3)
  378. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  379. assert_equal(ticket_count, 0)
  380. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  381. assert_equal(ticket_count, 1)
  382. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  383. assert_equal(ticket_count, 2)
  384. # search - updated_at
  385. condition = {
  386. 'ticket.group_id' => {
  387. operator: 'is',
  388. value: @group.id,
  389. },
  390. 'ticket.updated_at' => {
  391. operator: 'before (absolute)',
  392. value: 1.day.from_now.iso8601,
  393. },
  394. }
  395. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  396. assert_equal(ticket_count, 3)
  397. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  398. assert_equal(ticket_count, 0)
  399. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  400. assert_equal(ticket_count, 1)
  401. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  402. assert_equal(ticket_count, 2)
  403. condition = {
  404. 'ticket.group_id' => {
  405. operator: 'is',
  406. value: @group.id,
  407. },
  408. 'ticket.updated_at' => {
  409. operator: 'before (absolute)',
  410. value: 1.day.ago.iso8601,
  411. },
  412. }
  413. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  414. assert_equal(ticket_count, 0)
  415. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  416. assert_equal(ticket_count, 0)
  417. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  418. assert_equal(ticket_count, 0)
  419. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  420. assert_equal(ticket_count, 0)
  421. condition = {
  422. 'ticket.group_id' => {
  423. operator: 'is',
  424. value: @group.id,
  425. },
  426. 'ticket.updated_at' => {
  427. operator: 'after (absolute)',
  428. value: 1.day.from_now.iso8601,
  429. },
  430. }
  431. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  432. assert_equal(ticket_count, 0)
  433. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  434. assert_equal(ticket_count, 0)
  435. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  436. assert_equal(ticket_count, 0)
  437. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  438. assert_equal(ticket_count, 0)
  439. condition = {
  440. 'ticket.group_id' => {
  441. operator: 'is',
  442. value: @group.id,
  443. },
  444. 'ticket.updated_at' => {
  445. operator: 'after (absolute)',
  446. value: 1.day.ago.iso8601,
  447. },
  448. }
  449. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  450. assert_equal(ticket_count, 3)
  451. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  452. assert_equal(ticket_count, 0)
  453. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  454. assert_equal(ticket_count, 1)
  455. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  456. assert_equal(ticket_count, 2)
  457. condition = {
  458. 'ticket.group_id' => {
  459. operator: 'is',
  460. value: @group.id,
  461. },
  462. 'ticket.updated_at' => {
  463. operator: 'before (relative)',
  464. range: 'day', # minute|hour|day|month|
  465. value: '10',
  466. },
  467. }
  468. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  469. assert_equal(ticket_count, 0)
  470. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  471. assert_equal(ticket_count, 0)
  472. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  473. assert_equal(ticket_count, 0)
  474. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  475. assert_equal(ticket_count, 0)
  476. condition = {
  477. 'ticket.group_id' => {
  478. operator: 'is',
  479. value: @group.id,
  480. },
  481. 'ticket.updated_at' => {
  482. operator: 'till (relative)',
  483. range: 'year', # minute|hour|day|month|
  484. value: '10',
  485. },
  486. }
  487. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  488. assert_equal(ticket_count, 3)
  489. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  490. assert_equal(ticket_count, 0)
  491. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  492. assert_equal(ticket_count, 1)
  493. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  494. assert_equal(ticket_count, 2)
  495. condition = {
  496. 'ticket.group_id' => {
  497. operator: 'is',
  498. value: @group.id,
  499. },
  500. 'ticket.updated_at' => {
  501. operator: 'within last (relative)',
  502. range: 'year', # minute|hour|day|month|
  503. value: '10',
  504. },
  505. }
  506. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  507. assert_equal(ticket_count, 3)
  508. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  509. assert_equal(ticket_count, 0)
  510. ticket_count, = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  511. assert_equal(ticket_count, 1)
  512. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  513. assert_equal(ticket_count, 2)
  514. # invalid conditions
  515. assert_raise RuntimeError do
  516. ticket_count, tickets = Ticket.selectors(nil, limit: 10)
  517. end
  518. # search with customers
  519. condition = {
  520. 'ticket.group_id' => {
  521. operator: 'is',
  522. value: @group.id,
  523. },
  524. 'customer.email' => {
  525. operator: 'contains',
  526. value: 'ticket-selector-customer1',
  527. },
  528. }
  529. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  530. assert_equal(ticket_count, 1)
  531. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  532. assert_equal(ticket_count, 0)
  533. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  534. assert_equal(ticket_count, 1)
  535. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  536. assert_equal(ticket_count, 0)
  537. condition = {
  538. 'ticket.group_id' => {
  539. operator: 'is',
  540. value: @group.id,
  541. },
  542. 'customer.email' => {
  543. operator: 'contains not',
  544. value: 'ticket-selector-customer1-not_existing',
  545. },
  546. }
  547. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  548. assert_equal(ticket_count, 3)
  549. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  550. assert_equal(ticket_count, 0)
  551. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  552. assert_equal(ticket_count, 1)
  553. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  554. assert_equal(ticket_count, 2)
  555. # search with organizations
  556. condition = {
  557. 'ticket.group_id' => {
  558. operator: 'is',
  559. value: @group.id,
  560. },
  561. 'organization.name' => {
  562. operator: 'contains',
  563. value: 'selector',
  564. },
  565. }
  566. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  567. assert_equal(ticket_count, 1)
  568. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  569. assert_equal(ticket_count, 0)
  570. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  571. assert_equal(ticket_count, 1)
  572. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  573. assert_equal(ticket_count, 0)
  574. # search with organizations
  575. condition = {
  576. 'ticket.group_id' => {
  577. operator: 'is',
  578. value: @group.id,
  579. },
  580. 'organization.name' => {
  581. operator: 'contains',
  582. value: 'selector',
  583. },
  584. 'customer.email' => {
  585. operator: 'contains',
  586. value: 'ticket-selector-customer1',
  587. },
  588. }
  589. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  590. assert_equal(ticket_count, 1)
  591. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  592. assert_equal(ticket_count, 0)
  593. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  594. assert_equal(ticket_count, 1)
  595. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  596. assert_equal(ticket_count, 0)
  597. condition = {
  598. 'ticket.group_id' => {
  599. operator: 'is',
  600. value: @group.id,
  601. },
  602. 'organization.name' => {
  603. operator: 'contains',
  604. value: 'selector',
  605. },
  606. 'customer.email' => {
  607. operator: 'contains not',
  608. value: 'ticket-selector-customer1',
  609. },
  610. }
  611. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  612. assert_equal(ticket_count, 0)
  613. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  614. assert_equal(ticket_count, 0)
  615. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  616. assert_equal(ticket_count, 0)
  617. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  618. assert_equal(ticket_count, 0)
  619. # with owner/customer/org
  620. condition = {
  621. 'ticket.group_id' => {
  622. operator: 'is',
  623. value: @group.id,
  624. },
  625. 'ticket.owner_id' => {
  626. operator: 'is',
  627. pre_condition: 'specific',
  628. value: @agent1.id,
  629. },
  630. }
  631. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  632. assert_equal(ticket_count, 1)
  633. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  634. assert_equal(ticket_count, 0)
  635. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  636. assert_equal(ticket_count, 1)
  637. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  638. assert_equal(ticket_count, 0)
  639. condition = {
  640. 'ticket.group_id' => {
  641. operator: 'is',
  642. value: @group.id,
  643. },
  644. 'ticket.owner_id' => {
  645. operator: 'is',
  646. pre_condition: 'specific',
  647. # value: @agent1.id, # value is not set, no result should be shown
  648. },
  649. }
  650. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  651. assert_nil(ticket_count)
  652. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  653. assert_nil(ticket_count)
  654. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  655. assert_nil(ticket_count)
  656. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  657. assert_nil(ticket_count)
  658. condition = {
  659. 'ticket.group_id' => {
  660. operator: 'is',
  661. value: @group.id,
  662. },
  663. 'ticket.owner_id' => {
  664. operator: 'is',
  665. pre_condition: 'not_set',
  666. },
  667. }
  668. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  669. assert_equal(ticket_count, 2)
  670. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  671. assert_equal(ticket_count, 0)
  672. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  673. assert_equal(ticket_count, 0)
  674. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  675. assert_equal(ticket_count, 2)
  676. condition = {
  677. 'ticket.group_id' => {
  678. operator: 'is',
  679. value: @group.id,
  680. },
  681. 'ticket.owner_id' => {
  682. operator: 'is not',
  683. pre_condition: 'not_set',
  684. },
  685. }
  686. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  687. assert_equal(ticket_count, 1)
  688. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  689. assert_equal(ticket_count, 0)
  690. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  691. assert_equal(ticket_count, 1)
  692. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  693. assert_equal(ticket_count, 0)
  694. UserInfo.current_user_id = @agent1.id
  695. condition = {
  696. 'ticket.group_id' => {
  697. operator: 'is',
  698. value: @group.id,
  699. },
  700. 'ticket.owner_id' => {
  701. operator: 'is',
  702. pre_condition: 'current_user.id',
  703. },
  704. }
  705. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  706. assert_equal(ticket_count, 1)
  707. ticket_count, tickets = Ticket.selectors(condition, limit: 10)
  708. assert_equal(ticket_count, 1)
  709. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  710. assert_equal(ticket_count, 0)
  711. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  712. assert_equal(ticket_count, 0)
  713. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  714. assert_equal(ticket_count, 0)
  715. UserInfo.current_user_id = @agent2.id
  716. condition = {
  717. 'ticket.group_id' => {
  718. operator: 'is',
  719. value: @group.id,
  720. },
  721. 'ticket.owner_id' => {
  722. operator: 'is',
  723. pre_condition: 'current_user.id',
  724. },
  725. }
  726. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  727. assert_equal(ticket_count, 1)
  728. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  729. assert_equal(ticket_count, 0)
  730. ticket_count, tickets = Ticket.selectors(condition, limit: 10)
  731. assert_equal(ticket_count, 0)
  732. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  733. assert_equal(ticket_count, 0)
  734. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  735. assert_equal(ticket_count, 0)
  736. UserInfo.current_user_id = @customer1.id
  737. condition = {
  738. 'ticket.group_id' => {
  739. operator: 'is',
  740. value: @group.id,
  741. },
  742. 'ticket.customer_id' => {
  743. operator: 'is',
  744. pre_condition: 'current_user.id',
  745. },
  746. }
  747. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  748. assert_equal(ticket_count, 0)
  749. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  750. assert_equal(ticket_count, 0)
  751. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  752. assert_equal(ticket_count, 1)
  753. ticket_count, tickets = Ticket.selectors(condition, limit: 10)
  754. assert_equal(ticket_count, 1)
  755. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  756. assert_equal(ticket_count, 2)
  757. UserInfo.current_user_id = @customer2.id
  758. condition = {
  759. 'ticket.group_id' => {
  760. operator: 'is',
  761. value: @group.id,
  762. },
  763. 'ticket.customer_id' => {
  764. operator: 'is',
  765. pre_condition: 'current_user.id',
  766. },
  767. }
  768. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  769. assert_equal(ticket_count, 0)
  770. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  771. assert_equal(ticket_count, 0)
  772. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  773. assert_equal(ticket_count, 1)
  774. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  775. assert_equal(ticket_count, 2)
  776. ticket_count, tickets = Ticket.selectors(condition, limit: 10)
  777. assert_equal(ticket_count, 2)
  778. UserInfo.current_user_id = @customer1.id
  779. condition = {
  780. 'ticket.group_id' => {
  781. operator: 'is',
  782. value: @group.id,
  783. },
  784. 'ticket.organization_id' => {
  785. operator: 'is',
  786. pre_condition: 'current_user.organization_id',
  787. },
  788. }
  789. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  790. assert_equal(ticket_count, 0)
  791. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  792. assert_equal(ticket_count, 0)
  793. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  794. assert_equal(ticket_count, 1)
  795. ticket_count, tickets = Ticket.selectors(condition, limit: 10)
  796. assert_equal(ticket_count, 1)
  797. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  798. assert_equal(ticket_count, 0)
  799. UserInfo.current_user_id = @customer2.id
  800. condition = {
  801. 'ticket.group_id' => {
  802. operator: 'is',
  803. value: @group.id,
  804. },
  805. 'ticket.organization_id' => {
  806. operator: 'is',
  807. pre_condition: 'current_user.organization_id',
  808. },
  809. }
  810. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  811. assert_equal(ticket_count, 0)
  812. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  813. assert_equal(ticket_count, 0)
  814. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer1)
  815. assert_equal(ticket_count, 1)
  816. ticket_count, tickets = Ticket.selectors(condition, limit: 10, current_user: @customer2)
  817. assert_equal(ticket_count, 0)
  818. ticket_count, tickets = Ticket.selectors(condition, limit: 10)
  819. assert_equal(ticket_count, 0)
  820. travel_back
  821. end
  822. test 'ticket tags filter' do
  823. ticket_tags_1 = Ticket.create!(
  824. title: 'some title1',
  825. group: @group,
  826. customer_id: @customer1.id,
  827. owner_id: @agent1.id,
  828. state: Ticket::State.lookup(name: 'new'),
  829. priority: Ticket::Priority.lookup(name: '2 normal'),
  830. created_at: '2015-02-05 16:37:00',
  831. updated_by_id: 1,
  832. created_by_id: 1,
  833. )
  834. ticket_tags_2 = Ticket.create!(
  835. title: 'some title1',
  836. group: @group,
  837. customer_id: @customer1.id,
  838. owner_id: @agent1.id,
  839. state: Ticket::State.lookup(name: 'new'),
  840. priority: Ticket::Priority.lookup(name: '2 normal'),
  841. created_at: '2015-02-05 16:37:00',
  842. updated_by_id: 1,
  843. created_by_id: 1,
  844. )
  845. Ticket.create!(
  846. title: 'some title1',
  847. group: @group,
  848. customer_id: @customer1.id,
  849. owner_id: @agent1.id,
  850. state: Ticket::State.lookup(name: 'new'),
  851. priority: Ticket::Priority.lookup(name: '2 normal'),
  852. created_at: '2015-02-05 16:37:00',
  853. updated_by_id: 1,
  854. created_by_id: 1,
  855. )
  856. Tag.tag_add(
  857. object: 'Ticket',
  858. o_id: ticket_tags_1.id,
  859. item: 'contains_all_1',
  860. created_by_id: 1,
  861. )
  862. Tag.tag_add(
  863. object: 'Ticket',
  864. o_id: ticket_tags_1.id,
  865. item: 'contains_all_2',
  866. created_by_id: 1,
  867. )
  868. Tag.tag_add(
  869. object: 'Ticket',
  870. o_id: ticket_tags_1.id,
  871. item: 'contains_all_3',
  872. created_by_id: 1,
  873. )
  874. Tag.tag_add(
  875. object: 'Ticket',
  876. o_id: ticket_tags_2.id,
  877. item: 'contains_all_3',
  878. created_by_id: 1,
  879. )
  880. # search all with contains all
  881. condition = {
  882. 'ticket.tags' => {
  883. operator: 'contains all',
  884. value: 'contains_all_1, contains_all_2, contains_all_3',
  885. },
  886. }
  887. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  888. assert_equal(1, ticket_count)
  889. condition = {
  890. 'ticket.tags' => {
  891. operator: 'contains all',
  892. value: 'contains_all_1, contains_all_2, contains_all_3, xxx',
  893. },
  894. }
  895. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  896. assert_equal(0, ticket_count)
  897. # search all with contains one
  898. condition = {
  899. 'ticket.tags' => {
  900. operator: 'contains one',
  901. value: 'contains_all_1, contains_all_2, contains_all_3',
  902. },
  903. }
  904. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  905. assert_equal(2, ticket_count)
  906. condition = {
  907. 'ticket.tags' => {
  908. operator: 'contains one',
  909. value: 'contains_all_1, contains_all_2'
  910. },
  911. }
  912. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  913. assert_equal(1, ticket_count)
  914. # search all with contains one not
  915. condition = {
  916. 'ticket.tags' => {
  917. operator: 'contains one',
  918. value: 'contains_all_1, contains_all_3'
  919. },
  920. }
  921. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  922. assert_equal(2, ticket_count)
  923. condition = {
  924. 'ticket.tags' => {
  925. operator: 'contains one',
  926. value: 'contains_all_1, contains_all_2, contains_all_3'
  927. },
  928. }
  929. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  930. assert_equal(2, ticket_count)
  931. end
  932. test 'ticket title with certain content' do
  933. Ticket.create!(
  934. title: 'some_title1',
  935. group: @group,
  936. customer_id: @customer1.id,
  937. owner_id: @agent1.id,
  938. state: Ticket::State.lookup(name: 'new'),
  939. priority: Ticket::Priority.lookup(name: '2 normal'),
  940. created_at: '2015-02-05 16:37:00',
  941. updated_by_id: 1,
  942. created_by_id: 1,
  943. )
  944. Ticket.create!(
  945. title: 'some::title2',
  946. group: @group,
  947. customer_id: @customer1.id,
  948. owner_id: @agent1.id,
  949. state: Ticket::State.lookup(name: 'new'),
  950. priority: Ticket::Priority.lookup(name: '2 normal'),
  951. created_at: '2015-02-05 16:37:00',
  952. updated_by_id: 1,
  953. created_by_id: 1,
  954. )
  955. Ticket.create!(
  956. title: 'some-title3',
  957. group: @group,
  958. customer_id: @customer1.id,
  959. owner_id: @agent1.id,
  960. state: Ticket::State.lookup(name: 'new'),
  961. priority: Ticket::Priority.lookup(name: '2 normal'),
  962. created_at: '2015-02-05 16:37:00',
  963. updated_by_id: 1,
  964. created_by_id: 1,
  965. )
  966. # search all with contains
  967. condition = {
  968. 'ticket.title' => {
  969. operator: 'contains',
  970. value: 'some_title1',
  971. },
  972. }
  973. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  974. assert_equal(1, ticket_count)
  975. condition = {
  976. 'ticket.title' => {
  977. operator: 'contains',
  978. value: 'some::title2',
  979. },
  980. }
  981. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  982. assert_equal(1, ticket_count)
  983. condition = {
  984. 'ticket.title' => {
  985. operator: 'contains',
  986. value: 'some-title3',
  987. },
  988. }
  989. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  990. assert_equal(1, ticket_count)
  991. # search all with is
  992. condition = {
  993. 'ticket.title' => {
  994. operator: 'is',
  995. value: 'some_title1',
  996. },
  997. }
  998. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  999. assert_equal(1, ticket_count)
  1000. condition = {
  1001. 'ticket.title' => {
  1002. operator: 'is',
  1003. value: 'some::title2',
  1004. },
  1005. }
  1006. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  1007. assert_equal(1, ticket_count)
  1008. condition = {
  1009. 'ticket.title' => {
  1010. operator: 'is',
  1011. value: 'some-title3',
  1012. },
  1013. }
  1014. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  1015. assert_equal(1, ticket_count)
  1016. end
  1017. test 'access: "ignore"' do
  1018. Ticket.destroy_all
  1019. Ticket.create!(
  1020. title: 'some title1',
  1021. group: @group,
  1022. customer_id: @customer1.id,
  1023. owner_id: @agent1.id,
  1024. state: Ticket::State.lookup(name: 'new'),
  1025. priority: Ticket::Priority.lookup(name: '2 normal'),
  1026. created_at: '2015-02-05 16:37:00',
  1027. updated_by_id: 1,
  1028. created_by_id: 1,
  1029. )
  1030. Ticket.create!(
  1031. title: 'some title2',
  1032. group: @group,
  1033. customer_id: @customer1.id,
  1034. owner_id: @agent1.id,
  1035. state: Ticket::State.lookup(name: 'new'),
  1036. priority: Ticket::Priority.lookup(name: '2 normal'),
  1037. created_at: '2015-02-05 16:37:00',
  1038. updated_by_id: @agent2.id,
  1039. created_by_id: 1,
  1040. )
  1041. condition = {
  1042. 'ticket.title' => {
  1043. operator: 'contains',
  1044. value: 'some',
  1045. },
  1046. }
  1047. # visible by owner
  1048. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent1)
  1049. assert_equal(2, ticket_count)
  1050. # not visible by another agent
  1051. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2)
  1052. assert_equal(0, ticket_count)
  1053. # visible by another user when access: "ignore". For example, when tickets are performed after action of another user
  1054. ticket_count, _tickets = Ticket.selectors(condition, limit: 10, current_user: @agent2, access: 'ignore')
  1055. assert_equal(2, ticket_count)
  1056. condition2 = {
  1057. 'ticket.updated_by_id' => {
  1058. operator: 'is',
  1059. pre_condition: 'current_user.id',
  1060. value: '',
  1061. value_completion: ''
  1062. }
  1063. }
  1064. # not visible by another agent even if matches current user precondition
  1065. ticket_count, _tickets = Ticket.selectors(condition2, limit: 10, current_user: @agent2)
  1066. assert_equal(0, ticket_count)
  1067. # visible by another user when access: "ignore" if matches current user precondition
  1068. ticket_count, _tickets = Ticket.selectors(condition2, limit: 10, current_user: @agent2, access: 'ignore')
  1069. assert_equal(1, ticket_count)
  1070. end
  1071. end