blacklight 8.2.2 → 8.4.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.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -1
  3. data/.github/workflows/ruby.yml +60 -62
  4. data/.rubocop.yml +229 -21
  5. data/.rubocop_todo.yml +22 -55
  6. data/Gemfile +2 -10
  7. data/README.md +2 -2
  8. data/VERSION +1 -1
  9. data/app/assets/javascripts/blacklight/blacklight.esm.js +5 -1
  10. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  11. data/app/assets/javascripts/blacklight/blacklight.js +5 -1
  12. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
  13. data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -1
  14. data/app/assets/stylesheets/blacklight/_bookmark.scss +30 -0
  15. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +0 -4
  16. data/app/assets/stylesheets/blacklight/_constraints.scss +15 -9
  17. data/app/assets/stylesheets/blacklight/_controls.scss +0 -1
  18. data/app/assets/stylesheets/blacklight/_facets.scss +33 -37
  19. data/app/assets/stylesheets/blacklight/_header.scss +2 -35
  20. data/app/assets/stylesheets/blacklight/_icons.scss +3 -2
  21. data/app/assets/stylesheets/blacklight/_layout.scss +3 -0
  22. data/app/assets/stylesheets/blacklight/_mixins.scss +6 -21
  23. data/app/assets/stylesheets/blacklight/_search_form.scss +3 -8
  24. data/app/assets/stylesheets/blacklight/_search_history.scss +5 -5
  25. data/app/assets/stylesheets/blacklight/_search_results.scss +5 -2
  26. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +16 -10
  27. data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
  28. data/app/components/blacklight/advanced_search_form_component.rb +6 -0
  29. data/app/components/blacklight/constraint_layout_component.html.erb +2 -9
  30. data/app/components/blacklight/constraint_layout_component.rb +8 -0
  31. data/app/components/blacklight/constraints_component.rb +3 -3
  32. data/app/components/blacklight/document/action_component.rb +2 -1
  33. data/app/components/blacklight/document/bookmark_component.html.erb +2 -1
  34. data/app/components/blacklight/document/bookmark_component.rb +6 -0
  35. data/app/components/blacklight/document/page_header_component.html.erb +7 -0
  36. data/app/components/blacklight/document/page_header_component.rb +85 -0
  37. data/app/components/blacklight/document_component.rb +1 -1
  38. data/app/components/blacklight/facet_component.rb +1 -1
  39. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +1 -1
  40. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  41. data/app/components/blacklight/facet_field_inclusive_constraint_component.html.erb +1 -1
  42. data/app/components/blacklight/facet_field_list_component.html.erb +1 -1
  43. data/app/components/blacklight/facet_item_component.rb +1 -1
  44. data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
  45. data/app/components/blacklight/icons/bookmark_icon_component.rb +17 -0
  46. data/app/components/blacklight/icons/icon_component.rb +9 -4
  47. data/app/components/blacklight/icons/remove_component.rb +16 -0
  48. data/app/components/blacklight/metadata_field_component.html.erb +1 -1
  49. data/app/components/blacklight/metadata_field_component.rb +5 -0
  50. data/app/components/blacklight/response/facet_group_component.rb +1 -1
  51. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  52. data/app/components/blacklight/response/sort_component.html.erb +1 -6
  53. data/app/components/blacklight/response/sort_component.rb +15 -0
  54. data/app/components/blacklight/search/per_page_component.html.erb +2 -0
  55. data/app/components/blacklight/search/per_page_component.rb +50 -0
  56. data/app/components/blacklight/search_bar_component.html.erb +1 -1
  57. data/app/components/blacklight/search_context/server_item_pagination_component.html.erb +4 -7
  58. data/app/components/blacklight/skip_link_component.html.erb +7 -0
  59. data/app/components/blacklight/skip_link_component.rb +17 -0
  60. data/app/components/blacklight/system/dropdown_button_component.rb +18 -0
  61. data/app/components/blacklight/system/dropdown_component.rb +4 -7
  62. data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
  63. data/app/components/blacklight/top_navbar_component.html.erb +2 -2
  64. data/app/components/blacklight/top_navbar_component.rb +4 -0
  65. data/app/helpers/blacklight/catalog_helper_behavior.rb +3 -5
  66. data/app/helpers/blacklight/component_helper_behavior.rb +4 -4
  67. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -0
  68. data/app/helpers/blacklight/layout_helper_behavior.rb +3 -3
  69. data/app/javascript/blacklight/checkbox_submit.js +5 -1
  70. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -1
  71. data/app/presenters/blacklight/facet_checkbox_item_presenter.rb +11 -0
  72. data/app/presenters/blacklight/facet_field_presenter.rb +9 -1
  73. data/app/services/blacklight/search_service.rb +9 -1
  74. data/app/views/catalog/_per_page_widget.html.erb +1 -10
  75. data/app/views/catalog/_search_results.html.erb +1 -1
  76. data/app/views/catalog/_show_main_content.html.erb +1 -1
  77. data/app/views/catalog/show.html.erb +0 -2
  78. data/app/views/catalog/suggest.html.erb +1 -1
  79. data/app/views/kaminari/blacklight/_page.html.erb +14 -8
  80. data/app/views/layouts/blacklight/base.html.erb +3 -4
  81. data/app/views/shared/_flash_messages.html.erb +1 -1
  82. data/blacklight.gemspec +4 -0
  83. data/{docker-compose.yml → compose.yaml} +1 -1
  84. data/config/locales/blacklight.ar.yml +3 -0
  85. data/config/locales/blacklight.de.yml +3 -0
  86. data/config/locales/blacklight.en.yml +216 -229
  87. data/config/locales/blacklight.es.yml +3 -0
  88. data/config/locales/blacklight.fr.yml +3 -0
  89. data/config/locales/blacklight.hu.yml +3 -0
  90. data/config/locales/blacklight.it.yml +3 -0
  91. data/config/locales/blacklight.nl.yml +3 -0
  92. data/config/locales/blacklight.pt-BR.yml +3 -0
  93. data/config/locales/blacklight.sq.yml +3 -0
  94. data/config/locales/blacklight.zh.yml +3 -0
  95. data/lib/blacklight/abstract_repository.rb +6 -0
  96. data/lib/blacklight/configuration.rb +33 -19
  97. data/lib/blacklight/nested_open_struct_with_hash_access.rb +2 -2
  98. data/lib/blacklight/parameters.rb +1 -1
  99. data/lib/blacklight/solr/repository.rb +11 -4
  100. data/lib/blacklight/solr/request.rb +1 -1
  101. data/lib/blacklight/solr/response/facets.rb +1 -1
  102. data/lib/blacklight/solr/response/params.rb +1 -1
  103. data/lib/blacklight/solr/response.rb +0 -12
  104. data/lib/blacklight/solr/search_builder_behavior.rb +2 -2
  105. data/lib/blacklight/solr.rb +0 -6
  106. data/lib/blacklight.rb +4 -14
  107. data/lib/generators/blacklight/assets/propshaft_generator.rb +2 -2
  108. data/lib/generators/blacklight/models_generator.rb +1 -1
  109. data/package.json +1 -1
  110. data/spec/components/blacklight/advanced_search_form_component_spec.rb +2 -2
  111. data/spec/components/blacklight/constraint_layout_component_spec.rb +11 -11
  112. data/spec/components/blacklight/constraints_component_spec.rb +9 -9
  113. data/spec/components/blacklight/document/action_component_spec.rb +1 -1
  114. data/spec/components/blacklight/document/group_component_spec.rb +3 -3
  115. data/spec/components/blacklight/document/page_header_component_spec.rb +92 -0
  116. data/spec/components/blacklight/document/sidebar_component_spec.rb +3 -4
  117. data/spec/components/blacklight/document_component_spec.rb +41 -25
  118. data/spec/components/blacklight/facet_component_spec.rb +2 -2
  119. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +5 -5
  120. data/spec/components/blacklight/facet_field_list_component_spec.rb +13 -13
  121. data/spec/components/blacklight/facet_item_component_spec.rb +5 -5
  122. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +6 -6
  123. data/spec/components/blacklight/header_component_spec.rb +1 -2
  124. data/spec/components/blacklight/hidden_search_state_component_spec.rb +6 -6
  125. data/spec/components/blacklight/icons/icon_component_spec.rb +42 -0
  126. data/spec/components/blacklight/metadata_field_component_spec.rb +3 -3
  127. data/spec/components/blacklight/response/pagination_component_spec.rb +4 -4
  128. data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +1 -1
  129. data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +2 -4
  130. data/spec/components/blacklight/system/flash_message_component_spec.rb +5 -5
  131. data/spec/controllers/blacklight/catalog_spec.rb +2 -2
  132. data/spec/controllers/blacklight/{catalog/component_configuration_spec.rb → configurable_spec.rb} +1 -1
  133. data/spec/controllers/bookmarks_controller_spec.rb +10 -10
  134. data/spec/controllers/catalog_controller_spec.rb +29 -31
  135. data/spec/features/advanced_search_spec.rb +30 -16
  136. data/spec/features/alternate_controller_spec.rb +9 -9
  137. data/spec/features/axe_spec.rb +4 -4
  138. data/spec/features/bookmarks_spec.rb +34 -19
  139. data/spec/features/citation_spec.rb +1 -1
  140. data/spec/features/did_you_mean_spec.rb +23 -23
  141. data/spec/features/facet_missing_spec.rb +9 -9
  142. data/spec/features/facets_spec.rb +21 -20
  143. data/spec/features/modal_spec.rb +4 -4
  144. data/spec/features/record_view_spec.rb +2 -2
  145. data/spec/features/search_context_spec.rb +6 -6
  146. data/spec/features/search_crawler_spec.rb +5 -5
  147. data/spec/features/search_filters_spec.rb +65 -65
  148. data/spec/features/search_history_spec.rb +12 -12
  149. data/spec/features/search_pagination_spec.rb +10 -10
  150. data/spec/features/search_results_spec.rb +1 -1
  151. data/spec/features/search_sort_spec.rb +4 -4
  152. data/spec/features/search_spec.rb +25 -25
  153. data/spec/features/sitelinks_search_box_spec.rb +2 -2
  154. data/spec/features/sms_spec.rb +1 -1
  155. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +2 -2
  156. data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +20 -3
  157. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +2 -1
  158. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +7 -8
  159. data/spec/helpers/blacklight_helper_spec.rb +13 -15
  160. data/spec/helpers/catalog_helper_spec.rb +3 -6
  161. data/spec/i18n_spec.rb +2 -1
  162. data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +1 -1
  163. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +1 -1
  164. data/spec/lib/blacklight/search_state_spec.rb +4 -4
  165. data/spec/lib/tasks/blacklight_task_spec.rb +2 -1
  166. data/spec/models/blacklight/configurable_spec.rb +1 -1
  167. data/spec/models/blacklight/configuration/context_spec.rb +1 -1
  168. data/spec/models/blacklight/configuration_spec.rb +14 -14
  169. data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -1
  170. data/spec/models/blacklight/document/cache_key_spec.rb +1 -1
  171. data/spec/models/blacklight/document_spec.rb +1 -1
  172. data/spec/models/blacklight/facet_paginator_spec.rb +14 -14
  173. data/spec/models/blacklight/icon_spec.rb +1 -1
  174. data/spec/models/blacklight/search_builder_spec.rb +1 -1
  175. data/spec/models/blacklight/solr/document_spec.rb +3 -3
  176. data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -1
  177. data/spec/models/blacklight/solr/repository_spec.rb +33 -15
  178. data/spec/models/blacklight/solr/request_spec.rb +1 -1
  179. data/spec/models/blacklight/solr/response/facets_spec.rb +3 -3
  180. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -1
  181. data/spec/models/blacklight/solr/response/group_spec.rb +2 -2
  182. data/spec/models/blacklight/solr/response_spec.rb +3 -3
  183. data/spec/models/blacklight/solr/{search_builder_spec.rb → search_builder_behavior_spec.rb} +10 -20
  184. data/spec/models/blacklight/suggest/response_spec.rb +1 -1
  185. data/spec/models/blacklight/suggest_search_spec.rb +1 -1
  186. data/spec/models/blacklight/user_spec.rb +1 -1
  187. data/spec/models/bookmark_spec.rb +1 -1
  188. data/spec/models/solr_document_spec.rb +1 -1
  189. data/spec/presenters/blacklight/document_presenter_spec.rb +3 -4
  190. data/spec/presenters/blacklight/facet_checkbox_item_presenter_spec.rb +42 -0
  191. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +14 -0
  192. data/spec/presenters/blacklight/field_presenter_spec.rb +1 -1
  193. data/spec/presenters/blacklight/index_presenter_spec.rb +2 -3
  194. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -1
  195. data/spec/presenters/{pipeline_spec.rb → blacklight/rendering/pipeline_spec.rb} +1 -1
  196. data/spec/presenters/blacklight/show_presenter_spec.rb +5 -6
  197. data/spec/presenters/{thumbnail_presenter_spec.rb → blacklight/thumbnail_presenter_spec.rb} +5 -3
  198. data/spec/requests/load_suggestions_spec.rb +5 -5
  199. data/spec/routing/catalog_routing_spec.rb +1 -1
  200. data/spec/services/blacklight/field_retriever_spec.rb +1 -1
  201. data/spec/services/blacklight/search_service_spec.rb +11 -11
  202. data/spec/spec_helper.rb +2 -2
  203. data/spec/support/features/search_helpers.rb +2 -2
  204. data/spec/support/features/session_helpers.rb +3 -3
  205. data/spec/test_app_templates/lib/generators/test_app_generator.rb +3 -3
  206. data/spec/views/catalog/_document.html.erb_spec.rb +1 -4
  207. data/spec/views/catalog/_document_list.html.erb_spec.rb +2 -2
  208. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +5 -6
  209. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +7 -7
  210. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +4 -4
  211. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -4
  212. data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -2
  213. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +7 -7
  214. data/spec/views/catalog/email_success.html.erb_spec.rb +1 -1
  215. data/spec/views/catalog/facet.html.erb_spec.rb +1 -1
  216. data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -1
  217. data/spec/views/catalog/index.atom.builder_spec.rb +18 -19
  218. data/spec/views/catalog/index.html.erb_spec.rb +2 -4
  219. data/spec/views/catalog/index.json.jbuilder_spec.rb +5 -8
  220. data/spec/views/catalog/show.html.erb_spec.rb +3 -5
  221. data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -2
  222. data/spec/views/catalog/sms_success.html.erb_spec.rb +1 -1
  223. data/spec/views/shared/_user_util_links.html.erb_spec.rb +2 -3
  224. data/tasks/blacklight.rake +5 -5
  225. metadata +84 -12
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- RSpec.describe Blacklight::Solr::Response::GroupResponse, api: true do
5
+ RSpec.describe Blacklight::Solr::Response::GroupResponse, :api do
6
6
  let(:response) do
