ticket_merged_spec.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'lib/report_examples'
  4. RSpec.describe Report::TicketMerged, searchindex: true do
  5. include_examples 'with report examples'
  6. describe '.aggs' do
  7. it 'gets monthly aggregated results 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. )
  14. expect(result).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
  15. end
  16. it 'gets daily aggregated results in merged state' do
  17. result = described_class.aggs(
  18. range_start: Time.zone.parse('2015-11-01T00:00:00Z'),
  19. range_end: Time.zone.parse('2015-12-01T00:00:00Z'),
  20. interval: 'day',
  21. selector: {},
  22. )
  23. expected = Array.new(30, 0) # 30 days in November
  24. expected[1] = 1 # ticket exists on November 2nd
  25. expect(result).to eq expected
  26. end
  27. end
  28. describe '.items' do
  29. it 'gets items in year range in merged state' do
  30. result = described_class.items(
  31. range_start: Time.zone.parse('2015-01-01T00:00:00Z'),
  32. range_end: Time.zone.parse('2015-12-31T23:59:59Z'),
  33. selector: {},
  34. )
  35. expect(result).to match_tickets ticket_8
  36. end
  37. end
  38. end