Feature: Create conversations from Tweets (#470)

* Feature: Add tweets to conversations
This commit is contained in:
Pranav Raj S
2020-02-09 15:47:48 +05:30
committed by GitHub
parent 3465ebefd1
commit 272c481464
29 changed files with 333 additions and 68 deletions

View File

@@ -2,18 +2,28 @@ require 'rails_helper'
require 'webhooks/twitter'
describe Webhooks::Twitter do
subject(:process_twitter_event) { described_class.new(params).consume }
subject(:twitter_webhook) { described_class }
let!(:account) { create(:account) }
# FIX ME: recipient id is set to 1 inside event factories
let!(:twitter_channel) { create(:channel_twitter_profile, account: account, profile_id: '1') }
let!(:twitter_inbox) { create(:inbox, channel: twitter_channel, account: account) }
let!(:params) { build(:twitter_message_create_event).with_indifferent_access }
let!(:dm_params) { build(:twitter_message_create_event).with_indifferent_access }
let!(:tweet_params) { build(:tweet_create_event).with_indifferent_access }
describe '#perform' do
context 'with correct params' do
context 'with direct_message params' do
it 'creates incoming message in the twitter inbox' do
process_twitter_event
twitter_webhook.new(dm_params).consume
expect(twitter_inbox.contacts.count).to be 1
expect(twitter_inbox.conversations.count).to be 1
expect(twitter_inbox.messages.count).to be 1
end
end
context 'with tweet_params params' do
it 'creates incoming message in the twitter inbox' do
twitter_webhook.new(tweet_params).consume
expect(twitter_inbox.contacts.count).to be 1
expect(twitter_inbox.conversations.count).to be 1
expect(twitter_inbox.messages.count).to be 1