chore: Move agent availability to Account level (#3074)
- Move agent availability to the account level
This commit is contained in:
parent
1c6a539c0a
commit
c54aae21ff
84 changed files with 618 additions and 148 deletions
|
@ -89,16 +89,6 @@ RSpec.describe 'Profile API', type: :request do
|
|||
expect(agent.avatar.attached?).to eq(true)
|
||||
end
|
||||
|
||||
it 'updates the availability status' do
|
||||
put '/api/v1/profile',
|
||||
params: { profile: { availability: 'offline' } },
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(::OnlineStatusTracker.get_status(account.id, agent.id)).to eq('offline')
|
||||
end
|
||||
|
||||
it 'updates the ui settings' do
|
||||
put '/api/v1/profile',
|
||||
params: { profile: { ui_settings: { is_contact_sidebar_open: false } } },
|
||||
|
@ -111,4 +101,28 @@ RSpec.describe 'Profile API', type: :request do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /api/v1/profile/availability' do
|
||||
context 'when it is an unauthenticated user' do
|
||||
it 'returns unauthorized' do
|
||||
post '/api/v1/profile/availability'
|
||||
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it is an authenticated user' do
|
||||
let(:agent) { create(:user, password: 'Test123!', account: account, role: :agent) }
|
||||
|
||||
it 'updates the availability status' do
|
||||
post '/api/v1/profile/availability',
|
||||
params: { profile: { availability: 'busy', account_id: account.id } },
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(::OnlineStatusTracker.get_status(account.id, agent.id)).to eq('busy')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue