diff --git a/app/presenters/blacklight/document_presenter.rb b/app/presenters/blacklight/document_presenter.rb index e24019046f..0ac61aa06c 100644 --- a/app/presenters/blacklight/document_presenter.rb +++ b/app/presenters/blacklight/document_presenter.rb @@ -192,7 +192,7 @@ def get_field_values field, field_config, options = {} # rendering values case when (field_config and field_config.helper_method) - @controller.send(field_config.helper_method, options.merge(:document => @document, :field => field, :value => value)) + @controller.send(field_config.helper_method, options.merge(document: @document, field: field, config: field_config, value: value)) when (field_config and field_config.link_to_search) link_field = if field_config.link_to_search === true field_config.key diff --git a/spec/presenters/document_presenter_spec.rb b/spec/presenters/document_presenter_spec.rb index eb831aeba6..37a659ba1c 100644 --- a/spec/presenters/document_presenter_spec.rb +++ b/spec/presenters/document_presenter_spec.rb @@ -334,4 +334,32 @@ def mock_document_app_helper_url *args expect(subject.document_show_html_title).to eq "value" end end + + describe '#get_field_values' do + context 'for a field with the helper_method option' do + let(:field_name) { 'field_with_helper' } + let(:field_config) { config.add_facet_field 'field_with_helper', helper_method: 'render_field_with_helper' } + + before do + document['field_with_helper'] = 'value' + end + + it "should check call the helper method with arguments" do + allow(request_context).to receive(:render_field_with_helper) do |*args| + args.first + end + + render_options = { a: 1 } + + options = subject.get_field_values field_name, field_config, a: 1 + + expect(options).to include :document, :field, :value, :config, :a + expect(options[:document]).to eq document + expect(options[:field]).to eq 'field_with_helper' + expect(options[:value]).to eq 'value' + expect(options[:config]).to eq field_config + expect(options[:a]).to eq 1 + end + end + end end