diff --git a/addons/api/addon/adapters/application.js b/addons/api/addon/adapters/application.js index 8a072b077..4d3a86b5e 100644 --- a/addons/api/addon/adapters/application.js +++ b/addons/api/addon/adapters/application.js @@ -60,7 +60,7 @@ export default class ApplicationAdapter extends RESTAdapter.extend( /** * Prepends a scope to the URL prefix, if a scope is passed via the - * snapshot's `adapterOptions.scope_id` field. + * snapshot's `adapterOptions.scopeID` field. * @override * @param {string} path * @param {string} parentURL @@ -71,7 +71,7 @@ export default class ApplicationAdapter extends RESTAdapter.extend( */ urlPrefix(path, parentURL, modelName, id, snapshot={}) { const prefix = super.urlPrefix(...arguments); - let scopePath = getWithDefault(snapshot, 'adapterOptions.scope_id', ''); + let scopePath = getWithDefault(snapshot, 'adapterOptions.scopeID', ''); // Ensure a slash is added between prefix + scope path if needed. if (scopePath && prefix.charAt(prefix.length - 1) !== '/') { scopePath = `/${scopePath}`; diff --git a/addons/api/addon/models/base.js b/addons/api/addon/models/base.js index 9b2820a06..a1716da97 100644 --- a/addons/api/addon/models/base.js +++ b/addons/api/addon/models/base.js @@ -44,12 +44,12 @@ export default class BaseModel extends Model { /** * If this model instance has a related scope, the scope's ID will be passed - * via `adapterOptions.scope_id` automatically. End users may optionally + * via `adapterOptions.scopeID` automatically. End users may optionally * pass a custom scope ID to override. * * @example * model.save(); // passes the model's current scope ID - * model.save({adapterOptions: {scope_id: 'global'}}); // override scope ID + * model.save({adapterOptions: {scopeID: 'global'}}); // override scope ID * * End users may specify a _custom method_ via `adapterOptions.method`. * Custom methods are appended to the record's URL by the adapter. @@ -62,8 +62,8 @@ export default class BaseModel extends Model { */ save(options={adapterOptions: {}}) { const scopeID = this.belongsTo('scope').id(); - if (scopeID && !options.adapterOptions.scope_id) { - options.adapterOptions.scope_id = scopeID; + if (scopeID && !options.adapterOptions.scopeID) { + options.adapterOptions.scopeID = scopeID; } return super.save(options); } diff --git a/addons/api/tests/unit/adapters/application-test.js b/addons/api/tests/unit/adapters/application-test.js index 503b75762..b3c59adf3 100644 --- a/addons/api/tests/unit/adapters/application-test.js +++ b/addons/api/tests/unit/adapters/application-test.js @@ -24,15 +24,15 @@ module('Unit | Adapter | application', function (hooks) { assert.equal(adapter.urlPrefix(), config.api.namespace); }); - test('it generates URL prefixes with optional `scope_id` from adapterOptions', function (assert) { + test('it generates URL prefixes with optional `scopeID` from adapterOptions', function (assert) { assert.expect(2); - const scope_id = 'global'; + const scopeID = 'global'; const adapter = this.owner.lookup('adapter:application'); const prefix = adapter.urlPrefix(null, null, null, null, { - adapterOptions: {scope_id} + adapterOptions: {scopeID} }); assert.ok(config.api.namespace); - assert.equal(prefix, `v1/${scope_id}`); + assert.equal(prefix, `v1/${scopeID}`); }); test('it generates correct default URL suffixes', function (assert) { @@ -54,11 +54,11 @@ module('Unit | Adapter | application', function (hooks) { test('it generates correct complete URLs', function (assert) { assert.expect(6); - const scope_id = 'o_1'; + const scopeID = 'o_1'; const method = 'my-custom-method'; const mockSnapshot = { adapterOptions: { - scope_id, + scopeID, method } }; @@ -85,7 +85,7 @@ module('Unit | Adapter | application', function (hooks) { assert.ok(true, 'Scoped resource URL was requested.'); return {items: []}; }); - await store.findAll('group', {adapterOptions: {scope_id: 'p_456'}}); + await store.findAll('group', {adapterOptions: {scopeID: 'p_456'}}); }); test('it rewrites PUT to PATCH, but leaves others unchanged', function (assert) { diff --git a/addons/api/tests/unit/models/base-test.js b/addons/api/tests/unit/models/base-test.js index 066ba456e..516dbf240 100644 --- a/addons/api/tests/unit/models/base-test.js +++ b/addons/api/tests/unit/models/base-test.js @@ -117,17 +117,17 @@ module('Unit | Model | base', function (hooks) { assert.ok(true, 'Correctly scoped create record URL was requested.') return {}; }); - await model.save({adapterOptions: {scope_id: customScopeID}}); + await model.save({adapterOptions: {scopeID: customScopeID}}); this.server.patch('/v1/global/users', () => { assert.ok(true, 'Correctly scoped update record URL was requested.') return {}; }); - await model.save({adapterOptions: {scope_id: customScopeID}}); + await model.save({adapterOptions: {scopeID: customScopeID}}); this.server.delete('/v1/global/users', () => { assert.ok(true, 'Correctly scoped delete record URL was requested.') return {}; }); - await model.destroyRecord({adapterOptions: {scope_id: customScopeID}}); + await model.destroyRecord({adapterOptions: {scopeID: customScopeID}}); }); test('it saves records to a URL with a custom method if requested', async function (assert) {