From 4e3a167ef70a24c5ea8f0dafd1dbe8976395cdfa Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 22 Sep 2021 18:52:38 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20change=20host=20source?= =?UTF-8?q?=20custom=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/models/target.js | 10 ++++---- addons/api/mirage/config.js | 4 ++-- addons/api/tests/unit/models/target-test.js | 23 +++++++++++-------- .../scope/targets/target/add-host-sources.js | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index b50506dcb..15cd3e678 100644 --- a/addons/api/addon/models/target.js +++ b/addons/api/addon/models/target.js @@ -96,7 +96,7 @@ export default class TargetModel extends GeneratedTargetModel { // =methods /** - * Adds host sets via the `add-host-sets` method. + * Adds host sets via the `add-host-sources` method. * See serializer and adapter for more information. * @param {[string]} hostSetIDs * @param {object} options @@ -105,7 +105,7 @@ export default class TargetModel extends GeneratedTargetModel { */ addHostSources(hostSetIDs, options = { adapterOptions: {} }) { const defaultAdapterOptions = { - method: 'add-host-sets', + method: 'add-host-sources', hostSetIDs, }; // There is no "deep merge" in ES. @@ -119,7 +119,7 @@ export default class TargetModel extends GeneratedTargetModel { } /** - * Delete host sets via the `remove-host-sets` method. + * Delete host sets via the `remove-host-sources` method. * See serializer and adapter for more information. * @param {[string]} hostSetIDs * @param {object} options @@ -128,7 +128,7 @@ export default class TargetModel extends GeneratedTargetModel { */ removeHostSources(hostSetIDs, options = { adapterOptions: {} }) { const defaultAdapterOptions = { - method: 'remove-host-sets', + method: 'remove-host-sources', hostSetIDs, }; // There is no "deep merge" in ES. @@ -142,7 +142,7 @@ export default class TargetModel extends GeneratedTargetModel { } /** - * Delete a single host set via the `remove-host-sets` method. + * Delete a single host set via the `remove-host-sources` method. * @param {number} hostSetID * @param {object} options * @return {Promise} diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index b39dff5a2..c697bb6c5 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -368,7 +368,7 @@ export default function () { version: attrs.version, }; // If adding host sets, push them into the array - if (method === 'add-host-sets') { + if (method === 'add-host-sources') { updatedAttrs.hostSetIds = target.hostSetIds; attrs.hostSetIds.forEach((id) => { if (!updatedAttrs.hostSetIds.includes(id)) { @@ -377,7 +377,7 @@ export default function () { }); } // If deleting host sets, filter them out of the array - if (method === 'remove-host-sets') { + if (method === 'remove-host-sources') { updatedAttrs.hostSetIds = target.hostSetIds; updatedAttrs.hostSetIds = updatedAttrs.hostSetIds.filter((id) => { return !attrs.hostSetIds.includes(id); diff --git a/addons/api/tests/unit/models/target-test.js b/addons/api/tests/unit/models/target-test.js index 51be507e7..dc458a879 100644 --- a/addons/api/tests/unit/models/target-test.js +++ b/addons/api/tests/unit/models/target-test.js @@ -74,14 +74,17 @@ module('Unit | Model | target', function (hooks) { test('it has an `addHostSources` method that targets a specific POST API endpoint and serialization', async function (assert) { assert.expect(1); - this.server.post('/v1/targets/123abc:add-host-sets', (schema, request) => { - const body = JSON.parse(request.requestBody); - assert.deepEqual(body, { - host_set_ids: ['123_abc', 'foobar'], - version: 1, - }); - return { id: '123abc' }; - }); + this.server.post( + '/v1/targets/123abc:add-host-sources', + (schema, request) => { + const body = JSON.parse(request.requestBody); + assert.deepEqual(body, { + host_set_ids: ['123_abc', 'foobar'], + version: 1, + }); + return { id: '123abc' }; + } + ); const store = this.owner.lookup('service:store'); store.push({ data: { @@ -109,7 +112,7 @@ module('Unit | Model | target', function (hooks) { test('it has a `removeHostSources` method that targets a specific POST API endpoint and serialization', async function (assert) { assert.expect(1); this.server.post( - '/v1/targets/123abc:remove-host-sets', + '/v1/targets/123abc:remove-host-sources', (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { @@ -146,7 +149,7 @@ module('Unit | Model | target', function (hooks) { test('it has a `removeHostSource` method that deletes a single host set using `removeHostSources` method', async function (assert) { assert.expect(1); this.server.post( - '/v1/targets/123abc:remove-host-sets', + '/v1/targets/123abc:remove-host-sources', (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { diff --git a/ui/admin/app/routes/scopes/scope/targets/target/add-host-sources.js b/ui/admin/app/routes/scopes/scope/targets/target/add-host-sources.js index 44bb07406..cb4f2150c 100644 --- a/ui/admin/app/routes/scopes/scope/targets/target/add-host-sources.js +++ b/ui/admin/app/routes/scopes/scope/targets/target/add-host-sources.js @@ -42,7 +42,7 @@ export default class ScopesScopeTargetsTargetAddHostSourcesRoute extends Route { } /** - * Renders the add-host-sets-specific header template. + * Renders the add-host-sources-specific header template. * @override */ renderTemplate() {