blacklight 8.3.0 → 8.5.0
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/.github/workflows/ruby.yml +10 -6
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +22 -55
- data/Gemfile +2 -10
- data/README.md +2 -2
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +13 -7
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +13 -7
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -1
- data/app/assets/stylesheets/blacklight/_bookmark.scss +30 -0
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +0 -4
- data/app/assets/stylesheets/blacklight/_constraints.scss +15 -9
- data/app/assets/stylesheets/blacklight/_controls.scss +0 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +33 -37
- data/app/assets/stylesheets/blacklight/_header.scss +2 -35
- data/app/assets/stylesheets/blacklight/_icons.scss +3 -2
- data/app/assets/stylesheets/blacklight/_layout.scss +3 -0
- data/app/assets/stylesheets/blacklight/_mixins.scss +4 -4
- data/app/assets/stylesheets/blacklight/_search_form.scss +3 -8
- data/app/assets/stylesheets/blacklight/_search_history.scss +5 -5
- data/app/assets/stylesheets/blacklight/_search_results.scss +5 -2
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +16 -10
- data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +6 -0
- data/app/components/blacklight/constraint_layout_component.html.erb +2 -9
- data/app/components/blacklight/constraint_layout_component.rb +8 -0
- data/app/components/blacklight/constraints_component.rb +3 -3
- data/app/components/blacklight/document/action_component.rb +2 -1
- data/app/components/blacklight/document/bookmark_component.html.erb +2 -1
- data/app/components/blacklight/document/bookmark_component.rb +6 -0
- data/app/components/blacklight/document/page_header_component.html.erb +7 -0
- data/app/components/blacklight/document/page_header_component.rb +85 -0
- data/app/components/blacklight/document_component.rb +1 -1
- data/app/components/blacklight/facet_component.rb +1 -1
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +1 -1
- data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
- data/app/components/blacklight/facet_field_inclusive_constraint_component.html.erb +1 -1
- data/app/components/blacklight/facet_field_list_component.html.erb +1 -1
- data/app/components/blacklight/facet_item_component.rb +1 -1
- data/app/components/blacklight/icons/bookmark_icon_component.rb +17 -0
- data/app/components/blacklight/icons/icon_component.rb +9 -4
- data/app/components/blacklight/icons/remove_component.rb +16 -0
- data/app/components/blacklight/metadata_field_component.html.erb +1 -1
- data/app/components/blacklight/metadata_field_component.rb +5 -0
- data/app/components/blacklight/response/facet_group_component.rb +1 -1
- data/app/components/blacklight/response/pagination_component.html.erb +1 -1
- data/app/components/blacklight/response/sort_component.html.erb +1 -6
- data/app/components/blacklight/response/sort_component.rb +15 -0
- 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/search_bar_component.html.erb +1 -1
- data/app/components/blacklight/search_context/server_item_pagination_component.html.erb +5 -4
- data/app/components/blacklight/search_context/server_item_pagination_component.rb +1 -1
- data/app/components/blacklight/skip_link_component.html.erb +7 -0
- data/app/components/blacklight/skip_link_component.rb +17 -0
- data/app/components/blacklight/system/dropdown_button_component.rb +18 -0
- data/app/components/blacklight/system/dropdown_component.rb +3 -6
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/top_navbar_component.html.erb +2 -2
- data/app/components/blacklight/top_navbar_component.rb +4 -0
- data/app/helpers/blacklight/catalog_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/component_helper_behavior.rb +4 -4
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/document_helper_behavior.rb +14 -0
- data/app/javascript/blacklight/checkbox_submit.js +7 -1
- data/app/javascript/blacklight/core.js +5 -5
- data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -1
- data/app/presenters/blacklight/facet_checkbox_item_presenter.rb +11 -0
- data/app/presenters/blacklight/facet_field_presenter.rb +9 -1
- data/app/services/blacklight/search_service.rb +9 -1
- data/app/views/catalog/_per_page_widget.html.erb +1 -10
- data/app/views/catalog/_search_results.html.erb +1 -1
- data/app/views/catalog/_show_main_content.html.erb +1 -1
- data/app/views/catalog/_show_sidebar.html.erb +1 -0
- data/app/views/catalog/show.html.erb +3 -3
- data/app/views/catalog/suggest.html.erb +1 -1
- data/app/views/kaminari/blacklight/_page.html.erb +14 -8
- data/app/views/kaminari/blacklight/_paginator.html.erb +2 -1
- data/app/views/layouts/blacklight/base.html.erb +3 -5
- data/blacklight.gemspec +6 -2
- data/{docker-compose.yml → compose.yaml} +1 -1
- data/config/locales/blacklight.ar.yml +3 -0
- data/config/locales/blacklight.de.yml +3 -0
- data/config/locales/blacklight.en.yml +216 -229
- data/config/locales/blacklight.es.yml +3 -0
- data/config/locales/blacklight.fr.yml +3 -0
- data/config/locales/blacklight.hu.yml +3 -0
- data/config/locales/blacklight.it.yml +3 -0
- data/config/locales/blacklight.nl.yml +3 -0
- data/config/locales/blacklight.pt-BR.yml +3 -0
- data/config/locales/blacklight.sq.yml +3 -0
- data/config/locales/blacklight.zh.yml +3 -0
- data/lib/blacklight/abstract_repository.rb +6 -0
- data/lib/blacklight/component.rb +10 -47
- data/lib/blacklight/configuration.rb +32 -19
- data/lib/blacklight/engine.rb +6 -0
- data/lib/blacklight/parameters.rb +1 -1
- data/lib/blacklight/solr/repository.rb +11 -4
- data/lib/blacklight/solr/response/params.rb +1 -1
- data/lib/blacklight/solr/response.rb +0 -12
- data/lib/blacklight/solr/search_builder_behavior.rb +1 -1
- data/lib/blacklight/solr.rb +0 -6
- data/lib/blacklight.rb +4 -14
- data/lib/generators/blacklight/assets/propshaft_generator.rb +2 -2
- data/lib/generators/blacklight/models_generator.rb +1 -1
- data/lib/generators/blacklight/user_generator.rb +2 -0
- data/package.json +3 -2
- data/rollup.config.js +6 -12
- data/spec/components/blacklight/document/action_component_spec.rb +1 -1
- data/spec/components/blacklight/document/page_header_component_spec.rb +92 -0
- data/spec/components/blacklight/document_component_spec.rb +20 -0
- data/spec/components/blacklight/icons/icon_component_spec.rb +42 -0
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +13 -2
- data/spec/controllers/blacklight/catalog_spec.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +5 -5
- data/spec/features/advanced_search_spec.rb +16 -2
- data/spec/features/bookmarks_spec.rb +15 -0
- data/spec/features/search_context_spec.rb +2 -1
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +2 -2
- data/spec/lib/blacklight/component_spec.rb +32 -27
- data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +1 -1
- data/spec/models/blacklight/configuration_spec.rb +12 -12
- data/spec/models/blacklight/solr/document_spec.rb +2 -2
- data/spec/models/blacklight/solr/repository_spec.rb +31 -13
- data/spec/models/blacklight/solr/response/facets_spec.rb +2 -2
- data/spec/models/blacklight/solr/response/group_spec.rb +1 -1
- data/spec/models/blacklight/solr/response_spec.rb +2 -2
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +1 -1
- data/spec/models/bookmark_spec.rb +1 -1
- data/spec/presenters/blacklight/document_presenter_spec.rb +2 -2
- data/spec/presenters/blacklight/facet_checkbox_item_presenter_spec.rb +42 -0
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +14 -0
- data/spec/requests/load_suggestions_spec.rb +5 -5
- data/spec/services/blacklight/search_service_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -2
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/tasks/blacklight.rake +6 -6
- metadata +86 -8
@@ -13,7 +13,7 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
13
13
|
|
14
14
|
it 'wraps the facet data in a presenter' do
|
15
15
|
presenter = helper.facet_field_presenter(facet_config, display_facet)
|
16
|
-
expect(presenter).to
|
16
|
+
expect(presenter).to be_a Blacklight::FacetFieldPresenter
|
17
17
|
expect(presenter.facet_field).to eq facet_config
|
18
18
|
expect(presenter.display_facet).to eq display_facet
|
19
19
|
expect(presenter.view_context).to eq helper
|
@@ -23,7 +23,7 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
23
23
|
stub_const('SomePresenter', Class.new(Blacklight::FacetFieldPresenter))
|
24
24
|
facet_config.presenter = SomePresenter
|
25
25
|
presenter = helper.facet_field_presenter(facet_config, display_facet)
|
26
|
-
expect(presenter).to
|
26
|
+
expect(presenter).to be_a SomePresenter
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -1,43 +1,48 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe Blacklight::Component do
|
4
|
-
let(:component_class) { Blacklight::
|
3
|
+
RSpec.describe Blacklight::Component, type: :component do
|
4
|
+
let(:component_class) { Blacklight::System::ModalComponent }
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
before do
|
7
|
+
component_class.reset_compiler!
|
8
|
+
ViewComponent::CompileCache.invalidate!
|
9
|
+
|
10
|
+
component_class.class_eval do
|
11
|
+
undef :call if method_defined?(:call)
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
after do
|
16
|
+
component_class.reset_compiler!
|
17
|
+
ViewComponent::CompileCache.invalidate!
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
component_class.class_eval do
|
20
|
+
undef :call if method_defined?(:call)
|
21
|
+
end
|
22
|
+
end
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
24
|
+
context "without overrides" do
|
25
|
+
it "renders the engine template" do
|
26
|
+
render_inline(component_class.new)
|
27
|
+
expect(page).to have_css('.modal-header')
|
25
28
|
end
|
29
|
+
end
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
context "with overrides" do
|
32
|
+
around do |ex|
|
33
|
+
FileUtils.mkdir_p(Rails.root.join('app/components/blacklight/system'))
|
34
|
+
Rails.root.join("app/components/blacklight/system/modal_component.html.erb").open("w") do |f|
|
35
|
+
f.puts '<div class="custom-modal">Overridden</div>'
|
30
36
|
end
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
ex.run
|
39
|
+
ensure
|
40
|
+
Rails.root.join('app/components/blacklight/system/modal_component.html.erb').unlink
|
41
|
+
end
|
36
42
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
43
|
+
it "renders to application template" do
|
44
|
+
render_inline(component_class.new)
|
45
|
+
expect(page).to have_css('.custom-modal')
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
@@ -23,7 +23,7 @@ RSpec.describe Blacklight::NestedOpenStructWithHashAccess do
|
|
23
23
|
|
24
24
|
describe "#deep_dup" do
|
25
25
|
it "preserves the current class" do
|
26
|
-
expect(described_class.new(described_class).deep_dup).to
|
26
|
+
expect(described_class.new(described_class).deep_dup).to be_a described_class
|
27
27
|
end
|
28
28
|
|
29
29
|
it "preserves the default proc" do
|
@@ -14,7 +14,7 @@ RSpec.describe "Blacklight::Configuration", :api do
|
|
14
14
|
|
15
15
|
describe "initialization" do
|
16
16
|
it "is an OpenStructWithHashAccess" do
|
17
|
-
expect(config).to
|
17
|
+
expect(config).to be_a Blacklight::OpenStructWithHashAccess
|
18
18
|
end
|
19
19
|
|
20
20
|
it "accepts a block for configuration" do
|
@@ -30,22 +30,22 @@ RSpec.describe "Blacklight::Configuration", :api do
|
|
30
30
|
|
31
31
|
describe "defaults" do
|
32
32
|
it "has a hash of default rsolr query parameters" do
|
33
|
-
expect(config.default_solr_params).to
|
33
|
+
expect(config.default_solr_params).to be_a Hash
|
34
34
|
end
|
35
35
|
|
36
36
|
it "has openstruct values for show and index parameters" do
|
37
|
-
expect(config.show).to
|
38
|
-
expect(config.index).to
|
37
|
+
expect(config.show).to be_a OpenStruct
|
38
|
+
expect(config.index).to be_a OpenStruct
|
39
39
|
end
|
40
40
|
|
41
41
|
it "has ordered hashes for field configuration" do
|
42
|
-
expect(config.facet_fields).to
|
43
|
-
expect(config.index_fields).to
|
44
|
-
expect(config.show_fields).to
|
45
|
-
expect(config.search_fields).to
|
46
|
-
expect(config.show_fields).to
|
47
|
-
expect(config.search_fields).to
|
48
|
-
expect(config.sort_fields).to
|
42
|
+
expect(config.facet_fields).to be_a Hash
|
43
|
+
expect(config.index_fields).to be_a Hash
|
44
|
+
expect(config.show_fields).to be_a Hash
|
45
|
+
expect(config.search_fields).to be_a Hash
|
46
|
+
expect(config.show_fields).to be_a Hash
|
47
|
+
expect(config.search_fields).to be_a Hash
|
48
|
+
expect(config.sort_fields).to be_a Hash
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -197,7 +197,7 @@ RSpec.describe "Blacklight::Configuration", :api do
|
|
197
197
|
config.add_my_custom_facet_field 'qwerty', label: "asdf"
|
198
198
|
end
|
199
199
|
|
200
|
-
expect(config.my_custom_facet_fields['qwerty']).to
|
200
|
+
expect(config.my_custom_facet_fields['qwerty']).to be_a(Blacklight::Configuration::FacetField)
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
@@ -231,7 +231,7 @@ RSpec.describe "Blacklight::Solr::Document", :api do
|
|
231
231
|
end
|
232
232
|
|
233
233
|
it "returns an array even for a single-value field" do
|
234
|
-
expect(@doc1.to_semantic_values[:title]).to
|
234
|
+
expect(@doc1.to_semantic_values[:title]).to be_a(Array)
|
235
235
|
end
|
236
236
|
|
237
237
|
it "returns complete array for a multi-value field" do
|
@@ -290,7 +290,7 @@ RSpec.describe "Blacklight::Solr::Document", :api do
|
|
290
290
|
|
291
291
|
it "plucks the MoreLikeThis results from the Solr Response" do
|
292
292
|
expect(result).to have(1).item
|
293
|
-
expect(result.first).to
|
293
|
+
expect(result.first).to be_a(MockDocument)
|
294
294
|
expect(result.first.id).to eq 'abc'
|
295
295
|
expect(result.first.solr_response).to eq response
|
296
296
|
end
|
@@ -24,12 +24,12 @@ RSpec.describe Blacklight::Solr::Repository, :api do
|
|
24
24
|
blacklight_config.document_solr_path = 'abc'
|
25
25
|
blacklight_config.solr_path = 'xyz'
|
26
26
|
allow(subject.connection).to receive(:send_and_receive).with('abc', anything).and_return(mock_response)
|
27
|
-
expect(subject.find("123")).to
|
27
|
+
expect(subject.find("123")).to be_a Blacklight::Solr::Response
|
28
28
|
end
|
29
29
|
|
30
30
|
it "uses a default :qt param" do
|
31
31
|
allow(subject.connection).to receive(:send_and_receive).with('get', hash_including(params: hash_including(ids: '123'))).and_return(mock_response)
|
32
|
-
expect(subject.find("123", {})).to
|
32
|
+
expect(subject.find("123", {})).to be_a Blacklight::Solr::Response
|
33
33
|
end
|
34
34
|
|
35
35
|
context "without a document solr path configured" do
|
@@ -40,7 +40,7 @@ RSpec.describe Blacklight::Solr::Repository, :api do
|
|
40
40
|
it "uses the default solr path" do
|
41
41
|
blacklight_config.solr_path = 'xyz'
|
42
42
|
allow(subject.connection).to receive(:send_and_receive).with('xyz', anything).and_return(mock_response)
|
43
|
-
expect(subject.find("123")).to
|
43
|
+
expect(subject.find("123")).to be_a Blacklight::Solr::Response
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -53,14 +53,14 @@ RSpec.describe Blacklight::Solr::Repository, :api do
|
|
53
53
|
it "uses the provided :qt param" do
|
54
54
|
blacklight_config.document_solr_request_handler = 'xyz'
|
55
55
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'abc' })).and_return(mock_response)
|
56
|
-
expect(subject.find("123", qt: 'abc')).to
|
56
|
+
expect(subject.find("123", qt: 'abc')).to be_a Blacklight::Solr::Response
|
57
57
|
end
|
58
58
|
|
59
59
|
it "uses the :qt parameter from the default_document_solr_params" do
|
60
60
|
blacklight_config.default_document_solr_params[:qt] = 'abc'
|
61
61
|
blacklight_config.document_solr_request_handler = 'xyz'
|
62
62
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'abc' })).and_return(mock_response)
|
63
|
-
expect(subject.find("123")).to
|
63
|
+
expect(subject.find("123")).to be_a Blacklight::Solr::Response
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -68,8 +68,26 @@ RSpec.describe Blacklight::Solr::Repository, :api do
|
|
68
68
|
doc_params = ActiveSupport::HashWithIndifferentAccess.new
|
69
69
|
allow(subject.connection).to receive(:send_and_receive).with('get', anything).and_return(mock_response)
|
70
70
|
response = subject.find("123", doc_params)
|
71
|
-
expect(response).to
|
72
|
-
expect(response.params).to
|
71
|
+
expect(response).to be_a Blacklight::Solr::Response
|
72
|
+
expect(response.params).to be_a ActiveSupport::HashWithIndifferentAccess
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#find_many' do
|
77
|
+
context 'with a configured fetch_many_documents_path' do
|
78
|
+
it 'uses the path' do
|
79
|
+
blacklight_config.fetch_many_documents_path = 'documents'
|
80
|
+
allow(subject.connection).to receive(:send_and_receive).with('documents', anything).and_return(mock_response)
|
81
|
+
expect(subject.find_many({})).to be_a Blacklight::Solr::Response
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'without a configured fetch_many_documents_path' do
|
86
|
+
it 'falls back to the search path' do
|
87
|
+
blacklight_config.solr_path = 'xyz'
|
88
|
+
allow(subject.connection).to receive(:send_and_receive).with('xyz', anything).and_return(mock_response)
|
89
|
+
expect(subject.find_many({})).to be_a Blacklight::Solr::Response
|
90
|
+
end
|
73
91
|
end
|
74
92
|
end
|
75
93
|
|
@@ -77,24 +95,24 @@ RSpec.describe Blacklight::Solr::Repository, :api do
|
|
77
95
|
it "uses the search-specific solr path" do
|
78
96
|
blacklight_config.solr_path = 'xyz'
|
79
97
|
allow(subject.connection).to receive(:send_and_receive).with('xyz', anything).and_return(mock_response)
|
80
|
-
expect(subject.search({})).to
|
98
|
+
expect(subject.search({})).to be_a Blacklight::Solr::Response
|
81
99
|
end
|
82
100
|
|
83
101
|
it "uses the default solr path" do
|
84
102
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
85
|
-
expect(subject.search({})).to
|
103
|
+
expect(subject.search({})).to be_a Blacklight::Solr::Response
|
86
104
|
end
|
87
105
|
|
88
106
|
it "uses a default :qt param" do
|
89
107
|
blacklight_config.qt = 'xyz'
|
90
108
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'xyz' })).and_return(mock_response)
|
91
|
-
expect(subject.search({})).to
|
109
|
+
expect(subject.search({})).to be_a Blacklight::Solr::Response
|
92
110
|
end
|
93
111
|
|
94
112
|
it "uses the provided :qt param" do
|
95
113
|
blacklight_config.qt = 'xyz'
|
96
114
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'abc' })).and_return(mock_response)
|
97
|
-
expect(subject.search(qt: 'abc')).to
|
115
|
+
expect(subject.search(qt: 'abc')).to be_a Blacklight::Solr::Response
|
98
116
|
end
|
99
117
|
|
100
118
|
it "preserves the class of the incoming params" do
|
@@ -103,8 +121,8 @@ RSpec.describe Blacklight::Solr::Repository, :api do
|
|
103
121
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
104
122
|
|
105
123
|
response = subject.search(search_params)
|
106
|
-
expect(response).to
|
107
|
-
expect(response.params).to
|
124
|
+
expect(response).to be_a Blacklight::Solr::Response
|
125
|
+
expect(response.params).to be_a ActiveSupport::HashWithIndifferentAccess
|
108
126
|
end
|
109
127
|
|
110
128
|
it "calls send_and_receive with params returned from request factory method" do
|
@@ -247,7 +247,7 @@ RSpec.describe Blacklight::Solr::Response::Facets, :api do
|
|
247
247
|
it "converts the query facets into a double RSolr FacetField" do
|
248
248
|
field = subject.aggregations['my_query_facet_field']
|
249
249
|
|
250
|
-
expect(field).to
|
250
|
+
expect(field).to be_a Blacklight::Solr::Response::Facets::FacetField
|
251
251
|
|
252
252
|
expect(field.name).to eq 'my_query_facet_field'
|
253
253
|
expect(field.items.size).to eq 3
|
@@ -316,7 +316,7 @@ RSpec.describe Blacklight::Solr::Response::Facets, :api do
|
|
316
316
|
it "converts the pivot facet into a double RSolr FacetField" do
|
317
317
|
field = subject.aggregations['my_pivot_facet_field']
|
318
318
|
|
319
|
-
expect(field).to
|
319
|
+
expect(field).to be_a Blacklight::Solr::Response::Facets::FacetField
|
320
320
|
|
321
321
|
expect(field.name).to eq 'my_pivot_facet_field'
|
322
322
|
|
@@ -37,7 +37,7 @@ RSpec.describe Blacklight::Solr::Response::Group, :api do
|
|
37
37
|
describe "#docs" do
|
38
38
|
it "is a list of SolrDocuments" do
|
39
39
|
subject.docs.each do |doc|
|
40
|
-
expect(doc).to
|
40
|
+
expect(doc).to be_a SolrDocument
|
41
41
|
end
|
42
42
|
|
43
43
|
expect(subject.docs.first.id).to eq 1
|
@@ -79,7 +79,7 @@ RSpec.describe Blacklight::Solr::Response, :api do
|
|
79
79
|
if Kaminari.config.respond_to? :max_pages
|
80
80
|
expect(r.max_pages).to be_nil
|
81
81
|
end
|
82
|
-
expect(r).to
|
82
|
+
expect(r).to be_a Kaminari::PageScopeMethods
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "FacetItem" do
|
@@ -101,7 +101,7 @@ RSpec.describe Blacklight::Solr::Response, :api do
|
|
101
101
|
|
102
102
|
expect(item.hits).to eq 15
|
103
103
|
expect(item.value).to eq 'value'
|
104
|
-
expect(item).to
|
104
|
+
expect(item).to be_a(OpenStruct)
|
105
105
|
end
|
106
106
|
|
107
107
|
it "provides a label accessor" do
|
@@ -591,7 +591,7 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, :api do
|
|
591
591
|
|
592
592
|
subject.add_facet_fq_to_solr(solr_parameters)
|
593
593
|
|
594
|
-
expect(solr_parameters[:fq]).to
|
594
|
+
expect(solr_parameters[:fq]).to be_a Array
|
595
595
|
end
|
596
596
|
|
597
597
|
context "facet not defined in config" do
|
@@ -30,7 +30,7 @@ RSpec.describe Bookmark do
|
|
30
30
|
|
31
31
|
describe "#document" do
|
32
32
|
it "is a SolrDocument with just an id field" do
|
33
|
-
expect(subject.document).to
|
33
|
+
expect(subject.document).to be_a SolrDocument
|
34
34
|
expect(subject.document.id).to eq 'u001'
|
35
35
|
end
|
36
36
|
end
|
@@ -50,14 +50,14 @@ RSpec.describe Blacklight::DocumentPresenter do
|
|
50
50
|
|
51
51
|
describe '#thumbnail' do
|
52
52
|
it 'returns a thumbnail presenter' do
|
53
|
-
expect(presenter.thumbnail).to
|
53
|
+
expect(presenter.thumbnail).to be_a(Blacklight::ThumbnailPresenter)
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'use the configured thumbnail presenter' do
|
57
57
|
custom_presenter_class = Class.new(Blacklight::ThumbnailPresenter)
|
58
58
|
blacklight_config.index.thumbnail_presenter = custom_presenter_class
|
59
59
|
|
60
|
-
expect(presenter.thumbnail).to
|
60
|
+
expect(presenter.thumbnail).to be_a custom_presenter_class
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::FacetCheckboxItemPresenter, type: :presenter do
|
6
|
+
subject(:presenter) do
|
7
|
+
described_class.new(facet_item, facet_config, view_context, facet_field, search_state)
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:facet_item) { Blacklight::Solr::Response::Facets::FacetItem.new(value: 'Book', hits: 30) }
|
11
|
+
let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'format') }
|
12
|
+
let(:view_context) { controller.view_context }
|
13
|
+
let(:filter_field) { Blacklight::SearchState::FilterField.new(facet_config, search_state) }
|
14
|
+
let(:facet_field) { Blacklight::Solr::Response::Facets::FacetField.new('format', [facet_item]) }
|
15
|
+
let(:params) { ActionController::Parameters.new(f_inclusive: { format: ["Book"] }) }
|
16
|
+
let(:blacklight_config) { Blacklight::Configuration.new }
|
17
|
+
let(:search_state) { Blacklight::SearchState.new(params, blacklight_config) }
|
18
|
+
|
19
|
+
before do
|
20
|
+
blacklight_config.add_facet_field 'format'
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#selected?' do
|
24
|
+
subject { presenter.selected? }
|
25
|
+
|
26
|
+
context 'with a matching inclusive filter' do
|
27
|
+
it { is_expected.to be true }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with an inclusive filter that does not match' do
|
31
|
+
let(:params) { ActionController::Parameters.new(f_inclusive: { format: ["Manuscript"] }) }
|
32
|
+
|
33
|
+
it { is_expected.to be false }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with a matching exclusive filter' do
|
37
|
+
let(:params) { ActionController::Parameters.new(f: { format: ["Book"] }) }
|
38
|
+
|
39
|
+
it { is_expected.to be false }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -51,6 +51,20 @@ RSpec.describe Blacklight::FacetFieldPresenter, type: :presenter do
|
|
51
51
|
it "is false if no value for facet is selected" do
|
52
52
|
expect(presenter.active?).to be false
|
53
53
|
end
|
54
|
+
|
55
|
+
context 'with an advanced search action' do
|
56
|
+
before { controller.params[:action] = 'advanced_search' }
|
57
|
+
|
58
|
+
it "is true if any value for inclusive facet is selected" do
|
59
|
+
search_state.params[:f_inclusive] = ActiveSupport::HashWithIndifferentAccess.new(key: [1])
|
60
|
+
expect(presenter.active?).to be true
|
61
|
+
end
|
62
|
+
|
63
|
+
it "is false if no value for inclusive facet is selected" do
|
64
|
+
search_state.params[:f] = ActiveSupport::HashWithIndifferentAccess.new(key: [1])
|
65
|
+
expect(presenter.active?).to be false
|
66
|
+
end
|
67
|
+
end
|
54
68
|
end
|
55
69
|
|
56
70
|
describe '#in_modal?' do
|
@@ -6,11 +6,11 @@ RSpec.describe 'GET /catalog/suggest' do
|
|
6
6
|
it 'returns suggestions' do
|
7
7
|
get '/catalog/suggest?q=new'
|
8
8
|
expect(response.body).to eq <<-RESULT
|
9
|
-
<li role="option"><span>new jersey</span></li>
|
10
|
-
<li role="option"><span>new jersey bridgeton biography</span></li>
|
11
|
-
<li role="option"><span>new jersey bridgeton history</span></li>
|
12
|
-
<li role="option"><span>new york</span></li>
|
13
|
-
<li role="option"><span>nuwākshūṭ</span></li>
|
9
|
+
<li role="option" class="dropdown-item"><span>new jersey</span></li>
|
10
|
+
<li role="option" class="dropdown-item"><span>new jersey bridgeton biography</span></li>
|
11
|
+
<li role="option" class="dropdown-item"><span>new jersey bridgeton history</span></li>
|
12
|
+
<li role="option" class="dropdown-item"><span>new york</span></li>
|
13
|
+
<li role="option" class="dropdown-item"><span>nuwākshūṭ</span></li>
|
14
14
|
RESULT
|
15
15
|
end
|
16
16
|
end
|
@@ -77,7 +77,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
it "returns a grouped response" do
|
80
|
-
expect(service.search_results).to
|
80
|
+
expect(service.search_results).to be_a Blacklight::Solr::Response::GroupResponse
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -93,7 +93,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
93
93
|
|
94
94
|
it "returns a grouped response" do
|
95
95
|
solr_response = service.search_results
|
96
|
-
expect(solr_response).to
|
96
|
+
expect(solr_response).to be_a Blacklight::Solr::Response::GroupResponse
|
97
97
|
expect(solr_response.group_field).to eq "title_si"
|
98
98
|
end
|
99
99
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -49,8 +49,11 @@ RSpec.configure do |config|
|
|
49
49
|
# When we're testing the API, only run the api tests
|
50
50
|
config.filter_run api: true if ENV['BLACKLIGHT_API_TEST'].present?
|
51
51
|
|
52
|
-
|
53
|
-
|
52
|
+
if Rails.version.to_f >= 7.1
|
53
|
+
config.fixture_paths = [Rails.root.join("spec/fixtures")]
|
54
|
+
else
|
55
|
+
config.fixture_path = Rails.root.join("spec/fixtures")
|
56
|
+
end
|
54
57
|
|
55
58
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
56
59
|
# examples within a transaction, remove the following line or assign false
|
@@ -39,7 +39,7 @@ class TestAppGenerator < Rails::Generators::Base
|
|
39
39
|
src_template = File.join(Blacklight::Engine.root, 'app', 'components', 'blacklight', 'top_navbar_component.html.erb')
|
40
40
|
target_template = File.join('app', 'components', 'blacklight', 'top_navbar_component.html.erb')
|
41
41
|
create_file(target_template) do
|
42
|
-
File.read(src_template).gsub('
|
42
|
+
File.read(src_template).gsub('aria-label', 'data-template-override="top_navbar_component" aria-label')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
data/tasks/blacklight.rake
CHANGED
@@ -21,18 +21,18 @@ def system_with_error_handling(*args)
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def with_solr(&block)
|
24
|
-
# We're being invoked by the app entrypoint script and solr is already up via docker
|
24
|
+
# We're being invoked by the app entrypoint script and solr is already up via docker compose
|
25
25
|
if ENV['SOLR_ENV'] == 'docker-compose'
|
26
26
|
yield
|
27
|
-
elsif system('docker
|
28
|
-
# We're not running docker
|
27
|
+
elsif system('docker compose version')
|
28
|
+
# We're not running `docker compose up' but still want to use a docker instance of solr.
|
29
29
|
begin
|
30
30
|
puts "Starting Solr"
|
31
|
-
system_with_error_handling "docker
|
31
|
+
system_with_error_handling "docker compose up -d solr"
|
32
32
|
yield
|
33
33
|
ensure
|
34
34
|
puts "Stopping Solr"
|
35
|
-
system_with_error_handling "docker
|
35
|
+
system_with_error_handling "docker compose stop solr"
|
36
36
|
end
|
37
37
|
else
|
38
38
|
SolrWrapper.wrap do |solr|
|
@@ -47,7 +47,7 @@ task ci: ['build:npm'] do
|
|
47
47
|
with_solr do
|
48
48
|
Rake::Task['blacklight:internal:seed'].invoke
|
49
49
|
within_test_app do
|
50
|
-
# Precompiles the
|
50
|
+
# Precompiles the assets
|
51
51
|
system "bin/rake spec:prepare"
|
52
52
|
end
|
53
53
|
Rake::Task['blacklight:coverage'].invoke
|