-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#168781705 - Edit trip request #34
Conversation
7553bf1
to
7dadd80
Compare
ee4873f
to
fdfb06b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Job @ngireric123 . Kindly make your error messages descriptive to tell the user what exactly they are doing it wrong. Also, make a validation for the params id because when I pass an incorrect id format the app breaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @ngireric123 so far. It was a long road.
However, I suggest you have more descriptive error messages.
eg: You are not the owner of this request-id,
or for destinations' id => You are not the owner of this destination id.
In short, more descriptive messages.
Kindly make sure you test your feature extensively, why has the test coverage dropped by 2.5%?
Thanks
- added test - validation [finishes #168781705]
fdfb06b
to
a86dc9b
Compare
src/middlewares/inputValidation.js
Outdated
@@ -3,6 +3,7 @@ import models from '../database/models'; | |||
import responseError from '../utils/responseError'; | |||
import strings from '../utils/stringsUtil'; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line
static validateRequest(req, res, next) { | ||
const data = req.body; | ||
let minimumItems = 1; | ||
let maximumItems = 30; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an empty line
let maximumItems = 30; | ||
if (data.typeId === 1 || data.typeId === 2) { | ||
maximumItems = 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an empty line
} | ||
if (data.typeId === 3) { | ||
minimumItems = 2; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line
src/middlewares/request.js
Outdated
async selectPending(req, res, next) { | ||
const userId = req.user.payload.id; | ||
const id = parseInt(req.params.id, 10); | ||
const requester = await requests.findOne({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you are finding a request, not a requester. Create a helper function for this query.
src/middlewares/request.js
Outdated
|
||
async validateBody(req, res, next) { | ||
const { id } = req.params; | ||
const destination = req.body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using this cont anywhere? If not remove it.
src/middlewares/request.js
Outdated
}).then(destination => { | ||
if (!destination) { | ||
return responseError(res, 403, `Destination of id ${element.id} does not belong to this request`); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ngireric123 good job on the implementation however kindly work on the feedback below.
- Test
validateRequest.js
function to increase coverage. - Ensure that a user can edit a return date
- Go through the comments I have left on your pr
- squash commit [finishes #168781705]
a86dc9b
to
66706f4
Compare
What does this PR do?
Update trip request
Description of Task to be completed?
How should this be manually tested?
npm install
sequelize db:migrate
sequelize db:seed:all
npm run dev
- To Search Requests
Send a PATCH request to
http://localhost:port/api/v1/requests/:ID
Postman body example
Any background context you want to provide?
N/A
What are the relevant pivotal tracker stories?
#168781705
Screenshots (if appropriate)
Questions: