chore: Custom Roles to manage permissions [ UI ] (#9865)
In admin settings, this Pr will add the UI for managing custom roles ( ref: https://github.com/chatwoot/chatwoot/pull/9995 ). It also handles the routing logic changes to accommodate fine-tuned permissions. --------- Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: iamsivin <iamsivin@gmail.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -3,10 +3,25 @@ require 'rails_helper'
|
||||
RSpec.describe 'Enterprise Agents API', type: :request do
|
||||
let(:account) { create(:account) }
|
||||
let(:admin) { create(:user, account: account, role: :administrator) }
|
||||
let!(:custom_role) { create(:custom_role, account: account) }
|
||||
|
||||
describe 'POST /api/v1/accounts/{account.id}/agents' do
|
||||
let(:params) { { email: 'test@example.com', name: 'Test User', role: 'agent', custom_role_id: custom_role.id } }
|
||||
|
||||
context 'when it is an authenticated administrator' do
|
||||
it 'creates an agent with the specified custom role' do
|
||||
post "/api/v1/accounts/#{account.id}/agents", headers: admin.create_new_auth_token, params: params, as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
agent = account.agents.last
|
||||
expect(agent.account_users.first.custom_role_id).to eq(custom_role.id)
|
||||
expect(JSON.parse(response.body)['custom_role_id']).to eq(custom_role.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT /api/v1/accounts/{account.id}/agents/:id' do
|
||||
let(:other_agent) { create(:user, account: account, role: :agent) }
|
||||
let!(:custom_role) { create(:custom_role, account: account) }
|
||||
|
||||
context 'when it is an authenticated administrator' do
|
||||
it 'modified the custom role of the agent' do
|
||||
|
||||
Reference in New Issue
Block a user