Skip to content

Commit

Permalink
JsonPresenter has facets_from_request available to itself
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jul 20, 2018
1 parent 89f71c2 commit 1cf2f5e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion app/controllers/concerns/blacklight/catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def index
format.atom { render layout: false }
format.json do
@presenter = Blacklight::JsonPresenter.new(@response,
facets_from_request,
blacklight_config)
end
additional_response_formats(format)
Expand Down
5 changes: 2 additions & 3 deletions app/presenters/blacklight/json_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ class JsonPresenter

# @param [Solr::Response] response raw solr response.
# @param [Array] facets list of facets
def initialize(response, facets, blacklight_config)
def initialize(response, blacklight_config)
@response = response
@facets = facets
@blacklight_config = blacklight_config
end

Expand All @@ -18,7 +17,7 @@ def documents
end

def search_facets_as_json
@facets.as_json.each do |f|
facets_from_request.as_json.each do |f|
f.stringify_keys!
f.delete "options"
f["label"] = facet_configuration_for_field(f["name"]).label
Expand Down
3 changes: 1 addition & 2 deletions spec/views/catalog/index.json.jbuilder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
SolrDocument.new(id: '456', title_tsim: 'Book2', author_tsim: 'Rosie')
]
end
let(:facets) { double("facets") }
let(:config) do
Blacklight::Configuration.new do |config|
config.add_index_field 'title_tsim', label: 'Title:'
end
end
let(:presenter) { Blacklight::JsonPresenter.new(response, facets, config) }
let(:presenter) { Blacklight::JsonPresenter.new(response, config) }

let(:hash) do
render template: "catalog/index.json", format: :json
Expand Down

0 comments on commit 1cf2f5e

Please sign in to comment.