fix: open bot handled conversations on team takeover
This commit is contained in:
@@ -14,6 +14,10 @@ module AssignmentHandler
|
||||
|
||||
validate_current_assignee_team
|
||||
self.assignee ||= find_assignee_from_team
|
||||
return if assignee_id.blank?
|
||||
|
||||
self.status = :open if assignee_agent_bot_id.present? && pending?
|
||||
self.assignee_agent_bot = nil
|
||||
end
|
||||
|
||||
def validate_current_assignee_team
|
||||
|
||||
@@ -83,6 +83,7 @@ RSpec.describe 'Conversation Assignment API', type: :request do
|
||||
team_member = create(:user, account: account, role: :agent, auto_offline: false)
|
||||
create(:inbox_member, inbox: conversation.inbox, user: team_member)
|
||||
create(:team_member, team: team, user: team_member)
|
||||
conversation.update!(assignee_agent_bot: agent_bot, status: :pending)
|
||||
params = { team_id: team.id }
|
||||
|
||||
post api_v1_account_conversation_assignments_url(account_id: account.id, conversation_id: conversation.display_id),
|
||||
@@ -93,7 +94,10 @@ RSpec.describe 'Conversation Assignment API', type: :request do
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(conversation.reload.team).to eq(team)
|
||||
# assignee will be from team
|
||||
expect(conversation.reload.assignee).to eq(team_member)
|
||||
conversation.reload
|
||||
expect(conversation.assignee).to eq(team_member)
|
||||
expect(conversation.assignee_agent_bot).to be_nil
|
||||
expect(conversation.status).to eq('open')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user