Skip to content

Commit 5efbf21

Browse files
authored
feat(certif): update certification center memberships lastAccessedAt call
1 parent b3d18da commit 5efbf21

File tree

5 files changed

+8
-10
lines changed

5 files changed

+8
-10
lines changed

certif/app/adapters/certification-center-membership.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ export default class CertificationCenterMembershipAdapter extends ApplicationAda
55
const { adapterOptions } = snapshot;
66

77
if (adapterOptions && adapterOptions.updateLastAccessedAt) {
8-
const url = `${this.host}/api/certification-centers/${adapterOptions.certificationCenterId}/certification-center-memberships/me`;
8+
const url = `${this.host}/api/certification-center-memberships/${snapshot.id}/access`;
99

1010
delete adapterOptions.updateLastAccessedAt;
1111

12-
return this.ajax(url, 'PATCH');
12+
return this.ajax(url, 'POST');
1313
}
1414

1515
return super.updateRecord(...arguments);

certif/app/services/current-user.js

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export default class CurrentUserService extends Service {
7070
await this.currentCertificationCenterMembership.save({
7171
adapterOptions: {
7272
updateLastAccessedAt: true,
73-
certificationCenterId: this.currentCertificationCenterMembership.certificationCenterId,
7473
},
7574
});
7675
}

certif/mirage/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ function _configureCertificationCenterInvitationRoutes(context) {
432432
return certificationCenterInvitation;
433433
});
434434

435-
context.patch('/certification-centers/:certificationCenterId/certification-center-memberships/me', () => {
435+
context.post('/certification-center-memberships/:certificationCenterMembershipId/access', () => {
436436
return new Response(204);
437437
});
438438

certif/tests/unit/adapters/certification-center-membership-test.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@ module('Unit | Adapter | certificationCenterMembership', function (hooks) {
1616
module('when updateLastAccessedAt is true', function () {
1717
test('should call /api/certification-centers/{certification-center-id}/certification-center-memberships/me', async function (assert) {
1818
// given
19-
const certificationCenterId = 1;
2019

2120
const snapshot = {
21+
id: 1,
2222
adapterOptions: {
2323
updateLastAccessedAt: true,
24-
certificationCenterId,
2524
},
2625
};
27-
const expectedUrl = `http://localhost:3000/api/certification-centers/${certificationCenterId}/certification-center-memberships/me`;
28-
const expectedMethod = 'PATCH';
26+
const expectedUrl = `http://localhost:3000/api/certification-center-memberships/1/access`;
27+
const expectedMethod = 'POST';
2928

3029
// when
3130
await adapter.updateRecord(null, null, snapshot);

certif/tests/unit/services/current-user-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module('Unit | Service | current-user', function (hooks) {
5858
assert.deepEqual(currentUser.currentCertificationCenterMembership, certificationCenterMembershipA);
5959
assert.true(currentUser.isAdminOfCurrentCertificationCenter);
6060
sinon.assert.calledWith(certificationCenterMembershipA.save, {
61-
adapterOptions: { updateLastAccessedAt: true, certificationCenterId: 789 },
61+
adapterOptions: { updateLastAccessedAt: true },
6262
});
6363
assert.ok(true);
6464
});
@@ -213,7 +213,7 @@ module('Unit | Service | current-user', function (hooks) {
213213
assert.strictEqual(currentUser.currentCertificationCenterMembership, newCertificationCenterMembership);
214214
assert.true(currentUser.isAdminOfCurrentCertificationCenter);
215215
sinon.assert.calledWith(newCertificationCenterMembership.save, {
216-
adapterOptions: { updateLastAccessedAt: true, certificationCenterId: 222 },
216+
adapterOptions: { updateLastAccessedAt: true },
217217
});
218218
assert.ok(true);
219219
});

0 commit comments

Comments
 (0)