Skip to content

Commit

Permalink
Merge pull request #71 from andela/bg-fixing-bug-170307885
Browse files Browse the repository at this point in the history
#170307885 Fix bug about Like and Dislike
  • Loading branch information
shemaeric committed Feb 4, 2020
2 parents 5cd1b52 + ca98b30 commit fead4c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/middlewares/Validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ class Validate {
const MaxDate = new Date(year + 20, month, day).toDateString();
return [
check('tripTypeId', 'trip type id should be an integer(1: One-way, 2: two-way, 3: Multi-city)').isInt(),
check('user', 'user should be identified by id of integer type').isInt().optional(),
check('from', 'To date should be valid(YYYY-MM-DD)').isBefore(MaxDate),
check('to', 'End date should be valid(YYYY-MM-DD)').isBefore(MaxDate),
];
Expand Down
4 changes: 4 additions & 0 deletions src/services/AccommodationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ class AccommodationService {
setObject = { disliked: true, liked: false };
displayMessage = 'You disliked this accommodation!';
}
if (like && !liked && disliked) {
setObject = { disliked: false, liked: true };
displayMessage = 'You liked this accommodation!';
}
if (!liked && !disliked) {
setObject = { liked: like, disliked: !like };
displayMessage = like ? 'You liked this accommodation!' : 'You disliked this accommodation!';
Expand Down
4 changes: 2 additions & 2 deletions src/tests/060-tripTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,8 @@ describe('User stats for trips in X timeframe', () => {
.get('/api/v1/trips/stats/2?from=2020-01-01&to=2025-12-30&user=b')
.set('token', managerToken)
.end((err, res) => {
expect(res.status).eql(500);
expect(res.body).to.have.property('message', 'invalid input syntax for integer: "b"');
expect(res.status).eql(400);
expect(res.body.message).eql(['user should be identified by id of integer type']);
done(err);
});
});
Expand Down

0 comments on commit fead4c1

Please sign in to comment.