blacklight 7.16.0 → 7.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/VERSION +1 -1
- data/app/components/blacklight/advanced_search_form_component.html.erb +9 -3
- data/app/components/blacklight/advanced_search_form_component.rb +48 -35
- data/app/components/blacklight/constraints_component.html.erb +19 -3
- data/app/components/blacklight/constraints_component.rb +5 -1
- data/app/components/blacklight/content_areas_shim.rb +12 -0
- data/app/components/blacklight/document/action_component.rb +4 -0
- data/app/components/blacklight/document/actions_component.html.erb +3 -5
- data/app/components/blacklight/document/actions_component.rb +14 -1
- data/app/components/blacklight/document/thumbnail_component.html.erb +3 -3
- data/app/components/blacklight/document/thumbnail_component.rb +11 -3
- data/app/components/blacklight/document_component.html.erb +4 -7
- data/app/components/blacklight/document_component.rb +73 -73
- data/app/components/blacklight/document_metadata_component.html.erb +2 -2
- data/app/components/blacklight/document_metadata_component.rb +13 -2
- data/app/components/blacklight/document_title_component.html.erb +17 -0
- data/app/components/blacklight/document_title_component.rb +59 -0
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +2 -2
- data/app/components/blacklight/facet_field_component.rb +4 -1
- data/app/components/blacklight/facet_field_list_component.html.erb +2 -2
- data/app/components/blacklight/facet_field_no_layout_component.rb +4 -1
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_layout_component.html.erb +3 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +26 -1
- data/app/components/blacklight/response/view_type_button_component.html.erb +4 -0
- data/app/components/blacklight/response/view_type_button_component.rb +38 -0
- data/app/components/blacklight/response/view_type_component.html.erb +2 -5
- data/app/components/blacklight/response/view_type_component.rb +9 -13
- data/app/components/blacklight/search_bar_component.rb +4 -1
- data/app/components/blacklight/system/dropdown_component.html.erb +4 -7
- data/app/components/blacklight/system/dropdown_component.rb +24 -0
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/system/flash_message_component.rb +7 -1
- data/app/components/blacklight/system/modal_component.rb +7 -1
- data/app/helpers/blacklight/catalog_helper_behavior.rb +2 -0
- data/app/views/catalog/_citation.html.erb +1 -1
- data/app/views/catalog/_document.html.erb +2 -2
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_show_main_content.html.erb +3 -3
- data/app/views/catalog/email.html.erb +2 -2
- data/app/views/catalog/email_success.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +3 -3
- data/app/views/catalog/sms.html.erb +2 -2
- data/app/views/catalog/sms_success.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.de.yml +2 -2
- data/lib/blacklight/configuration/view_config.rb +2 -0
- data/lib/blacklight/engine.rb +3 -1
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +23 -7
- data/lib/blacklight/search_builder.rb +1 -0
- data/lib/blacklight/solr/facet_paginator.rb +2 -0
- data/lib/blacklight/solr/request.rb +31 -0
- data/lib/blacklight/solr/response.rb +2 -16
- data/lib/blacklight/solr/response/facets.rb +76 -22
- data/lib/blacklight/solr/response/params.rb +104 -0
- data/lib/blacklight/solr/search_builder_behavior.rb +56 -30
- data/lib/generators/blacklight/assets_generator.rb +6 -2
- data/lib/generators/blacklight/install_generator.rb +5 -5
- data/lib/generators/blacklight/solr_generator.rb +4 -2
- data/lib/generators/blacklight/user_generator.rb +5 -3
- data/spec/components/blacklight/document_component_spec.rb +3 -3
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +6 -7
- data/spec/helpers/blacklight_helper_spec.rb +2 -2
- data/spec/helpers/catalog_helper_spec.rb +1 -1
- data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +14 -0
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +4 -0
- data/spec/models/blacklight/solr/request_spec.rb +62 -29
- data/spec/models/blacklight/solr/response/facets_spec.rb +109 -0
- data/spec/models/blacklight/solr/response_spec.rb +10 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +26 -0
- data/spec/services/blacklight/search_service_spec.rb +1 -1
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +8 -9
- metadata +14 -8
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Blacklight::Solr::Response::Params
|
3
|
+
# From https://solr.apache.org/guide/8_8/json-request-api.html#supported-properties-and-syntax
|
4
|
+
QUERY_PARAMETER_TO_JSON_PARAMETER_MAPPING = {
|
5
|
+
q: :query,
|
6
|
+
fq: :filter,
|
7
|
+
start: :offset,
|
8
|
+
rows: :limit,
|
9
|
+
fl: :fields,
|
10
|
+
sort: :sort
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
def params
|
14
|
+
header['params'] || request_params
|
15
|
+
end
|
16
|
+
|
17
|
+
def start
|
18
|
+
search_builder&.start || single_valued_param(:start).to_i
|
19
|
+
end
|
20
|
+
|
21
|
+
def rows
|
22
|
+
search_builder&.rows || single_valued_param(:rows).to_i
|
23
|
+
end
|
24
|
+
|
25
|
+
def sort
|
26
|
+
search_builder&.sort || single_valued_param(:sort)
|
27
|
+
end
|
28
|
+
|
29
|
+
def facet_field_aggregation_options(facet_field_name)
|
30
|
+
defaults = {
|
31
|
+
sort: single_valued_param(:'facet.sort'),
|
32
|
+
limit: single_valued_param(:"facet.limit")&.to_i || 100,
|
33
|
+
offset: single_valued_param(:"facet.offset")&.to_i || 0,
|
34
|
+
prefix: single_valued_param(:"facet.prefix")
|
35
|
+
}
|
36
|
+
|
37
|
+
json_facet = json_params.dig('facet', facet_field_name)&.slice(:limit, :offset, :prefix, :sort)&.symbolize_keys || {}
|
38
|
+
|
39
|
+
param_facet = {
|
40
|
+
sort: single_valued_param(:"f.#{facet_field_name}.facet.sort"),
|
41
|
+
limit: single_valued_param(:"f.#{facet_field_name}.facet.limit")&.to_i,
|
42
|
+
offset: single_valued_param(:"f.#{facet_field_name}.facet.offset")&.to_i,
|
43
|
+
prefix: single_valued_param(:"f.#{facet_field_name}.facet.prefix")
|
44
|
+
}.reject { |_k, v| v.nil? }
|
45
|
+
|
46
|
+
options = defaults.merge(json_facet).merge(param_facet)
|
47
|
+
options[:sort] ||= options[:limit].positive? ? 'count' : 'index'
|
48
|
+
|
49
|
+
options
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def search_builder
|
55
|
+
request_params if request_params.is_a?(Blacklight::SearchBuilder)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Extract JSON Request API parameters from the response header or the request itself
|
59
|
+
def json_params
|
60
|
+
encoded_json_params = header&.dig('params', 'json')
|
61
|
+
|
62
|
+
return request_params['json'] || {} if encoded_json_params.blank?
|
63
|
+
|
64
|
+
@json_params ||= JSON.parse(encoded_json_params).with_indifferent_access
|
65
|
+
end
|
66
|
+
|
67
|
+
# Handle merging solr parameters from the myriad of ways they may be expressed by applying the single-value
|
68
|
+
# precedence logic:
|
69
|
+
#
|
70
|
+
# From https://solr.apache.org/guide/8_8/json-request-api.html#json-parameter-merging :
|
71
|
+
# When multiple parameter values conflict with one another a single value is chosen based on the following precedence rules:
|
72
|
+
# - Traditional query parameters (q, rows, etc.) take first precedence and are used over any other specified values.
|
73
|
+
# - json-prefixed query parameters are considered next.
|
74
|
+
# - Values specified in the JSON request body have the lowest precedence and are only used if specified nowhere else.
|
75
|
+
#
|
76
|
+
# @param [String] key the solr parameter to use
|
77
|
+
def single_valued_param(key)
|
78
|
+
json_key = QUERY_PARAMETER_TO_JSON_PARAMETER_MAPPING[key]
|
79
|
+
|
80
|
+
params[key] ||
|
81
|
+
params["json.#{key}"] ||
|
82
|
+
json_params[json_key || key] ||
|
83
|
+
json_params.dig(:params, key) ||
|
84
|
+
json_params.dig(:params, "json.#{key}")
|
85
|
+
end
|
86
|
+
|
87
|
+
# Merge together multi-valued solr parameters from the myriad of ways they may be expressed.
|
88
|
+
# Unlike single-valued parameters, this merges all the values across the params.
|
89
|
+
#
|
90
|
+
# @param [String] key the solr parameter to use
|
91
|
+
def multivalued_param(key)
|
92
|
+
json_key = QUERY_PARAMETER_TO_JSON_PARAMETER_MAPPING[key]
|
93
|
+
|
94
|
+
[
|
95
|
+
params[key],
|
96
|
+
params["json.#{key}"],
|
97
|
+
json_params[json_key || key],
|
98
|
+
json_params.dig(:params, key),
|
99
|
+
json_params.dig(:params, "json.#{key}")
|
100
|
+
].select(&:present?).inject([]) do |memo, arr|
|
101
|
+
memo.concat(Array.wrap(arr))
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -32,6 +32,7 @@ module Blacklight::Solr
|
|
32
32
|
# Take the user-entered query, and put it in the solr params,
|
33
33
|
# including config's "search field" params for current search field.
|
34
34
|
# also include setting spellcheck.q.
|
35
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
35
36
|
def add_query_to_solr(solr_parameters)
|
36
37
|
###
|
37
38
|
# legacy behavior of user param :qt is passed through, but over-ridden
|
@@ -64,25 +65,31 @@ module Blacklight::Solr
|
|
64
65
|
elsif search_field&.solr_local_parameters.present?
|
65
66
|
add_search_field_with_local_parameters(solr_parameters)
|
66
67
|
elsif search_state.query_param.is_a? Hash
|
67
|
-
|
68
|
+
if search_state.query_param == @additional_filters && !processor_chain.include?(:add_additional_filters)
|
69
|
+
Deprecation.warn('Expecting to see the processor step add_additional_filters; falling back to legacy query handling')
|
70
|
+
add_additional_filters(solr_parameters, search_state.query_param)
|
71
|
+
end
|
68
72
|
elsif search_state.query_param
|
69
|
-
solr_parameters
|
73
|
+
solr_parameters.append_query search_state.query_param
|
70
74
|
end
|
71
75
|
end
|
76
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
72
77
|
|
73
78
|
def add_additional_filters(solr_parameters, additional_filters = nil)
|
74
79
|
q = additional_filters || @additional_filters
|
75
80
|
|
76
81
|
return if q.blank?
|
77
82
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
if q.values.any?(&:blank?)
|
84
|
+
# if any field parameters are empty, exclude _all_ results
|
85
|
+
solr_parameters.append_query "{!lucene}NOT *:*"
|
86
|
+
else
|
87
|
+
composed_query = q.map do |field, values|
|
88
|
+
"#{field}:(#{Array(values).map { |x| solr_param_quote(x) }.join(' OR ')})"
|
89
|
+
end.join(" AND ")
|
90
|
+
|
91
|
+
solr_parameters.append_query "{!lucene}#{composed_query}"
|
92
|
+
end
|
86
93
|
|
87
94
|
solr_parameters[:defType] = 'lucene'
|
88
95
|
solr_parameters[:spellcheck] = 'false'
|
@@ -91,9 +98,7 @@ module Blacklight::Solr
|
|
91
98
|
def add_search_field_with_json_query_parameters(solr_parameters)
|
92
99
|
bool_query = search_field.clause_params.transform_values { |v| v.merge(query: search_state.query_param) }
|
93
100
|
|
94
|
-
solr_parameters
|
95
|
-
solr_parameters[:json][:query] ||= { bool: { must: [] } }
|
96
|
-
solr_parameters[:json][:query][:bool][:must] << bool_query
|
101
|
+
solr_parameters.append_boolean_query(:must, bool_query)
|
97
102
|
end
|
98
103
|
|
99
104
|
# Transform "clause" parameters into the Solr JSON Query DSL
|
@@ -101,21 +106,15 @@ module Blacklight::Solr
|
|
101
106
|
return if search_state.clause_params.blank?
|
102
107
|
|
103
108
|
defaults = { must: [], must_not: [], should: [] }
|
104
|
-
bool_query = (solr_parameters.dig(:json, :query, :bool) || {}).reverse_merge(defaults)
|
105
|
-
|
106
109
|
default_op = blacklight_params[:op]&.to_sym || :must
|
110
|
+
solr_parameters[:mm] = 1 if default_op == :should && search_state.clause_params.values.any? { |clause| }
|
107
111
|
|
108
112
|
search_state.clause_params.each_value do |clause|
|
109
113
|
op, query = adv_search_clause(clause, default_op)
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
return if bool_query.values.all?(&:blank?)
|
114
|
+
next unless defaults.key?(op)
|
114
115
|
|
115
|
-
|
116
|
-
|
117
|
-
solr_parameters[:json][:query] ||= { bool: {} }
|
118
|
-
solr_parameters[:json][:query][:bool] = bool_query.reject { |_k, v| v.blank? }
|
116
|
+
solr_parameters.append_boolean_query(op, query)
|
117
|
+
end
|
119
118
|
end
|
120
119
|
|
121
120
|
# @return [Array] the first element is the query operator and the second is the value to add
|
@@ -141,7 +140,7 @@ module Blacklight::Solr
|
|
141
140
|
if filter.config.filter_query_builder
|
142
141
|
filter_query, subqueries = filter.config.filter_query_builder.call(self, filter, solr_parameters)
|
143
142
|
|
144
|
-
solr_parameters.append_filter_query(filter_query)
|
143
|
+
solr_parameters.append_filter_query(filter_query) if filter_query
|
145
144
|
solr_parameters.merge!(subqueries) if subqueries
|
146
145
|
else
|
147
146
|
filter.values.reject(&:blank?).each do |value|
|
@@ -158,6 +157,21 @@ module Blacklight::Solr
|
|
158
157
|
end
|
159
158
|
end
|
160
159
|
|
160
|
+
def add_solr_facet_json_params(solr_parameters, field_name, facet, **additional_parameters)
|
161
|
+
solr_parameters[:json] ||= { facet: {} }
|
162
|
+
solr_parameters[:json][:facet] ||= {}
|
163
|
+
|
164
|
+
field_config = facet.json.respond_to?(:reverse_merge) ? facet.json : {}
|
165
|
+
|
166
|
+
field_config = field_config.reverse_merge(
|
167
|
+
type: 'terms',
|
168
|
+
field: facet.field,
|
169
|
+
limit: facet_limit_with_pagination(field_name)
|
170
|
+
).merge(additional_parameters)
|
171
|
+
|
172
|
+
solr_parameters[:json][:facet][field_name] = field_config.select { |_k, v| v.present? }
|
173
|
+
end
|
174
|
+
|
161
175
|
##
|
162
176
|
# Add appropriate Solr facetting directives in, including
|
163
177
|
# taking account of our facet paging/'more'. This is not
|
@@ -166,6 +180,11 @@ module Blacklight::Solr
|
|
166
180
|
facet_fields_to_include_in_request.each do |field_name, facet|
|
167
181
|
solr_parameters[:facet] ||= true
|
168
182
|
|
183
|
+
if facet.json
|
184
|
+
add_solr_facet_json_params(solr_parameters, field_name, facet)
|
185
|
+
next
|
186
|
+
end
|
187
|
+
|
169
188
|
if facet.pivot
|
170
189
|
solr_parameters.append_facet_pivot with_ex_local_param(facet.ex, facet.pivot.join(","))
|
171
190
|
elsif facet.query
|
@@ -235,9 +254,7 @@ module Blacklight::Solr
|
|
235
254
|
|
236
255
|
facet_config = blacklight_config.facet_fields[facet]
|
237
256
|
|
238
|
-
|
239
|
-
facet_ex = facet_config.respond_to?(:ex) ? facet_config.ex : nil
|
240
|
-
solr_params[:"facet.field"] = with_ex_local_param(facet_ex, facet_config.field)
|
257
|
+
solr_params[:rows] = 0
|
241
258
|
|
242
259
|
limit = if solr_params["facet.limit"]
|
243
260
|
solr_params["facet.limit"].to_i
|
@@ -250,13 +267,21 @@ module Blacklight::Solr
|
|
250
267
|
prefix = search_state.facet_prefix
|
251
268
|
offset = (page - 1) * limit
|
252
269
|
|
270
|
+
if facet_config.json
|
271
|
+
add_solr_facet_json_params(solr_parameters, facet, facet_config, limit: limit + 1, offset: offset, sort: sort, prefix: prefix)
|
272
|
+
return
|
273
|
+
end
|
274
|
+
|
275
|
+
# Now override with our specific things for fetching facet values
|
276
|
+
facet_ex = facet_config.respond_to?(:ex) ? facet_config.ex : nil
|
277
|
+
solr_params[:"facet.field"] = with_ex_local_param(facet_ex, facet_config.field)
|
278
|
+
|
253
279
|
# Need to set as f.facet_field.facet.* to make sure we
|
254
280
|
# override any field-specific default in the solr request handler.
|
255
281
|
solr_params[:"f.#{facet_config.field}.facet.limit"] = limit + 1
|
256
282
|
solr_params[:"f.#{facet_config.field}.facet.offset"] = offset
|
257
283
|
solr_params[:"f.#{facet_config.field}.facet.sort"] = sort if sort
|
258
284
|
solr_params[:"f.#{facet_config.field}.facet.prefix"] = prefix if prefix
|
259
|
-
solr_params[:rows] = 0
|
260
285
|
end
|
261
286
|
|
262
287
|
def with_ex_local_param(ex, value)
|
@@ -302,6 +327,7 @@ module Blacklight::Solr
|
|
302
327
|
# around the term unless it's a bare-word. Escape internal quotes
|
303
328
|
# if needed.
|
304
329
|
def solr_param_quote(val, options = {})
|
330
|
+
val = val.to_s
|
305
331
|
options[:quote] ||= '"'
|
306
332
|
unless val =~ /^[a-zA-Z0-9$_\-\^]+$/
|
307
333
|
val = options[:quote] +
|
@@ -395,7 +421,7 @@ module Blacklight::Solr
|
|
395
421
|
def add_search_field_query_builder_params(solr_parameters)
|
396
422
|
q, additional_parameters = search_field.query_builder.call(self, search_field, solr_parameters)
|
397
423
|
|
398
|
-
solr_parameters
|
424
|
+
solr_parameters.append_query q
|
399
425
|
solr_parameters.merge!(additional_parameters) if additional_parameters
|
400
426
|
end
|
401
427
|
|
@@ -403,7 +429,7 @@ module Blacklight::Solr
|
|
403
429
|
local_params = search_field.solr_local_parameters.map do |key, val|
|
404
430
|
key.to_s + "=" + solr_param_quote(val, quote: "'")
|
405
431
|
end.join(" ")
|
406
|
-
solr_parameters
|
432
|
+
solr_parameters.append_query "{!#{local_params}}#{search_state.query_param}"
|
407
433
|
|
408
434
|
##
|
409
435
|
# Set Solr spellcheck.q to be original user-entered query, without
|
@@ -68,11 +68,15 @@ module Blacklight
|
|
68
68
|
private
|
69
69
|
|
70
70
|
def turbolinks?
|
71
|
-
@turbolinks ||=
|
71
|
+
@turbolinks ||= application_js.include?('turbolinks')
|
72
72
|
end
|
73
73
|
|
74
74
|
def has_blacklight_assets?
|
75
|
-
|
75
|
+
application_js.include?('blacklight/blacklight')
|
76
|
+
end
|
77
|
+
|
78
|
+
def application_js
|
79
|
+
IO.read(File.expand_path("app/assets/javascripts/application.js", destination_root))
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
@@ -37,8 +37,10 @@ module Blacklight
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def bundle_install
|
40
|
-
|
41
|
-
|
40
|
+
inside destination_root do
|
41
|
+
Bundler.with_clean_env do
|
42
|
+
run "bundle install"
|
43
|
+
end
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
@@ -81,9 +83,7 @@ module Blacklight
|
|
81
83
|
blacklight_marc = String.new('blacklight-marc')
|
82
84
|
gem blacklight_marc, '>= 7.0.0.rc1', '< 8'
|
83
85
|
|
84
|
-
|
85
|
-
run "bundle install"
|
86
|
-
end
|
86
|
+
bundle_install
|
87
87
|
|
88
88
|
generate 'blacklight:marc:install'
|
89
89
|
end
|
@@ -24,8 +24,10 @@ module Blacklight
|
|
24
24
|
gem "devise"
|
25
25
|
gem "devise-guests", "~> 0.6"
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
inside destination_root do
|
28
|
+
Bundler.with_clean_env do
|
29
|
+
run "bundle install"
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
generate "devise:install"
|
@@ -47,7 +49,7 @@ module Blacklight
|
|
47
49
|
# Add Blacklight to the user model
|
48
50
|
def inject_blacklight_user_behavior
|
49
51
|
file_path = "app/models/#{model_name.underscore}.rb"
|
50
|
-
if File.exist?(file_path)
|
52
|
+
if File.exist?(File.expand_path(file_path, destination_root))
|
51
53
|
inject_into_class file_path, model_name.classify do
|
52
54
|
"\n # Connects this user object to Blacklights Bookmarks." \
|
53
55
|
"\n include Blacklight::User\n"
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::DocumentComponent, type: :component do
|
6
|
-
subject(:component) { described_class.new(document: document, **attr) }
|
6
|
+
subject(:component) { described_class.new(document: document, presenter: view_context.document_presenter(document), **attr) }
|
7
7
|
|
8
8
|
let(:attr) { {} }
|
9
9
|
let(:view_context) { controller.view_context }
|
@@ -47,7 +47,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
47
47
|
component.with(:embed, 'Embed')
|
48
48
|
component.with(:metadata, 'Metadata')
|
49
49
|
component.with(:thumbnail, 'Thumbnail')
|
50
|
-
component.with(:actions
|
50
|
+
component.with(:actions) { 'Actions' }
|
51
51
|
|
52
52
|
expect(rendered).to have_content 'Title'
|
53
53
|
expect(rendered).to have_content 'Embed'
|
@@ -65,7 +65,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
65
65
|
|
66
66
|
context 'with a provided body' do
|
67
67
|
it 'opts-out of normal component content' do
|
68
|
-
component.with(:body
|
68
|
+
component.with(:body) { 'Body content' }
|
69
69
|
|
70
70
|
expect(rendered).to have_content 'Body content'
|
71
71
|
expect(rendered).not_to have_selector 'header'
|
@@ -33,9 +33,8 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
33
33
|
|
34
34
|
describe "#default_document_index_view_type" do
|
35
35
|
it "uses the first view with default set to true" do
|
36
|
-
blacklight_config.view.a
|
37
|
-
blacklight_config.view.b
|
38
|
-
blacklight_config.view.b.default = true
|
36
|
+
blacklight_config.view.a({})
|
37
|
+
blacklight_config.view.b(default: true)
|
39
38
|
expect(helper.default_document_index_view_type).to eq :b
|
40
39
|
end
|
41
40
|
|
@@ -48,8 +47,8 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
48
47
|
describe "#document_index_views" do
|
49
48
|
before do
|
50
49
|
blacklight_config.view.abc = false
|
51
|
-
blacklight_config.view.def
|
52
|
-
blacklight_config.view.xyz
|
50
|
+
blacklight_config.view.def(if: false)
|
51
|
+
blacklight_config.view.xyz(unless: true)
|
53
52
|
end
|
54
53
|
|
55
54
|
it "filters views using :if/:unless configuration" do
|
@@ -62,8 +61,8 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
62
61
|
|
63
62
|
describe '#document_index_view_controls' do
|
64
63
|
before do
|
65
|
-
blacklight_config.view.a
|
66
|
-
blacklight_config.view.b
|
64
|
+
blacklight_config.view.a({})
|
65
|
+
blacklight_config.view.b(display_control: false)
|
67
66
|
end
|
68
67
|
|
69
68
|
it "filters index views to those set to display controls" do
|
@@ -127,7 +127,7 @@ RSpec.describe BlacklightHelper do
|
|
127
127
|
|
128
128
|
it "renders view type specific actions" do
|
129
129
|
allow(helper).to receive(:document_index_view_type).and_return(:custom)
|
130
|
-
config.view.custom
|
130
|
+
config.view.custom(document_actions: [])
|
131
131
|
expect(helper.render_index_doc_actions(document)).to be_blank
|
132
132
|
end
|
133
133
|
end
|
@@ -315,7 +315,7 @@ RSpec.describe BlacklightHelper do
|
|
315
315
|
end
|
316
316
|
|
317
317
|
it "ignores missing templates" do
|
318
|
-
blacklight_config.view.view_type
|
318
|
+
blacklight_config.view.view_type(partials: %w[index_header a b])
|
319
319
|
|
320
320
|
response = helper.render_document_index_with_view :view_type, [obj1, obj1]
|
321
321
|
expect(response).to have_selector "div#documents"
|