Skip to content

Commit

Permalink
Fix a regression from 8b658e6 to allow show views to use different i1…
Browse files Browse the repository at this point in the history
…8n'ed labels
  • Loading branch information
cbeer committed Sep 30, 2020
1 parent 6c15f20 commit 312a4ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/components/blacklight/metadata_field_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(field:, layout: nil, show: false)
def label
Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
if @show
@view_context.render_document_show_field_label @field.document, label: @field.label, field: @field.key
@view_context.render_document_show_field_label @field.document, label: @field.label('show'), field: @field.key
else
@view_context.render_index_field_label @field.document, label: @field.label, field: @field.key
end
Expand Down
12 changes: 12 additions & 0 deletions spec/components/blacklight/metadata_field_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,16 @@
it 'renders the field value' do
expect(rendered).to have_selector 'dd.blacklight-field', text: 'Value'
end

context 'from a show view' do
subject(:render) do
render_inline(described_class.new(field: field, show: true))
end

it 'renders the right field label' do
allow(field).to receive(:label).with('show').and_return('custom label')

expect(rendered).to have_selector 'dt.blacklight-field', text: 'custom label'
end
end
end

0 comments on commit 312a4ea

Please sign in to comment.