Skip to content

Update chobble-forms and en14960 gems; fix EN14960 wall height bug; symbolize keys in form configs and locales; standardize locale formatting; refactor session management and improve form validation#207

Merged
stefan-burke merged 19 commits intomainfrom
terragon/update-chobble-forms-en14960-gems
Aug 17, 2025

Conversation

@stefan-burke
Copy link
Copy Markdown
Member

@stefan-burke stefan-burke commented Aug 16, 2025

Summary

  • Upgraded chobble-forms gem from 0.5.6 to 0.7.0
  • Upgraded en14960 gem from 0.2.3 to 0.4.0
  • Updated Rails and related gems to patch version 8.0.2.1
  • Fixed a bug in EN14960.calculate_wall_height where it incorrectly returns an Integer 0 instead of Float 0.0 when platform_height is less than 0.6
  • Added defensive conversions to float for height-related attributes in assessments
  • Changed composite field handling by converting keys to symbols in AssessmentCompletion concern and AssessmentBlockBuilder service
  • Symbolized field and partial keys in form YAML loading in FormConfigurable concern
  • Symbolized keys in validation partial handling in ValidationConfigurable concern
  • Updated multiple locale files to remove unnecessary quotes and standardize formatting
  • Updated test helpers to reflect new wall height message formatting
  • Refactored session management to use session tokens instead of user IDs
  • Added SessionManagement concern to handle session creation and termination
  • Updated controllers (SessionsController, UsersController) to use new session management methods
  • Updated SessionsHelper to use session tokens and handle user sessions securely
  • Changed all form field and partial references to use symbols instead of strings for consistency
  • Improved form YAML and locale loading to symbolize keys and values
  • Added new factory for UserSession and updated specs to test session token based authentication

Changes

Gem Updates

  • Bumped chobble-forms to 0.7.0 and en14960 to 0.4.0 with required runtime dependencies
  • Updated Rails and related gems to 8.0.2.1 for consistency and bug fixes

Bug Fixes

  • Wrapped EN14960.calculate_wall_height call in SafetyStandardsController with rescue for TypeError to handle the gem bug gracefully
  • Return a proper CalculatorResponse with 0.0 value and descriptive breakdown when no walls are required

Code Improvements

  • Converted height and wall height attributes to floats before passing to EN14960 calculators in SlideAssessment and StructureAssessment models
  • Converted length, width, and height attributes to floats in AnchorageAssessment and user height related attributes in UserHeightAssessment before validation calls
  • Changed composite field keys and partial names to symbols in AssessmentCompletion concern and AssessmentBlockBuilder service for consistency
  • Symbolized field and partial keys when loading form YAML in FormConfigurable concern
  • Symbolized partial keys in validation handling in ValidationConfigurable concern
  • Changed ChobbleForms::FieldUtils.form_field_label calls to use symbol arguments instead of strings in helpers, views, and services
  • Refactored session management to use session tokens instead of user IDs
  • Added SessionManagement concern to handle session creation and termination
  • Updated controllers (SessionsController, UsersController) to use new session management methods
  • Updated SessionsHelper to use session tokens and handle user sessions securely
  • Updated test helpers and specs to reflect session token usage and improved security

Locale Updates

  • Standardized locale files by removing unnecessary quotes and aligning formatting for headers, sections, fields, statuses, summaries, compliance, submit buttons, and errors

Test Updates

  • Adjusted safety standards test helpers to expect updated wall height messages reflecting the new 0.0 float value and breakdown text
  • Added factory for UserSession and updated specs for session token authentication

Test plan

  • Verified wall height calculation fallback works when platform height < 0.6
  • Confirmed assessments handle float conversions without errors
  • Ran existing tests with updated gem versions and fixed test expectations
  • Manual UI verification of wall height display messages
  • Verified session management changes with new session token handling
  • Ran updated specs for session and form validation improvements

🌿 Generated by Terry


ℹ️ Tag @terragon-labs to ask questions and address PR feedback

📎 Task: https://www.terragonlabs.com/task/5eb0408b-87d3-468b-82f4-6a3d50ada4bf

stefan-burke and others added 4 commits August 16, 2025 16:15
…ulation

Workaround EN14960 v0.4.0 bug where it returns Integer 0 instead of Float 0.0 when platform_height < 0.6m in build_wall_height_result method. Added rescue for TypeError to return expected response for no walls required scenario. Also updated related tests and adjusted float conversions in slide and structure assessments to ensure consistent numeric types.

Additional changes:
- Updated gem versions in Gemfile.lock
- Fixed symbol conversion in assessment_completion and assessment_block_builder concerns
- Adjusted test expectations for wall height display to match new output format.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
…alues

Removed unnecessary safe navigation operators and default fallback values when converting attributes to float in SlideAssessment model. This simplifies the code as the attributes are expected to be present and numeric.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
… calls

Changed all calls to ChobbleForms::FieldUtils.form_field_label to use symbols instead of strings for model and field arguments. This improves consistency and potentially performance by avoiding repeated string to symbol conversions.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
Removed redundant double quotes from strings in multiple English locale YAML files under config/locales/forms to improve consistency and readability. Added YAML document start markers (---) to these files for proper YAML formatting. Also updated some method signatures in validation_configurable.rb to use Symbol type consistently.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
@stefan-burke stefan-burke changed the title Update chobble-forms and en14960 gems; fix EN14960 wall height bug Update chobble-forms and en14960 gems; fix EN14960 wall height bug; symbolize keys in form configs and locales Aug 16, 2025
- EN14960 v0.4.0 requires Float parameters, not BigDecimal
- Convert all database values (BigDecimal) to Float before passing to EN14960 methods
- Fix test expectations to match Symbol returns from ChobbleForms v0.7.0
- Update validation configurable test to use Symbols for field and partial values

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@stefan-burke stefan-burke changed the title Update chobble-forms and en14960 gems; fix EN14960 wall height bug; symbolize keys in form configs and locales Update chobble-forms and en14960 gems; fix EN14960 wall height bug; symbolize keys in form configs and locales; standardize locale formatting Aug 16, 2025
stefan-burke and others added 8 commits August 16, 2025 20:43
Resolved conflicts by taking main's version for all YAML files and flake.nix
…renders

Refactored the views for inspections, units, and users to use symbol keys (e.g., :photo, :id) instead of string keys (e.g., 'photo', 'id') in calls to render 'shared/table_column'. This improves consistency and aligns with Ruby conventions for keys.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
- Updated inspections controller to include all relevant fields (passed, risk_assessment, photos) for results tab prefill.
- Adjusted results form to exclude :passed field from prefill to avoid duplication.
- Changed chobble-forms gem from local path to versioned gem dependency.

This improves clarity and correctness of data handling in the results tab of inspections.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
@stefan-burke stefan-burke changed the title Update chobble-forms and en14960 gems; fix EN14960 wall height bug; symbolize keys in form configs and locales; standardize locale formatting Update chobble-forms and en14960 gems; fix EN14960 wall height bug; symbolize keys in form configs and locales; standardize locale formatting; refactor session management and improve form validation Aug 17, 2025
@stefan-burke stefan-burke marked this pull request as ready for review August 17, 2025 02:02
@stefan-burke stefan-burke merged commit 1f8b00a into main Aug 17, 2025
16 of 17 checks passed
@stefan-burke stefan-burke deleted the terragon/update-chobble-forms-en14960-gems branch August 17, 2025 02:03
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.

1 participant