stats_spec.rb 793 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Stats do
  4. describe '#generate' do
  5. before do
  6. # create a user for which the stats can be generated
  7. create(:agent)
  8. end
  9. it 'generates stats' do
  10. expect { described_class.generate }.not_to raise_error
  11. end
  12. context 'when backend registration is invalid' do
  13. it 'fails for empty registration' do
  14. Setting.set('Stats::TicketWaitingTime', nil)
  15. expect { described_class.generate }.to raise_error(RuntimeError)
  16. end
  17. it 'fails for unknown backend' do
  18. Setting.set('Stats::TicketWaitingTime', 'Stats::UNKNOWN')
  19. expect { described_class.generate }.to raise_error(NameError)
  20. end
  21. end
  22. end
  23. end