blacklight 7.33.1 → 7.34.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -0
  3. data/.github/workflows/ruby.yml +21 -1
  4. data/.rubocop.yml +2 -0
  5. data/Gemfile +4 -0
  6. data/VERSION +1 -1
  7. data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
  8. data/app/components/blacklight/advanced_search_form_component.rb +5 -5
  9. data/app/components/blacklight/content_areas_shim.rb +1 -1
  10. data/app/components/blacklight/document/action_component.html.erb +2 -9
  11. data/app/components/blacklight/document/action_component.rb +18 -0
  12. data/app/components/blacklight/document/actions_component.rb +1 -1
  13. data/app/components/blacklight/document_component.rb +33 -10
  14. data/app/components/blacklight/document_metadata_component.html.erb +4 -2
  15. data/app/components/blacklight/document_metadata_component.rb +6 -2
  16. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +2 -2
  17. data/app/components/blacklight/facet_field_list_component.html.erb +2 -2
  18. data/app/components/blacklight/header_component.html.erb +2 -0
  19. data/app/components/blacklight/header_component.rb +26 -0
  20. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  21. data/app/components/blacklight/metadata_field_layout_component.rb +7 -4
  22. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  23. data/app/components/blacklight/response/pagination_component.rb +5 -1
  24. data/app/components/blacklight/response/view_type_component.rb +1 -1
  25. data/app/components/blacklight/search_navbar_component.html.erb +5 -0
  26. data/app/components/blacklight/search_navbar_component.rb +34 -0
  27. data/app/components/blacklight/system/dropdown_component.rb +2 -2
  28. data/app/components/blacklight/system/flash_message_component.rb +1 -1
  29. data/app/components/blacklight/top_navbar_component.html.erb +12 -0
  30. data/app/components/blacklight/top_navbar_component.rb +17 -0
  31. data/app/controllers/concerns/blacklight/base.rb +5 -0
  32. data/app/controllers/concerns/blacklight/catalog.rb +4 -1
  33. data/app/controllers/concerns/blacklight/controller.rb +3 -2
  34. data/app/helpers/blacklight/blacklight_helper_behavior.rb +2 -2
  35. data/app/helpers/blacklight/render_partials_helper_behavior.rb +1 -0
  36. data/app/models/concerns/blacklight/document/attributes.rb +50 -0
  37. data/app/models/concerns/blacklight/document.rb +12 -20
  38. data/app/presenters/blacklight/rendering/join.rb +1 -1
  39. data/app/values/blacklight/types.rb +99 -11
  40. data/app/views/catalog/_document.html.erb +1 -1
  41. data/app/views/catalog/_facet_layout.html.erb +2 -2
  42. data/app/views/catalog/_search_form.html.erb +1 -1
  43. data/app/views/catalog/_show_main_content.html.erb +2 -2
  44. data/app/views/catalog/_show_sidebar.html.erb +1 -1
  45. data/app/views/catalog/_show_tools.html.erb +4 -3
  46. data/app/views/catalog/facet.html.erb +3 -3
  47. data/app/views/layouts/blacklight/base.html.erb +7 -7
  48. data/app/views/shared/_header_navbar.html.erb +1 -22
  49. data/blacklight.gemspec +1 -2
  50. data/config/locales/blacklight.en.yml +1 -0
  51. data/docker-compose.yml +1 -0
  52. data/lib/blacklight/configuration.rb +39 -2
  53. data/lib/blacklight/engine.rb +4 -0
  54. data/lib/blacklight/solr/repository.rb +14 -2
  55. data/lib/blacklight/solr/request.rb +2 -0
  56. data/lib/blacklight/solr/search_builder_behavior.rb +2 -1
  57. data/lib/blacklight.rb +1 -1
  58. data/lib/generators/blacklight/assets_generator.rb +1 -1
  59. data/lib/generators/blacklight/install_generator.rb +1 -1
  60. data/lib/generators/blacklight/templates/catalog_controller.rb +4 -0
  61. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +69 -0
  62. data/lib/generators/blacklight/templates/solr_document.rb +1 -1
  63. data/lib/railties/blacklight.rake +4 -4
  64. data/package.json +1 -1
  65. data/spec/components/blacklight/document_component_spec.rb +60 -11
  66. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +3 -2
  67. data/spec/components/blacklight/header_component_spec.rb +20 -0
  68. data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
  69. data/spec/controllers/blacklight/base_spec.rb +1 -1
  70. data/spec/features/advanced_search_spec.rb +56 -0
  71. data/spec/features/axe_spec.rb +5 -0
  72. data/spec/features/sitelinks_search_box_spec.rb +13 -0
  73. data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +8 -15
  74. data/spec/models/blacklight/configuration_spec.rb +22 -0
  75. data/spec/models/blacklight/solr/repository_spec.rb +27 -0
  76. data/spec/models/blacklight/solr/search_builder_spec.rb +16 -0
  77. data/spec/models/solr_document_spec.rb +21 -3
  78. data/spec/presenters/blacklight/show_presenter_spec.rb +4 -10
  79. data/spec/spec_helper.rb +4 -5
  80. data/spec/support/view_component_test_helpers.rb +35 -0
  81. data/spec/views/catalog/_show_tools.html.erb_spec.rb +24 -10
  82. metadata +24 -23
  83. data/spec/features/sitelinks_search_box.rb +0 -13
  84. data/spec/support/view_component_capybara_test_helpers.rb +0 -8
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ViewComponentTestHelpers
4
+ # Work around for https://github.com/teamcapybara/capybara/issues/2466
5
+ def render_inline_to_capybara_node(component)
6
+ Capybara::Node::Simple.new(render_inline(component).to_s)
7
+ end
8
+
9
+ # Work-around for https://github.com/ViewComponent/view_component/pull/1661
10
+ # which made the component test's controller method (more) private. This makes
11
+ # it available so we can set up controller-level state for our tests.
12
+ def controller
13
+ # ViewComponent 2.x
14
+ return super if defined?(super)
15
+
16
+ # ViewComponent 3.x
17
+ return vc_test_controller if defined?(vc_test_controller)
18
+
19
+ ApplicationController.new.extend(Rails.application.routes.url_helpers)
20
+ end
21
+
22
+ # Nokogiri 1.15.0 upgrades the vendored libxml2 from v2.10.4 to v2.11.3
23
+ # libxml2 v2.11.0 introduces a change to parsing HTML href attributes
24
+ # in nokogiri < 1.15, brackets in href attributes are escaped:
25
+ # - <a class="facet-select" rel="nofollow" href="/catalog?f%5Bz%5D%5B%5D=x:1">x:1</a>
26
+ # in nokogiri >= 1.15, brackets in href attributes are not escaped:
27
+ # - <a class="facet-select" rel="nofollow" href="/catalog?f[z][]=x:1">x:1</a>
28
+ # until we can spec a minimum nokogiri version of 1.15.0, we need to see how
29
+ # the installed version parsed the html
30
+ def nokogiri_mediated_href(href)
31
+ start = "<a href=\"".length
32
+ stop = -"\"></a>".length
33
+ Nokogiri::HTML.fragment("<a href=\"#{href}\"></a>").to_s[start...stop]
34
+ end
35
+ end
@@ -6,67 +6,81 @@ RSpec.describe "catalog/_show_tools.html.erb" do
6
6
 
