ticket_reopened_spec.rb 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'lib/report_examples'
  4. RSpec.describe Report::TicketReopened, searchindex: true do
  5. include_examples 'with report examples'
  6. describe '.aggs' do
  7. it 'gets monthly aggregated results' 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. )
  14. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
  15. end
  16. it 'gets monthly aggregated results with high priority' do
  17. result = described_class.aggs(
  18. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  19. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  20. interval: 'month',
  21. selector: {
  22. 'ticket.priority_id' => {
  23. 'operator' => 'is',
  24. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  25. }
  26. }
  27. )
  28. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
  29. end
  30. it 'gets monthly aggregated results with not high priority' do
  31. result = described_class.aggs(
  32. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  33. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  34. interval: 'month',
  35. selector: {
  36. 'ticket.priority_id' => {
  37. 'operator' => 'is not',
  38. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  39. }
  40. },
  41. )
  42. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  43. end
  44. it 'gets monthly aggregated results with not merged' do
  45. result = described_class.aggs(
  46. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  47. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  48. interval: 'month',
  49. selector: {
  50. 'ticket_state.name' => {
  51. 'operator' => 'is not',
  52. 'value' => 'merged',
  53. }
  54. },
  55. )
  56. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
  57. end
  58. end
  59. describe '.items' do
  60. it 'gets items in year range' do
  61. result = described_class.items(
  62. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  63. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  64. selector: {},
  65. )
  66. expect(result).to match_tickets ticket_5
  67. end
  68. it 'gets items in year range with high priority' do
  69. result = described_class.items(
  70. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  71. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  72. selector: {
  73. 'ticket.priority_id' => {
  74. 'operator' => 'is',
  75. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  76. }
  77. },
  78. )
  79. expect(result).to match_tickets ticket_5
  80. end
  81. it 'gets items in year range with not high priority' do
  82. result = described_class.items(
  83. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  84. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  85. selector: {
  86. 'ticket.priority_id' => {
  87. 'operator' => 'is not',
  88. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  89. }
  90. },
  91. )
  92. expect(result).to match_tickets []
  93. end
  94. it 'gets items in year range with not merged' 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_state.name' => {
  100. 'operator' => 'is not',
  101. 'value' => 'merged',
  102. }
  103. },
  104. )
  105. expect(result).to match_tickets ticket_5
  106. end
  107. end
  108. end