Prevent failing import from file system from deleting assessment files #1945
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Summary generated by Reviewpad on 25 Jul 23 04:32 UTC
This pull request includes three patches.
The first patch (PATCH 1/3) makes changes to the assessments_controller.rb file. It adds a check to ensure that each assessment has an associated yaml file with a name field that matches the filename. It also handles errors when displaying existing assessments.
The second patch (PATCH 2/3) also modifies the assessments_controller.rb file. It updates the comments to clarify the requirements for each assessment's associated yaml file, and it fixes some formatting issues.
The third patch (PATCH 3/3) addresses comments from a previous pull request. It renames the isTarImport parameter to cleanup_on_failure and updates the corresponding code. It also improves error handling and removes unnecessary code.
Overall, these patches enhance the functionality and error handling of the assessments_controller.rb file.
Description
isTarImport
parameter toimportAssessment
to determine whether import is from tarball (aka fromimportAsmtTar
) or from file systeminstall_assessment
to check for invalid name field in yaml to prevent installation of invalid assessment (and thus prevent yaml from getting wiped out, which happens if the error was only caught during deserialization)Motivation and Context
How Has This Been Tested?
name
field to not match filenameRegression:
spec/fixtures/assessments/homework02-yaml-name-field-wrong.tar
), and try importing itbundle exec rake spec
multiple times and see that tests passTypes of changes
Checklist:
overcommit --install && overcommit --sign
to use pre-commit hook for linting