Update tests to assert against translation strings
This commit is contained in:
@@ -143,7 +143,7 @@ api.get = function(req, res, next) {
|
||||
q.exec(function(err, group){
|
||||
if (err) return next(err);
|
||||
if(!group){
|
||||
if(gid !== 'party') return res.json(404,{err: "Group not found or you don't have access."});
|
||||
if(gid !== 'party') return res.json(404,{err: shared.i18n.t('messageGroupNotFound')});
|
||||
|
||||
// Don't send a 404 when querying for a party even if it doesn't exist
|
||||
// so that users with no party don't get a 404 on every access to the site
|
||||
@@ -184,7 +184,7 @@ api.create = function(req, res, next) {
|
||||
group.leader = user._id;
|
||||
|
||||
if(group.type === 'guild'){
|
||||
if(user.balance < 1) return res.json(401, {err: 'Not enough gems!'});
|
||||
if(user.balance < 1) return res.json(401, {err: shared.i18n.t('messageInsufficientGems')});
|
||||
|
||||
group.balance = 1;
|
||||
user.balance--;
|
||||
@@ -209,7 +209,7 @@ api.create = function(req, res, next) {
|
||||
Group.findOne({type:'party',members:{$in:[user._id]}},cb);
|
||||
},
|
||||
function(found, cb){
|
||||
if (found) return cb('Already in a party, try refreshing.');
|
||||
if (found) return cb(shared.i18n.t('messageGroupAlreadyInParty'));
|
||||
group.save(cb);
|
||||
},
|
||||
function(saved, count, cb){
|
||||
@@ -218,7 +218,7 @@ api.create = function(req, res, next) {
|
||||
saved.populate('members', nameFields, cb);
|
||||
}
|
||||
], function(err, populated){
|
||||
if (err == 'Already in a party, try refreshing.') return res.json(400,{err:err});
|
||||
if (err === shared.i18n.t('messageGroupAlreadyInParty')) return res.json(400,{err:err});
|
||||
if (err) return next(err);
|
||||
group = user = null;
|
||||
return res.json(populated);
|
||||
@@ -231,7 +231,7 @@ api.update = function(req, res, next) {
|
||||
var user = res.locals.user;
|
||||
|
||||
if(group.leader !== user._id)
|
||||
return res.json(401, {err: "Only the group leader can update the group!"});
|
||||
return res.json(401, {err: shared.i18n.t('messageGroupOnlyLeaderCanUpdate')});
|
||||
|
||||
'name description logo logo leaderMessage leader leaderOnly'.split(' ').forEach(function(attr){
|
||||
group[attr] = req.body[attr];
|
||||
@@ -251,7 +251,7 @@ api.attachGroup = function(req, res, next) {
|
||||
var q = (gid == 'party') ? Group.findOne({type: 'party', members: {'$in': [res.locals.user._id]}}) : Group.findById(gid);
|
||||
q.exec(function(err, group){
|
||||
if(err) return next(err);
|
||||
if(!group) return res.json(404, {err: "Group not found"});
|
||||
if(!group) return res.json(404, {err: shared.i18n.t('messageGroupNotFound')});
|
||||
res.locals.group = group;
|
||||
next();
|
||||
});
|
||||
@@ -270,7 +270,7 @@ api.getChat = function(req, res, next) {
|
||||
populateQuery(gid, q);
|
||||
q.exec(function(err, group){
|
||||
if (err) return next(err);
|
||||
if (!group && gid!=='party') return res.json(404,{err: "Group not found or you don't have access."});
|
||||
if (!group && gid!=='party') return res.json(404,{err: shared.i18n.t('messageGroupNotFound')});
|
||||
res.json(res.locals.group.chat);
|
||||
gid = null;
|
||||
});
|
||||
@@ -470,7 +470,7 @@ api.join = function(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!isUserInvited) return res.json(401, {err: "Can't join a group you're not invited to."});
|
||||
if(!isUserInvited) return res.json(401, {err: shared.i18n.t('messageGroupRequiresInvite')});
|
||||
|
||||
if (!_.contains(group.members, user._id)){
|
||||
if (group.members.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user