feat: Add team assignment & filter APIs (#1712)
This commit is contained in:
@@ -16,6 +16,7 @@ RSpec.describe 'Conversation Assignment API', type: :request do
|
||||
|
||||
context 'when it is an authenticated user' do
|
||||
let(:agent) { create(:user, account: account, role: :agent) }
|
||||
let(:team) { create(:team, account: account) }
|
||||
|
||||
it 'assigns a user to the conversation' do
|
||||
params = { assignee_id: agent.id }
|
||||
@@ -28,6 +29,18 @@ RSpec.describe 'Conversation Assignment API', type: :request do
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(conversation.reload.assignee).to eq(agent)
|
||||
end
|
||||
|
||||
it 'assigns a team to the conversation' do
|
||||
params = { team_id: team.id }
|
||||
|
||||
post api_v1_account_conversation_assignments_url(account_id: account.id, conversation_id: conversation.display_id),
|
||||
params: params,
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(conversation.reload.team).to eq(team)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when conversation already has an assignee' do
|
||||
@@ -37,7 +50,7 @@ RSpec.describe 'Conversation Assignment API', type: :request do
|
||||
conversation.update!(assignee: agent)
|
||||
end
|
||||
|
||||
it 'unassigns a user from the conversation' do
|
||||
it 'unassigns the assignee from the conversation' do
|
||||
params = { assignee_id: 0 }
|
||||
post api_v1_account_conversation_assignments_url(account_id: account.id, conversation_id: conversation.display_id),
|
||||
params: params,
|
||||
@@ -49,5 +62,25 @@ RSpec.describe 'Conversation Assignment API', type: :request do
|
||||
expect(conversation.messages.last.content).to eq("Conversation unassigned by #{agent.name}")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when conversation already has a team' do
|
||||
let(:agent) { create(:user, account: account, role: :agent) }
|
||||
let(:team) { create(:team, account: account) }
|
||||
|
||||
before do
|
||||
conversation.update!(team: team)
|
||||
end
|
||||
|
||||
it 'unassigns the team from the conversation' do
|
||||
params = { team_id: 0 }
|
||||
post api_v1_account_conversation_assignments_url(account_id: account.id, conversation_id: conversation.display_id),
|
||||
params: params,
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(conversation.reload.team).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user