2019-10-12 18:08:41 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
FactoryBot.define do
|
|
|
|
factory :message do
|
2020-07-15 11:03:52 +00:00
|
|
|
content { 'Incoming Message' }
|
2019-10-12 18:08:41 +00:00
|
|
|
status { 'sent' }
|
|
|
|
message_type { 'incoming' }
|
2020-01-09 07:36:40 +00:00
|
|
|
content_type { 'text' }
|
|
|
|
account { create(:account) }
|
|
|
|
|
|
|
|
after(:build) do |message|
|
2020-08-11 04:27:42 +00:00
|
|
|
message.sender ||= message.outgoing? ? create(:user, account: message.account) : create(:contact, account: message.account)
|
2020-10-31 18:44:33 +00:00
|
|
|
message.inbox ||= message.conversation&.inbox || create(:inbox, account: message.account)
|
2020-07-16 19:02:32 +00:00
|
|
|
message.conversation ||= create(:conversation, account: message.account, inbox: message.inbox)
|
2020-01-09 07:36:40 +00:00
|
|
|
end
|
2019-10-12 18:08:41 +00:00
|
|
|
end
|
|
|
|
end
|