2017-01-02 21:49:44 +03:00
|
|
|
import {Response} from 'ember-cli-mirage';
|
2016-08-23 17:27:46 +03:00
|
|
|
|
2016-08-17 18:01:46 +03:00
|
|
|
let themeCount = 1;
|
|
|
|
|
|
|
|
export default function mockThemes(server) {
|
2017-02-21 21:28:44 +03:00
|
|
|
server.get('/themes');
|
|
|
|
|
|
|
|
server.post('/themes/upload/', function ({themes}) {
|
2016-08-17 18:01:46 +03:00
|
|
|
// 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'
|
2017-02-21 21:28:44 +03:00
|
|
|
}
|
2016-08-17 18:01:46 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
themeCount++;
|
|
|
|
|
2017-02-21 21:28:44 +03:00
|
|
|
theme = themes.create(theme);
|
2016-08-17 18:01:46 +03:00
|
|
|
|
|
|
|
return {
|
|
|
|
themes: [theme]
|
|
|
|
};
|
|
|
|
});
|
2016-08-23 17:27:46 +03:00
|
|
|
|
2017-02-21 21:28:44 +03:00
|
|
|
server.del('/themes/:theme/', function ({themes}, {params}) {
|
|
|
|
themes.findBy({name: params.theme}).destroy();
|
2016-08-23 17:27:46 +03:00
|
|
|
|
2017-01-02 21:49:44 +03:00
|
|
|
return new Response(204, {}, null);
|
2016-08-23 17:27:46 +03:00
|
|
|
});
|
2017-03-03 18:31:42 +03:00
|
|
|
|
|
|
|
server.put('/themes/:theme/activate/', function ({themes}, {params}) {
|
|
|
|
themes.all().update('active', false);
|
|
|
|
themes.findBy({name: params.theme}).update({active: true});
|
|
|
|
|
|
|
|
return themes.all();
|
|
|
|
});
|
2016-08-17 18:01:46 +03:00
|
|
|
}
|