feat: Assign team with teams none option (#5871)

This commit is contained in:
Tejaswini Chile
2022-11-17 14:15:16 +05:30
committed by GitHub
parent e85f998a08
commit 9bfbd528ef
7 changed files with 46 additions and 3 deletions

View File

@@ -78,6 +78,9 @@ RSpec.describe 'Api::V1::Accounts::MacrosController', type: :request do
'action_name': :add_label,
'action_params': %w[support priority_customer]
},
{
'action_name': :remove_assigned_team
},
{
'action_name': :send_message,
'action_params': ['Welcome to the chatwoot platform.']
@@ -379,6 +382,34 @@ RSpec.describe 'Api::V1::Accounts::MacrosController', type: :request do
expect(conversation.messages.last.sender).to eq(administrator)
expect(conversation.messages.last.private).to be_truthy
end
it 'Assign the team if team_ids are present' do
expect(conversation.team).to be_nil
perform_enqueued_jobs do
post "/api/v1/accounts/#{account.id}/macros/#{macro.id}/execute",
params: { conversation_ids: [conversation.display_id] },
headers: administrator.create_new_auth_token
end
expect(conversation.reload.team_id).to eq(team.id)
end
it 'Unassign the team' do
macro.update!(actions: [
{ 'action_name' => 'remove_assigned_team' }
])
conversation.update!(team_id: team.id)
expect(conversation.reload.team).not_to be_nil
perform_enqueued_jobs do
post "/api/v1/accounts/#{account.id}/macros/#{macro.id}/execute",
params: { conversation_ids: [conversation.display_id] },
headers: administrator.create_new_auth_token
end
expect(conversation.reload.team_id).to be_nil
end
end
end
end