19ab0fe108
* Chore: Enable Users to create multiple accounts Addresses: #402 - migrations to split roles and other attributes from users table - make changes in code to accommodate this change Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
33 lines
1.1 KiB
Ruby
33 lines
1.1 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe 'Conversation Assignment API', type: :request do
|
|
let(:account) { create(:account) }
|
|
|
|
describe 'POST /api/v1/accounts/{account.id}/conversations/<id>/assignments' do
|
|
let(:conversation) { create(:conversation, account: account) }
|
|
|
|
context 'when it is an unauthenticated user' do
|
|
it 'returns unauthorized' do
|
|
post api_v1_account_conversation_assignments_url(account_id: account.id, conversation_id: conversation.display_id)
|
|
|
|
expect(response).to have_http_status(:unauthorized)
|
|
end
|
|
end
|
|
|
|
context 'when it is an authenticated user' do
|
|
let(:agent) { create(:user, account: account, role: :agent) }
|
|
|
|
it 'assigns a user to the conversation' do
|
|
params = { assignee_id: agent.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.assignee).to eq(agent)
|
|
end
|
|
end
|
|
end
|
|
end
|