Skip to content

Commit

Permalink
[#4554] ClausePresenter: don't attempt to call #display_label on a no…
Browse files Browse the repository at this point in the history
…n-existant field configuration (#4559)

This fixes an error that appeared when a user specified a search field that
does not exist.  It is essentially the same as upstream fix projectblacklight/blacklight#3442,
so if that is accepted and we start using a Blacklight release that includes
it, we can remove our customized version.
  • Loading branch information
sandbergja authored Nov 11, 2024
1 parent c3d3d84 commit 4e84f4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/presenters/orangelight/clause_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@ def label
super
end
end

# We will no longer need to override #field_label when/if we
# use a release of Blacklight that includes
# /~https://github.com/projectblacklight/blacklight/pull/3442
def field_label
field_config&.display_label('search')
end
end
end
13 changes: 13 additions & 0 deletions spec/presenters/orangelight/clause_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,17 @@
expect(subject.label).to eq 'NOT some search string'
end
end
describe '#field_label' do
context 'when the field config does not exist' do
let(:field_config) { nil }

it 'returns nil' do
expect(subject.field_label).to be_nil
end

it 'does not raise an error' do
expect { subject.field_label }.not_to raise_error
end
end
end
end

0 comments on commit 4e84f4f

Please sign in to comment.