feat: sla-2 add automation backend support for SLA (#8775)

* feat: add automation support for SLA

* feat: add sla action in automtion UI

* chore: revert frontend changes

* chore: refactor to ee namespace

* chore: refactor automation rule to ee namespace

* feat: create applied_sla table entry

* chore: add applied_sla spec

* chore: rubocop fixes

---------

Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
Vishnu Narayanan
2024-02-01 15:42:12 +05:30
committed by GitHub
parent de98e434d6
commit b8047f0912
6 changed files with 68 additions and 6 deletions

View File

@@ -25,5 +25,12 @@ RSpec.describe AutomationRule do
expect(Audited::Audit.where(auditable_type: 'AutomationRule', action: 'destroy').count).to eq 1
end
end
context 'when automation rule is in enterprise namespace' do
it 'has associated sla methods available' do
expect(automation_rule.conditions_attributes).to include('sla_policy_id')
expect(automation_rule.actions_attributes).to include('add_sla')
end
end
end
end

View File

@@ -0,0 +1,23 @@
require 'rails_helper'
describe ActionService do
let(:account) { create(:account) }
describe '#add_sla' do
let(:sla_policy) { create(:sla_policy, account: account) }
let(:conversation) { create(:conversation, account: account) }
let(:action_service) { described_class.new(conversation) }
it 'adds the sla policy to the conversation and create applied_sla entry' do
action_service.add_sla(sla_policy)
expect(conversation.reload.sla_policy_id).to eq(sla_policy.id)
# check if appliedsla table entry is created with matching attributes
applied_sla = AppliedSla.last
expect(applied_sla.account_id).to eq(account.id)
expect(applied_sla.sla_policy_id).to eq(sla_policy.id)
expect(applied_sla.conversation_id).to eq(conversation.id)
expect(applied_sla.sla_status).to eq('active')
end
end
end