7
7
  before do
8
8
  assign :response, instance_double(Blacklight::Solr::Response, params: {})
9
- assign :document, document
10
9
  allow(view).to receive(:blacklight_config).and_return blacklight_config
11
10
  allow(view).to receive(:has_user_authentication_provider?).and_return false
12
11
  end
13
12
 
13
+ context 'without passing in a document local explicitly' do
14
+ before do
15
+ assign :document, document
16
+ end
17
+
18
+ let(:document_actions) { blacklight_config.show.document_actions }
19
+
20
+ it 'defaults to the @document and renders the action' do
21
+ allow(view).to receive(:some_action_solr_document_path).with(document, any_args).and_return 'x'
22
+ document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new key: :some_action, name: :some_action, partial: 'document_action'
23
+ render 'catalog/show_tools'
24
+ expect(rendered).to have_link "Some action", href: "x"
25
+ end
26
+ end
27
+
14
28
  describe "document actions" do
15
29
  let(:document_actions) { blacklight_config.show.document_actions }
16
30
 
17
31
  it "renders a document action" do
18
32
  allow(view).to receive(:some_action_solr_document_path).with(document, any_args).and_return 'x'
19
33
  document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new key: :some_action, name: :some_action, partial: 'document_action'
20
- render partial: 'catalog/show_tools'
34
+ render 'catalog/show_tools', document: document
21
35
  expect(rendered).to have_link "Some action", href: "x"
