mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03: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
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,7 @@ var Promise = require('bluebird'),
|
||||
setup,
|
||||
doAuth,
|
||||
createUser,
|
||||
createPost,
|
||||
login,
|
||||
togglePermalinks,
|
||||
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) {
|
||||
// CASE: by default we use the owner to login
|
||||
if (!request.user) {
|
||||
@ -857,6 +872,7 @@ module.exports = {
|
||||
setup: setup,
|
||||
doAuth: doAuth,
|
||||
createUser: createUser,
|
||||
createPost: createPost,
|
||||
login: login,
|
||||
togglePermalinks: togglePermalinks,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user