From 2397326324e3fb08366cb7227c068b2c26911b28 Mon Sep 17 00:00:00 2001 From: Tejaswini Chile Date: Fri, 12 Aug 2022 13:40:28 +0530 Subject: [PATCH] fix: Auto populate team after assigned via API (#5250) --- app/models/team.rb | 7 +++++++ app/presenters/conversations/event_data_presenter.rb | 1 + spec/models/conversation_spec.rb | 1 + spec/presenters/conversations/event_data_presenter_spec.rb | 1 + 4 files changed, 10 insertions(+) diff --git a/app/models/team.rb b/app/models/team.rb index eac2b7532..b4811e232 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -44,4 +44,11 @@ class Team < ApplicationRecord def reporting_events account.reporting_events.where(conversation_id: conversations.pluck(:id)) end + + def push_event_data + { + id: id, + name: name + } + end end diff --git a/app/presenters/conversations/event_data_presenter.rb b/app/presenters/conversations/event_data_presenter.rb index 9f3b1dced..5981af051 100644 --- a/app/presenters/conversations/event_data_presenter.rb +++ b/app/presenters/conversations/event_data_presenter.rb @@ -27,6 +27,7 @@ class Conversations::EventDataPresenter < SimpleDelegator { sender: contact.push_event_data, assignee: assignee&.push_event_data, + team: team&.push_event_data, hmac_verified: contact_inbox&.hmac_verified } end diff --git a/spec/models/conversation_spec.rb b/spec/models/conversation_spec.rb index 48cfb5af1..6982714e5 100644 --- a/spec/models/conversation_spec.rb +++ b/spec/models/conversation_spec.rb @@ -428,6 +428,7 @@ RSpec.describe Conversation, type: :model do meta: { sender: conversation.contact.push_event_data, assignee: conversation.assignee, + team: conversation.team, hmac_verified: conversation.contact_inbox.hmac_verified }, id: conversation.display_id, diff --git a/spec/presenters/conversations/event_data_presenter_spec.rb b/spec/presenters/conversations/event_data_presenter_spec.rb index b22057435..c883597a8 100644 --- a/spec/presenters/conversations/event_data_presenter_spec.rb +++ b/spec/presenters/conversations/event_data_presenter_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Conversations::EventDataPresenter do meta: { sender: conversation.contact.push_event_data, assignee: conversation.assignee, + team: conversation.team, hmac_verified: conversation.contact_inbox.hmac_verified }, id: conversation.display_id,