fix: Resolve name only if assignee exists during unassignment (#1649)

This commit is contained in:
Pranav Raj S
2021-01-14 14:21:41 +05:30
committed by GitHub
parent dad737021f
commit 75c2a7cb2f
2 changed files with 21 additions and 1 deletions

View File

@@ -29,5 +29,25 @@ RSpec.describe 'Conversation Assignment API', type: :request do
expect(conversation.reload.assignee).to eq(agent)
end
end
context 'when conversation already has an assignee' do
let(:agent) { create(:user, account: account, role: :agent) }
before do
conversation.update!(assignee: agent)
end
it 'unassigns a user 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,
headers: agent.create_new_auth_token,
as: :json
expect(response).to have_http_status(:success)
expect(conversation.reload.assignee).to eq(nil)
expect(conversation.messages.last.content).to eq("Conversation unassigned by #{agent.name}")
end
end
end
end