ticket_reopened_spec.rb 3.8 KB

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