Skip to content

Fix nested emt attribute label humanize#2564

Merged
whomingbird merged 5 commits into
seek-1.18from
fix-nested-emt-attribute-label-humanize
May 15, 2026
Merged

Fix nested emt attribute label humanize#2564
whomingbird merged 5 commits into
seek-1.18from
fix-nested-emt-attribute-label-humanize

Conversation

@whomingbird
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

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

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#label to read the raw label attribute (with .presence) before falling back to title.humanize.
  • Add a unit test intended to cover nested-attribute label behavior.
  • Refactor parts of SamplesHelper linked-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
Comment thread app/helpers/samples_helper.rb Outdated
end
else
html += '<label>'+attr.title+'</label>'+' : '
html += "<label>#{attr.label}</label> : "
@stuzart stuzart added this to the 1.18.0 milestone May 11, 2026
@stuzart stuzart moved this to In review in SEEK 1.18.x May 11, 2026
@stuzart stuzart changed the base branch from main to seek-1.18 May 13, 2026 13:58
@whomingbird whomingbird merged commit 735aba7 into seek-1.18 May 15, 2026
24 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in SEEK 1.18.x May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants