chore: 🤖 change host source custom methods

This commit is contained in:
Randall Morey committed 2021-09-22 18:52:38 -04:00
1 parent 77420d29c6
commit 4e3a167ef7
4 files changed
+21 -18

No files matched your search

+5 -5
View File
@@ -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}
+2 -2
View File
@@ -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);
+13 -10
View File
@@ -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, {
@@ -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() {