From 6c1538f96eceb754c0419e8124791649c8a3b917 Mon Sep 17 00:00:00 2001 From: tejaswini chile Date: Tue, 18 Oct 2022 14:14:19 +0530 Subject: [PATCH] fix: spec for conversation.updated --- spec/listeners/action_cable_listener_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/listeners/action_cable_listener_spec.rb b/spec/listeners/action_cable_listener_spec.rb index d1bad487f..b0c14c4d0 100644 --- a/spec/listeners/action_cable_listener_spec.rb +++ b/spec/listeners/action_cable_listener_spec.rb @@ -128,4 +128,20 @@ describe ActionCableListener do listener.contact_deleted(event) end end + + describe '#conversation_updated' do + let(:event_name) { :'conversation.updated' } + let!(:event) { Events::Base.new(event_name, Time.zone.now, conversation: conversation, user: agent, is_private: false) } + + it 'sends update to inbox members' do + expect(conversation.inbox.reload.inbox_members.count).to eq(1) + + expect(ActionCableBroadcastJob).to receive(:perform_later).with( + [agent.pubsub_token, admin.pubsub_token, conversation.contact_inbox.pubsub_token], + 'conversation.updated', + conversation.push_event_data.merge(account_id: account.id) + ) + listener.conversation_updated(event) + end + end end