fix: preserve decimal hours in activity create and update#352
Open
bmortimer wants to merge 3 commits intonavapbc:mainfrom
Open
fix: preserve decimal hours in activity create and update#352bmortimer wants to merge 3 commits intonavapbc:mainfrom
bmortimer wants to merge 3 commits intonavapbc:mainfrom
Conversation
Change .to_i to .to_f in activity_attributes_from_params to prevent silent truncation of decimal hour values (e.g., 5.25 → 5, 3.5 → 3). Adds test coverage for decimal hours on both create and update paths. Co-Authored-By: Claude <noreply@anthropic.com>
nkutub
approved these changes
Mar 18, 2026
Author
|
@nkutub Anything I need to be doing to adjust my PR or is this just a pure CI/CD pipeline thing that I let y'all work out? |
Contributor
Your PR is good, we are investigating the pipeline issues.. once they clear we can merge |
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.
Change .to_i to .to_f in activity_attributes_from_params to prevent silent truncation of decimal hour values (e.g., 5.25 → 5, 3.5 → 3).
Adds test coverage for decimal hours on both create and update paths.
Ticket
Resolves #350
Changes
activities_controller.rbline 157: change.to_ito.to_finactivity_attributes_from_paramsactivities_spec.rb: add two tests — decimal hours preserved on create (5.25) and update (3.5)Context for reviewers
Both
createandupdatecall the sharedactivity_attributes_from_paramsmethod which was converting hours with.to_i. The database column isdecimal, the model declaresstrata_attribute :hours, :decimal, and the input field usesinputmode: "decimal"so decimal support appears to be intended at every other layer..to_fis consistent with how hours are handled elsewhere in the codebase.No change to income handling — the existing
.to_i * 100for dollar-to-cents conversion appears correct.Testing
Full test suite passes (1489 examples, 0 failures):
bundle exec rspec --exclude-pattern '**/image_to_pdf*'
1489 examples, 0 failures, 1 pending
New test cases:
.to_freturns 0.0 for invalid input, letting model validationhandle the error)