2019-02-26 06:38:00 +03:00
|
|
|
import {Response} from 'ember-cli-mirage';
|
2017-08-22 10:53:26 +03:00
|
|
|
import {isEmpty} from '@ember/utils';
|
2016-10-28 16:07:50 +03:00
|
|
|
|
2019-02-25 17:47:17 +03:00
|
|
|
export default function mockConfig(server) {
|
2019-02-26 06:38:00 +03:00
|
|
|
server.get('/config/', function ({db}, request) {
|
|
|
|
if (!request.requestHeaders.Authorization) {
|
|
|
|
return new Response(403, {}, {
|
|
|
|
errors: [{
|
|
|
|
type: 'NoPermissionError',
|
|
|
|
message: 'Authorization failed',
|
|
|
|
context: 'Unable to determine the authenticated user or integration. Check that cookies are being passed through if using session authentication.'
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-25 17:47:17 +03:00
|
|
|
if (isEmpty(db.configs)) {
|
|
|
|
server.loadFixtures('configs');
|
2016-10-28 16:07:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2019-02-25 17:47:17 +03:00
|
|
|
config: db.configs.find(1)
|
2016-10-28 16:07:50 +03:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2017-01-02 21:49:44 +03:00
|
|
|
server.get('/configuration/timezones/', function ({db}) {
|
|
|
|
if (isEmpty(db.timezones)) {
|
|
|
|
server.loadFixtures('timezones');
|
|
|
|
}
|
|
|
|
|
2016-10-28 16:07:50 +03:00
|
|
|
return {
|
|
|
|
configuration: [{
|
|
|
|
timezones: db.timezones
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|