refactor: 💡 implement new pathing for groups

This commit is contained in:
Randall Morey committed 2020-09-09 16:24:48 -04:00
1 parent a368d65d10
commit e80708eeb4
17 files changed
+75 -36

No files matched your search

@@ -93,13 +93,11 @@ module('Unit | Adapter | application', function (hooks) {
test('it can request records through the store from a specified scope', async function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
this.server.get('/v1/scopes/p_456/groups', () => {
assert.ok(true, 'Scoped resource URL was requested.');
this.server.get('/v1/groups', (_, { queryParams: { scope_id }}) => {
assert.equal(scope_id, 'p_456', 'Scoped resource URL was requested.');
return {items: []};
});
await store.findAll('group', {
adapterOptions: { scopeID: 'p_456' }
});
await store.query('group', { scope_id: 'p_456' });
});
test('it rewrites PUT to PATCH, but leaves others unchanged', function (assert) {
@@ -0,0 +1,12 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Adapter | group', function(hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
let adapter = this.owner.lookup('adapter:group');
assert.ok(adapter);
});
});
+3 -3
View File
@@ -43,7 +43,7 @@ module('Unit | Model | group', function(hooks) {
test('it has an `addMembers` method that groups a specific POST API endpoint and serialization', async function (assert) {
assert.expect(1);
this.server.post('/v1/scopes/o_1/groups/123abc:add-members', (schema, request) => {
this.server.post('/v1/groups/123abc:add-members', (schema, request) => {
const body = JSON.parse(request.requestBody);
assert.deepEqual(body, {
member_ids: ['123_abc', 'foobar'],
@@ -73,7 +73,7 @@ module('Unit | Model | group', function(hooks) {
test('it has a `removeMembers` method that groups a specific POST API endpoint and serialization', async function (assert) {
assert.expect(1);
this.server.post('/v1/scopes/o_1/groups/123abc:remove-members', (schema, request) => {
this.server.post('/v1/groups/123abc:remove-members', (schema, request) => {
const body = JSON.parse(request.requestBody);
assert.deepEqual(body, {
member_ids: ['1', '3'],
@@ -103,7 +103,7 @@ module('Unit | Model | group', function(hooks) {
test('it has a `removeMember` method that deletes a single member set using `removeMembers` method', async function (assert) {
assert.expect(1);
this.server.post('/v1/scopes/o_1/groups/123abc:remove-members', (schema, request) => {
this.server.post('/v1/groups/123abc:remove-members', (schema, request) => {
const body = JSON.parse(request.requestBody);
assert.deepEqual(body, {
member_ids: ['3'],