Skip to content

fix: preserve custom human_name for both states and events #46

Merged
seuros merged 2 commits intomasterfrom
fix/preserve-custom-human-names
Jun 29, 2025
Merged

fix: preserve custom human_name for both states and events #46
seuros merged 2 commits intomasterfrom
fix/preserve-custom-human-names

Conversation

@seuros
Copy link
Copy Markdown
Member

@seuros seuros commented Jun 29, 2025

No description provided.

@seuros seuros requested a review from Copilot June 29, 2025 18:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where custom human names for states and events were being overwritten by default translations.

  • Added comprehensive tests to ensure custom human names are preserved in various scenarios (states, events, and complex I18n lookups).
  • Updated the ActiveModel integration to use a conditional assignment (||=) for human names and refined block parameter usage and eval markers.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test/state_human_name_test.rb Adds tests to verify that custom state human names are preserved.
test/human_name_preservation_test.rb Adds tests for preserving custom human names using ActiveModel integration.
test/event_human_name_test.rb Adds tests to verify that custom event human names are preserved and prioritized.
lib/state_machines/integrations/active_model.rb Updates integration: uses

- Cherry-picked fix from PR #38 to use ||= instead of = in add_states
- Applied same fix to add_events method to preserve event human names
- Added comprehensive tests for both state and event human_name preservation
- Added regression test specifically for issue #37

This ensures that hard-coded human_name values are not overwritten by
the default translation lambdas when using ActiveModel integration.

Fixes #37
Closes #38
@seuros seuros force-pushed the fix/preserve-custom-human-names branch from ed2c574 to d7a41ba Compare June 29, 2025 20:43
@seuros seuros merged commit 3e19695 into master Jun 29, 2025
14 checks passed
@seuros seuros deleted the fix/preserve-custom-human-names branch June 29, 2025 22:01
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.

3 participants