chore: Move agent availability to Account level (#3074)

- Move agent availability to the account level
This commit is contained in:
Sojan Jose 2021-10-07 13:21:46 +05:30 committed by GitHub
parent 1c6a539c0a
commit c54aae21ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
84 changed files with 618 additions and 148 deletions

View file

@ -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