Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

939 B
Raw Blame
require 'rails_helper'

RSpec.describe Sla::ProcessAppliedSlaJob do
  context 'when perform is called' do
    let(:account) { create(:account) }
    let(:applied_sla) { create(:applied_sla, account: account) }

    before { account.enable_features!('sla') }

    it 'enqueues the job' do
      expect { described_class.perform_later(applied_sla) }.to have_enqueued_job(described_class)
        .with(applied_sla)
        .on_queue('medium')
    end

    it 'calls the EvaluateAppliedSlaService' do
      expect(Sla::EvaluateAppliedSlaService).to receive(:new).with(applied_sla: applied_sla).and_call_original
      described_class.perform_now(applied_sla.reload)
    end

    it 'does not call the EvaluateAppliedSlaService when the sla feature is disabled' do
      account.disable_features!('sla')

      expect(Sla::EvaluateAppliedSlaService).not_to receive(:new)
      described_class.perform_now(applied_sla.reload)
    end
  end
end