refactor: 💡 implement new pathing for users

This commit is contained in:
Randall Morey committed 2020-09-09 16:53:41 -04:00
1 parent e80708eeb4
commit 4a63c6484f
17 files changed
+154 -78

No files matched your search

+7 -7
View File
@@ -97,17 +97,17 @@ module('Unit | Model | base', function (hooks) {
assert.expect(3);
const store = this.owner.lookup('service:store');
const model = store.createRecord('user', { scopeID: 'o_123' });
this.server.post('/v1/scopes/o_123/users', () => {
this.server.post('/v1/users', () => {
assert.ok(true, 'Correctly scoped create record URL was requested.')
return {};
});
await model.save();
this.server.patch('/v1/scopes/o_123/users', () => {
this.server.patch('/v1/users', () => {
assert.ok(true, 'Correctly scoped update record URL was requested.')
return {};
});
await model.save();
this.server.delete('/v1/scopes/o_123/users', () => {
this.server.delete('/v1/users', () => {
assert.ok(true, 'Correctly scoped delete record URL was requested.')
return {};
});
@@ -120,17 +120,17 @@ module('Unit | Model | base', function (hooks) {
const customScopeID = 'global';
const scope = {scope_id: 'o_123'};
const model = store.createRecord('user', { scope });
this.server.post('/v1/scopes/global/users', () => {
this.server.post('/v1/users', () => {
assert.ok(true, 'Correctly scoped create record URL was requested.')
return {};
});
await model.save({adapterOptions: {scopeID: customScopeID}});
this.server.patch('/v1/scopes/global/users', () => {
this.server.patch('/v1/users', () => {
assert.ok(true, 'Correctly scoped update record URL was requested.')
return {};
});
await model.save({adapterOptions: {scopeID: customScopeID}});
this.server.delete('/v1/scopes/global/users', () => {
this.server.delete('/v1/users', () => {
assert.ok(true, 'Correctly scoped delete record URL was requested.')
return {};
});
@@ -143,7 +143,7 @@ module('Unit | Model | base', function (hooks) {
const method = 'my-custom-method';
const scope = {scope_id: 'o_123'};
const model = store.createRecord('user', { scope });
this.server.post(`/v1/scopes/o_123/users:${method}`, () => {
this.server.post(`/v1/users:${method}`, () => {
assert.ok(true, 'Correctly scoped create record URL was requested.')
return {};
});