22
36
  end
23
37
 
24
38
  it "uses the provided label" do
25
39
  allow(view).to receive(:some_action_solr_document_path).and_return "x"
26
40
  document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new key: :some_action, name: :some_action, label: "Some label", partial: 'document_action'
27
- render partial: 'catalog/show_tools'
41
+ render 'catalog/show_tools', document: document
28
42
  expect(rendered).to have_selector '.some_action', text: "Some label"
29
43
  end
30
44
 
31
45
  it "evaluates a document action's if configurations" do
32
46
  allow(view).to receive(:some_action_solr_document_path).and_return "x"
33
47
  document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new key: :some_action, name: :some_action, if: false, partial: 'document_action'
34
- render partial: 'catalog/show_tools'
48
+ render 'catalog/show_tools', document: document
35
49
  expect(rendered).not_to have_selector '.some_action', text: "Some action"
36
50
  end
37
51
 
38
52
  it "evaluates a document action's if configuration with a proc" do
39
53
  allow(view).to receive(:some_action_solr_document_path).and_return "x"
40
54
  document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new key: :some_action, name: :some_action, partial: 'document_action', if: proc { |_config, doc| doc.id == "xyz" }
41
- render partial: 'catalog/show_tools'
55
+ render 'catalog/show_tools', document: document
42
56
  expect(rendered).not_to have_selector '.some_action', text: "Some action"
43
57
  end
44
58
 
45
59
  it "evaluates a document action's unless configurations" do
46
60
  allow(view).to receive(:some_action_solr_document_path).and_return "x"
47
61
  document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new key: :some_action, name: :some_action, partial: 'document_action', unless: true
48
- render partial: 'catalog/show_tools'
62
+ render 'catalog/show_tools', document: document
49
63
  expect(rendered).not_to have_selector '.some_action', text: "Some action"
50
64
  end
51
65
 
52
66
  it "allows the tool to have a custom id" do
53
67
  allow(view).to receive(:some_action_solr_document_path).and_return "x"
54
68
  document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new key: :some_action, name: :some_action, partial: 'document_action', id: "some_action"
55
- render partial: 'catalog/show_tools'
69
+ render 'catalog/show_tools', document: document
56
70
  expect(rendered).to have_selector '#some_action', text: "Some action"
57
71
  end
58
72
 
59
73
  it "defaults to modal behavior" do
60
74
  allow(view).to receive(:some_action_solr_document_path).and_return "x"
61
75
  document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new key: :some_action, name: :some_action, partial: 'document_action'
62
- render partial: 'catalog/show_tools'
76
+ render 'catalog/show_tools', document: document
63
77
  expect(rendered).to have_selector '.some_action > a[data-blacklight-modal="trigger"]', text: "Some action"
64
78
  end
65
79
 
66
80
  it "allows configuration to opt out of modal behavior" do
67
81
  allow(view).to receive(:some_action_solr_document_path).and_return "x"
68
82
  document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new key: :some_action, name: :some_action, partial: 'document_action', modal: false
69
- render partial: 'catalog/show_tools'
83
+ render 'catalog/show_tools', document: document
70
84
  expect(rendered).not_to have_selector '.some_action > a[data-blacklight-modal="trigger"]', text: "Some action"
71
85
  end
72
86
 
@@ -76,7 +90,7 @@ RSpec.describe "catalog/_show_tools.html.erb" do
76
90
  end
77
91
 
78
92
  it 'does not display the tools' do
79
- render partial: 'catalog/show_tools'
93
+ render 'catalog/show_tools', document: document
80
94
 
81
95
  expect(rendered).to be_blank
