ticket_reopened_spec.rb 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # Copyright (C) 2012-2025 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 excluding merged tickets' 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. end
  45. describe '.items' do
  46. it 'gets items in year range excluding merged tickets' do
  47. result = described_class.items(
  48. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  49. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  50. selector: {},
  51. )
  52. expect(result).to match_tickets ticket_5
  53. end
  54. it 'gets items in year range with high priority' do
  55. result = described_class.items(
  56. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  57. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  58. selector: {
  59. 'ticket.priority_id' => {
  60. 'operator' => 'is',
  61. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  62. }
  63. },
  64. )
  65. expect(result).to match_tickets ticket_5
  66. end
  67. it 'gets items in year range with not high priority' 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.priority_id' => {
  73. 'operator' => 'is not',
  74. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  75. }
  76. },
  77. )
  78. expect(result).to match_tickets []
  79. end
  80. end
  81. end