require 'rails_helper' RSpec.describe AutomationRule, type: :model do describe 'associations' do 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', 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_administrator, action_params: [1] }, { action_name: :update_additional_attributes, action_params: [{ intiated_at: '2021-12-03 17:25:26.844536 +0530' }] } ] }.with_indifferent_access end it 'returns valid record' do rule = FactoryBot.build(:automation_rule, params) expect(rule.valid?).to eq true end end end