blacklight 7.38.0 → 7.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env +1 -1
- data/.github/workflows/ruby.yml +1 -43
- data/.rubocop.yml +13 -4
- data/.rubocop_todo.yml +396 -160
- data/Gemfile +0 -8
- data/README.md +1 -1
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_constraints.scss +4 -4
- data/app/components/blacklight/advanced_search_form_component.html.erb +2 -2
- data/app/components/blacklight/document_component.html.erb +4 -0
- data/app/components/blacklight/document_component.rb +27 -4
- data/app/components/blacklight/document_title_component.rb +4 -1
- data/app/components/blacklight/facet_component.rb +2 -2
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +1 -1
- data/app/components/blacklight/icons/icon_component.rb +9 -4
- data/app/components/blacklight/response/pagination_component.rb +6 -1
- data/app/components/blacklight/response/sort_component.html.erb +1 -6
- data/app/components/blacklight/response/sort_component.rb +17 -2
- data/app/components/blacklight/response/spellcheck_component.rb +1 -1
- data/app/components/blacklight/response/view_type_button_component.rb +1 -1
- data/app/components/blacklight/response/view_type_component.rb +1 -1
- data/app/components/blacklight/search/per_page_component.html.erb +2 -0
- data/app/components/blacklight/search/per_page_component.rb +50 -0
- data/app/components/blacklight/system/dropdown_button_component.rb +18 -0
- data/app/components/blacklight/system/dropdown_component.rb +4 -7
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/system/flash_message_component.rb +1 -1
- data/app/components/blacklight/system/modal_component.rb +1 -1
- data/app/helpers/blacklight/catalog_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/icon_helper_behavior.rb +3 -0
- data/app/helpers/blacklight/layout_helper_behavior.rb +3 -3
- data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -1
- data/app/views/catalog/_per_page_widget.html.erb +1 -10
- data/app/views/kaminari/blacklight/_page.html.erb +1 -2
- data/app/views/shared/_flash_messages.html.erb +1 -1
- data/blacklight.gemspec +8 -5
- data/docker-compose.yml +0 -2
- data/lib/blacklight/configuration/view_config.rb +6 -0
- data/lib/blacklight/configuration.rb +4 -17
- data/lib/blacklight/open_struct_with_hash_access.rb +0 -15
- data/lib/blacklight/solr/response.rb +0 -12
- data/lib/blacklight/solr/search_builder_behavior.rb +2 -0
- data/lib/blacklight/solr.rb +0 -6
- data/lib/blacklight.rb +5 -20
- data/lib/generators/blacklight/assets_generator.rb +0 -3
- data/package.json +1 -1
- data/spec/components/blacklight/document/action_component_spec.rb +1 -6
- data/spec/components/blacklight/document_component_spec.rb +50 -0
- data/spec/components/blacklight/icons/icon_component_spec.rb +42 -0
- data/spec/components/blacklight/response/pagination_component_spec.rb +53 -0
- data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +20 -3
- data/spec/models/blacklight/solr/search_builder_spec.rb +13 -0
- data/spec/services/blacklight/search_service_spec.rb +12 -12
- data/spec/spec_helper.rb +0 -28
- data/spec/test_app_templates/Gemfile.extra +0 -1
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -0
- data/spec/views/catalog/index.atom.builder_spec.rb +2 -1
- data/template.demo.rb +7 -7
- metadata +61 -12
@@ -4,22 +4,6 @@ module Blacklight
|
|
4
4
|
# Blacklight::Configuration holds the configuration for a Blacklight::Controller, including
|
5
5
|
# fields to display, facets to show, sort options, and search fields.
|
6
6
|
class Configuration < OpenStructWithHashAccess
|
7
|
-
extend ActiveSupport::Autoload
|
8
|
-
eager_autoload do
|
9
|
-
autoload :Context
|
10
|
-
autoload :ViewConfig
|
11
|
-
autoload :ToolConfig
|
12
|
-
autoload :Fields
|
13
|
-
autoload :Field
|
14
|
-
autoload :NullField
|
15
|
-
autoload :SearchField
|
16
|
-
autoload :FacetField
|
17
|
-
autoload :SortField
|
18
|
-
autoload :DisplayField
|
19
|
-
autoload :IndexField
|
20
|
-
autoload :ShowField
|
21
|
-
end
|
22
|
-
|
23
7
|
class_attribute :default_values, default: {}
|
24
8
|
|
25
9
|
# Set up Blacklight::Configuration.default_values to contain the basic, required Blacklight fields
|
@@ -51,6 +35,7 @@ module Blacklight
|
|
51
35
|
end
|
52
36
|
|
53
37
|
property :logo_link
|
38
|
+
property :full_width_layout, default: false
|
54
39
|
property :header_component, default: nil
|
55
40
|
def header_component
|
56
41
|
super || Blacklight::HeaderComponent
|
@@ -205,7 +190,9 @@ module Blacklight
|
|
205
190
|
# component class used to render search constraints
|
206
191
|
constraints_component: nil,
|
207
192
|
# component class used to render the search bar
|
208
|
-
search_bar_component: nil
|
193
|
+
search_bar_component: nil,
|
194
|
+
# pagination parameters to pass to kaminari
|
195
|
+
pagination_options: Blacklight::Engine.config.blacklight.default_pagination_options.dup
|
209
196
|
)
|
210
197
|
|
211
198
|
# @!attribute show
|
@@ -51,20 +51,5 @@ module Blacklight
|
|
51
51
|
def deep_dup
|
52
52
|
self.class.new @table.deep_dup
|
53
53
|
end
|
54
|
-
|
55
|
-
if Rails.version < '6'
|
56
|
-
# Ported from Rails 6 to fix an incompatibility with ostruct
|
57
|
-
def try(method_name = nil, *args, &block)
|
58
|
-
if method_name.nil? && block_given?
|
59
|
-
if b.arity.zero?
|
60
|
-
instance_eval(&block)
|
61
|
-
else
|
62
|
-
yield self
|
63
|
-
end
|
64
|
-
elsif respond_to?(method_name)
|
65
|
-
public_send(method_name, *args, &b)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
54
|
end
|
70
55
|
end
|
@@ -1,17 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
3
|
-
extend ActiveSupport::Autoload
|
4
|
-
eager_autoload do
|
5
|
-
autoload :PaginationMethods
|
6
|
-
autoload :Response
|
7
|
-
autoload :Spelling
|
8
|
-
autoload :Facets
|
9
|
-
autoload :MoreLikeThis
|
10
|
-
autoload :GroupResponse
|
11
|
-
autoload :Group
|
12
|
-
autoload :Params
|
13
|
-
end
|
14
|
-
|
15
3
|
include PaginationMethods
|
16
4
|
include Spelling
|
17
5
|
include Facets
|
@@ -105,6 +105,8 @@ module Blacklight::Solr
|
|
105
105
|
return unless search_state.query_param
|
106
106
|
|
107
107
|
bool_query = search_field.clause_params.transform_values { |v| v.merge(query: search_state.query_param) }
|
108
|
+
solr_parameters["spellcheck.q"] ||= search_state.query_param
|
109
|
+
|
108
110
|
solr_parameters.append_boolean_query(:must, bool_query)
|
109
111
|
end
|
110
112
|
|
data/lib/blacklight/solr.rb
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Blacklight
|
3
3
|
module Solr
|
4
|
-
autoload :Document, 'blacklight/solr/document'
|
5
|
-
autoload :FacetPaginator, 'blacklight/solr/facet_paginator'
|
6
|
-
autoload :Repository, 'blacklight/solr/repository'
|
7
|
-
autoload :Request, 'blacklight/solr/request'
|
8
|
-
autoload :Response, 'blacklight/solr/response'
|
9
|
-
autoload :SearchBuilderBehavior, 'blacklight/solr/search_builder_behavior'
|
10
4
|
end
|
11
5
|
end
|
data/lib/blacklight.rb
CHANGED
@@ -1,25 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'kaminari'
|
3
3
|
require 'deprecation'
|
4
|
-
require 'blacklight/open_struct_with_hash_access'
|
5
|
-
require 'blacklight/nested_open_struct_with_hash_access'
|
6
4
|
require 'jbuilder'
|
5
|
+
require "zeitwerk"
|
6
|
+
loader = Zeitwerk::Loader.for_gem
|
7
|
+
loader.ignore("#{__dir__}/generators")
|
8
|
+
loader.setup
|
7
9
|
|
8
10
|
module Blacklight
|
9
|
-
autoload :AbstractRepository, 'blacklight/abstract_repository'
|
10
|
-
autoload :Component, 'blacklight/component'
|
11
|
-
autoload :Configuration, 'blacklight/configuration'
|
12
|
-
autoload :Exceptions, 'blacklight/exceptions'
|
13
|
-
autoload :Parameters, 'blacklight/parameters'
|
14
|
-
autoload :Routes, 'blacklight/routes'
|
15
|
-
autoload :RuntimeRegistry, 'blacklight/runtime_registry'
|
16
|
-
autoload :SearchBuilder, 'blacklight/search_builder'
|
17
|
-
autoload :SearchState, 'blacklight/search_state'
|
18
|
-
autoload :Solr, 'blacklight/solr'
|
19
|
-
|
20
11
|
extend Deprecation
|
21
|
-
|
22
|
-
require 'blacklight/version'
|
23
12
|
require 'blacklight/engine' if defined?(Rails)
|
24
13
|
|
25
14
|
def self.blacklight_config_file
|
@@ -93,11 +82,7 @@ module Blacklight
|
|
93
82
|
end
|
94
83
|
|
95
84
|
begin
|
96
|
-
@blacklight_yml =
|
97
|
-
YAML.safe_load(blacklight_erb, aliases: true)
|
98
|
-
else
|
99
|
-
YAML.safe_load(blacklight_erb, [], [], true)
|
100
|
-
end
|
85
|
+
@blacklight_yml = YAML.safe_load(blacklight_erb, aliases: true)
|
101
86
|
rescue => e
|
102
87
|
raise("#{blacklight_config_file} was found, but could not be parsed.\n#{e.inspect}")
|
103
88
|
end
|
@@ -19,9 +19,6 @@ module Blacklight
|
|
19
19
|
|
20
20
|
# Add sprockets javascript if needed
|
21
21
|
def create_sprockets_javascript
|
22
|
-
# Rails 5 already has an application.js file
|
23
|
-
return if Rails.version < '6'
|
24
|
-
|
25
22
|
create_file 'app/assets/javascripts/application.js' do
|
26
23
|
<<~CONTENT
|
27
24
|
//= require jquery3
|
data/package.json
CHANGED
@@ -23,12 +23,7 @@ RSpec.describe Blacklight::Document::ActionComponent, type: :component do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'renders an action link' do
|
26
|
-
|
27
|
-
allow(view_context).to receive(:some_tool_solr_document_path).with(document, { only_path: true }).and_return('/asdf')
|
28
|
-
else
|
29
|
-
allow(view_context).to receive(:some_tool_solr_document_path).with(document).and_return('/asdf')
|
30
|
-
end
|
31
|
-
|
26
|
+
allow(view_context).to receive(:some_tool_solr_document_path).with(document, { only_path: true }).and_return('/asdf')
|
32
27
|
expect(rendered).to have_link 'Some tool', href: '/asdf'
|
33
28
|
end
|
34
29
|
|
@@ -160,6 +160,26 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
160
160
|
expect(rendered).to have_content 'embed'
|
161
161
|
end
|
162
162
|
|
163
|
+
context 'show view with custom translation' do
|
164
|
+
let!(:original_translations) { I18n.backend.send(:translations).deep_dup }
|
165
|
+
|
166
|
+
before do
|
167
|
+
controller.action_name = "show"
|
168
|
+
I18n.backend.store_translations(:en, blacklight: { search: { show: { label: "testing:%{label}" } } })
|
169
|
+
end
|
170
|
+
|
171
|
+
after do
|
172
|
+
I18n.backend.reload!
|
173
|
+
I18n.backend.store_translations(:en, original_translations[:en])
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'renders with show-specific metadata with correct translation' do
|
177
|
+
expect(rendered).to have_css 'dl.document-metadata'
|
178
|
+
expect(rendered).to have_css 'dt', text: 'testing:ISBN'
|
179
|
+
expect(rendered).to have_css 'dd', text: 'Value'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
163
183
|
context 'with configured metadata component' do
|
164
184
|
let(:custom_component_class) do
|
165
185
|
Class.new(Blacklight::DocumentMetadataComponent) do
|
@@ -216,6 +236,36 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
216
236
|
end
|
217
237
|
end
|
218
238
|
|
239
|
+
context 'with partials rendered into a component slot' do
|
240
|
+
it 'does not automatically renders partials' do
|
241
|
+
component.with_partial { 'Partials' }
|
242
|
+
expect(rendered).not_to have_content 'Partials'
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
context 'with render_partials_in_component set to true' do
|
247
|
+
before do
|
248
|
+
blacklight_config.index.render_partials_in_component = true
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'renders partials' do
|
252
|
+
component.with_partial { 'Partials' }
|
253
|
+
expect(rendered).to have_content 'Partials'
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
context 'with partials passed into the component constructor' do
|
258
|
+
let(:attr) { { partials: ['a'] } }
|
259
|
+
|
260
|
+
before do
|
261
|
+
allow(view_context).to receive(:render_document_partial).and_return('Partials')
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'renders partials' do
|
265
|
+
expect(rendered).to have_content 'Partials'
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
219
269
|
context 'with before_titles' do
|
220
270
|
let(:render) do
|
221
271
|
component.render_in(view_context) do
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::Icons::IconComponent, type: :component do
|
6
|
+
subject(:component) { sub_component.new }
|
7
|
+
|
8
|
+
let(:sub_component) do
|
9
|
+
Class.new(described_class) do
|
10
|
+
def self.name
|
11
|
+
'TestIconComponent'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when no classes are passed in' do
|
17
|
+
subject(:component) { sub_component.new }
|
18
|
+
|
19
|
+
it "renders component" do
|
20
|
+
render_inline(component)
|
21
|
+
expect(page).to have_css "span[class='blacklight-icons blacklight-icons-test_icon']"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when classes are passed in' do
|
26
|
+
subject(:component) { sub_component.new(classes: 'my-icon') }
|
27
|
+
|
28
|
+
it "renders component" do
|
29
|
+
render_inline(component)
|
30
|
+
expect(page).to have_css "span[class='my-icon blacklight-icons blacklight-icons-test_icon']"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when name is passed in' do
|
35
|
+
subject(:component) { sub_component.new(name: 'my-icon') }
|
36
|
+
|
37
|
+
it "renders component" do
|
38
|
+
render_inline(component)
|
39
|
+
expect(page).to have_css "span[class='blacklight-icons blacklight-icons-my-icon']"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::Response::PaginationComponent, type: :component do
|
6
|
+
let(:render) do
|
7
|
+
with_request_url '/catalog?q=foo' do
|
8
|
+
render_inline(instance)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:instance) { described_class.new(response: response) }
|
13
|
+
|
14
|
+
context 'when there are many results' do
|
15
|
+
let(:response) { instance_double(Blacklight::Solr::Response, total: 10, current_page: 5, limit_value: 10_000, total_pages: 100) }
|
16
|
+
|
17
|
+
context 'with default config' do
|
18
|
+
before { render }
|
19
|
+
|
20
|
+
it "has links to deep pages" do
|
21
|
+
expect(page).not_to have_link '98'
|
22
|
+
expect(page).to have_link '99'
|
23
|
+
expect(page).to have_link '100'
|
24
|
+
expect(page).not_to have_link '101'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when a different configuration that removes deep links is passed as a parameter' do
|
29
|
+
let(:instance) { described_class.new(response: response, left: 5, right: 0, outer_window: nil) }
|
30
|
+
|
31
|
+
before { render }
|
32
|
+
|
33
|
+
it "does not link to deep pages" do
|
34
|
+
expect(page).to have_link '1'
|
35
|
+
expect(page).not_to have_link '100'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when a different configuration that removes deep links is configured in the controller' do
|
40
|
+
before do
|
41
|
+
allow(controller.blacklight_config.index)
|
42
|
+
.to receive(:pagination_options)
|
43
|
+
.and_return(theme: 'blacklight', left: 5, right: 0)
|
44
|
+
render
|
45
|
+
end
|
46
|
+
|
47
|
+
it "does not link to deep pages" do
|
48
|
+
expect(page).to have_link '1'
|
49
|
+
expect(page).not_to have_link '100'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -30,9 +30,26 @@ RSpec.describe Blacklight::LayoutHelperBehavior do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe '#container_classes' do
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
before do
|
34
|
+
allow(view).to receive(:blacklight_config).and_return(config)
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when not full-width' do
|
38
|
+
let(:config) { Blacklight::Configuration.new }
|
39
|
+
|
40
|
+
it 'returns a string of classe(s)' do
|
41
|
+
expect(helper.container_classes).to be_an String
|
42
|
+
expect(helper.container_classes).to eq 'container'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when full-width' do
|
47
|
+
let(:config) { Blacklight::Configuration.new(full_width_layout: true) }
|
48
|
+
|
49
|
+
it 'returns a string of classe(s)' do
|
50
|
+
expect(helper.container_classes).to be_an String
|
51
|
+
expect(helper.container_classes).to eq 'container-fluid'
|
52
|
+
end
|
36
53
|
end
|
37
54
|
end
|
38
55
|
|
@@ -335,6 +335,7 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
335
335
|
qf: '$subject_qf',
|
336
336
|
pf: '$subject_pf'
|
337
337
|
}
|
338
|
+
blacklight_config.search_fields['subject'].clause_params = nil
|
338
339
|
end
|
339
340
|
|
340
341
|
it "looks up qt from field definition" do
|
@@ -374,6 +375,18 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
374
375
|
expect(key_value_pairs).to include("pf=$subject_pf")
|
375
376
|
expect(key_value_pairs).to include("qf=$subject_qf")
|
376
377
|
end
|
378
|
+
|
379
|
+
context 'when subject field uses JSON query DSL' do
|
380
|
+
before do
|
381
|
+
blacklight_config.search_fields['subject'].clause_params = {
|
382
|
+
edismax: {}
|
383
|
+
}
|
384
|
+
end
|
385
|
+
|
386
|
+
it "includes spellcheck.q, without LocalParams" do
|
387
|
+
expect(subject["spellcheck.q"]).to eq "wome"
|
388
|
+
end
|
389
|
+
end
|
377
390
|
end
|
378
391
|
|
379
392
|
describe "solr json query parameters from the fielded search" do
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# to talk with solr and get results)? when we do a document request, does
|
9
9
|
# blacklight code get a single document returned?)
|
10
10
|
#
|
11
|
-
RSpec.describe Blacklight::SearchService, api
|
11
|
+
RSpec.describe Blacklight::SearchService, :api do
|
12
12
|
subject { service }
|
13
13
|
|
14
14
|
let(:context) { { whatever: :value } }
|
@@ -49,7 +49,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# SPECS FOR SEARCH RESULTS FOR QUERY
|
52
|
-
describe 'Search Results', integration
|
52
|
+
describe 'Search Results', :integration do
|
53
53
|
let(:blacklight_config) { copy_of_catalog_config }
|
54
54
|
|
55
55
|
describe 'for a sample query returning results' do
|
@@ -100,11 +100,11 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
100
100
|
|
101
101
|
it "returns a grouped response" do
|
102
102
|
expect(@document_list).to be_empty
|
103
|
-
expect(@solr_response).to
|
103
|
+
expect(@solr_response).to be_a Blacklight::Solr::Response::GroupResponse
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
describe "for a query returning multiple groups", integration
|
107
|
+
describe "for a query returning multiple groups", :integration do
|
108
108
|
let(:blacklight_config) { copy_of_catalog_config }
|
109
109
|
let(:user_params) { { q: all_docs_query } }
|
110
110
|
|
@@ -117,7 +117,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
117
117
|
|
118
118
|
it "returns a grouped response" do
|
119
119
|
expect(@document_list).to be_empty
|
120
|
-
expect(@solr_response).to
|
120
|
+
expect(@solr_response).to be_a Blacklight::Solr::Response::GroupResponse
|
121
121
|
expect(@solr_response.group_field).to eq "title_si"
|
122
122
|
end
|
123
123
|
end
|
@@ -167,7 +167,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
167
167
|
end # Search Results
|
168
168
|
|
169
169
|
# SPECS FOR SEARCH RESULTS FOR FACETS
|
170
|
-
describe 'Facets in Search Results for All Docs Query', integration
|
170
|
+
describe 'Facets in Search Results for All Docs Query', :integration do
|
171
171
|
let(:blacklight_config) { copy_of_catalog_config }
|
172
172
|
let(:user_params) { { q: all_docs_query } }
|
173
173
|
|
@@ -181,7 +181,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
181
181
|
end
|
182
182
|
|
183
183
|
it 'has all facets specified in initializer' do
|
184
|
-
expect(@facets.keys).to include
|
184
|
+
expect(@facets.keys).to include(*blacklight_config.facet_fields.keys)
|
185
185
|
expect(@facets.none? { |_k, v| v.nil? }).to eq true
|
186
186
|
end
|
187
187
|
|
@@ -205,14 +205,14 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
205
205
|
it 'has all value counts > 0' do
|
206
206
|
@facets.each do |_key, facet|
|
207
207
|
facet.items.each do |facet_vals|
|
208
|
-
expect(facet_vals.hits).to
|
208
|
+
expect(facet_vals.hits).to be_positive
|
209
209
|
end
|
210
210
|
end
|
211
211
|
end
|
212
212
|
end # facet specs
|
213
213
|
|
214
214
|
# SPECS FOR SEARCH RESULTS FOR PAGING
|
215
|
-
describe 'Paging', integration
|
215
|
+
describe 'Paging', :integration do
|
216
216
|
let(:blacklight_config) { copy_of_catalog_config }
|
217
217
|
let(:user_params) { { q: all_docs_query } }
|
218
218
|
|
@@ -309,7 +309,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
309
309
|
end # page specs
|
310
310
|
|
311
311
|
# SPECS FOR SINGLE DOCUMENT REQUESTS
|
312
|
-
describe 'Get Document By Id', integration
|
312
|
+
describe 'Get Document By Id', :integration do
|
313
313
|
let(:doc_id) { '2007020969' }
|
314
314
|
let(:bad_id) { 'redrum' }
|
315
315
|
|
@@ -336,7 +336,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
336
336
|
end
|
337
337
|
end
|
338
338
|
|
339
|
-
describe 'Get multiple documents By Id', integration
|
339
|
+
describe 'Get multiple documents By Id', :integration do
|
340
340
|
let(:doc_id) { '2007020969' }
|
341
341
|
let(:bad_id) { 'redrum' }
|
342
342
|
let(:response) { service.fetch([doc_id]).first }
|
@@ -355,7 +355,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
355
355
|
end
|
356
356
|
|
357
357
|
# SPECS FOR SPELLING SUGGESTIONS VIA SEARCH
|
358
|
-
describe "Searches should return spelling suggestions", integration
|
358
|
+
describe "Searches should return spelling suggestions", :integration do
|
359
359
|
context "for just-poor-enough-query term" do
|
360
360
|
let(:user_params) { { q: 'boo' } }
|
361
361
|
|
data/spec/spec_helper.rb
CHANGED
@@ -117,31 +117,3 @@ RSpec.configure do |config|
|
|
117
117
|
# as the one that triggered the failure.
|
118
118
|
Kernel.srand config.seed
|
119
119
|
end
|
120
|
-
|
121
|
-
# RSpec's stub_template method needs a differnet implementation for Rails 7.1, that
|
122
|
-
# isn't yet in an rspec-rails release.
|
123
|
-
#
|
124
|
-
# First rspec-rails tried this:
|
125
|
-
# https://github.com/rspec/rspec-rails/commit/4d65bea0619955acb15023b9c3f57a3a53183da8
|
126
|
-
#
|
127
|
-
# But it was subject to this problem:
|
128
|
-
# https://github.com/rspec/rspec-rails/issues/2696
|
129
|
-
#
|
130
|
-
# Below implementation appears to work for our purposes here, so we will patch it in
|
131
|
-
# if we are on Rails 7.1+, and not yet rspec-rails 6.1 which we expect to have it.
|
132
|
-
|
133
|
-
if ::Rails.version.to_f >= 7.1 && Gem.loaded_specs["rspec-rails"].version.release < Gem::Version.new('6.1')
|
134
|
-
|
135
|
-
module RSpec
|
136
|
-
module Rails
|
137
|
-
module ViewExampleGroup
|
138
|
-
module ExampleMethods
|
139
|
-
def stub_template(hash)
|
140
|
-
controller.prepend_view_path(StubResolverCache.resolver_for(hash))
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
@@ -2,9 +2,11 @@
|
|
2
2
|
|
3
3
|
RSpec.describe "catalog/_paginate_compact.html.erb" do
|
4
4
|
let(:user) { User.new { |u| u.save(validate: false) } }
|
5
|
+
let(:blacklight_config) { Blacklight::Configuration.new }
|
5
6
|
|
6
7
|
before do
|
7
8
|
controller.request.path_parameters[:action] = 'index'
|
9
|
+
allow(controller).to receive(:blacklight_config).and_return(blacklight_config)
|
8
10
|
end
|
9
11
|
|
10
12
|
it "renders paginatable arrays" do
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'rexml/document'
|
3
4
|
|
4
5
|
RSpec.describe "catalog/index" do
|
@@ -6,7 +7,7 @@ RSpec.describe "catalog/index" do
|
|
6
7
|
10.times.map do |i|
|
7
8
|
doc = SolrDocument.new(id: i)
|
8
9
|
allow(doc).to receive(:export_as_some_format).and_return("")
|
9
|
-
allow(doc).to receive(:to_semantic_values).and_return(author: ['xyz']) if i
|
10
|
+
allow(doc).to receive(:to_semantic_values).and_return(author: ['xyz']) if i.zero?
|
10
11
|
doc.will_export_as(:some_format, "application/some-format") if i == 1
|
11
12
|
doc
|
12
13
|
end
|
data/template.demo.rb
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
gem 'blacklight', '>= 7.0'
|
4
4
|
|
5
|
-
|
5
|
+
after_bundle do
|
6
|
+
# run the blacklight install generator
|
7
|
+
options = ENV.fetch("BLACKLIGHT_INSTALL_OPTIONS", '--devise --marc')
|
6
8
|
|
7
|
-
|
8
|
-
options = ENV.fetch("BLACKLIGHT_INSTALL_OPTIONS", '--devise --marc')
|
9
|
+
generate 'blacklight:install', options
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
rake "db:migrate"
|
11
|
+
# run the database migrations
|
12
|
+
rake "db:migrate"
|
13
|
+
end
|