Update RR settings to support string-based date ranges#158
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances ResourceRegistry::Setting to automatically convert supported string-based date ranges into Range<Date> objects and adds corresponding specs.
- Override
itemaccessor to normalize date-range strings - Implement
convert_range_strings,looks_like_date?, andparse_datehelpers - Add RSpec tests covering various date-range and non–date-range scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| spec/resource_registry/setting_spec.rb | Added tests for parsing and preserving different item values |
| lib/resource_registry/setting.rb | Overrode item and added string-to-date-range conversion logic |
Comments suppressed due to low confidence (2)
lib/resource_registry/setting.rb:47
- [nitpick] Returning
nilfor partially parsed date ranges may introduce unexpected nil values downstream. Consider returning the original string or raising a descriptive error to make failures explicit.
return nil
spec/resource_registry/setting_spec.rb:87
- [nitpick] The test description says it returns
nilfor non-date ranges, but the expectation asserts the original string. Update the description to reflect that it returns the original string.
it "returns nil for non-date ranges" do
b282ece to
f9bec13
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR enhances the ResourceRegistry::Setting class to support string-based date ranges in item attribute.
ERROR:
SOLUTION:
Centralized the fix in the correct place (ResourceRegistry::Setting)
Automatically handle "MM/DD/YYYY..MM/DD/YYYY" and "YYYY-MM-DD..YYYY-MM-DD" formats
This update overrides the item method in ResourceRegistry::Setting to normalize string-based date ranges.
If the item value is a String in the format "MM/DD/YYYY..MM/DD/YYYY" or "YYYY-MM-DD..YYYY-MM-DD", it is parsed and converted into a proper Range
This change maintains backward compatibility && requires no updates on Enroll.
TESTING:
Tested this change on ENROLL with branch - fix_trunk_failures_7_1_2025.
No rspec errors related to cover? Date string