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:
@@ -0,0 +1,28 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Profile API', type: :request do
|
||||
describe 'GET /api/v1/profile' do
|
||||
let(:account) { create(:account) }
|
||||
let!(:custom_role_account) { create(:account, name: 'Custom Role Account') }
|
||||
let!(:custom_role) { create(:custom_role, name: 'Custom Role', account: custom_role_account) }
|
||||
let!(:agent) { create(:user, account: account, custom_attributes: { test: 'test' }, role: :agent) }
|
||||
|
||||
before do
|
||||
create(:account_user, account: custom_role_account, user: agent, custom_role: custom_role)
|
||||
end
|
||||
|
||||
context 'when it is an authenticated user' do
|
||||
it 'returns user custom role information' do
|
||||
get '/api/v1/profile',
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
parsed_response = response.parsed_body
|
||||
# map accounts object and make sure custom role id and name are present
|
||||
role_account = parsed_response['accounts'].find { |account| account['id'] == custom_role_account.id }
|
||||
expect(role_account['custom_role']['id']).to eq(custom_role.id)
|
||||
expect(role_account['custom_role']['name']).to eq(custom_role.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user