mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added role-specifics to post API tests (#9058)
refs #9043 - this is preparation for adding Author-specific tests later - the changes the posts_spec.js, so that all the tests are inside an "As Owner" describe block, similar to the users_spec.js - Added new util for creating a specific post - This will make it easier to do routing tests on the post model in future - Our `index.js` file in test/utils really needs a bit of love 🙈 - Also added all the framework for author role tests in post_spec.js - Added a single test, showing we can edit posts, including author_id
This commit is contained in:
parent
af01f51204
commit
f280fbcaaf
2 changed files with 1366 additions and 1219 deletions
File diff suppressed because it is too large
Load diff
|
@ -40,6 +40,7 @@ var Promise = require('bluebird'),
|
||||||
setup,
|
setup,
|
||||||
doAuth,
|
doAuth,
|
||||||
createUser,
|
createUser,
|
||||||
|
createPost,
|
||||||
login,
|
login,
|
||||||
togglePermalinks,
|
togglePermalinks,
|
||||||
startGhost,
|
startGhost,
|
||||||
|
@ -679,6 +680,20 @@ createUser = function createUser(options) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
createPost = function createPost(options) {
|
||||||
|
var post = DataGenerator.forKnex.createPost(options.post);
|
||||||
|
|
||||||
|
if (options.author) {
|
||||||
|
post.author_id = options.author.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return db.knex('posts')
|
||||||
|
.insert(post)
|
||||||
|
.then(function () {
|
||||||
|
return post;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
login = function login(request) {
|
login = function login(request) {
|
||||||
// CASE: by default we use the owner to login
|
// CASE: by default we use the owner to login
|
||||||
if (!request.user) {
|
if (!request.user) {
|
||||||
|
@ -857,6 +872,7 @@ module.exports = {
|
||||||
setup: setup,
|
setup: setup,
|
||||||
doAuth: doAuth,
|
doAuth: doAuth,
|
||||||
createUser: createUser,
|
createUser: createUser,
|
||||||
|
createPost: createPost,
|
||||||
login: login,
|
login: login,
|
||||||
togglePermalinks: togglePermalinks,
|
togglePermalinks: togglePermalinks,
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue