ticket_moved_spec.rb 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # Copyright (C) 2012-2025 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. params: {
  14. type: 'in',
  15. },
  16. )
  17. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  18. end
  19. it 'gets monthly aggregated results in users group' do
  20. result = described_class.aggs(
  21. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  22. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  23. interval: 'month',
  24. selector: {
  25. 'ticket.group_id' => {
  26. 'operator' => 'is',
  27. 'value' => [Group.lookup(name: 'Users').id],
  28. }
  29. },
  30. params: {
  31. type: 'in',
  32. },
  33. )
  34. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
  35. end
  36. it 'gets monthly aggregated results not in merged state and outgoing' do
  37. result = described_class.aggs(
  38. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  39. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  40. interval: 'month',
  41. selector: {},
  42. params: {
  43. type: 'out',
  44. },
  45. )
  46. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  47. end
  48. it 'gets monthly aggregated results in users group and outgoing' do
  49. result = described_class.aggs(
  50. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  51. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  52. interval: 'month',
  53. selector: {
  54. 'ticket.group_id' => {
  55. 'operator' => 'is',
  56. 'value' => [Group.lookup(name: 'Users').id],
  57. }
  58. },
  59. params: {
  60. type: 'out',
  61. },
  62. )
  63. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
  64. end
  65. end
  66. describe '.items' do
  67. it 'gets items in year range in users group' do
  68. result = described_class.items(
  69. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  70. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  71. selector: {
  72. 'ticket.group_id' => {
  73. 'operator' => 'is',
  74. 'value' => [Group.lookup(name: 'Users').id],
  75. }
  76. },
  77. params: {
  78. type: 'in',
  79. },
  80. )
  81. expect(result).to match_tickets ticket_1
  82. end
  83. it 'gets items in year range not merged and outgoing' do
  84. result = described_class.items(
  85. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  86. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  87. selector: {},
  88. params: {
  89. type: 'out',
  90. },
  91. )
  92. expect(result).to match_tickets []
  93. end
  94. it 'gets items in year range in users group and outgoing' do
  95. result = described_class.items(
  96. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  97. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  98. selector: {
  99. 'ticket.group_id' => {
  100. 'operator' => 'is',
  101. 'value' => [Group.lookup(name: 'Users').id],
  102. }
  103. },
  104. params: {
  105. type: 'out',
  106. },
  107. )
  108. expect(result).to match_tickets ticket_2
  109. end
  110. end
  111. end