test: 💍 add tests for adapter and serializer scope options

This commit is contained in:
Randall Morey committed 2020-09-03 14:48:59 -04:00
1 parent bce27df1f4
commit 2eeb73b622
6 files changed
+76 -8

No files matched your search

+2 -3
View File
@@ -41,7 +41,7 @@ function prenormalizeArrayResponse(response) {
export default class ApplicationAdapter extends RESTAdapter.extend(
AdapterBuildURLMixin
) {
// =attributes
/**
@@ -84,7 +84,6 @@ export default class ApplicationAdapter extends RESTAdapter.extend(
*/
urlPrefix(path, parentURL, modelName, id, snapshot) {
const prefix = super.urlPrefix(...arguments);
const isScope = modelName === 'scope';
let scopePath = '';
let scopeID = '';
if (snapshot && this.hasScopePrefix) {
@@ -101,7 +100,7 @@ export default class ApplicationAdapter extends RESTAdapter.extend(
// Only non-scope resources need a scope path, since scope resources
// aren't technically "scoped" the same way.
// Ensure a slash is added between prefix + scope path if needed.
if (!isScope && scopeID && prefix.charAt(prefix.length - 1) !== '/') {
if (scopeID && prefix.charAt(prefix.length - 1) !== '/') {
scopePath = `/scopes/${scopeID}`;
}
return `${prefix}${scopePath}`;
+10
View File
@@ -3,6 +3,16 @@ import { serializeIntoHash } from '@ember-data/adapter/-private';
export default class ScopeAdapter extends ApplicationAdapter {
// =attributes
/**
* Scopes do not include a scope prefix.
* @override
*/
hasScopePrefix = false;
// =methods
/**
* Identical to default method except that we pass a query parameter
* indicating the parent scope.