1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/mirage/config/themes.js
Kevin Ansfield 4a604ce64f Update code to match eslint rules
no issue
- switch `jscs` and `jshint` inline config to `eslint` config
- fix eslint errors, predominantly in tests where the config now the main app config more closely
2016-11-14 13:26:00 +00:00

42 lines
1.2 KiB
JavaScript

import Mirage from 'ember-cli-mirage';
let themeCount = 1;
export default function mockThemes(server) {
server.post('/themes/upload/', function (db) {
let [availableThemes] = db.settings.where({key: 'availableThemes'});
// pretender/mirage doesn't currently process FormData so we can't use
// any info passed in through the request
let theme = {
name: `test-${themeCount}`,
package: {
name: `Test ${themeCount}`,
version: '0.1'
},
active: false
};
themeCount++;
availableThemes.value.pushObject(theme);
db.settings.remove({key: 'availableThemes'});
db.settings.insert(availableThemes);
return {
themes: [theme]
};
});
server.del('/themes/:theme/', function (db, request) {
let [availableThemes] = db.settings.where({key: 'availableThemes'});
availableThemes.value = availableThemes.value.filter((theme) => {
return theme.name !== request.params.theme;
});
db.settings.remove({key: 'availableThemes'});
db.settings.insert(availableThemes);
return new Mirage.Response(204, {}, null);
});
}