CSUMB-SP17-CST499 / Group-Assignment-Tool

0 stars 3 forks source link

Update employee roles using api #105

Closed eliasargandara closed 7 years ago

eliasargandara commented 7 years ago

Description: I added code to be able to add roles to an employee by sending a list of role ids with our API. Using this new change, I also updated the add employee page to be able to add employees to the app with a role that is chosen from a drop-down menu. I had to change some things in our database model relationships to do this. I also updated the database schema.

Test Plan: To test things work, make sure the view pages for the employee and roles work (that they display the roles and employees in the database). Also, check that adding an employee from the employee/add page works.

The other part of the test plan is testing the API works. With curl, we can specify values for the request headers, data payload, the request method, and the url to request information from. The header should have a content type of JSON. The request method depends on which URL you are trying to request from. The data payload depends on what data the api expects to receive.

curl --header 'Content-Type: application/json' https://assistive-permissions-manager-gand4052.c9users.io/api/employees -X GET

curl --header 'Content-Type: application/json' https://assistive-permissions-manager-gand4052.c9users.io/api/employee -X GET --data '{"id":1}'

curl --header 'Content-Type: application/json' https://assistive-permissions-manager-gand4052.c9users.io/api/employee -X DELETE --data '{"id": 1}'

curl --header 'Content-Type: application/json' https://assistive-permissions-manager-gand4052.c9users.io/api/employee -X PUT --data '{"first_name": "Test", "last_name": "Test", "email": "test@email.com"}'

These test only include endpoints for employees, but you can test the other ones. They are located in the views folder of the project's root directory.