7
7
  create_response(sample_response)
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- RSpec.describe Blacklight::Solr::Response::Group, api: true do
5
+ RSpec.describe Blacklight::Solr::Response::Group, :api do
6
6
  subject do
7
7
  group.groups.first
8
8
  end
@@ -37,7 +37,7 @@ RSpec.describe Blacklight::Solr::Response::Group, api: true 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 be_a_kind_of SolrDocument
40
+ expect(doc).to be_a SolrDocument
41
41
  end
42
42
 
43
43
  expect(subject.docs.first.id).to eq 1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::Solr::Response, api: true do
3
+ RSpec.describe Blacklight::Solr::Response, :api do
4
4
  let(:raw_response) { eval(mock_query_response) }
5
5
 
6
6
  let(:config) { Blacklight::Configuration.new }
@@ -79,7 +79,7 @@ RSpec.describe Blacklight::Solr::Response, api: true 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 be_a_kind_of Kaminari::PageScopeMethods
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: true do
101
101
 
102
102
  expect(item.hits).to eq 15
103
103
  expect(item.value).to eq 'value'
104
- expect(item).to be_a_kind_of(OpenStruct)
104
+ expect(item).to be_a(OpenStruct)
105
105
  end
106
106
 
107
107
  it "provides a label accessor" do
