Skip to content
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

Merged
merged 9 commits into from
Dec 18, 2023

Conversation

mimischly7
Copy link
Contributor

@mimischly7 mimischly7 commented Dec 8, 2023

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 new api/sections_controller controller, featuring a new api route responsible for creating and deleting a section.

Your Changes

Description:

  • Created a new api/sections_controller with a destroy and 'create' action.
  • Added 'resources :sections ...' line to the ~/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):

  • New feature (non-breaking change which adds functionality)

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

  • I have performed a self-review of my own code.
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported on Coveralls.
  • I have added tests for my changes.
  • I have updated the Changelog.md file.
  • Link for PR regarding additional API documentation: RESTful API documentation for api/sections_controller actions Wiki#200

Bruce-8 and others added 6 commits December 7, 2023 01:47
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.
@coveralls
Copy link
Collaborator

coveralls commented Dec 8, 2023

Pull Request Test Coverage Report for Build 7236388337

  • 51 of 51 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 91.573%

Totals Coverage Status
Change from base Build 7226755465: 0.01%
Covered Lines: 38590
Relevant Lines: 41520

💛 - Coveralls

@Bruce-8 Bruce-8 removed the request for review from david-yz-liu December 9, 2023 17:32
@mimischly7 mimischly7 changed the title Section Destroy API route Section Create/Destroy API route Dec 10, 2023
Copy link
Collaborator

@david-yz-liu david-yz-liu left a 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.

Bruce-8 and others added 2 commits December 16, 2023 03:30
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.
Copy link
Collaborator

@david-yz-liu david-yz-liu left a 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

@mimischly7
Copy link
Contributor Author

@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

MarkUsProject/Wiki#200

@david-yz-liu david-yz-liu merged commit c7e8433 into MarkUsProject:master Dec 18, 2023
2 checks passed
@david-yz-liu david-yz-liu added this to the v2.4.2 milestone Dec 18, 2023
donny-wong pushed a commit to donny-wong/Markus that referenced this pull request Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants