blacklight 7.2.0 → 7.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -3
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/controllers/concerns/blacklight/facet.rb +17 -5
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +25 -4
- data/app/presenters/blacklight/field_presenter.rb +12 -9
- data/app/presenters/blacklight/index_presenter.rb +2 -1
- data/app/presenters/blacklight/json_presenter.rb +1 -1
- data/app/presenters/blacklight/rendering/pipeline.rb +20 -5
- data/app/views/catalog/_constraints_element.html.erb +1 -1
- data/app/views/catalog/_document.atom.builder +1 -1
- data/app/views/catalog/_facet_group.html.erb +2 -2
- data/app/views/catalog/index.atom.builder +2 -2
- data/app/views/layouts/blacklight/base.html.erb +3 -4
- data/blacklight.gemspec +2 -3
- data/lib/blacklight/solr/response/facets.rb +9 -0
- data/lib/generators/blacklight/assets_generator.rb +13 -0
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +10 -6
- data/spec/helpers/blacklight_helper_spec.rb +42 -0
- data/spec/models/blacklight/solr/response/facets_spec.rb +37 -0
- data/spec/presenters/pipeline_spec.rb +25 -5
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -1
- data/tasks/blacklight.rake +3 -8
- metadata +12 -21
- data/.solr_wrapper.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 958a6b0c5bfc8cfdd7fa31fe600d5bc77219f389b850453ade7a7a7aef6f8229
|
4
|
+
data.tar.gz: f6a49835143c4126550be6f937e7328e002e2c63f20dcb36adfa77150d6e60a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fce42f491e0dd73fc1f0f71d051d0afc8c324ac07b4fbaf9f0d728e0bdb0bde657000ef044e48b28fad008015b29c4dc0e73c47671677ae37cf2e38a06137741
|
7
|
+
data.tar.gz: eb4d53904c2d1a309aef41fbcb166c18fabde6d0a8eaf8851df1032c783ea4b34af8115ffb91464f9aaed907078f42cacb644d12770f14fc301e9c008c3e4648
|
data/.travis.yml
CHANGED
@@ -8,12 +8,12 @@ notifications:
|
|
8
8
|
|
9
9
|
matrix:
|
10
10
|
include:
|
11
|
+
- rvm: 2.6.5
|
12
|
+
env: "RAILS_VERSION=6.0.0 ENGINE_CART_RAILS_OPTIONS=\"--skip-webpack-install\""
|
11
13
|
- rvm: 2.6.5
|
12
14
|
env: "RAILS_VERSION=5.2.3"
|
13
15
|
- rvm: 2.5.7
|
14
16
|
env: "RAILS_VERSION=5.1.7"
|
15
|
-
- rvm: 2.4.9
|
16
|
-
env: "RAILS_VERSION=5.2.3"
|
17
17
|
- rvm: 2.5.7
|
18
18
|
env: "RAILS_VERSION=5.2.3 BLACKLIGHT_API_TEST=true ENGINE_CART_RAILS_OPTIONS=\"--api --skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-action-cable --skip-coffee --skip-test\""
|
19
19
|
- rvm: 2.4.9
|
@@ -25,6 +25,9 @@ matrix:
|
|
25
25
|
fast_finish: true
|
26
26
|
|
27
27
|
before_install:
|
28
|
+
- docker pull solr:7
|
29
|
+
- docker run -d -p 8983:8983 -v $PWD/lib/generators/blacklight/templates/solr/conf:/myconfig solr:7 solr-create -c blacklight-core -d /myconfig
|
30
|
+
- docker ps -a
|
28
31
|
- google-chrome-stable --headless --disable-gpu --no-sandbox --remote-debugging-port=9222 http://localhost &
|
29
32
|
|
30
33
|
notifications:
|
@@ -34,7 +37,7 @@ notifications:
|
|
34
37
|
|
35
38
|
global_env:
|
36
39
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
37
|
-
- ENGINE_CART_RAILS_OPTIONS='--skip-git --skip-
|
40
|
+
- ENGINE_CART_RAILS_OPTIONS='--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
38
41
|
- CC_TEST_REPORTER_ID=5042c7358c96b0b926088a4cda3e132fffe7a66ce8047cdb1dc6f0b4b6676b79
|
39
42
|
|
40
43
|
jdk: openjdk11
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.3.0
|
@@ -18,8 +18,14 @@ module Blacklight
|
|
18
18
|
|
19
19
|
# @param fields [Array<String>] a list of facet field names
|
20
20
|
# @return [Array<Solr::Response::Facets::FacetField>]
|
21
|
-
def facets_from_request(fields = facet_field_names)
|
22
|
-
|
21
|
+
def facets_from_request(fields = facet_field_names, response = nil)
|
22
|
+
unless response
|
23
|
+
Deprecation.warn(self, 'Calling facets_from_request without passing the ' \
|
24
|
+
'second argument (response) is deprecated and will be removed in Blacklight ' \
|
25
|
+
'8.0.0')
|
26
|
+
response = @response
|
27
|
+
end
|
28
|
+
fields.map { |field| facet_by_field_name(field, response) }.compact
|
23
29
|
end
|
24
30
|
|
25
31
|
def facet_group_names
|
@@ -27,13 +33,19 @@ module Blacklight
|
|
27
33
|
end
|
28
34
|
|
29
35
|
# Get a FacetField object from the @response
|
30
|
-
def facet_by_field_name(field_or_field_name)
|
36
|
+
def facet_by_field_name(field_or_field_name, response = nil)
|
37
|
+
unless response
|
38
|
+
Deprecation.warn(self, 'Calling facet_by_field_name without passing the ' \
|
39
|
+
'second argument (response) is deprecated and will be removed in Blacklight ' \
|
40
|
+
'8.0.0')
|
41
|
+
response = @response
|
42
|
+
end
|
31
43
|
case field_or_field_name
|
32
44
|
when String, Symbol
|
33
45
|
facet_field = facet_configuration_for_field(field_or_field_name)
|
34
|
-
|
46
|
+
response.aggregations[facet_field.field]
|
35
47
|
when Blacklight::Configuration::FacetField
|
36
|
-
|
48
|
+
response.aggregations[field_or_field_name.field]
|
37
49
|
else
|
38
50
|
# is this really a useful case?
|
39
51
|
field_or_field_name
|
@@ -7,8 +7,14 @@ module Blacklight::FacetsHelperBehavior
|
|
7
7
|
#
|
8
8
|
# @param [Array<String>] fields
|
9
9
|
# @return [Boolean]
|
10
|
-
def has_facet_values? fields = facet_field_names
|
11
|
-
|
10
|
+
def has_facet_values? fields = facet_field_names, response = nil
|
11
|
+
unless response
|
12
|
+
Deprecation.warn(self, 'Calling has_facet_values? without passing the ' \
|
13
|
+
'second argument (response) is deprecated and will be removed in Blacklight ' \
|
14
|
+
'8.0.0')
|
15
|
+
response = @response
|
16
|
+
end
|
17
|
+
facets_from_request(fields, response).any? { |display_facet| should_render_facet?(display_facet) }
|
12
18
|
end
|
13
19
|
|
14
20
|
##
|
@@ -17,9 +23,24 @@ module Blacklight::FacetsHelperBehavior
|
|
17
23
|
#
|
18
24
|
# @param [Array<String>] fields
|
19
25
|
# @param [Hash] options
|
26
|
+
# @options options [Blacklight::Solr::Response] :response the Solr response object
|
20
27
|
# @return String
|
21
|
-
def render_facet_partials fields =
|
22
|
-
|
28
|
+
def render_facet_partials fields = nil, options = {}
|
29
|
+
unless fields
|
30
|
+
Deprecation.warn(self, 'Calling render_facet_partials without passing the ' \
|
31
|
+
'first argument (fields) is deprecated and will be removed in Blacklight ' \
|
32
|
+
'8.0.0')
|
33
|
+
fields = facet_field_names
|
34
|
+
end
|
35
|
+
|
36
|
+
response = options.delete(:response)
|
37
|
+
unless response
|
38
|
+
Deprecation.warn(self, 'Calling render_facet_partials without passing the ' \
|
39
|
+
'response keyword is deprecated and will be removed in Blacklight ' \
|
40
|
+
'8.0.0')
|
41
|
+
response = @response
|
42
|
+
end
|
43
|
+
safe_join(facets_from_request(fields, response).map do |display_facet|
|
23
44
|
render_facet_limit(display_facet, options)
|
24
45
|
end.compact, "\n")
|
25
46
|
end
|
@@ -3,6 +3,12 @@
|
|
3
3
|
module Blacklight
|
4
4
|
# Renders a field and handles link_to_facet or helper_method if supplied
|
5
5
|
class FieldPresenter
|
6
|
+
# @param controller [Object] the context in which to execute helper methods
|
7
|
+
# @param document [SolrDocument] the document
|
8
|
+
# @param field_config [Blacklight::Configuration::Field] the field's configuration
|
9
|
+
# @param options [Hash]
|
10
|
+
# @option options [Object] :value when this is provided, we don't want the pipeline to deal with helper methods.
|
11
|
+
# this happens when drawing the label for the document
|
6
12
|
def initialize(controller, document, field_config, options)
|
7
13
|
@controller = controller
|
8
14
|
@document = document
|
@@ -13,15 +19,12 @@ module Blacklight
|
|
13
19
|
attr_reader :controller, :document, :field_config, :options
|
14
20
|
|
15
21
|
def render
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
values = retrieve_values
|
23
|
-
end
|
24
|
-
Rendering::Pipeline.render(values, config, document, controller, options)
|
22
|
+
return Rendering::Pipeline.render(retrieve_values, field_config, document, controller, options) unless options[:value]
|
23
|
+
|
24
|
+
values = Array.wrap(options[:value])
|
25
|
+
# Prevents helper methods from drawing.
|
26
|
+
steps = Rendering::Pipeline.operations - [Rendering::HelperMethod]
|
27
|
+
Rendering::Pipeline.new(values, field_config, document, controller, steps, options).render
|
25
28
|
end
|
26
29
|
|
27
30
|
private
|
@@ -17,7 +17,8 @@ module Blacklight
|
|
17
17
|
end
|
18
18
|
|
19
19
|
##
|
20
|
-
# Render the document index heading
|
20
|
+
# Render the document index heading. This is used when making a link to a
|
21
|
+
# document, where we don't want any HTML markup added from the pipeline.
|
21
22
|
#
|
22
23
|
# @param [Symbol, Proc, String] field_or_string_or_proc Render the given field or evaluate the proc or render the given string
|
23
24
|
# @param [Hash] opts
|
@@ -18,7 +18,7 @@ module Blacklight
|
|
18
18
|
|
19
19
|
# @return [Array<Blacklight::Solr::Response::Facets::FacetField>]
|
20
20
|
def search_facets
|
21
|
-
facets_from_request.select { |display_facet| display_facet.items.present? }
|
21
|
+
facets_from_request(facet_field_names, @response).select { |display_facet| display_facet.items.present? }
|
22
22
|
end
|
23
23
|
|
24
24
|
# extract the pagination info from the response object
|
@@ -2,27 +2,42 @@
|
|
2
2
|
|
3
3
|
module Blacklight
|
4
4
|
module Rendering
|
5
|
-
# The field rendering pipeline
|
5
|
+
# The field rendering pipeline.
|
6
|
+
# This takes a field and its values and transforms them through a list of
|
7
|
+
# operations.
|
6
8
|
class Pipeline
|
7
|
-
class_attribute :operations
|
9
|
+
class_attribute :operations, instance_accessor: false
|
8
10
|
|
9
11
|
# The ordered list of pipeline operations
|
10
12
|
self.operations = [HelperMethod, LinkToFacet, Microdata, Join]
|
11
13
|
|
12
|
-
|
14
|
+
# @param values [Array] the values for the field
|
15
|
+
# @param config [Blacklight::Configuration::Field] the field's configuration
|
16
|
+
# @param document [SolrDocument] the document
|
17
|
+
# @param context [Object] an execution context, used to execute the helper method in.
|
18
|
+
# @param operations [Array<Class>] the list of operations in this Pipeline
|
19
|
+
# @param options [Hash] options to pass to the processors. Typically only `:value` is used
|
20
|
+
def initialize(values, config, document, context, operations, options)
|
13
21
|
@values = values
|
14
22
|
@config = config
|
15
23
|
@document = document
|
16
24
|
@context = context
|
25
|
+
@operations = operations
|
17
26
|
@options = options
|
18
27
|
end
|
19
28
|
|
20
|
-
attr_reader :values, :config, :document, :context, :options
|
29
|
+
attr_reader :values, :config, :document, :context, :operations, :options
|
21
30
|
|
31
|
+
# @param values [Array] the values for the field
|
32
|
+
# @param config [Blacklight::Configuration::Field] the field's configuration
|
33
|
+
# @param document [SolrDocument] the document
|
34
|
+
# @param context [Object] an execution context, used to execute the helper method in.
|
35
|
+
# @param options [Hash] options to pass to the processors. Typically only `:value` is used
|
22
36
|
def self.render(values, config, document, context, options)
|
23
|
-
new(values, config, document, context, options).render
|
37
|
+
new(values, config, document, context, operations, options).render
|
24
38
|
end
|
25
39
|
|
40
|
+
# Perform the processing by the pipeline
|
26
41
|
def render
|
27
42
|
first, *rest = *stack
|
28
43
|
first.new(values, config, document, context, options, rest).render
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<span class="filter-name"><%= label %></span>
|
14
14
|
<% end %>
|
15
15
|
<% unless value.blank? %>
|
16
|
-
<%= content_tag :span, value, class: 'filter-value', title: value %>
|
16
|
+
<%= content_tag :span, value, class: 'filter-value', title: strip_tags(value) %>
|
17
17
|
<% end %>
|
18
18
|
</span>
|
19
19
|
<% unless options[:remove].blank? %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% # main container for facets/limits menu -%>
|
2
|
-
<% if has_facet_values? facet_field_names(groupname) %>
|
2
|
+
<% if has_facet_values? facet_field_names(groupname), @response %>
|
3
3
|
<div id="facets<%= "-#{groupname}" unless groupname.nil? %>" class="facets sidenav facets-toggleable-md">
|
4
4
|
|
5
5
|
<div class="navbar">
|
@@ -13,7 +13,7 @@
|
|
13
13
|
</div>
|
14
14
|
|
15
15
|
<div id="facet-panel<%= "-#{groupname}" unless groupname.nil? %>-collapse" class="facets-collapse collapse">
|
16
|
-
<%= render_facet_partials facet_field_names(groupname) %>
|
16
|
+
<%= render_facet_partials facet_field_names(groupname), response: @response %>
|
17
17
|
</div>
|
18
18
|
</div>
|
19
19
|
<% end %>
|
@@ -12,8 +12,8 @@ xml.feed("xmlns" => "http://www.w3.org/2005/Atom",
|
|
12
12
|
xml.author { xml.name application_name }
|
13
13
|
|
14
14
|
xml.link "rel" => "self", "href" => url_for(search_state.to_h.merge(only_path: false))
|
15
|
-
xml.link "rel" => "alternate", "href" => url_for(search_state.to_h.merge(only_path: false, format:
|
16
|
-
xml.id url_for(search_state.to_h.merge(:
|
15
|
+
xml.link "rel" => "alternate", "href" => url_for(search_state.to_h.merge(only_path: false, format: :html)), "type" => "text/html"
|
16
|
+
xml.id url_for(search_state.to_h.merge(only_path: false, format: :html, content_format: nil, "type" => "text/html"))
|
17
17
|
|
18
18
|
# Navigational and context links
|
19
19
|
|
@@ -27,11 +27,10 @@
|
|
27
27
|
<main id="main-container" class="<%= container_classes %>" role="main" aria-label="<%= t('blacklight.main.aria.main_container') %>">
|
28
28
|
<%= content_for(:container_header) %>
|
29
29
|
|
30
|
-
|
30
|
+
<%= render partial: 'shared/flash_msg', layout: 'shared/flash_messages' %>
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
</div>
|
32
|
+
<div class="row">
|
33
|
+
<%= content_for?(:content) ? yield(:content) : yield %>
|
35
34
|
</div>
|
36
35
|
</main>
|
37
36
|
|
data/blacklight.gemspec
CHANGED
@@ -25,15 +25,14 @@ Gem::Specification.new do |s|
|
|
25
25
|
|
26
26
|
s.required_ruby_version = '~> 2.1'
|
27
27
|
|
28
|
-
s.add_dependency "rails",
|
28
|
+
s.add_dependency "rails", '>= 5.1', '< 7'
|
29
29
|
s.add_dependency "globalid"
|
30
30
|
s.add_dependency "jbuilder", '~> 2.7'
|
31
31
|
s.add_dependency "kaminari", ">= 0.15" # the pagination (page 1,2,3, etc..) of our search results
|
32
32
|
s.add_dependency "deprecation"
|
33
33
|
|
34
34
|
s.add_development_dependency "rsolr", ">= 1.0.6", "< 3" # Library for interacting with rSolr.
|
35
|
-
s.add_development_dependency "
|
36
|
-
s.add_development_dependency "rspec-rails", "~> 3.5"
|
35
|
+
s.add_development_dependency "rspec-rails", "~> 4.0.0.beta2"
|
37
36
|
s.add_development_dependency "rspec-its"
|
38
37
|
s.add_development_dependency "rspec-collection_matchers", ">= 1.0"
|
39
38
|
s.add_development_dependency "capybara", '~> 3'
|
@@ -120,6 +120,15 @@ module Blacklight::Solr::Response::Facets
|
|
120
120
|
@facet_pivot ||= facet_counts['facet_pivot'] || {}
|
121
121
|
end
|
122
122
|
|
123
|
+
# Merge or add new facet count values to existing response
|
124
|
+
def merge_facet(name:, value:, hits: nil)
|
125
|
+
if dig('facet_counts', 'facet_fields', name)
|
126
|
+
self['facet_counts']['facet_fields'][name] << value << hits
|
127
|
+
else
|
128
|
+
self['facet_counts']['facet_fields'][name] = [value, hits]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
123
132
|
private
|
124
133
|
|
125
134
|
##
|
@@ -9,6 +9,19 @@ module Blacklight
|
|
9
9
|
gem 'twitter-typeahead-rails', '0.11.1.pre.corejavascript'
|
10
10
|
end
|
11
11
|
|
12
|
+
# Add sprockets javascript to Rails 6.
|
13
|
+
def create_sprockets_javascript
|
14
|
+
return if Rails.version < '6.0.0'
|
15
|
+
|
16
|
+
create_file 'app/assets/javascripts/application.js' do
|
17
|
+
<<~CONTENT
|
18
|
+
//= require jquery
|
19
|
+
//= require rails-ujs
|
20
|
+
//= require turbolinks
|
21
|
+
CONTENT
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
12
25
|
def assets
|
13
26
|
copy_file "blacklight.scss", "app/assets/stylesheets/blacklight.scss"
|
14
27
|
|
@@ -9,16 +9,17 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
9
9
|
|
10
10
|
describe "has_facet_values?" do
|
11
11
|
let(:empty) { double(items: [], name: 'empty') }
|
12
|
+
let(:response) { instance_double(Blacklight::Solr::Response) }
|
12
13
|
|
13
14
|
it "is true if there are any facets to display" do
|
14
15
|
a = double(items: [1, 2], name: 'a')
|
15
16
|
b = double(items: %w[b c], name: 'b')
|
16
17
|
fields = [a, b, empty]
|
17
|
-
expect(helper.has_facet_values?(fields)).to be true
|
18
|
+
expect(helper.has_facet_values?(fields, response)).to be true
|
18
19
|
end
|
19
20
|
|
20
21
|
it "is false if all facets are empty" do
|
21
|
-
expect(helper.has_facet_values?([empty])).to be false
|
22
|
+
expect(helper.has_facet_values?([empty], response)).to be false
|
22
23
|
end
|
23
24
|
|
24
25
|
describe "different config" do
|
@@ -26,7 +27,7 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
26
27
|
|
27
28
|
it "is false if no facets are displayable" do
|
28
29
|
a = double(items: [1, 2], name: 'basic_field')
|
29
|
-
expect(helper.has_facet_values?([a])).to be false
|
30
|
+
expect(helper.has_facet_values?([a], response)).to be false
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -106,15 +107,16 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
106
107
|
facet_config = double(query: nil, field: 'b', key: 'a')
|
107
108
|
facet_field = double
|
108
109
|
allow(helper).to receive(:facet_configuration_for_field).with('b').and_return(facet_config)
|
109
|
-
|
110
|
+
response = instance_double(Blacklight::Solr::Response, aggregations: { 'b' => facet_field })
|
110
111
|
|
111
|
-
expect(helper.facet_by_field_name('b')).to eq facet_field
|
112
|
+
expect(helper.facet_by_field_name('b', response)).to eq facet_field
|
112
113
|
end
|
113
114
|
end
|
114
115
|
|
115
116
|
describe "render_facet_partials" do
|
116
117
|
let(:a) { double(items: [1, 2]) }
|
117
118
|
let(:b) { double(items: %w[b c]) }
|
119
|
+
let(:response) { instance_double(Blacklight::Solr::Response) }
|
118
120
|
|
119
121
|
it "tries to render all provided facets" do
|
120
122
|
empty = double(items: [])
|
@@ -122,14 +124,16 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
122
124
|
expect(helper).to receive(:render_facet_limit).with(a, {})
|
123
125
|
expect(helper).to receive(:render_facet_limit).with(b, {})
|
124
126
|
expect(helper).to receive(:render_facet_limit).with(empty, {})
|
125
|
-
helper.render_facet_partials fields
|
127
|
+
helper.render_facet_partials fields, response: response
|
126
128
|
end
|
127
129
|
|
128
130
|
it "defaults to the configured facets" do
|
131
|
+
allow(Deprecation).to receive(:warn)
|
129
132
|
expect(helper).to receive(:facet_field_names) { [a, b] }
|
130
133
|
expect(helper).to receive(:render_facet_limit).with(a, {})
|
131
134
|
expect(helper).to receive(:render_facet_limit).with(b, {})
|
132
135
|
helper.render_facet_partials
|
136
|
+
expect(Deprecation).to have_received(:warn).twice
|
133
137
|
end
|
134
138
|
end
|
135
139
|
|
@@ -388,4 +388,46 @@ RSpec.describe BlacklightHelper do
|
|
388
388
|
expect(helper.render_document_heading(document, tag: "h3")).to have_selector "h3", text: "Document Heading"
|
389
389
|
end
|
390
390
|
end
|
391
|
+
|
392
|
+
describe "#presenter" do
|
393
|
+
let(:document) { double }
|
394
|
+
|
395
|
+
before do
|
396
|
+
allow(helper).to receive(:index_presenter).and_return(:index_presenter)
|
397
|
+
allow(helper).to receive(:show_presenter).and_return(:show_presenter)
|
398
|
+
allow(helper).to receive(:action_name).and_return(action_name)
|
399
|
+
end
|
400
|
+
|
401
|
+
context "action is show" do
|
402
|
+
let(:action_name) { "show" }
|
403
|
+
|
404
|
+
it "uses the show presenter" do
|
405
|
+
expect(helper.presenter(document)).to eq(:show_presenter)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
context "action is citation" do
|
410
|
+
let(:action_name) { "citation" }
|
411
|
+
|
412
|
+
it "uses the show presenter" do
|
413
|
+
expect(helper.presenter(document)).to eq(:show_presenter)
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
context "action is index" do
|
418
|
+
let(:action_name) { "index" }
|
419
|
+
|
420
|
+
it "uses the index presenter" do
|
421
|
+
expect(helper.presenter(document)).to eq(:index_presenter)
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
context "action is foo" do
|
426
|
+
let(:action_name) { "foo" }
|
427
|
+
|
428
|
+
it "uses the index presenter (by default)" do
|
429
|
+
expect(helper.presenter(document)).to eq(:index_presenter)
|
430
|
+
end
|
431
|
+
end
|
432
|
+
end
|
391
433
|
end
|
@@ -104,6 +104,43 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
+
describe "#merge_facet" do
|
108
|
+
let(:response) { Blacklight::Solr::Response.new(facet_counts, {}, {}) }
|
109
|
+
let(:facet) { { name: "foo", value: "bar", hits: 1 } }
|
110
|
+
|
111
|
+
before do
|
112
|
+
response.merge_facet(facet)
|
113
|
+
end
|
114
|
+
|
115
|
+
context "facet does not already exist" do
|
116
|
+
it "adds the facet and appends the new field name and value" do
|
117
|
+
expect(response.facet_fields["foo"]).to eq(["bar", 1])
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context "facet exists but field does not exist" do
|
122
|
+
let(:facet) { { name: "cat", value: "bar", hits: 1 } }
|
123
|
+
|
124
|
+
it "appends the new field name and value" do
|
125
|
+
expect(response.facet_fields["cat"]).to eq(["memory", 3, "card", 2, "bar", 1])
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "facet exists and field exists" do
|
130
|
+
let(:facet) { { name: "cat", value: "memory", hits: 4 } }
|
131
|
+
|
132
|
+
it "appends the new field name and value and aggregations uses new value" do
|
133
|
+
expect(response.aggregations["cat"].items.count).to eq(2)
|
134
|
+
expect(response.aggregations["cat"].items.first.value).to eq("memory")
|
135
|
+
expect(response.aggregations["cat"].items.first.hits).to eq(4)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def facet_counts
|
140
|
+
{ "facet_counts" => { "facet_fields" => { "cat" => ["memory", 3, "card", 2] } } }
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
107
144
|
context "facet.missing" do
|
108
145
|
subject { Blacklight::Solr::Response.new(response, {}) }
|
109
146
|
|
@@ -4,11 +4,10 @@ RSpec.describe Blacklight::Rendering::Pipeline do
|
|
4
4
|
include Capybara::RSpecMatchers
|
5
5
|
let(:document) { instance_double(SolrDocument) }
|
6
6
|
let(:context) { double }
|
7
|
-
let(:options) { double }
|
8
|
-
let(:presenter) { described_class.new(values, field_config, document, context, options) }
|
7
|
+
let(:options) { double('options') }
|
9
8
|
|
10
|
-
describe
|
11
|
-
subject {
|
9
|
+
describe '.render' do
|
10
|
+
subject { described_class.render(values, field_config, document, context, options) }
|
12
11
|
|
13
12
|
let(:values) { %w[a b] }
|
14
13
|
let(:field_config) { Blacklight::Configuration::NullField.new }
|
@@ -28,9 +27,17 @@ RSpec.describe Blacklight::Rendering::Pipeline do
|
|
28
27
|
|
29
28
|
it { is_expected.to have_selector("span[@itemprop='some-prop']", text: "a") }
|
30
29
|
end
|
30
|
+
|
31
|
+
it 'sets the operations on the instance as equal to the class variable' do
|
32
|
+
allow(described_class).to receive(:new)
|
33
|
+
.and_return(instance_double(described_class, render: true))
|
34
|
+
subject
|
35
|
+
expect(described_class).to have_received(:new)
|
36
|
+
.with(values, field_config, document, context, described_class.operations, options)
|
37
|
+
end
|
31
38
|
end
|
32
39
|
|
33
|
-
describe
|
40
|
+
describe '.operations' do
|
34
41
|
subject { described_class.operations }
|
35
42
|
|
36
43
|
it {
|
@@ -40,4 +47,17 @@ RSpec.describe Blacklight::Rendering::Pipeline do
|
|
40
47
|
Blacklight::Rendering::Join]
|
41
48
|
}
|
42
49
|
end
|
50
|
+
|
51
|
+
describe '#operations' do
|
52
|
+
subject(:operations) { presenter.operations }
|
53
|
+
|
54
|
+
let(:presenter) { described_class.new(values, field_config, document, context, steps, options) }
|
55
|
+
let(:steps) { [Blacklight::Rendering::HelperMethod] }
|
56
|
+
let(:values) { ['a'] }
|
57
|
+
let(:field_config) { Blacklight::Configuration::NullField.new }
|
58
|
+
|
59
|
+
it 'sets the operations to the value passed to the initializer' do
|
60
|
+
expect(operations).to eq steps
|
61
|
+
end
|
62
|
+
end
|
43
63
|
end
|
@@ -15,7 +15,7 @@ RSpec.describe "catalog/_show_tools.html.erb" do
|
|
15
15
|
let(:document_actions) { blacklight_config.show.document_actions }
|
16
16
|
|
17
17
|
it "renders a document action" do
|
18
|
-
allow(view).to receive(:some_action_solr_document_path).with(document).and_return
|
18
|
+
allow(view).to receive(:some_action_solr_document_path).with(document, any_args).and_return 'x'
|
19
19
|
document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new partial: 'document_action'
|
20
20
|
render partial: 'catalog/show_tools'
|
21
21
|
expect(rendered).to have_link "Some action", href: "x"
|
data/tasks/blacklight.rake
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'solr_wrapper'
|
4
3
|
require 'engine_cart/rake_task'
|
5
4
|
|
6
5
|
require 'rspec/core/rake_task'
|
@@ -13,14 +12,10 @@ RuboCop::RakeTask.new(:rubocop)
|
|
13
12
|
|
14
13
|
desc "Run test suite"
|
15
14
|
task ci: ['blacklight:generate'] do
|
16
|
-
|
17
|
-
|
18
|
-
within_test_app do
|
19
|
-
system "RAILS_ENV=test rake blacklight:index:seed"
|
20
|
-
end
|
21
|
-
Rake::Task['blacklight:coverage'].invoke
|
22
|
-
end
|
15
|
+
within_test_app do
|
16
|
+
system "RAILS_ENV=test rake blacklight:index:seed"
|
23
17
|
end
|
18
|
+
Rake::Task['blacklight:coverage'].invoke
|
24
19
|
end
|
25
20
|
|
26
21
|
namespace :blacklight do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -17,22 +17,28 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: exe
|
19
19
|
cert_chain: []
|
20
|
-
date: 2019-10-
|
20
|
+
date: 2019-10-30 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|
24
24
|
requirement: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - "
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '5.1'
|
29
|
+
- - "<"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '7'
|
29
32
|
type: :runtime
|
30
33
|
prerelease: false
|
31
34
|
version_requirements: !ruby/object:Gem::Requirement
|
32
35
|
requirements:
|
33
|
-
- - "
|
36
|
+
- - ">="
|
34
37
|
- !ruby/object:Gem::Version
|
35
38
|
version: '5.1'
|
39
|
+
- - "<"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '7'
|
36
42
|
- !ruby/object:Gem::Dependency
|
37
43
|
name: globalid
|
38
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,34 +115,20 @@ dependencies:
|
|
109
115
|
- - "<"
|
110
116
|
- !ruby/object:Gem::Version
|
111
117
|
version: '3'
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: solr_wrapper
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
-
requirements:
|
116
|
-
- - ">="
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: '0'
|
119
|
-
type: :development
|
120
|
-
prerelease: false
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
requirements:
|
123
|
-
- - ">="
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
118
|
- !ruby/object:Gem::Dependency
|
127
119
|
name: rspec-rails
|
128
120
|
requirement: !ruby/object:Gem::Requirement
|
129
121
|
requirements:
|
130
122
|
- - "~>"
|
131
123
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
124
|
+
version: 4.0.0.beta2
|
133
125
|
type: :development
|
134
126
|
prerelease: false
|
135
127
|
version_requirements: !ruby/object:Gem::Requirement
|
136
128
|
requirements:
|
137
129
|
- - "~>"
|
138
130
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
131
|
+
version: 4.0.0.beta2
|
140
132
|
- !ruby/object:Gem::Dependency
|
141
133
|
name: rspec-its
|
142
134
|
requirement: !ruby/object:Gem::Requirement
|
@@ -309,7 +301,6 @@ files:
|
|
309
301
|
- ".rspec"
|
310
302
|
- ".rubocop.yml"
|
311
303
|
- ".rubocop_todo.yml"
|
312
|
-
- ".solr_wrapper.yml"
|
313
304
|
- ".travis.yml"
|
314
305
|
- ".yardopts"
|
315
306
|
- CONTRIBUTING.md
|
data/.solr_wrapper.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# Place configuration for solr_wrapper here
|
2
|
-
#
|
3
|
-
# Specify the port to run solr on
|
4
|
-
# port: 8983
|
5
|
-
#
|
6
|
-
# Specify a version of Solr to download
|
7
|
-
# version: 7.3.1
|
8
|
-
#
|
9
|
-
# Create a collection when starting solr
|
10
|
-
collection:
|
11
|
-
dir: lib/generators/blacklight/templates/solr/conf/
|
12
|
-
name: blacklight-core
|