mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-18 15:55:30 +00:00
Update Users.edit to use FormData when submitting avatar updates (#3644)
This commit is contained in:
parent
e4aa240ff8
commit
d8bdf42788
@ -156,7 +156,7 @@ export type AllUsersOptions = {
|
||||
export type CreateUserOptions = {
|
||||
admin?: boolean;
|
||||
auditor?: boolean;
|
||||
avatar?: { content: Blob; filepath?: string };
|
||||
avatar?: { content: Blob; filename?: string };
|
||||
bio?: string;
|
||||
canCreateGroup?: boolean;
|
||||
colorSchemeId?: number;
|
||||
@ -487,9 +487,16 @@ export class Users<C extends boolean = false> extends BaseResource<C> {
|
||||
|
||||
edit<E extends boolean = false>(
|
||||
userId: number,
|
||||
options?: EditUserOptions & Sudo & ShowExpanded<E>,
|
||||
{ avatar, ...options }: EditUserOptions & Sudo & ShowExpanded<E> = {},
|
||||
) {
|
||||
return RequestHelper.put<ExpandedUserSchema>()(this, endpoint`users/${userId}`, options);
|
||||
const opts: Record<string, unknown> = {
|
||||
...options,
|
||||
isForm: true,
|
||||
};
|
||||
|
||||
if (avatar) opts.avatar = [avatar.content, avatar.filename];
|
||||
|
||||
return RequestHelper.put<ExpandedUserSchema>()(this, endpoint`users/${userId}`, opts);
|
||||
}
|
||||
|
||||
editStatus<E extends boolean = false>(
|
||||
|
||||
@ -181,7 +181,10 @@ describe('Users.edit', () => {
|
||||
it('should request PUT users/:id', async () => {
|
||||
await service.edit(1, { name: 'Okoye' });
|
||||
|
||||
expect(RequestHelper.put()).toHaveBeenCalledWith(service, 'users/1', { name: 'Okoye' });
|
||||
expect(RequestHelper.put()).toHaveBeenCalledWith(service, 'users/1', {
|
||||
isForm: true,
|
||||
name: 'Okoye',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user