2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
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')
|
2019-04-15 01:41:17 +00:00
|
|
|
expect { described_class.generate }.to raise_error(LoadError)
|
2019-01-24 08:58:58 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|