feat: Ability to update avatars from super admin (#7264)

- Ability to update user avatars from super admin
- Ability to update bot avatars from super admin

fixes: #7060
This commit is contained in:
Sojan Jose
2023-06-09 15:32:24 +05:30
committed by GitHub
parent c715e396f0
commit 48f2e58e59
12 changed files with 94 additions and 3 deletions

View File

@@ -22,4 +22,25 @@ RSpec.describe 'Super Admin agent-bots API', type: :request do
end
end
end
describe 'DELETE /super_admin/agent_bots/:id/destroy_avatar' do
let!(:agent_bot) { create(:agent_bot, :with_avatar) }
context 'when it is an unauthenticated super admin' do
it 'returns unauthorized' do
delete "/super_admin/agent_bots/#{agent_bot.id}/avatar", params: { attachment_id: agent_bot.avatar.id }
expect(response).to have_http_status(:redirect)
expect(agent_bot.reload.avatar).to be_attached
end
end
context 'when it is an authenticated super admin' do
it 'destroys the avatar' do
sign_in(super_admin, scope: :super_admin)
delete "/super_admin/agent_bots/#{agent_bot.id}/avatar", params: { attachment_id: agent_bot.avatar.id }
expect(response).to have_http_status(:redirect)
expect(agent_bot.reload.avatar).not_to be_attached
end
end
end
end