Skip to content

Commit de37b0c

Browse files
committed
adapters/crate: Fix inviteOwner() error handling code
1 parent 7c688d6 commit de37b0c

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

app/adapters/crate.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ export default ApplicationAdapter.extend({
55
return this.ajax(this.urlForFollowAction(id), 'PUT');
66
},
77

8-
inviteOwner(id, username) {
9-
return this.ajax(this.urlForOwnerAction(id), 'PUT', {
8+
async inviteOwner(id, username) {
9+
let result = await this.ajax(this.urlForOwnerAction(id), 'PUT', {
1010
data: {
1111
owners: [username],
1212
},
1313
});
14+
15+
if (result.ok) {
16+
return result;
17+
} else {
18+
throw result;
19+
}
1420
},
1521

1622
removeOwner(id, username) {

tests/acceptance/crate-test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ module('Acceptance | crate page', function (hooks) {
281281
await fillIn('input[name="username"]', 'spookyghostboo');
282282
await click('[data-test-save-button]');
283283

284-
assert.dom('[data-test-error-message]').hasText('Error sending invite: Not Found');
284+
assert
285+
.dom('[data-test-error-message]')
286+
.hasText('Error sending invite: could not find user with login `spookyghostboo`');
285287
assert.dom('[data-test-owners] [data-test-owner-team]').exists({ count: 2 });
286288
assert.dom('[data-test-owners] [data-test-owner-user]').exists({ count: 2 });
287289
});

tests/models/crate-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ module('Model | Crate', function (hooks) {
3333
let crateRecord = await this.store.findRecord('crate', crate.id);
3434

3535
await assert.rejects(crateRecord.inviteOwner('unknown'), function (error) {
36-
assert.deepEqual(error.errors, [{ detail: 'Not Found' }]);
37-
return error instanceof AdapterError;
36+
assert.deepEqual(error.errors, [{ detail: 'could not find user with login `unknown`' }]);
37+
return true;
3838
});
3939
});
4040
});

0 commit comments

Comments
 (0)