Fixes #11119: Added check for wacky pet before feeding (#12106)

* Added check for wacky pet before feeding

* added test for feeding wacky pets

* Fixed typo in test for feeding wacky pets

Co-authored-by: Jack Somers <somersjw9@gmail.com>
This commit is contained in:
Jack Somers
2020-04-20 16:17:42 -04:00
committed by GitHub
parent 13123c0bae
commit 6d6adfd919
2 changed files with 13 additions and 1 deletions

View File

@@ -89,6 +89,18 @@ describe('shared.ops.feed', () => {
}
});
it('does not allow feeding of wacky pets', done => {
user.items.pets['Wolf-Veggie'] = 5;
user.items.food.Meat = 1;
try {
feed(user, { params: { pet: 'Wolf-Veggie', food: 'Meat' } });
} catch (err) {
expect(err).to.be.an.instanceof(NotAuthorized);
expect(err.message).to.equal(i18n.t('messageCannotFeedPet'));
done();
}
});
it('does not allow feeding of mounts', done => {
user.items.pets['Wolf-Base'] = -1;
user.items.mounts['Wolf-Base'] = true;

View File

@@ -61,7 +61,7 @@ export default function feed (user, req = {}, analytics) {
throw new NotFound(i18n.t('messageFoodNotFound', req.language));
}
if (pet.type === 'special') {
if (pet.type === 'special' || pet.type === 'wacky') {
throw new NotAuthorized(i18n.t('messageCannotFeedPet', req.language));
}