feat: Add send message, fix issues with message conditions (#4423)
Co-authored-by: Tejaswini <tejaswini@chatwoot.com>
This commit is contained in:
@@ -259,17 +259,41 @@ RSpec.describe 'Api::V1::Accounts::AutomationRulesController', type: :request do
|
||||
end
|
||||
|
||||
context 'when it is an authenticated user' do
|
||||
it 'returns for updated automation_rule for account' do
|
||||
params = { name: 'Update name' }
|
||||
let(:update_params) do
|
||||
{
|
||||
description: 'Update description',
|
||||
name: 'Update name',
|
||||
conditions: [
|
||||
{
|
||||
attribute_key: 'browser_language',
|
||||
filter_operator: 'equal_to',
|
||||
values: ['en'],
|
||||
query_operator: 'AND'
|
||||
}
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
action_name: :update_additional_attributes,
|
||||
action_params: [{ intiated_at: '2021-12-03 17:25:26.844536 +0530' }]
|
||||
}
|
||||
]
|
||||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
it 'returns for cloned automation_rule for account' do
|
||||
expect(account.automation_rules.count).to eq(1)
|
||||
expect(account.automation_rules.first.actions.size).to eq(4)
|
||||
|
||||
patch "/api/v1/accounts/#{account.id}/automation_rules/#{automation_rule.id}",
|
||||
headers: administrator.create_new_auth_token,
|
||||
params: params
|
||||
params: update_params
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
body = JSON.parse(response.body, symbolize_names: true)
|
||||
expect(body[:payload][:name]).to eq('Update name')
|
||||
expect(body[:payload][:description]).to eq('Update description')
|
||||
expect(body[:payload][:conditions].size).to eq(1)
|
||||
expect(body[:payload][:actions].size).to eq(1)
|
||||
end
|
||||
|
||||
it 'returns for updated active flag for automation_rule' do
|
||||
|
||||
Reference in New Issue
Block a user