@@ -1,9 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
3
+ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, :api do
4
4
  subject { search_builder.with(user_params) }
5
5
 
6
6
  let(:single_facet) { { format: ['Book'] } }
7
+ let(:search_builder_class) do
8
+ Class.new(Blacklight::SearchBuilder) do
9
+ include Blacklight::Solr::SearchBuilderBehavior
10
+ end
11
+ end
12
+ let(:search_builder) { search_builder_class.new(context) }
7
13
  let(:multi_facets) { { format: ['Book'], language_ssim: ['Tibetan'] } }
8
14
  let(:mult_word_query) { 'tibetan history' }
9
15
  let(:subject_search_params) { { commit: "search", search_field: "subject", action: "index", controller: "catalog", rows: "10", q: "wome" } }
@@ -14,13 +20,6 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
14
20
 
15
21
  before { allow(context).to receive(:blacklight_config).and_return(blacklight_config) }
16
22
 
17
- let(:search_builder_class) do
18
- Class.new(Blacklight::SearchBuilder) do
19
- include Blacklight::Solr::SearchBuilderBehavior
20
- end
21
- end
22
- let(:search_builder) { search_builder_class.new(context) }
23
-
24
23
  context "with default processor chain" do
25
24
  subject { search_builder }
26
25
 
@@ -117,7 +116,7 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
117
116
  end
