Skip to content

Commit

Permalink
organization-invite: Fix throwing a typed error when passing an unkon…
Browse files Browse the repository at this point in the history
…wn role

Change-type: patch
  • Loading branch information
thgreasi committed Aug 23, 2023
1 parent 8f6eb98 commit d9d9293
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/models/organization-invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const getOrganizationInviteModel = function (
message,
};
if (roles) {
const [{ id: roleId }] = roles;
const roleId = roles[0]?.id;
// Throw if the user provided a roleName, but we didn't find that role
if (!roleId && roleName) {
throw new errors.BalenaOrganizationMembershipRoleNotFound(roleName);
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/models/organizationInvite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ describe('Organization Invite Model', function () {
},
);
await expect(promise).to.be.rejected.then((error) => {
expect(error).to.have.property('code', 'BalenaRequestError');
expect(error).to.have.property('statusCode', 404);
expect(error).to.have.property(
'code',
'BalenaOrganizationMembershipRoleNotFound',
);
expect(error)
.to.have.property('message')
.that.contains(
Expand Down

0 comments on commit d9d9293

Please sign in to comment.