stats_spec.rb 716 B

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