-
Notifications
You must be signed in to change notification settings - Fork 244
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
Move the exceptions raised in student.rb to a localization file, and add test coverage for cases where Group and Grouping save return false #7218
Conversation
en: | ||
students: | ||
errors: | ||
group_creation_failure: "Sorry! For some reason, your group could not be created. Please wait a few seconds, then hit refresh to try again. If you come back to this page, you should inform the course instructor." |
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.
From the other localizations files I saw, the text strings were generally one sentence. Also, since the Please wait a few seconds...
part is repeated, would it be better if I extract that into a seperate text? I wasn't sure since they each represent different exceptions
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 also have to still modify the changelog, is New Features and Improvements
the correct section I should add it under
EDIT Pranav suggested to add it under Internal changes
…ithub.com/anubhajoshi01/Markus-Anubha into add-test-coverage-save-fail-student-model
Pull Request Test Coverage Report for Build 10913837694Details
💛 - 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.
@anubhajoshi01 good work. I left one inline comment about the localization strings. Also:
- It's okay for the strings to contain some duplicated text; there's no super elegant want of decomposing locale strings into sub-strings other than just concatenation, and that's not super typical in the MarkUs codebase.
- Please add your name to the list of contributors (see my comment on your other PR).
- When filling out the checklist, make sure not to include a space in
[X]
, otherwise the formatting isn't parsed correctly. - You received a commit from our pre-commit.ci bot. This suggests you haven't set up your pre-commit hooks properly. See this section of the setup guide: https://github.com/MarkUsProject/Wiki/blob/master/Developer-Guide--Set-Up-With-Docker.md#installing-pre-commit-hooks
@@ -0,0 +1,6 @@ | |||
--- | |||
en: |
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.
This change overall is good, but there's a better (existing) location: locales/views/users/en.yml
. There's already a students
key there you can add onto (but the errors
is good).
While you've correctly noted that the text is used in a model method, in general most user-facing strings are put under views
; the exceptions are strings inherent to model the models themselves: class name, attribute names, and validation error messages.
Separately, we already have users
which actually combines messages for all of: users
, roles
, instructors
, students
, tas
. This is more of a historical artifact than anything else.
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.
ohh ok I made the change! out of curiosity, what type of text do the config files in locales/models
store?
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.
@anubhajoshi01 I answered this question in my previous comment. See "the exceptions are..."
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.
sorry, i missed that
86cdd27
to
fbae051
Compare
d77597c
to
5feb5a1
Compare
doc/markus-contributors.txt
Outdated
@@ -212,3 +212,4 @@ Yujin Cho | |||
Yusi Fan | |||
Zachary Munro-Cape | |||
Ziyuan (Jerry) Zhang | |||
Anubha Joshi |
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.
Make sure to respect the existing order of names
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.
ohh sorry, did you mean alphabetical order?
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.
Yes, that's correct
.pre-commit-config.yaml
Outdated
@@ -55,3 +55,6 @@ exclude: vendor | |||
|
|||
ci: | |||
autoupdate_schedule: monthly | |||
|
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.
Do not include this in this branch
b5cae4c
to
b92a873
Compare
ed84755
to
2b01e0b
Compare
for more information, see https://pre-commit.ci
Changelog.md
Outdated
@@ -16,6 +16,8 @@ | |||
- Upgrade Docker environment to use Ruby v3.3 (#7185) | |||
- Upgrade to Rails v7.2 (#7185) | |||
- Manually specify chromedriver port number in Github actions (#7209) | |||
- Move Exception message in student model to a localization file |
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.
@anubhajoshi01 oh I didn't notice this last time, but you should also make sure to add the pull request number here (7218) for both entries. This is the standard practice for this changelog.
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 made the change
Great job, @anubhajoshi01 🎉 |
Proposed Changes
(Describe your changes here. Also describe the motivation for your changes: what problem do they solve, or how do they improve the application or codebase? If this pull request fixes an open issue, use a keyword to link this pull request to the issue.)
Must move the exceptions raised in
student.rb
to a localization file, and add test coverage for the case where Group or Grouping save fail.Type of Change
(Write an
X
or a brief description next to the type or types that best describe your changes.)First, I added a localization file
config/locales/models/students/en.yml
with the text string of the Exceptions raised in when Group or Grouping save fails, and switched to usingI18n
to lookup those strings when raising the exceptionI also added two tests in
student_spec.rb
, where it stubs the Group and Grouping save methods to return false, and ensures that the exception is raised in these cases as expected.Verify new line coverage:
Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]
into a[x]
in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)