fix: API error when using SuperAdmin token (#8739)

- Fixes the issue in release 3.5.0, which causes SuperAdmin tokens to throw error during API calls

Fixes: #8719
This commit is contained in:
Sojan Jose
2024-01-18 18:49:32 +04:00
committed by GitHub
parent aacf326ca1
commit ce8190dacf
2 changed files with 27 additions and 1 deletions

View File

@@ -29,6 +29,25 @@ RSpec.describe 'API Base', type: :request do
end
end
describe 'request with api_access_token for a super admin' do
before do
user.update!(type: 'SuperAdmin')
end
context 'when its a valid api_access_token' do
it 'returns current user information' do
get '/api/v1/profile',
headers: { api_access_token: user.access_token.token },
as: :json
expect(response).to have_http_status(:success)
json_response = response.parsed_body
expect(json_response['id']).to eq(user.id)
expect(json_response['email']).to eq(user.email)
end
end
end
describe 'request with api_access_token for bot' do
let!(:agent_bot) { create(:agent_bot) }
let!(:inbox) { create(:inbox, account: account) }