-
Notifications
You must be signed in to change notification settings - Fork 246
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
Section Create/Destroy API route #6873
Section Create/Destroy API route #6873
Conversation
Added a new api route for 'deleting' a section. This included creating a new sections_controller in the api sub-package, and specifying 'resources' line to the ~/config/routes.rb file (in the appropriate location so that the new api URI's look like .../courses/.../sections/...). I also created a new rspec_test testing the functionality of this new API route, e.g. for authorized vs unauthorized attempts.
Pull Request Test Coverage Report for Build 7236388337
💛 - Coveralls |
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.
@mimischly7 @Bruce-8 good work. I left one inline comment. In addition to that, the Coveralls report suggests the need for an additional test case for the #delete
route.
Added a rspec test for when an (authorized) instructor attempts to delete/destroy a 'non-empty' section (i.e. one that still has students). Includes slight correction in the controller for returning status codes. I used the :conflict status code for this scenario.
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.
@mimischly7 @Bruce-8 sorry one more thing, can you please make a PR to update the Wiki API page: https://github.com/MarkUsProject/Wiki/blob/master/RESTful-API.md
|
Co-authored-by: Bruce Liu <[email protected]>
Motivation and Context
Currently, most models are associated with two different controllers, one "main" controller responsible for "business logic", and one api-controller mostly responsible for CRUD operations (on that model). The
Section
model does not yet adhere to this pattern, hence this pull request, which includes a newapi/sections_controller
controller, featuring a new api route responsible for creating and deleting a section.Your Changes
Description:
api/sections_controller
with adestroy
and 'create' action.~/config/routes.rb
file (in the appropriate location so that the new api URI's have the appropriate nested format, i.e. .../courses/.../sections/...).Type of change (select all that apply):
Testing
Created a new rspec file (
api/sections_controller_spec.rb
) to test the functionality of this new API route, for authorized and unauthorized attempts.Questions and Comments (if applicable)
Checklist