82
96
  end
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.33.1
4
+ version: 7.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -17,7 +17,7 @@ authors:
17
17
  autorequire:
18
18
  bindir: exe
19
19
  cert_chain: []
20
- date: 2023-02-02 00:00:00.000000000 Z
20
+ date: 2023-10-04 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -127,16 +127,22 @@ dependencies:
127
127
  name: view_component
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - "~>"
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '2.66'
133
+ - - "<"
134
+ - !ruby/object:Gem::Version
135
+ version: '4'
133
136
  type: :runtime
134
137
  prerelease: false
135
138
  version_requirements: !ruby/object:Gem::Requirement
136
139
  requirements:
137
- - - "~>"
140
+ - - ">="
138
141
  - !ruby/object:Gem::Version
139
142
  version: '2.66'
143
+ - - "<"
144
+ - !ruby/object:Gem::Version
145
+ version: '4'
140
146
  - !ruby/object:Gem::Dependency
141
147
  name: hashdiff
142
148
  requirement: !ruby/object:Gem::Requirement
@@ -227,20 +233,6 @@ dependencies:
227
233
  - - "~>"
228
234
  - !ruby/object:Gem::Version
229
235
  version: '3'
230
- - !ruby/object:Gem::Dependency
231
- name: webdrivers
232
- requirement: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - ">="
235
- - !ruby/object:Gem::Version
236
- version: '0'
237
- type: :development
238
- prerelease: false
239
- version_requirements: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - ">="
242
- - !ruby/object:Gem::Version
243
- version: '0'
244
236
  - !ruby/object:Gem::Dependency
245
237
  name: selenium-webdriver
246
238
  requirement: !ruby/object:Gem::Requirement
@@ -469,6 +461,8 @@ files:
469
461
  - app/components/blacklight/facet_field_pagination_component.rb
470
462
  - app/components/blacklight/facet_item_component.rb
471
463
  - app/components/blacklight/facet_item_pivot_component.rb
464
+ - app/components/blacklight/header_component.html.erb
465
+ - app/components/blacklight/header_component.rb
472
466
  - app/components/blacklight/hidden_search_state_component.rb
473
467
  - app/components/blacklight/icons/icon_component.rb
474
468
  - app/components/blacklight/metadata_field_component.html.erb
@@ -493,6 +487,8 @@ files:
493
487
  - app/components/blacklight/search_context_component.html.erb
494
488
  - app/components/blacklight/search_context_component.rb
495
489
  - app/components/blacklight/search_history_constraint_layout_component.rb
490
+ - app/components/blacklight/search_navbar_component.html.erb
491
+ - app/components/blacklight/search_navbar_component.rb
496
492
  - app/components/blacklight/start_over_button_component.rb
497
493
  - app/components/blacklight/system/dropdown_component.html.erb
498
494
  - app/components/blacklight/system/dropdown_component.rb
@@ -500,6 +496,8 @@ files:
500
496
  - app/components/blacklight/system/flash_message_component.rb
501
497
  - app/components/blacklight/system/modal_component.html.erb
502
498
  - app/components/blacklight/system/modal_component.rb
499
+ - app/components/blacklight/top_navbar_component.html.erb
500
+ - app/components/blacklight/top_navbar_component.rb
503
501
  - app/controllers/bookmarks_controller.rb
504
502
  - app/controllers/catalog_controller.rb
505
503
  - app/controllers/concerns/blacklight/base.rb
@@ -544,6 +542,7 @@ files:
544
542
  - app/models/concerns/blacklight/configurable.rb
545
543
  - app/models/concerns/blacklight/document.rb
546
544
  - app/models/concerns/blacklight/document/active_model_shim.rb
545
+ - app/models/concerns/blacklight/document/attributes.rb
547
546
  - app/models/concerns/blacklight/document/cache_key.rb
548
547
  - app/models/concerns/blacklight/document/dublin_core.rb
549
548
  - app/models/concerns/blacklight/document/email.rb
@@ -790,6 +789,7 @@ files:
790
789
  - spec/components/blacklight/facet_field_list_component_spec.rb
791
790
  - spec/components/blacklight/facet_item_component_spec.rb
792
791
  - spec/components/blacklight/facet_item_pivot_component_spec.rb