118
117
 
119
118
  it 'is negative' do
120
- expect(subject[:'f.subject_ssim.facet.limit']).to eq -1
119
+ expect(subject[:'f.subject_ssim.facet.limit']).to eq(-1)
121
120
  end
122
121
  end
123
122
 
@@ -522,15 +521,6 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
522
521
  expect(subject[:qq1]).to eq 'xyz'
523
522
  end
524
523
  end
525
-
526
- describe "mapping facet.field" do
527
- let(:blacklight_config) do
528
- Blacklight::Configuration.new do |config|
529
- config.add_facet_field 'some_field'
530
- config.add_facet_fields_to_solr_request!
531
- end
532
- end
533
- end
534
524
  end
535
525
 
536
526
  describe "#facet_value_to_fq_string" do
@@ -564,7 +554,7 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
564
554
  expect(subject.send(:facet_value_to_fq_string, "facet_name", 1.11)).to eq '{!term f=facet_name}1.11'
565
555
  end
566
556
 
567
- it "passes floats through" do
557
+ it "passes floats in strings through" do
568
558
  expect(subject.send(:facet_value_to_fq_string, "facet_name", "1.11")).to eq '{!term f=facet_name}1.11'
569
559
  end
570
560
 
@@ -601,7 +591,7 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
601
591
 
