Skip to content

Commit

Permalink
Merge b004b54 into 50162d7
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Dec 18, 2018
2 parents 50162d7 + b004b54 commit 34578a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/presenters/blacklight/index_presenter.rb
Expand Up @@ -53,13 +53,17 @@ def render_document_index_label(*args)
# @option options [String] :value
def field_value field_or_name, options = {}
field = case field_or_name
when Blacklight::Configuration::Field
field_or_name
when String, Symbol
Deprecation.warn(self, "You provided a String or Symbol value to IndexPresenter#field_value " \
"Provide a Blacklight::Configuration::Field instead. field_value() will not accept " \
"strings or symbols in Blacklight 7")
Deprecation.warn(self, "You provided a #{field_or_name.class} value to IndexPresenter#field_value " \
"Provide a Blacklight::Configuration::Field instead. This behavior is deprecated in Blacklight 7")
field_config(field_or_name)
else
field_or_name
Deprecation.warn(self, "You provided a #{field_or_name.class} value to IndexPresenter#field_value. " \
"This will be silently ignored and will be an error in Blacklight 7.")

Configuration::NullField.new
end
field_values(field, options)
end
Expand Down
9 changes: 9 additions & 0 deletions spec/presenters/index_presenter_spec.rb
Expand Up @@ -58,6 +58,15 @@
expect(subject).to eq 'document qwer value'
end
end

context 'with a name as an integer' do
subject { presenter.field_value 123 }

it 'raises a deprecation' do
expect(Deprecation).to receive(:warn)
expect(subject).to eq ''
end
end
end

context 'when an explicit value is provided' do
Expand Down

0 comments on commit 34578a4

Please sign in to comment.