Fix nested emt attribute label humanize#2564
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes how ExtendedMetadataAttribute#label is derived so nested extended metadata attributes correctly prefer an explicitly stored label, while still falling back to a humanized title when no label is set (Issue #2563).
Changes:
- Update
ExtendedMetadataAttribute#labelto read the rawlabelattribute (with.presence) before falling back totitle.humanize. - Add a unit test intended to cover nested-attribute label behavior.
- Refactor parts of
SamplesHelperlinked-extended-metadata rendering (formatting/label usage).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
app/models/extended_metadata_attribute.rb |
Adjusts label lookup to prefer stored attribute value before humanizing title. |
test/unit/extended_metadata_attribute_test.rb |
Adds a test for nested attribute label behavior. |
app/helpers/samples_helper.rb |
Refactors linked extended metadata HTML generation and updates label rendering in some cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+219
to
237
| test 'label prioritizes explicit label over humanized title for nested attributes' do | ||
| nested_type = FactoryBot.create(:role_name_extended_metadata_type) | ||
| nested_attr = nested_type.extended_metadata_attributes.first | ||
|
|
||
| # Verify explicit label is used when set | ||
| original_title = nested_attr.title | ||
| nested_attr.label = 'Custom Label' | ||
| nested_attr.save | ||
| nested_attr.reload | ||
| assert_equal 'Custom Label', nested_attr.label | ||
| assert_equal original_title, nested_attr.title | ||
|
|
||
| # Verify humanized title is used when label is not explicitly set | ||
| nested_attr2 = nested_type.extended_metadata_attributes.last | ||
| nested_attr2.label = nil | ||
| nested_attr2.save | ||
| nested_attr2.reload | ||
| assert_equal nested_attr2.title.humanize, nested_attr2.label | ||
| end |
Comment on lines
51
to
55
| attribute.linked_extended_metadata_type.extended_metadata_attributes.each do |attr| | ||
| attr_element_name = "#{element_name}[#{attr.title}]" | ||
| html += '<div class="form-group"><label>'+attr.label+'</label>' | ||
| html += required_span if attr.required? | ||
| html += "<div class=\"form-group\"><label>#{attr.label}</label>" | ||
| html += required_span if attr.required? | ||
| v = value ? value[attr.title] : nil |
| end | ||
| else | ||
| html += '<label>'+attr.title+'</label>'+' : ' | ||
| html += "<label>#{attr.label}</label> : " |
stuzart
approved these changes
May 14, 2026
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.
#2563