Chatwoot/spec/models/automation_rule_spec.rb

53 lines
1.4 KiB
Ruby
Raw Normal View History

2022-01-10 07:11:59 +00:00
require 'rails_helper'
RSpec.describe AutomationRule, type: :model do
describe 'associations' do
2022-03-21 07:42:27 +00:00
let(:account) { create(:account) }
2022-01-10 07:11:59 +00:00
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',
2022-03-21 07:42:27 +00:00
account_id: account.id,
2022-01-10 07:11:59 +00:00
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_agent,
2022-01-10 07:11:59 +00:00
action_params: [1]
}
]
}.with_indifferent_access
end
it 'returns valid record' do
rule = FactoryBot.build(:automation_rule, params)
expect(rule.valid?).to be true
2022-01-10 07:11:59 +00:00
end
end
end