ticket_moved_spec.rb 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'lib/report_examples'
  4. RSpec.describe Report::TicketMoved, searchindex: true do
  5. include_examples 'with report examples'
  6. describe '.aggs' do
  7. it 'gets monthly aggregated results not in merged state' do
  8. result = described_class.aggs(
  9. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  10. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  11. interval: 'month',
  12. selector: {
  13. 'ticket_state.name' => {
  14. 'operator' => 'is not',
  15. 'value' => 'merged',
  16. }
  17. },
  18. params: {
  19. type: 'in',
  20. },
  21. )
  22. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  23. end
  24. it 'gets monthly aggregated results in users group' do
  25. result = described_class.aggs(
  26. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  27. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  28. interval: 'month',
  29. selector: {
  30. 'ticket.group_id' => {
  31. 'operator' => 'is',
  32. 'value' => [Group.lookup(name: 'Users').id],
  33. }
  34. },
  35. params: {
  36. type: 'in',
  37. },
  38. )
  39. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
  40. end
  41. it 'gets monthly aggregated results not in merged state and outgoing' do
  42. result = described_class.aggs(
  43. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  44. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  45. interval: 'month',
  46. selector: {
  47. 'ticket_state.name' => {
  48. 'operator' => 'is not',
  49. 'value' => 'merged',
  50. }
  51. },
  52. params: {
  53. type: 'out',
  54. },
  55. )
  56. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  57. end
  58. it 'gets monthly aggregated results in users group and outgoing' do
  59. result = described_class.aggs(
  60. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  61. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  62. interval: 'month',
  63. selector: {
  64. 'ticket.group_id' => {
  65. 'operator' => 'is',
  66. 'value' => [Group.lookup(name: 'Users').id],
  67. }
  68. },
  69. params: {
  70. type: 'out',
  71. },
  72. )
  73. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
  74. end
  75. end
  76. describe '.items' do
  77. it 'gets items in year range in users group' do
  78. result = described_class.items(
  79. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  80. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  81. selector: {
  82. 'ticket.group_id' => {
  83. 'operator' => 'is',
  84. 'value' => [Group.lookup(name: 'Users').id],
  85. }
  86. },
  87. params: {
  88. type: 'in',
  89. },
  90. )
  91. expect(result).to match_tickets ticket_1
  92. end
  93. it 'gets items in year range not merged and outgoing' do
  94. result = described_class.items(
  95. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  96. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  97. selector: {
  98. 'ticket_state.name' => {
  99. 'operator' => 'is not',
  100. 'value' => 'merged',
  101. }
  102. }, # ticket selector to get only a collection of tickets
  103. params: {
  104. type: 'out',
  105. },
  106. )
  107. expect(result).to match_tickets []
  108. end
  109. it 'gets items in year range in users group and outgoing' do
  110. result = described_class.items(
  111. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  112. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  113. selector: {
  114. 'ticket.group_id' => {
  115. 'operator' => 'is',
  116. 'value' => [Group.lookup(name: 'Users').id],
  117. }
  118. },
  119. params: {
  120. type: 'out',
  121. },
  122. )
  123. expect(result).to match_tickets ticket_2
  124. end
  125. end
  126. end