fix tests

v1.18.x
barisusakli 8 years ago
parent 827e4b4ffd
commit 190b3759a0

@ -7,7 +7,7 @@ define('forum/topic/move-post', [], function () {
var MovePost = {}; var MovePost = {};
MovePost.openMovePostModal = function(button) { MovePost.openMovePostModal = function (button) {
app.parseAndTranslate('partials/move_post_modal', {}, function (html) { app.parseAndTranslate('partials/move_post_modal', {}, function (html) {
var moveModal = $(html); var moveModal = $(html);

@ -13,91 +13,83 @@ var accountHelpers = require('./helpers');
var postsController = {}; var postsController = {};
postsController.getBookmarks = function (req, res, next) { var templateToData = {
var data = { 'account/bookmarks': {
template: 'account/bookmarks',
set: 'bookmarks', set: 'bookmarks',
type: 'posts', type: 'posts',
noItemsFoundKey: '[[topic:bookmarks.has_no_bookmarks]]', noItemsFoundKey: '[[topic:bookmarks.has_no_bookmarks]]',
method: posts.getPostSummariesFromSet,
crumb: '[[user:bookmarks]]' crumb: '[[user:bookmarks]]'
}; },
getFromUserSet(data, req, res, next); 'account/posts': {
};
postsController.getPosts = function (req, res, next) {
var data = {
template: 'account/posts',
set: 'posts', set: 'posts',
type: 'posts', type: 'posts',
noItemsFoundKey: '[[user:has_no_posts]]', noItemsFoundKey: '[[user:has_no_posts]]',
method: posts.getPostSummariesFromSet,
crumb: '[[global:posts]]' crumb: '[[global:posts]]'
}; },
getFromUserSet(data, req, res, next); 'account/upvoted': {
};
postsController.getUpVotedPosts = function (req, res, next) {
var data = {
template: 'account/upvoted',
set: 'upvote', set: 'upvote',
type: 'posts', type: 'posts',
noItemsFoundKey: '[[user:has_no_upvoted_posts]]', noItemsFoundKey: '[[user:has_no_upvoted_posts]]',
method: posts.getPostSummariesFromSet,
crumb: '[[global:upvoted]]' crumb: '[[global:upvoted]]'
}; },
getFromUserSet(data, req, res, next); 'account/downvoted': {
};
postsController.getDownVotedPosts = function (req, res, next) {
var data = {
template: 'account/downvoted',
set: 'downvote', set: 'downvote',
type: 'posts', type: 'posts',
noItemsFoundKey: '[[user:has_no_downvoted_posts]]', noItemsFoundKey: '[[user:has_no_downvoted_posts]]',
method: posts.getPostSummariesFromSet,
crumb: '[[global:downvoted]]' crumb: '[[global:downvoted]]'
}; },
getFromUserSet(data, req, res, next); 'account/best': {
};
postsController.getBestPosts = function (req, res, next) {
var data = {
template: 'account/best',
set: 'posts:votes', set: 'posts:votes',
type: 'posts', type: 'posts',
noItemsFoundKey: '[[user:has_no_voted_posts]]', noItemsFoundKey: '[[user:has_no_voted_posts]]',
method: posts.getPostSummariesFromSet,
crumb: '[[global:best]]' crumb: '[[global:best]]'
}; },
getFromUserSet(data, req, res, next); 'account/watched': {
};
postsController.getWatchedTopics = function (req, res, next) {
var data = {
template: 'account/watched',
set: 'followed_tids', set: 'followed_tids',
type: 'topics', type: 'topics',
noItemsFoundKey: '[[user:has_no_watched_topics]]', noItemsFoundKey: '[[user:has_no_watched_topics]]',
method: topics.getTopicsFromSet,
crumb: '[[user:watched]]' crumb: '[[user:watched]]'
}; },
getFromUserSet(data, req, res, next); 'account/topics': {
};
postsController.getTopics = function (req, res, next) {
var data = {
template: 'account/topics',
set: 'topics', set: 'topics',
type: 'topics', type: 'topics',
noItemsFoundKey: '[[user:has_no_topics]]', noItemsFoundKey: '[[user:has_no_topics]]',
method: topics.getTopicsFromSet,
crumb: '[[global:topics]]' crumb: '[[global:topics]]'
}; }
getFromUserSet(data, req, res, next); };
postsController.getBookmarks = function (req, res, next) {
getFromUserSet('account/bookmarks', req, res, next);
};
postsController.getPosts = function (req, res, next) {
getFromUserSet('account/posts', req, res, next);
};
postsController.getUpVotedPosts = function (req, res, next) {
getFromUserSet('account/upvoted', req, res, next);
};
postsController.getDownVotedPosts = function (req, res, next) {
getFromUserSet('account/downvoted', req, res, next);
};
postsController.getBestPosts = function (req, res, next) {
getFromUserSet('account/best', req, res, next);
};
postsController.getWatchedTopics = function (req, res, next) {
getFromUserSet('account/watched', req, res, next);
};
postsController.getTopics = function (req, res, next) {
getFromUserSet('account/topics', req, res, next);
}; };
function getFromUserSet(data, req, res, callback) { function getFromUserSet(template, req, res, callback) {
var data = templateToData[template];
data.template = template;
data.method = data.type === 'posts' ? posts.getPostSummariesFromSet : topics.getTopicsFromSet;
var userData; var userData;
var itemsPerPage; var itemsPerPage;
var page = Math.max(1, parseInt(req.query.page, 10) || 1); var page = Math.max(1, parseInt(req.query.page, 10) || 1);

Loading…
Cancel
Save