602
592
  subject.add_facet_fq_to_solr(solr_parameters)
603
593
 
604
- expect(solr_parameters[:fq]).to be_a_kind_of Array
594
+ expect(solr_parameters[:fq]).to be_a Array
605
595
  end
606
596
 
607
597
  context "facet not defined in config" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::Suggest::Response, api: true do
3
+ RSpec.describe Blacklight::Suggest::Response, :api do
4
4
  let(:empty_response) { described_class.new({}, { q: 'hello' }, 'suggest', 'mySuggester') }
5
5
  let(:full_response) do
6
6
  described_class.new(
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::SuggestSearch, api: true do
3
+ RSpec.describe Blacklight::SuggestSearch, :api do
4
4
  let(:params) { { q: 'test' } }
5
5
  let(:response) { instance_double(Blacklight::Suggest::Response) }
6
6
  let(:repository) { instance_double(Blacklight::Solr::Repository, suggestions: response) }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe "Blacklight::User", api: true do
3
+ RSpec.describe "Blacklight::User", :api do
4
4
  subject { User.create! email: 'xyz@example.com', password: 'xyz12345' }
5
5
 
6
6
  def mock_bookmark document_id
@@ -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 be_a_kind_of SolrDocument
33
+ expect(subject.document).to be_a SolrDocument
34
34
  expect(subject.document.id).to eq 'u001'
35
35
  end
36
36
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe SolrDocument, api: true do
3
+ RSpec.describe SolrDocument, :api do
4
4
  describe "access methods" do
5
5
  let(:solrdoc) do
6
6
  described_class.new(id: '00282214', format: ['Book'], title_tsim: 'some-title')
@@ -11,8 +11,7 @@ RSpec.describe Blacklight::DocumentPresenter do
11
11
  let(:search_state) { Blacklight::SearchState.new(params, blacklight_config, controller) }
12
12
 
13
13
  before do
14
- allow(request_context).to receive(:search_state).and_return(search_state)
15
- allow(request_context).to receive(:action_name).and_return(:show)
14
+ allow(request_context).to receive_messages(search_state: search_state, action_name: :show)
16
15
  end
17
16
 
18
17
  describe '#fields_to_render' do
@@ -51,14 +50,14 @@ RSpec.describe Blacklight::DocumentPresenter do
51
50
 
52
51
  describe '#thumbnail' do
53
52
  it 'returns a thumbnail presenter' do
54
- expect(presenter.thumbnail).to be_a_kind_of(Blacklight::ThumbnailPresenter)
53
+ expect(presenter.thumbnail).to be_a(Blacklight::ThumbnailPresenter)
55
54
  end
56
55
 
57
56
  it 'use the configured thumbnail presenter' do
58
57
  custom_presenter_class = Class.new(Blacklight::ThumbnailPresenter)
59
58
  blacklight_config.index.thumbnail_presenter = custom_presenter_class
60
59
 
61
- expect(presenter.thumbnail).to be_a_kind_of custom_presenter_class
60
+ expect(presenter.thumbnail).to be_a custom_presenter_class
62
61
  end
63
62
  end
64
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::FieldPresenter, api: true do
3
+ RSpec.describe Blacklight::FieldPresenter, :api do
4
4
  subject(:presenter) { described_class.new(request_context, document, field_config, options) }
5
5
 
6
6
  let(:request_context) { double('View context', params: { x: '1' }, search_state: search_state, should_render_field?: true, blacklight_config: config) }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::IndexPresenter, api: true do
3
+ RSpec.describe Blacklight::IndexPresenter, :api do
4
4
  include Capybara::RSpecMatchers
5
5
  subject { presenter }
6
6
 
@@ -21,8 +21,7 @@ RSpec.describe Blacklight::IndexPresenter, api: true do
21
21
  end
22
22
 
23
23
  before do
24
- allow(request_context).to receive(:search_state).and_return(search_state)
25
- allow(request_context).to receive(:action_name).and_return(:index)
24
+ allow(request_context).to receive_messages(search_state: search_state, action_name: :index)
26
25
  end
27
26
 
28
27
  describe '#fields' do
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe Blacklight::JsonPresenter, api: true do
5
+ RSpec.describe Blacklight::JsonPresenter, :api do
6
6
  let(:response) do
7
7
  instance_double(Blacklight::Solr::Response,
8
8
  documents: docs,
@@ -25,7 +25,7 @@ RSpec.describe Blacklight::Rendering::Pipeline do
25
25
  let(:values) { ['a'] }
26
26
  let(:field_config) { Blacklight::Configuration::NullField.new(itemprop: 'some-prop', separator_options: nil) }
27
27
 
28
- it { is_expected.to have_selector("span[@itemprop='some-prop']", text: "a") }
28
+ it { is_expected.to have_css("span[@itemprop='some-prop']", text: "a") }
29
29
  end
30
30
 
31
31
  it 'sets the operations on the instance as equal to the class variable' do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::ShowPresenter, api: true do
3
+ RSpec.describe Blacklight::ShowPresenter, :api do
4
4
  include Capybara::RSpecMatchers
5
5
  subject { presenter }
6
6
 
@@ -18,8 +18,7 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
18
18
  end
19
19
 
20
20
  before do
21
- allow(request_context).to receive(:search_state).and_return(search_state)
22
- allow(request_context).to receive(:action_name).and_return(:show)
21
+ allow(request_context).to receive_messages(search_state: search_state, action_name: :show)
23
22
  end
24
23
 
25
24
  describe "link_rel_alternates" do
@@ -64,7 +63,7 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
64
63
  tmp_value = Capybara.ignore_hidden_elements
65
64
  Capybara.ignore_hidden_elements = false
66
65
  document.export_formats.each_pair do |format, _spec|
67
- expect(subject).to have_selector("link[href$='.#{format}']", count: 1) do |tag|
66
+ expect(subject).to have_css("link[href$='.#{format}']", count: 1) do |tag|
68
67
  expect(tag["rel"]).to eq "alternate"
69
68
  expect(tag["title"]).to eq format.to_s
70
69
  expect(tag["href"]).to eq "url.#{format}"
@@ -82,7 +81,7 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
82
81
  it "respects unique: true" do
83
82
  tmp_value = Capybara.ignore_hidden_elements
84
83
  Capybara.ignore_hidden_elements = false
85
- expect(subject).to have_selector("link[type='application/weird']", count: 1)
84
+ expect(subject).to have_css("link[type='application/weird']", count: 1)
86
85
  Capybara.ignore_hidden_elements = tmp_value
87
86
  end
88
87
  end
@@ -93,7 +92,7 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
93
92
  it "excludes formats from :exclude" do
94
93
  tmp_value = Capybara.ignore_hidden_elements
95
94
  Capybara.ignore_hidden_elements = false
96
- expect(subject).not_to have_selector("link[href$='.weird_dup']")
95
+ expect(subject).to have_no_css("link[href$='.weird_dup']")
97
96
  Capybara.ignore_hidden_elements = tmp_value
98
97
  end
99
98
  end
@@ -75,10 +75,10 @@ RSpec.describe Blacklight::ThumbnailPresenter do
75
75
  end
76
76
 
77
77
  it "calls the provided thumbnail method" do
78
- expect(view_context).to receive_messages(xyz: "some-thumbnail")
79
78
  allow(view_context).to receive(:link_to_document).with(document, "some-thumbnail", {})
80
79
  .and_return("link")
81
80
  expect(subject).to eq "link"
81
+ expect(view_context).to have_received(:xyz)
82
82
  end
83
83
 
84
84
  context "and url options have :suppress_link" do
@@ -107,8 +107,9 @@ RSpec.describe Blacklight::ThumbnailPresenter do
107
107
  it "creates an image tag from the given field" do
108
108
  allow(document).to receive(:fetch).with(:xyz, nil).and_return("http://example.com/some.jpg")
109
109
  allow(view_context).to receive(:image_tag).with("http://example.com/some.jpg", {}).and_return('<img src="image.jpg">')
110
- expect(view_context).to receive(:link_to_document).with(document, '<img src="image.jpg">', {})
110
+ allow(view_context).to receive(:link_to_document)
111
111
  subject
112
+ expect(view_context).to have_received(:link_to_document).with(document, '<img src="image.jpg">', {})
112
113
  end
113
114
 
114
115
  it "returns nil if no thumbnail is in the document" do
@@ -126,8 +127,9 @@ RSpec.describe Blacklight::ThumbnailPresenter do
126
127
 
127
128
  it "creates an image tag from the given field" do
128
129
  allow(view_context).to receive(:image_tag).with("http://example.com/some.jpg", {}).and_return('<img src="image.jpg">')
129
- expect(view_context).to receive(:link_to_document).with(document, '<img src="image.jpg">', {}).and_return('<a><img></a>')
130
+ allow(view_context).to receive(:link_to_document).and_return('<a><img></a>')
130
131
  expect(presenter.thumbnail_tag).to eq '<a><img></a>'
132
+ expect(view_context).to have_received(:link_to_document).with(document, '<img src="image.jpg">', {})
131
133
  end
132
134
  end
133
135
  end
@@ -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
@@ -30,7 +30,7 @@ RSpec.describe "Routing" do
30
30
  end
31
31
  end
32
32
 
33
- describe "solr_document_path for SolrDocument", test: true do
33
+ describe "solr_document_path for SolrDocument", :test do
34
34
  it "routes correctly" do
35
35
  expect(get: solr_document_path(SolrDocument.new(id: 'asdf'))).to route_to(controller: 'catalog', action: 'show', id: 'asdf')
36
36
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::FieldRetriever, api: true do
3
+ RSpec.describe Blacklight::FieldRetriever, :api do
4
4
  let(:service) { described_class.new(document, blacklight_field_config) }
5
5
 
6
6
  let(:blacklight_field_config) { Blacklight::Configuration::Field.new(field: 'author_field', highlight: true) }
@@ -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: true do
11
+ RSpec.describe Blacklight::SearchService, :api do
12
12
  subject { service }
13
13
 
14
14
  let(:context) { { whatever: :value } }
@@ -17,7 +17,7 @@ RSpec.describe Blacklight::SearchService, api: true do
17
17
  let(:user_params) { {} }
18
18
 
19
19
  let(:blacklight_config) { Blacklight::Configuration.new }
20
- let(:copy_of_catalog_config) { ::CatalogController.blacklight_config.deep_copy }
20
+ let(:copy_of_catalog_config) { CatalogController.blacklight_config.deep_copy }
21
21
  let(:blacklight_solr) { RSolr.connect(Blacklight.connection_config.except(:adapter)) }
22
22
 
23
23
  let(:all_docs_query) { '' }
@@ -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: true do
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
@@ -77,11 +77,11 @@ RSpec.describe Blacklight::SearchService, api: true do
77
77
  end
78
78
 
79
79
  it "returns a grouped response" do
80
- expect(service.search_results).to be_a_kind_of Blacklight::Solr::Response::GroupResponse
80
+ expect(service.search_results).to be_a Blacklight::Solr::Response::GroupResponse
81
81
  end
82
82
  end
83
83
 
84
- describe "for a query returning multiple groups", integration: true do
84
+ describe "for a query returning multiple groups", :integration do
85
85
  let(:blacklight_config) { copy_of_catalog_config }
86
86
  let(:user_params) { { q: all_docs_query } }
87
87
 
@@ -93,7 +93,7 @@ RSpec.describe Blacklight::SearchService, api: true do
93
93
 
94
94
  it "returns a grouped response" do
95
95
  solr_response = service.search_results
96
- expect(solr_response).to be_a_kind_of Blacklight::Solr::Response::GroupResponse
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
@@ -139,7 +139,7 @@ RSpec.describe Blacklight::SearchService, api: true do
139
139
  end # Search Results
140
140
 
141
141
  # SPECS FOR SEARCH RESULTS FOR FACETS
142
- describe 'Facets in Search Results for All Docs Query', integration: true do
142
+ describe 'Facets in Search Results for All Docs Query', :integration do
143
143
  let(:blacklight_config) { copy_of_catalog_config }
144
144
  let(:user_params) { { q: all_docs_query } }
145
145
 
@@ -184,7 +184,7 @@ RSpec.describe Blacklight::SearchService, api: true do
184
184
  end # facet specs
185
185
 
186
186
  # SPECS FOR SEARCH RESULTS FOR PAGING
187
- describe 'Paging', integration: true do
187
+ describe 'Paging', :integration do
188
188
  let(:blacklight_config) { copy_of_catalog_config }
189
189
  let(:user_params) { { q: all_docs_query } }
190
190
 
@@ -276,7 +276,7 @@ RSpec.describe Blacklight::SearchService, api: true do
276
276
  end # page specs
277
277
 
278
278
  # SPECS FOR SINGLE DOCUMENT REQUESTS
279
- describe 'Get Document By Id', integration: true do
279
+ describe 'Get Document By Id', :integration do
280
280
  let(:doc_id) { '2007020969' }
281
281
  let(:bad_id) { 'redrum' }
282
282
 
@@ -299,7 +299,7 @@ RSpec.describe Blacklight::SearchService, api: true do
299
299
  end
300
300
  end
301
301
 
302
- describe 'Get multiple documents By Id', integration: true do
302
+ describe 'Get multiple documents By Id', :integration do
303
303
  let(:doc_id) { '2007020969' }
304
304
  let(:bad_id) { 'redrum' }
305
305
  let(:response) { service.fetch([doc_id]) }
@@ -318,7 +318,7 @@ RSpec.describe Blacklight::SearchService, api: true do
318
318
  end
319
319
 
320
320
  # SPECS FOR SPELLING SUGGESTIONS VIA SEARCH
321
- describe "Searches should return spelling suggestions", integration: true do
321
+ describe "Searches should return spelling suggestions", :integration do
322
322
  context "for just-poor-enough-query term" do
323
323
  let(:user_params) { { q: 'boo' } }
324
324
 
data/spec/spec_helper.rb CHANGED
@@ -28,7 +28,7 @@ Capybara.javascript_driver = :headless_chrome
28
28
 
29
29
  Capybara.register_driver :headless_chrome do |app|
30
30
  Capybara::Selenium::Driver.load_selenium
31
- capabilities = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
31
+ capabilities = Selenium::WebDriver::Chrome::Options.new.tap do |opts|
32
32
  opts.args << '--headless'
33
33
  opts.args << '--disable-gpu'
34
34
  opts.args << '--no-sandbox'
@@ -41,7 +41,7 @@ end
41
41
  # in spec/support/ and its subdirectories.
42
42
  # Blacklight, again, make sure we're looking in the right place for em.
43
43
  # Relative to HERE, NOT to Rails.root, which is off somewhere else.
44
- Dir[Pathname.new(File.expand_path('support/**/*.rb', __dir__))].sort.each { |f| require f }
44
+ Dir[Pathname.new(File.expand_path('support/**/*.rb', __dir__))].each { |f| require f }
45
45
 
46
46
  RSpec.configure do |config|
47
47
  config.disable_monkey_patching!
@@ -6,7 +6,7 @@ module Features
6
6
  def search_for q
7
7
  visit root_path
8
8
  fill_in "q", with: q
9
- click_button 'search'
9
+ click_on 'search'
10
10
  end
11
11
 
12
12
  def position_in_result_page(page, id)
@@ -20,7 +20,7 @@ module Features
20
20
  def number_of_results_for_query(query)
21
21
  visit root_path
22
22
  fill_in "q", with: query
23
- click_button "search"
23
+ click_on "search"
24
24
  get_number_of_results_from_page(page)
25
25
  end
26
26
 
@@ -9,7 +9,7 @@ module Features
9
9
  fill_in 'Email', with: email
10
10
  fill_in 'Password', with: password
11
11
  fill_in 'Password confirmation', with: password
12
- click_button 'Sign up'
12
+ click_on 'Sign up'
13
13
  end
14
14
 
15
15
  def sign_in(login = 'user1')
@@ -20,9 +20,9 @@ module Features
20
20
  fill_in("user_password", with: "password")
21
21
 
22
22
  if has_button? "Sign in"
23
- click_button("Sign in")
23
+ click_on("Sign in")
24
24
  elsif has_button? "Log in"
25
- click_button("Log in")
25
+ click_on("Log in")
26
26
  else
27
27
  raise "Unable to find sign in button"
28
28
  end
@@ -20,13 +20,13 @@ class TestAppGenerator < Rails::Generators::Base
20
20
  options += ' --skip-assets'
21
21
  end
22
22
 
23
- generate 'blacklight:install', options
23
+ generate :'blacklight:install', options
24
24
  end
25
25
 
26
26
  def run_test_support_generator
27
27
  say_status("warning", "GENERATING test_support", :yellow)
28
28
 
29
- generate 'blacklight:test_support'
29
+ generate(:'blacklight:test_support')
30
30
  end
31
31
 
32
32
  def add_local_assets_for_propshaft
@@ -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('role="navigation"', 'role="navigation" data-template-override="top_navbar_component"')
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
@@ -6,10 +6,7 @@ RSpec.describe "catalog/_document" do
6
6
 
7
7
  before do
8
8
  allow(controller).to receive(:controller_name).and_return('test')
9
- allow(view).to receive(:render_grouped_response?).and_return(false)
10
- allow(view).to receive(:blacklight_config).and_return(blacklight_config)
11
- allow(view).to receive(:search_session).and_return({})
12
- allow(view).to receive(:current_search_session).and_return(nil)
9
+ allow(view).to receive_messages(render_grouped_response?: false, blacklight_config: blacklight_config, search_session: {}, current_search_session: nil)
13
10
  allow(view.main_app).to receive(:track_test_path).and_return('/track')
14
11
  assign(:response, instance_double(Blacklight::Solr::Response, start: 20))
15
12
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe "catalog/_document_list", type: :view do
3
+ RSpec.describe "catalog/_document_list" do
4
4
  let(:view_type) { 'some-view' }
5
5
  let(:view_config) { double(Blacklight::Configuration::ViewConfig) }
6
6
 
@@ -12,6 +12,6 @@ RSpec.describe "catalog/_document_list", type: :view do
12
12
 
13
13
  it "includes a class for the current view" do
14
14
  render(partial: "catalog/document_list", locals: { view_config: view_config })
15
- expect(rendered).to have_selector(".documents-some-view")
15
+ expect(rendered).to have_css(".documents-some-view")
16
16
  end
17
17
  end