Skip to content

Commit

Permalink
fix show label in metadatadocument
Browse files Browse the repository at this point in the history
  • Loading branch information
dnoneill committed Sep 4, 2024
1 parent 69373f2 commit 5f422fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/components/blacklight/document_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def classes
def before_render
set_slot(:title, nil) unless title
set_slot(:thumbnail, nil) unless thumbnail || show?
set_slot(:metadata, nil, fields: presenter.field_presenters) unless metadata
set_slot(:metadata, nil, fields: presenter.field_presenters, show: @show) unless metadata
set_slot(:embed, nil) unless embed
if view_partials.present?
view_partials.each do |view_partial|
Expand Down
20 changes: 20 additions & 0 deletions spec/components/blacklight/document_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ def call
expect(rendered).to have_content 'embed'
end

context 'show view with custom translation' do
let!(:original_translations) { I18n.backend.send(:translations).deep_dup }

before do
controller.action_name = "show"
I18n.backend.store_translations(:en, blacklight: { search: { show: { label: "testing:%{label}" } } })
end

after do
I18n.backend.reload!
I18n.backend.store_translations(:en, original_translations[:en])
end

it 'renders with show-specific metadata with correct translation' do
expect(rendered).to have_css 'dl.document-metadata'
expect(rendered).to have_css 'dt', text: 'testing:ISBN'
expect(rendered).to have_css 'dd', text: 'Value'
end
end

context 'with configured metadata component' do
let(:custom_component_class) do
Class.new(Blacklight::DocumentMetadataComponent) do
Expand Down

0 comments on commit 5f422fa

Please sign in to comment.