Chatwoot/spec/factories/conversations.rb
Saurabh Mehta 627d3a575a
chore: Automate conversation display_id generation with db triggers (#1412)
Automate conversation display_id generation with db triggers

Co-authored-by: Saurabh Mehta <saurabh1.mehta@airtel.com>
Co-authored-by: Sojan Jose <sojan@pepalo.com>
2021-01-05 20:07:04 +05:30

21 lines
670 B
Ruby

# frozen_string_literal: true
FactoryBot.define do
factory :conversation do
status { 'open' }
agent_last_seen_at { Time.current }
locked { false }
identifier { SecureRandom.hex }
after(:build) do |conversation|
conversation.account ||= create(:account)
conversation.inbox ||= create(
:inbox,
account: conversation.account,
channel: create(:channel_widget, account: conversation.account)
)
conversation.contact ||= create(:contact, account: conversation.account)
conversation.contact_inbox ||= create(:contact_inbox, contact: conversation.contact, inbox: conversation.inbox)
end
end
end