chore: Fixes the missing gem warning (#3207)

* chore: Fixes the missing gem warning

fixes: #3143

* chore: rubocop fixes

Co-authored-by: Tejaswini Chile <tejaswini776@gmail.com>
This commit is contained in:
Sojan Jose
2021-10-14 13:57:01 +05:30
committed by GitHub
parent 590001cca2
commit 0c65db925d
7 changed files with 115 additions and 96 deletions

View File

@@ -54,7 +54,7 @@ RSpec.describe 'Installation::Onboarding API', type: :request do
end
context 'when onboarding is not successfull' do
it ' does not deletes the redis key' do
it 'does not deletes the redis key' do
allow(AccountBuilder).to receive(:new).and_raise('error')
post '/installation/onboarding', params: { user: {} }
expect(::Redis::Alfred.get(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING)).not_to eq nil

View File

@@ -21,7 +21,7 @@ RSpec.describe TriggerScheduledItemsJob, type: :job do
described_class.perform_now
end
it 'triggers Conversations::ReopenSnoozedConversationsJob' do
it 'triggers Conversations::ReopenSnoozedConversationsJob' do
expect(Conversations::ReopenSnoozedConversationsJob).to receive(:perform_later).once
described_class.perform_now
end

View File

@@ -56,7 +56,7 @@ describe ::EmailTemplates::DbResolverService do
Current.account = nil
end
it 'return installation template when current account dont have template' do
it 'return installation template when current account dont have template' do
Current.account = create(:account)
handler = ActionView::Template.registered_template_handler(:liquid)
template_details = {

View File

@@ -1,41 +1,43 @@
require 'rails_helper'
describe RoundRobin::ManageService do
subject(:round_robin_manage_service) { ::RoundRobin::ManageService.new(inbox: inbox) }
let!(:account) { create(:account) }
let!(:inbox) { create(:inbox, account: account) }
let!(:inbox_members) { create_list(:inbox_member, 5, inbox: inbox) }
let(:subject) { ::RoundRobin::ManageService.new(inbox: inbox) }
describe '#available_agent' do
it 'gets the first available agent and move agent to end of the list' do
expected_queue = [inbox_members[0].user_id, inbox_members[4].user_id, inbox_members[3].user_id, inbox_members[2].user_id,
inbox_members[1].user_id].map(&:to_s)
subject.available_agent
expect(subject.send(:queue)).to eq(expected_queue)
round_robin_manage_service.available_agent
expect(round_robin_manage_service.send(:queue)).to eq(expected_queue)
end
it 'gets intersection of priority list and agent queue. get and move agent to the end of the list' do
expected_queue = [inbox_members[2].user_id, inbox_members[4].user_id, inbox_members[3].user_id, inbox_members[1].user_id,
inbox_members[0].user_id].map(&:to_s)
expect(subject.available_agent(priority_list: [inbox_members[3].user_id, inbox_members[2].user_id])).to eq inbox_members[2].user
expect(subject.send(:queue)).to eq(expected_queue)
expect(round_robin_manage_service.available_agent(priority_list: [inbox_members[3].user_id,
inbox_members[2].user_id])).to eq inbox_members[2].user
expect(round_robin_manage_service.send(:queue)).to eq(expected_queue)
end
it 'constructs round_robin_queue if queue is not present' do
subject.clear_queue
expect(subject.send(:queue)).to eq([])
subject.available_agent
round_robin_manage_service.clear_queue
expect(round_robin_manage_service.send(:queue)).to eq([])
round_robin_manage_service.available_agent
# the service constructed the redis queue before performing
expect(subject.send(:queue).sort.map(&:to_i)).to eq(inbox_members.map(&:user_id).sort)
expect(round_robin_manage_service.send(:queue).sort.map(&:to_i)).to eq(inbox_members.map(&:user_id).sort)
end
it 'validates the queue and correct it before performing round robin' do
# adding some invalid ids to queue
subject.add_agent_to_queue([2, 3, 5, 9])
expect(subject.send(:queue).sort.map(&:to_i)).not_to eq(inbox_members.map(&:user_id).sort)
subject.available_agent
round_robin_manage_service.add_agent_to_queue([2, 3, 5, 9])
expect(round_robin_manage_service.send(:queue).sort.map(&:to_i)).not_to eq(inbox_members.map(&:user_id).sort)
round_robin_manage_service.available_agent
# the service have refreshed the redis queue before performing
expect(subject.send(:queue).sort.map(&:to_i)).to eq(inbox_members.map(&:user_id).sort)
expect(round_robin_manage_service.send(:queue).sort.map(&:to_i)).to eq(inbox_members.map(&:user_id).sort)
end
end
end