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

raise error for role API requests with nonexistent sections #6663

Merged
merged 2 commits into from
Jul 8, 2023

Conversation

pretendWhale
Copy link
Contributor

@pretendWhale pretendWhale commented Jul 7, 2023

Motivation and Context

Currently, the roles API allows requests with non-existent or malformed section_name and sets the section to nil. This PR introduces an error message for this case.

Your Changes

Description:
Changed role API controller to raise an error if a section cannot be found based on the section_name parameter.

Type of change (select all that apply):

  • Bug fix (non-breaking change which fixes an issue)

Testing

Tested with the web api, and added tests for creating/updating with an invalid section name.

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.

Pull request to make documentation changes (if applicable)

@coveralls
Copy link
Collaborator

coveralls commented Jul 7, 2023

Pull Request Test Coverage Report for Build 5490571978

  • 34 of 34 (100.0%) changed or added relevant lines in 2 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 91.621%

Files with Coverage Reduction New Missed Lines %
spec/models/course_spec.rb 2 99.21%
Totals Coverage Status
Change from base Build 5478301019: 0.01%
Covered Lines: 37095
Relevant Lines: 39943

💛 - Coveralls

Copy link
Contributor

@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.

@pretendWhale thanks! I realized as I was reviewing this that we do need a way for the user to remove a section from a student, e.g. with section_name: nil. This should be handled differently from either of the cases (1) section_name doesn't correspond to an existing section, and (2) section_name is not present in the params.

@pretendWhale
Copy link
Contributor Author

@david-yz-liu Thanks for the catch, you're totally right!

@david-yz-liu david-yz-liu merged commit b889f32 into MarkUsProject:master Jul 8, 2023
2 checks passed
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.

3 participants