Chatwoot/spec/models/automation_rule_spec.rb

52 lines
1.4 KiB
Ruby

require 'rails_helper'
RSpec.describe AutomationRule, type: :model do
describe 'associations' do
let(:account) { create(:account) }
let(:params) do
{
name: 'Notify Conversation Created and mark priority query',
description: 'Notify all administrator about conversation created and mark priority query',
event_name: 'conversation_created',
account_id: account.id,
conditions: [
{
attribute_key: 'browser_language',
filter_operator: 'equal_to',
values: ['en'],
query_operator: 'AND'
},
{
attribute_key: 'country_code',
filter_operator: 'equal_to',
values: %w[USA UK],
query_operator: nil
}
],
actions: [
{
action_name: :send_message,
action_params: ['Welcome to the chatwoot platform.']
},
{
action_name: :assign_team,
action_params: [1]
},
{
action_name: :add_label,
action_params: %w[support priority_customer]
},
{
action_name: :assign_best_agent,
action_params: [1]
}
]
}.with_indifferent_access
end
it 'returns valid record' do
rule = FactoryBot.build(:automation_rule, params)
expect(rule.valid?).to be true
end
end
end