Skip to content

Commit 6af5959

Browse files
committed
feat: update mirage tests and route handlers for owner invites
Uses `api/private` over `api/v1/me` for mirage pending owner invites endpoint. And also adds the `expires_at` attribute as part of the payload received as found in the `EncodableCrateOwnerInvitationV1` struct from the API.
1 parent 6ce9be1 commit 6af5959

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

mirage/route-handlers/me.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function register(server) {
9898
return { ok: true };
9999
});
100100

101-
server.get('/api/v1/me/crate_owner_invitations', function (schema) {
101+
server.get('/api/private/crate_owner_invitations', function (schema) {
102102
let { user } = getSession(schema);
103103
if (!user) {
104104
return new Response(403, {}, { errors: [{ detail: 'must be logged in to perform that action' }] });

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import fetch from 'fetch';
55
import { setupTest } from '../../../helpers';
66
import setupMirage from '../../../helpers/setup-mirage';
77

8-
module('Mirage | GET /api/v1/me/crate_owner_invitations', function (hooks) {
8+
module('Mirage | GET /api/private/crate_owner_invitations', function (hooks) {
99
setupTest(hooks);
1010
setupMirage(hooks);
1111

1212
test('empty case', async function (assert) {
1313
let user = this.server.create('user');
1414
this.server.create('mirage-session', { user });
1515

16-
let response = await fetch('/api/v1/me/crate_owner_invitations');
16+
let response = await fetch('/api/private/crate_owner_invitations');
1717
assert.equal(response.status, 200);
1818
assert.deepEqual(await response.json(), { crate_owner_invitations: [] });
1919
});
@@ -44,7 +44,7 @@ module('Mirage | GET /api/v1/me/crate_owner_invitations', function (hooks) {
4444
inviter: inviter2,
4545
});
4646

47-
let response = await fetch('/api/v1/me/crate_owner_invitations');
47+
let response = await fetch('/api/private/crate_owner_invitations');
4848
assert.equal(response.status, 200);
4949
assert.deepEqual(await response.json(), {
5050
crate_owner_invitations: [
@@ -55,6 +55,7 @@ module('Mirage | GET /api/v1/me/crate_owner_invitations', function (hooks) {
5555
invited_by_username: 'janed',
5656
invitee_id: Number(user.id),
5757
inviter_id: Number(inviter.id),
58+
expires_at: '2017-01-24T12:34:56Z',
5859
},
5960
{
6061
crate_id: Number(ember.id),
@@ -63,6 +64,7 @@ module('Mirage | GET /api/v1/me/crate_owner_invitations', function (hooks) {
6364
invited_by_username: 'wycats',
6465
invitee_id: Number(user.id),
6566
inviter_id: Number(inviter2.id),
67+
expires_at: '2017-01-31T12:34:56Z',
6668
},
6769
],
6870
users: [
@@ -92,7 +94,7 @@ module('Mirage | GET /api/v1/me/crate_owner_invitations', function (hooks) {
9294
});
9395

9496
test('returns an error if unauthenticated', async function (assert) {
95-
let response = await fetch('/api/v1/me/crate_owner_invitations');
97+
let response = await fetch('/api/private/crate_owner_invitations');
9698
assert.equal(response.status, 403);
9799
assert.deepEqual(await response.json(), {
98100
errors: [{ detail: 'must be logged in to perform that action' }],

tests/mirage/private/crate-owner-invitations/get-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module('Mirage | GET /api/private/crate_owner_invitations', function (hooks) {
4646
invited_by_username: 'janed',
4747
invitee_id: Number(user.id),
4848
inviter_id: Number(inviter.id),
49+
expires_at: '2017-01-24T12:34:56Z',
4950
},
5051
{
5152
crate_id: Number(ember.id),
@@ -54,6 +55,7 @@ module('Mirage | GET /api/private/crate_owner_invitations', function (hooks) {
5455
invited_by_username: 'wycats',
5556
invitee_id: Number(user.id),
5657
inviter_id: Number(inviter2.id),
58+
expires_at: '2017-01-31T12:34:56Z',
5759
},
5860
],
5961
users: [

0 commit comments

Comments
 (0)