2014-03-03 00:12:06 +04:00
|
|
|
import postFixtures from 'ghost/fixtures/posts';
|
2014-03-11 20:23:32 +04:00
|
|
|
import userFixtures from 'ghost/fixtures/users';
|
2014-03-21 06:55:32 +04:00
|
|
|
import settingsFixtures from 'ghost/fixtures/settings';
|
2014-05-28 10:57:55 +04:00
|
|
|
import appFixtures from 'ghost/fixtures/apps';
|
2014-03-11 20:23:32 +04:00
|
|
|
|
|
|
|
var response = function (responseBody, status) {
|
|
|
|
status = status || 200;
|
|
|
|
var textStatus = (status === 200) ? 'success' : 'error';
|
2014-03-03 00:12:06 +04:00
|
|
|
|
|
|
|
return {
|
2014-03-11 20:23:32 +04:00
|
|
|
response: responseBody,
|
|
|
|
jqXHR: { status: status },
|
|
|
|
textStatus: textStatus
|
2014-03-03 00:12:06 +04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-03-11 20:23:32 +04:00
|
|
|
var user = function (status) {
|
|
|
|
return response(userFixtures.findBy('id', 1), status);
|
|
|
|
};
|
|
|
|
|
|
|
|
var post = function (id, status) {
|
|
|
|
return response(postFixtures.findBy('id', id), status);
|
|
|
|
};
|
|
|
|
|
|
|
|
var posts = function (status) {
|
|
|
|
return response({
|
|
|
|
'posts': postFixtures,
|
|
|
|
'page': 1,
|
|
|
|
'limit': 15,
|
|
|
|
'pages': 1,
|
|
|
|
'total': 2
|
|
|
|
}, status);
|
2014-03-03 00:12:06 +04:00
|
|
|
};
|
|
|
|
|
2014-03-21 06:55:32 +04:00
|
|
|
var settings = function (status) {
|
|
|
|
return response(settingsFixtures, status);
|
|
|
|
};
|
|
|
|
|
2014-05-28 10:57:55 +04:00
|
|
|
var apps = function (status) {
|
|
|
|
return response(appFixtures, status);
|
|
|
|
};
|
|
|
|
|
2014-03-11 20:23:32 +04:00
|
|
|
var defineFixtures = function (status) {
|
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/posts', posts(status));
|
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/posts/1', post(1, status));
|
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/posts/2', post(2, status));
|
2014-04-20 18:48:34 +04:00
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/posts/3', post(3, status));
|
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/posts/4', post(4, status));
|
2014-05-29 19:14:36 +04:00
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/slugs/post/test%20title/', response('generated-slug', status));
|
2014-04-20 18:48:34 +04:00
|
|
|
|
2014-03-23 06:31:45 +04:00
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/users/me/', user(status));
|
|
|
|
ic.ajax.defineFixture('/ghost/changepw/', response({
|
|
|
|
msg: 'Password changed successfully'
|
|
|
|
}));
|
2014-03-26 03:34:30 +04:00
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/forgotten/', response({
|
|
|
|
redirect: '/ghost/signin/'
|
|
|
|
}));
|
2014-03-31 13:57:50 +04:00
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/reset/', response({
|
|
|
|
msg: 'Password changed successfully'
|
|
|
|
}));
|
2014-03-21 06:55:32 +04:00
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/settings/?type=blog,theme,app', settings(status));
|
2014-05-28 10:57:55 +04:00
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/apps', apps(status));
|
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/apps/1', response({
|
|
|
|
response: 'success'
|
|
|
|
}));
|
2014-03-04 00:18:10 +04:00
|
|
|
};
|
|
|
|
|
2014-04-20 18:48:34 +04:00
|
|
|
export default defineFixtures;
|