Revert "chore: Improve the behaviour of lock to single conversation (… (#7886)

This commit is contained in:
Pranav Raj S
2023-09-08 21:29:21 -07:00
committed by GitHub
parent 4503ba018d
commit f05535c5ad
6 changed files with 6 additions and 91 deletions

View File

@@ -35,30 +35,6 @@ describe Whatsapp::IncomingMessageService do
expect(last_conversation.messages.last.content).to eq(params[:messages].first[:text][:body])
end
it 'reopen last conversation if last conversation is resolved and lock to single conversation is enabled' do
whatsapp_channel.inbox.update(lock_to_single_conversation: true)
contact_inbox = create(:contact_inbox, inbox: whatsapp_channel.inbox, source_id: params[:messages].first[:from])
last_conversation = create(:conversation, inbox: whatsapp_channel.inbox, contact_inbox: contact_inbox)
last_conversation.update(status: 'resolved')
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
# no new conversation should be created
expect(whatsapp_channel.inbox.conversations.count).to eq(1)
# message appended to the last conversation
expect(last_conversation.messages.last.content).to eq(params[:messages].first[:text][:body])
expect(last_conversation.reload.status).to eq('open')
end
it 'creates a new conversation if last conversation is resolved and lock to single conversation is disabled' do
whatsapp_channel.inbox.update(lock_to_single_conversation: false)
contact_inbox = create(:contact_inbox, inbox: whatsapp_channel.inbox, source_id: params[:messages].first[:from])
last_conversation = create(:conversation, inbox: whatsapp_channel.inbox, contact_inbox: contact_inbox)
last_conversation.update(status: 'resolved')
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
# new conversation should be created
expect(whatsapp_channel.inbox.conversations.count).to eq(2)
expect(contact_inbox.conversations.last.messages.last.content).to eq(params[:messages].first[:text][:body])
end
it 'will not create duplicate messages when same message is received' do
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.messages.count).to eq(1)