Skip to content

Commit 9fc0045

Browse files
committed
Auto merge of #3869 - Turbo87:invitations, r=hi-rustin
mirage/crate-owner-invitation: Adjust fake API to match the real API #3763 changed a few minor things about the crate owner invitations responses. This PR adjusts our mirage code to match these changes (excluding pagination).
2 parents 640e96c + cb6c0fd commit 9fc0045

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

mirage/serializers/crate-owner-invitation.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import BaseSerializer from './application';
22

33
export default BaseSerializer.extend({
44
// eslint-disable-next-line ember/avoid-leaking-state-in-ember-objects
5-
include: ['inviter'],
5+
include: ['inviter', 'invitee'],
66

77
getHashForResource() {
88
let [hash, addToIncludes] = BaseSerializer.prototype.getHashForResource.apply(this, arguments);
@@ -15,13 +15,17 @@ export default BaseSerializer.extend({
1515
this._adjust(hash);
1616
}
1717

18+
addToIncludes.sort((a, b) => a.id - b.id);
19+
1820
return [hash, addToIncludes];
1921
},
2022

2123
_adjust(hash) {
2224
delete hash.id;
2325
delete hash.token;
2426

27+
hash.crate_id = Number(hash.crate_id);
28+
2529
let crate = this.schema.crates.find(hash.crate_id);
2630
hash.crate_name = crate.name;
2731

tests/mirage/me/crate-owner-invitations/list-test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ module('Mirage | GET /api/v1/me/crate_owner_invitations', function (hooks) {
4949
assert.deepEqual(await response.json(), {
5050
crate_owner_invitations: [
5151
{
52-
crate_id: nanomsg.id,
52+
crate_id: Number(nanomsg.id),
5353
crate_name: 'nanomsg',
5454
created_at: '2016-12-24T12:34:56Z',
5555
invited_by_username: 'janed',
5656
invitee_id: Number(user.id),
5757
inviter_id: Number(inviter.id),
5858
},
5959
{
60-
crate_id: ember.id,
60+
crate_id: Number(ember.id),
6161
crate_name: 'ember-rs',
6262
created_at: '2020-12-31T12:34:56Z',
6363
invited_by_username: 'wycats',
@@ -66,6 +66,13 @@ module('Mirage | GET /api/v1/me/crate_owner_invitations', function (hooks) {
6666
},
6767
],
6868
users: [
69+
{
70+
avatar: user.avatar,
71+
id: Number(user.id),
72+
login: user.login,
73+
name: user.name,
74+
url: user.url,
75+
},
6976
{
7077
avatar: 'https://avatars1.githubusercontent.com/u/14631425?v=4',
7178
id: Number(inviter.id),

0 commit comments

Comments
 (0)