model_ticket.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. window.onload = function() {
  2. App.Ticket.refresh([{
  3. id: 1,
  4. title: 'ticket1',
  5. state_id: 1,
  6. customer_id: 33,
  7. organization_id: 1,
  8. owner_id: 1,
  9. },
  10. {
  11. id: 2,
  12. title: 'ticket2',
  13. state_id: 1,
  14. customer_id: 44,
  15. organization_id: 1,
  16. owner_id: 1,
  17. },
  18. {
  19. id: 3,
  20. title: 'ticket3',
  21. state_id: 1,
  22. customer_id: 55,
  23. organization_id: undefined,
  24. owner_id: 1,
  25. },
  26. {
  27. id: 4,
  28. title: 'ticket4',
  29. state_id: 1,
  30. customer_id: 66,
  31. organization_id: undefined,
  32. owner_id: 1,
  33. group_id: 1,
  34. }])
  35. App.User.refresh([{
  36. id: 33,
  37. login: 'hh@1example.com',
  38. firstname: 'Harald',
  39. lastname: 'Habebe',
  40. email: 'hh1@example.com',
  41. organization_id: 1,
  42. role_ids: [3],
  43. active: true,
  44. },
  45. {
  46. id: 44,
  47. login: 'hh2@example.com',
  48. firstname: 'Harald',
  49. lastname: 'Habebe',
  50. email: 'hh2@example.com',
  51. organization_id: 2,
  52. role_ids: [3],
  53. active: true,
  54. },
  55. {
  56. id: 55,
  57. login: 'hh3example.com',
  58. firstname: 'Harald',
  59. lastname: 'Habebe',
  60. email: 'hh3@example.com',
  61. organization_id: undefined,
  62. role_ids: [3],
  63. active: true,
  64. }])
  65. test('ticket.editabe customer user #1', function() {
  66. App.Session.set(33)
  67. ticket1 = App.Ticket.find(1);
  68. ok(ticket1.editable(), 'access via customer_id');
  69. ticket2 = App.Ticket.find(2);
  70. ok(ticket2.editable(), 'access via organization_id');
  71. ticket3 = App.Ticket.find(3);
  72. ok(!ticket3.editable(), 'no access');
  73. ticket4 = App.Ticket.find(4);
  74. ok(!ticket4.editable(), 'no access');
  75. });
  76. test('ticket.editabe customer user #2', function() {
  77. App.Session.set(44)
  78. ticket1 = App.Ticket.find(1);
  79. ok(!ticket1.editable(), 'no access');
  80. ticket2 = App.Ticket.find(2);
  81. ok(ticket2.editable(), 'access via customer_id');
  82. ticket3 = App.Ticket.find(3);
  83. ok(!ticket3.editable(), 'no access');
  84. ticket4 = App.Ticket.find(4);
  85. ok(!ticket4.editable(), 'no access');
  86. });
  87. test('ticket.editabe customer user #3', function() {
  88. App.Session.set(55)
  89. ticket1 = App.Ticket.find(1);
  90. ok(!ticket1.editable(), 'no access');
  91. ticket2 = App.Ticket.find(2);
  92. ok(!ticket2.editable(), 'no access');
  93. ticket3 = App.Ticket.find(3);
  94. ok(ticket3.editable(), 'access via customer_id');
  95. ticket4 = App.Ticket.find(4);
  96. ok(!ticket4.editable(), 'no access');
  97. });
  98. }