Merge branch 'main' into feature-api-modeling-managed-groups
This commit is contained in:
16 files changed
+94
-57
No files matched your search
@@ -2,7 +2,7 @@ import RESTAdapter from '@ember-data/adapter/rest';
|
||||
import { serializeIntoHash } from '@ember-data/adapter/-private';
|
||||
/* eslint-disable-next-line ember/no-mixins */
|
||||
import AdapterBuildURLMixin from '../mixins/adapter-build-url';
|
||||
import config from 'ember-get-config';
|
||||
import { getOwner } from '@ember/application';
|
||||
import { get } from '@ember/object';
|
||||
import { InvalidError } from '@ember-data/adapter/error';
|
||||
import { dasherize } from '@ember/string';
|
||||
@@ -44,19 +44,36 @@ export default class ApplicationAdapter extends RESTAdapter.extend(
|
||||
) {
|
||||
// =attributes
|
||||
|
||||
#host;
|
||||
#namespace;
|
||||
|
||||
/**
|
||||
* Sets host to the `api.host` string in the application's config,
|
||||
* if set.
|
||||
* @type {string}
|
||||
*/
|
||||
host = get(config, 'api.host');
|
||||
get host() {
|
||||
const config = getOwner(this).resolveRegistration('config:environment');
|
||||
return this.#host || get(config, 'api.host');
|
||||
}
|
||||
set host(value) {
|
||||
// Setting this value is useful for testing purposes.
|
||||
this.#host = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets namespace to the `api.namespace` string in the application's config,
|
||||
* if set.
|
||||
* @type {string}
|
||||
*/
|
||||
namespace = get(config, 'api.namespace');
|
||||
get namespace() {
|
||||
const config = getOwner(this).resolveRegistration('config:environment');
|
||||
return this.#namespace || get(config, 'api.namespace');
|
||||
}
|
||||
set namespace(value) {
|
||||
// Setting this value is useful for testing purposes.
|
||||
this.#namespace = value;
|
||||
}
|
||||
|
||||
// =methods
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import makeBooleanFilter from './helpers/bexpr-filter';
|
||||
const isTesting = config.environment === 'test';
|
||||
|
||||
export default function () {
|
||||
initializeMockIPC(this);
|
||||
initializeMockIPC(this, config);
|
||||
|
||||
// make this `http://localhost:8080`, for example, if your API is on a different server
|
||||
// this.urlPrefix = '';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import config from 'ember-get-config';
|
||||
import { datatype } from 'faker';
|
||||
|
||||
const isTesting = config.environment === 'test';
|
||||
export default function initializeMockIPC(server, config) {
|
||||
const isTesting = config.environment === 'test';
|
||||
|
||||
export default function initializeMockIPC(server) {
|
||||
/**
|
||||
* We strive to make this application runnable in a regular web browser, since
|
||||
* it is a convenient environment for development and testing. But only an
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
"ember-copy": "^2.0.1",
|
||||
"ember-disable-prototype-extensions": "^1.1.3",
|
||||
"ember-export-application-global": "^2.0.1",
|
||||
"ember-get-config": "^0.3.0",
|
||||
"ember-load-initializers": "^2.1.2",
|
||||
"ember-maybe-import-regenerator": "^1.0.0",
|
||||
"ember-page-title": "^6.2.2",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import config from 'ember-get-config';
|
||||
import RESTAdapter from '@ember-data/adapter/rest';
|
||||
import { InvalidError } from '@ember-data/adapter/error';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
@@ -10,6 +9,12 @@ module('Unit | Adapter | application', function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let config;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
config = this.owner.resolveRegistration('config:environment');
|
||||
});
|
||||
|
||||
test('its namespace is equal to the configured namespace', function (assert) {
|
||||
assert.expect(2);
|
||||
const adapter = this.owner.lookup('adapter:application');
|
||||
|
||||
Reference in new issue
Block a user