792
+ - spec/components/blacklight/header_component_spec.rb
793
793
  - spec/components/blacklight/hidden_search_state_component_spec.rb
794
794
  - spec/components/blacklight/metadata_field_component_spec.rb
795
795
  - spec/components/blacklight/response/spellcheck_component_spec.rb
@@ -823,7 +823,7 @@ files:
823
823
  - spec/features/search_results_spec.rb
824
824
  - spec/features/search_sort_spec.rb
825
825
  - spec/features/search_spec.rb
826
- - spec/features/sitelinks_search_box.rb
826
+ - spec/features/sitelinks_search_box_spec.rb
827
827
  - spec/fixtures/sample_solr_documents.yml
828
828
  - spec/helpers/blacklight/configuration_helper_behavior_spec.rb
829
829
  - spec/helpers/blacklight/facets_helper_behavior_spec.rb
@@ -900,7 +900,7 @@ files:
900
900
  - spec/support/features.rb
901
901
  - spec/support/features/session_helpers.rb
902
902
  - spec/support/presenter_test_helpers.rb
903
- - spec/support/view_component_capybara_test_helpers.rb
903
+ - spec/support/view_component_test_helpers.rb
904
904
  - spec/test_app_templates/Gemfile.extra
905
905
  - spec/test_app_templates/lib/generators/test_app_generator.rb
906
906
  - spec/views/catalog/_constraints.html.erb_spec.rb
@@ -954,7 +954,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
954
954
  - !ruby/object:Gem::Version
955
955
  version: '0'
956
956
  requirements: []
957
- rubygems_version: 3.3.26
957
+ rubygems_version: 3.4.10
958
958
  signing_key:
959
959
  specification_version: 4
960
960
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
@@ -972,6 +972,7 @@ test_files:
972
972
  - spec/components/blacklight/facet_field_list_component_spec.rb
973
973
  - spec/components/blacklight/facet_item_component_spec.rb
974
974
  - spec/components/blacklight/facet_item_pivot_component_spec.rb
975
+ - spec/components/blacklight/header_component_spec.rb
975
976
  - spec/components/blacklight/hidden_search_state_component_spec.rb
976
977
  - spec/components/blacklight/metadata_field_component_spec.rb
977
978
  - spec/components/blacklight/response/spellcheck_component_spec.rb
@@ -1005,7 +1006,7 @@ test_files:
1005
1006
  - spec/features/search_results_spec.rb
1006
1007
  - spec/features/search_sort_spec.rb
1007
1008
  - spec/features/search_spec.rb
1008
- - spec/features/sitelinks_search_box.rb
1009
+ - spec/features/sitelinks_search_box_spec.rb
1009
1010
  - spec/fixtures/sample_solr_documents.yml
1010
1011
  - spec/helpers/blacklight/configuration_helper_behavior_spec.rb
1011
1012
  - spec/helpers/blacklight/facets_helper_behavior_spec.rb
@@ -1082,7 +1083,7 @@ test_files:
1082
1083
  - spec/support/features.rb
1083
1084
  - spec/support/features/session_helpers.rb
1084
1085
  - spec/support/presenter_test_helpers.rb
1085
- - spec/support/view_component_capybara_test_helpers.rb
1086
+ - spec/support/view_component_test_helpers.rb
1086
1087
  - spec/test_app_templates/Gemfile.extra
1087
1088
  - spec/test_app_templates/lib/generators/test_app_generator.rb
1088
1089
  - spec/views/catalog/_constraints.html.erb_spec.rb
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Sitelinks search box' do
4
- it 'is home page' do
5
- visit root_path
6
- expect(page).to have_css 'script[type="application/ld+json"]'
7
- end
8
-
9
- it 'on search page' do
10
- visit search_catalog_path q: 'book'
11
- expect(page).not_to have_css 'script[type="application/ld+json"]'
12
- end
13
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ViewComponentCapybaraTestHelpers
4
- # Work around for https://github.com/teamcapybara/capybara/issues/2466
5
- def render_inline_to_capybara_node(component)
6
- Capybara::Node::Simple.new(render_inline(component).to_s)
7
- end
8
- end