2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2019-01-24 08:58:58 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Stats do
|
|
|
|
|
|
|
|
describe '#generate' do
|
|
|
|
|
|
|
|
before do
|
|
|
|
# create a user for which the stats can be generated
|
2020-06-19 09:17:18 +00:00
|
|
|
create(:agent)
|
2019-01-24 08:58:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'generates stats' do
|
2019-04-15 01:41:17 +00:00
|
|
|
expect { described_class.generate }.not_to raise_error
|
2019-01-24 08:58:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when backend registration is invalid' do
|
|
|
|
|
|
|
|
it 'fails for empty registration' do
|
|
|
|
Setting.set('Stats::TicketWaitingTime', nil)
|
2019-04-15 01:41:17 +00:00
|
|
|
expect { described_class.generate }.to raise_error(RuntimeError)
|
2019-01-24 08:58:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'fails for unknown backend' do
|
|
|
|
Setting.set('Stats::TicketWaitingTime', 'Stats::UNKNOWN')
|
2021-06-23 11:35:27 +00:00
|
|
|
expect { described_class.generate }.to raise_error(NameError)
|
2019-01-24 08:58:58 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|