Skip to content

Commit 4e84f4f

Browse files
authored
[#4554] ClausePresenter: don't attempt to call #display_label on a non-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.
1 parent c3d3d84 commit 4e84f4f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

app/presenters/orangelight/clause_presenter.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,12 @@ def label
88
super
99
end
1010
end
11+
12+
# We will no longer need to override #field_label when/if we
13+
# use a release of Blacklight that includes
14+
# https://github.com/projectblacklight/blacklight/pull/3442
15+
def field_label
16+
field_config&.display_label('search')
17+
end
1118
end
1219
end

spec/presenters/orangelight/clause_presenter_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,17 @@
1616
expect(subject.label).to eq 'NOT some search string'
1717
end
1818
end
19+
describe '#field_label' do
20+
context 'when the field config does not exist' do
21+
let(:field_config) { nil }
22+
23+
it 'returns nil' do
24+
expect(subject.field_label).to be_nil
25+
end
26+
27+
it 'does not raise an error' do
28+
expect { subject.field_label }.not_to raise_error
29+
end
30+
end
31+
end
1932
end

0 commit comments

Comments
 (0)