fix: preserve custom human_name for both states and events #46
Merged
fix: preserve custom human_name for both states and events #46
Conversation
There was a problem hiding this comment.
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
ed2c574 to
d7a41ba
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.
No description provided.