2014-03-02 15:12:06 -05:00
|
|
|
import postFixtures from 'ghost/fixtures/posts';
|
2014-03-11 11:23:32 -05:00
|
|
|
import userFixtures from 'ghost/fixtures/users';
|
|
|
|
|
|
|
|
var response = function (responseBody, status) {
|
|
|
|
status = status || 200;
|
|
|
|
var textStatus = (status === 200) ? 'success' : 'error';
|
2014-03-02 15:12:06 -05:00
|
|
|
|
|
|
|
return {
|
2014-03-11 11:23:32 -05:00
|
|
|
response: responseBody,
|
|
|
|
jqXHR: { status: status },
|
|
|
|
textStatus: textStatus
|
2014-03-02 15:12:06 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-03-11 11:23:32 -05: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-02 15:12:06 -05:00
|
|
|
};
|
|
|
|
|
2014-03-11 11:23:32 -05: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));
|
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/signin', user(status));
|
2014-03-22 21:31:45 -05:00
|
|
|
ic.ajax.defineFixture('/ghost/api/v0.1/users/me/', user(status));
|
|
|
|
ic.ajax.defineFixture('/ghost/changepw/', response({
|
|
|
|
msg: 'Password changed successfully'
|
|
|
|
}));
|
2014-03-03 15:18:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
export default defineFixtures;
|