blacklight 7.41.0 → 8.0.0.beta1

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 (425) hide show
  1. checksums.yaml +4 -4
  2. data/.env +2 -3
  3. data/.github/workflows/ruby.yml +81 -0
  4. data/.rubocop.yml +243 -14
  5. data/.rubocop_todo.yml +137 -429
  6. data/Gemfile +11 -6
  7. data/README.md +11 -3
  8. data/VERSION +1 -1
  9. data/app/assets/javascripts/blacklight/blacklight.esm.js +384 -0
  10. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
  11. data/app/assets/javascripts/blacklight/blacklight.js +374 -493
  12. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -0
  13. data/app/assets/stylesheets/blacklight/_autocomplete.scss +25 -0
  14. data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -1
  15. data/app/assets/stylesheets/blacklight/_bookmark.scss +16 -0
  16. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +8 -0
  17. data/app/assets/stylesheets/blacklight/_constraints.scss +4 -4
  18. data/app/assets/stylesheets/blacklight/_facets.scss +72 -44
  19. data/app/assets/stylesheets/blacklight/_header.scss +0 -15
  20. data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
  21. data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
  22. data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
  23. data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
  24. data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
  25. data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
  26. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
  27. data/app/builders/blacklight/action_builder.rb +18 -9
  28. data/app/components/blacklight/advanced_search_form_component.html.erb +3 -3
  29. data/app/components/blacklight/advanced_search_form_component.rb +8 -10
  30. data/app/components/blacklight/constraints_component.rb +27 -37
  31. data/app/components/blacklight/document/action_component.rb +12 -10
  32. data/app/components/blacklight/document/actions_component.rb +2 -2
  33. data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
  34. data/app/components/blacklight/document/bookmark_component.rb +4 -2
  35. data/app/components/blacklight/document/citation_component.rb +5 -3
  36. data/app/components/blacklight/document/group_component.rb +7 -3
  37. data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
  38. data/app/components/blacklight/document/sidebar_component.rb +16 -0
  39. data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
  40. data/app/components/blacklight/document/thumbnail_component.rb +1 -9
  41. data/app/components/blacklight/document_component.html.erb +1 -1
  42. data/app/components/blacklight/document_component.rb +16 -78
  43. data/app/components/blacklight/document_metadata_component.html.erb +2 -4
  44. data/app/components/blacklight/document_metadata_component.rb +5 -10
  45. data/app/components/blacklight/facet_component.rb +3 -3
  46. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +4 -4
  47. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  48. data/app/components/blacklight/facet_field_component.html.erb +4 -5
  49. data/app/components/blacklight/facet_field_component.rb +9 -2
  50. data/app/components/blacklight/facet_field_list_component.html.erb +3 -3
  51. data/app/components/blacklight/facet_field_list_component.rb +37 -5
  52. data/app/components/blacklight/facet_field_no_layout_component.rb +0 -2
  53. data/app/components/blacklight/facet_item_component.rb +1 -43
  54. data/app/components/blacklight/facet_item_pivot_component.rb +21 -23
  55. data/app/components/blacklight/header_component.rb +1 -1
  56. data/app/components/blacklight/hidden_search_state_component.rb +1 -2
  57. data/app/components/blacklight/icons/icon_component.rb +4 -9
  58. data/app/components/blacklight/icons/legacy_icon_component.rb +30 -0
  59. data/app/components/blacklight/icons/list_component.rb +16 -0
  60. data/app/components/blacklight/icons/search_component.rb +16 -0
  61. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  62. data/app/components/blacklight/metadata_field_component.rb +24 -8
  63. data/app/components/blacklight/metadata_field_layout_component.rb +4 -25
  64. data/app/components/blacklight/response/facet_group_component.html.erb +3 -5
  65. data/app/components/blacklight/response/facet_group_component.rb +29 -8
  66. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  67. data/app/components/blacklight/response/pagination_component.rb +2 -11
  68. data/app/components/blacklight/response/sort_component.html.erb +6 -1
  69. data/app/components/blacklight/response/sort_component.rb +1 -16
  70. data/app/components/blacklight/response/spellcheck_component.rb +18 -7
  71. data/app/components/blacklight/response/view_type_button_component.rb +3 -7
  72. data/app/components/blacklight/response/view_type_component.rb +4 -6
  73. data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
  74. data/app/components/blacklight/search/sidebar_component.rb +17 -0
  75. data/app/components/blacklight/search_bar_component.html.erb +20 -15
  76. data/app/components/blacklight/search_bar_component.rb +2 -16
  77. data/app/components/blacklight/search_button_component.rb +3 -3
  78. data/app/components/blacklight/search_context_component.rb +43 -10
  79. data/app/components/blacklight/search_header_component.html.erb +2 -0
  80. data/app/components/blacklight/search_header_component.rb +6 -0
  81. data/app/components/blacklight/start_over_button_component.rb +5 -3
  82. data/app/components/blacklight/system/dropdown_component.rb +8 -5
  83. data/app/components/blacklight/system/flash_message_component.html.erb +4 -2
  84. data/app/components/blacklight/system/flash_message_component.rb +12 -3
  85. data/app/components/blacklight/system/modal_component.html.erb +1 -1
  86. data/app/components/blacklight/system/modal_component.rb +1 -3
  87. data/app/components/blacklight/top_navbar_component.html.erb +1 -1
  88. data/app/components/blacklight/top_navbar_component.rb +0 -4
  89. data/app/controllers/bookmarks_controller.rb +1 -0
  90. data/app/controllers/catalog_controller.rb +1 -0
  91. data/app/controllers/concerns/blacklight/bookmarks.rb +10 -9
  92. data/app/controllers/concerns/blacklight/catalog.rb +21 -83
  93. data/app/controllers/concerns/blacklight/controller.rb +3 -41
  94. data/app/controllers/concerns/blacklight/search_context.rb +25 -7
  95. data/app/controllers/concerns/blacklight/search_history.rb +2 -0
  96. data/app/controllers/concerns/blacklight/searchable.rb +12 -1
  97. data/app/controllers/concerns/blacklight/token_based_user.rb +13 -1
  98. data/app/controllers/search_history_controller.rb +1 -0
  99. data/app/helpers/blacklight/blacklight_helper_behavior.rb +12 -310
  100. data/app/helpers/blacklight/catalog_helper_behavior.rb +22 -139
  101. data/app/helpers/blacklight/component_helper_behavior.rb +2 -53
  102. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -119
  103. data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
  104. data/app/helpers/blacklight/icon_helper_behavior.rb +5 -7
  105. data/app/helpers/blacklight/layout_helper_behavior.rb +4 -3
  106. data/app/helpers/blacklight/render_partials_helper_behavior.rb +11 -31
  107. data/app/helpers/blacklight/url_helper_behavior.rb +12 -97
  108. data/app/helpers/blacklight_helper.rb +1 -0
  109. data/app/helpers/catalog_helper.rb +1 -0
  110. data/app/javascript/blacklight/bookmark_toggle.js +13 -19
  111. data/app/javascript/blacklight/button_focus.js +12 -10
  112. data/app/javascript/blacklight/checkbox_submit.js +68 -123
  113. data/app/javascript/blacklight/core.js +5 -7
  114. data/app/javascript/blacklight/index.js +13 -0
  115. data/app/javascript/blacklight/modal.js +99 -164
  116. data/app/javascript/blacklight/modalForm.js +60 -0
  117. data/app/javascript/blacklight/search_context.js +46 -54
  118. data/app/models/blacklight/facet_paginator.rb +3 -2
  119. data/app/models/blacklight/icon.rb +4 -2
  120. data/app/models/bookmark.rb +0 -2
  121. data/app/models/concerns/blacklight/configurable.rb +5 -4
  122. data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -10
  123. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  124. data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
  125. data/app/models/concerns/blacklight/document/email.rb +1 -0
  126. data/app/models/concerns/blacklight/document/export.rb +2 -1
  127. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  128. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  129. data/app/models/concerns/blacklight/document/semantic_fields.rb +2 -1
  130. data/app/models/concerns/blacklight/document/sms.rb +1 -0
  131. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  132. data/app/models/concerns/blacklight/user.rb +17 -8
  133. data/app/models/record_mailer.rb +13 -12
  134. data/app/models/search.rb +1 -7
  135. data/app/models/solr_document.rb +1 -0
  136. data/app/presenters/blacklight/clause_presenter.rb +1 -1
  137. data/app/presenters/blacklight/document_presenter.rb +23 -50
  138. data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
  139. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
  140. data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
  141. data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
  142. data/app/presenters/blacklight/field_presenter.rb +1 -0
  143. data/app/presenters/blacklight/index_presenter.rb +2 -40
  144. data/app/presenters/blacklight/json_presenter.rb +10 -6
  145. data/app/presenters/blacklight/rendering/link_to_facet.rb +2 -5
  146. data/app/presenters/blacklight/show_presenter.rb +1 -9
  147. data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
  148. data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
  149. data/app/services/blacklight/field_retriever.rb +12 -21
  150. data/app/services/blacklight/search_service.rb +10 -17
  151. data/app/values/blacklight/types.rb +0 -18
  152. data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
  153. data/app/views/bookmarks/_tools.html.erb +7 -12
  154. data/app/views/catalog/_advanced_search_form.html.erb +0 -1
  155. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  156. data/app/views/catalog/_citation.html.erb +1 -1
  157. data/app/views/catalog/_constraints.html.erb +1 -14
  158. data/app/views/catalog/_document.atom.builder +12 -14
  159. data/app/views/catalog/_document.html.erb +5 -3
  160. data/app/views/catalog/_document.rss.builder +2 -4
  161. data/app/views/catalog/_facet_layout.html.erb +2 -2
  162. data/app/views/catalog/_facets.html.erb +5 -4
  163. data/app/views/catalog/_home_text.html.erb +2 -14
  164. data/app/views/catalog/_per_page_widget.html.erb +10 -1
  165. data/app/views/catalog/_search_form.html.erb +2 -2
  166. data/app/views/catalog/_search_header.html.erb +1 -2
  167. data/app/views/catalog/_search_results.html.erb +2 -2
  168. data/app/views/catalog/_search_sidebar.html.erb +5 -1
  169. data/app/views/catalog/_show_main_content.html.erb +11 -16
  170. data/app/views/catalog/_show_sidebar.html.erb +2 -2
  171. data/app/views/catalog/_show_tools.html.erb +8 -14
  172. data/app/views/catalog/_view_type_group.html.erb +1 -1
  173. data/app/views/catalog/email.html.erb +2 -2
  174. data/app/views/catalog/email_success.html.erb +5 -6
  175. data/app/views/catalog/facet.html.erb +7 -5
  176. data/app/views/catalog/index.atom.builder +12 -14
  177. data/app/views/catalog/index.html.erb +4 -1
  178. data/app/views/catalog/index.json.jbuilder +19 -19
  179. data/app/views/catalog/index.rss.builder +1 -1
  180. data/app/views/catalog/opensearch.xml.builder +1 -1
  181. data/app/views/catalog/sms.html.erb +2 -2
  182. data/app/views/catalog/sms_success.html.erb +5 -6
  183. data/app/views/catalog/suggest.html.erb +3 -0
  184. data/app/views/kaminari/blacklight/_page.html.erb +2 -1
  185. data/app/views/layouts/blacklight/base.html.erb +13 -2
  186. data/app/views/search_history/index.html.erb +6 -2
  187. data/app/views/shared/_flash_messages.html.erb +1 -1
  188. data/app/views/shared/_modal.html.erb +3 -3
  189. data/blacklight.gemspec +7 -11
  190. data/config/importmap.rb +3 -0
  191. data/config/locales/blacklight.ar.yml +0 -1
  192. data/config/locales/blacklight.ca.yml +0 -1
  193. data/config/locales/blacklight.de.yml +0 -1
  194. data/config/locales/blacklight.en.yml +0 -2
  195. data/config/locales/blacklight.es.yml +0 -1
  196. data/config/locales/blacklight.fr.yml +0 -1
  197. data/config/locales/blacklight.hu.yml +0 -1
  198. data/config/locales/blacklight.it.yml +0 -1
  199. data/config/locales/blacklight.nl.yml +0 -1
  200. data/config/locales/blacklight.pt-BR.yml +0 -1
  201. data/config/locales/blacklight.sq.yml +0 -1
  202. data/config/locales/blacklight.zh.yml +0 -1
  203. data/config/routes.rb +3 -2
  204. data/db/migrate/20140202020201_create_searches.rb +1 -0
  205. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  206. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  207. data/docker-compose.yml +3 -3
  208. data/lib/blacklight/abstract_repository.rb +1 -6
  209. data/lib/blacklight/component.rb +47 -10
  210. data/lib/blacklight/configuration/context.rb +4 -4
  211. data/lib/blacklight/configuration/display_field.rb +7 -9
  212. data/lib/blacklight/configuration/facet_field.rb +17 -11
  213. data/lib/blacklight/configuration/field.rb +1 -0
  214. data/lib/blacklight/configuration/fields.rb +12 -15
  215. data/lib/blacklight/configuration/index_field.rb +1 -0
  216. data/lib/blacklight/configuration/null_display_field.rb +17 -0
  217. data/lib/blacklight/configuration/search_field.rb +1 -0
  218. data/lib/blacklight/configuration/show_field.rb +1 -0
  219. data/lib/blacklight/configuration/sort_field.rb +1 -0
  220. data/lib/blacklight/configuration/tool_config.rb +1 -0
  221. data/lib/blacklight/configuration/view_config.rb +14 -10
  222. data/lib/blacklight/configuration.rb +310 -365
  223. data/lib/blacklight/engine.rb +8 -24
  224. data/lib/blacklight/exceptions.rb +2 -2
  225. data/lib/blacklight/nested_open_struct_with_hash_access.rb +7 -13
  226. data/lib/blacklight/open_struct_with_hash_access.rb +23 -6
  227. data/lib/blacklight/parameters.rb +7 -21
  228. data/lib/blacklight/routes/exportable.rb +1 -0
  229. data/lib/blacklight/routes/searchable.rb +2 -1
  230. data/lib/blacklight/routes.rb +1 -0
  231. data/lib/blacklight/search_builder.rb +10 -10
  232. data/lib/blacklight/search_state/filter_field.rb +8 -25
  233. data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
  234. data/lib/blacklight/search_state.rb +23 -79
  235. data/lib/blacklight/solr/document.rb +1 -0
  236. data/lib/blacklight/solr/facet_paginator.rb +1 -0
  237. data/lib/blacklight/solr/repository.rb +4 -24
  238. data/lib/blacklight/solr/request.rb +1 -0
  239. data/lib/blacklight/solr/response/facets.rb +21 -5
  240. data/lib/blacklight/solr/response/group.rb +1 -0
  241. data/lib/blacklight/solr/response/group_response.rb +1 -0
  242. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  243. data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
  244. data/lib/blacklight/solr/response/params.rb +5 -4
  245. data/lib/blacklight/solr/response/response.rb +1 -0
  246. data/lib/blacklight/solr/response/spelling.rb +1 -0
  247. data/lib/blacklight/solr/response.rb +16 -3
  248. data/lib/blacklight/solr/search_builder_behavior.rb +16 -35
  249. data/lib/blacklight/solr.rb +7 -0
  250. data/lib/blacklight/version.rb +1 -0
  251. data/lib/blacklight.rb +26 -14
  252. data/lib/generators/blacklight/assets/importmap_generator.rb +55 -0
  253. data/lib/generators/blacklight/assets/propshaft_generator.rb +25 -0
  254. data/lib/generators/blacklight/assets/sprockets_generator.rb +66 -0
  255. data/lib/generators/blacklight/assets_generator.rb +13 -86
  256. data/lib/generators/blacklight/controller_generator.rb +4 -3
  257. data/lib/generators/blacklight/document_generator.rb +1 -0
  258. data/lib/generators/blacklight/install_generator.rb +4 -3
  259. data/lib/generators/blacklight/models_generator.rb +1 -0
  260. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  261. data/lib/generators/blacklight/solr_generator.rb +1 -1
  262. data/lib/generators/blacklight/templates/catalog_controller.rb +34 -8
  263. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +1 -70
  264. data/lib/generators/blacklight/test_support_generator.rb +5 -3
  265. data/lib/generators/blacklight/user_generator.rb +7 -9
  266. data/lib/railties/blacklight.rake +6 -7
  267. data/package.json +10 -13
  268. data/rollup.config.js +27 -0
  269. data/spec/components/blacklight/constraints_component_spec.rb +17 -13
  270. data/spec/components/blacklight/document/action_component_spec.rb +6 -1
  271. data/spec/components/blacklight/document_component_spec.rb +22 -131
  272. data/spec/components/blacklight/facet_component_spec.rb +3 -18
  273. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
  274. data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
  275. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +10 -9
  276. data/spec/components/blacklight/response/view_type_component_spec.rb +66 -0
  277. data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
  278. data/spec/components/blacklight/search_context_component_spec.rb +17 -8
  279. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
  280. data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
  281. data/spec/controllers/bookmarks_controller_spec.rb +2 -3
  282. data/spec/controllers/catalog_controller_spec.rb +13 -135
  283. data/spec/features/advanced_search_spec.rb +0 -56
  284. data/spec/features/autocomplete_spec.rb +1 -1
  285. data/spec/features/axe_spec.rb +1 -6
  286. data/spec/features/bookmarks_spec.rb +1 -1
  287. data/spec/features/facets_spec.rb +6 -4
  288. data/spec/features/search_context_spec.rb +5 -11
  289. data/spec/features/search_results_spec.rb +0 -33
  290. data/spec/features/sitelinks_search_box.rb +13 -0
  291. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +2 -138
  292. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +0 -387
  293. data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +8 -0
  294. data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +3 -20
  295. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +5 -7
  296. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +9 -131
  297. data/spec/helpers/blacklight_helper_spec.rb +8 -252
  298. data/spec/helpers/catalog_helper_spec.rb +7 -118
  299. data/spec/i18n_spec.rb +1 -0
  300. data/spec/integration/generators/blacklight/solr_generator_spec.rb +1 -1
  301. data/spec/lib/blacklight/component_spec.rb +27 -32
  302. data/spec/lib/blacklight/configuration/facet_field_spec.rb +27 -16
  303. data/spec/lib/blacklight/configuration/field_spec.rb +1 -1
  304. data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
  305. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +2 -2
  306. data/spec/lib/blacklight/parameters_spec.rb +1 -4
  307. data/spec/lib/blacklight/search_state/filter_field_spec.rb +4 -4
  308. data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +117 -0
  309. data/spec/lib/blacklight/search_state_spec.rb +80 -198
  310. data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
  311. data/spec/models/blacklight/configuration_spec.rb +17 -51
  312. data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
  313. data/spec/models/blacklight/icon_spec.rb +31 -15
  314. data/spec/models/blacklight/search_builder_spec.rb +9 -9
  315. data/spec/models/blacklight/solr/document_spec.rb +3 -3
  316. data/spec/models/blacklight/solr/repository_spec.rb +0 -45
  317. data/spec/models/blacklight/solr/response/facets_spec.rb +27 -27
  318. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  319. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  320. data/spec/models/blacklight/solr/response_spec.rb +9 -2
  321. data/spec/models/blacklight/solr/search_builder_spec.rb +24 -44
  322. data/spec/models/blacklight/user_spec.rb +22 -0
  323. data/spec/models/solr_document_spec.rb +3 -9
  324. data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
  325. data/spec/presenters/blacklight/document_presenter_spec.rb +2 -3
  326. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +85 -12
  327. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +1 -0
  328. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +14 -13
  329. data/spec/presenters/blacklight/field_presenter_spec.rb +0 -14
  330. data/spec/presenters/blacklight/index_presenter_spec.rb +2 -5
  331. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -0
  332. data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -2
  333. data/spec/presenters/blacklight/show_presenter_spec.rb +20 -30
  334. data/spec/presenters/thumbnail_presenter_spec.rb +1 -1
  335. data/spec/requests/load_suggestions_spec.rb +16 -0
  336. data/spec/routing/catalog_routing_spec.rb +2 -1
  337. data/spec/services/blacklight/search_service_spec.rb +39 -76
  338. data/spec/spec_helper.rb +8 -9
  339. data/spec/support/controller_level_helpers.rb +1 -2
  340. data/spec/support/features/search_helpers.rb +39 -0
  341. data/spec/support/features/session_helpers.rb +1 -0
  342. data/spec/support/features.rb +3 -0
  343. data/spec/support/view_component_capybara_test_helpers.rb +8 -0
  344. data/spec/test_app_templates/Gemfile.extra +1 -0
  345. data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -2
  346. data/spec/views/catalog/_document.html.erb_spec.rb +3 -34
  347. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
  348. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +0 -2
  349. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  350. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  351. data/spec/views/catalog/_show_tools.html.erb_spec.rb +5 -66
  352. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
  353. data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
  354. data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
  355. data/spec/views/catalog/index.atom.builder_spec.rb +17 -11
  356. data/spec/views/catalog/index.html.erb_spec.rb +5 -6
  357. data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
  358. data/spec/views/catalog/show.html.erb_spec.rb +3 -25
  359. data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
  360. data/tasks/blacklight.rake +11 -9
  361. data/template.demo.rb +7 -7
  362. metadata +77 -189
  363. data/.babelrc +0 -11
  364. data/.github/matrix.json +0 -62
  365. data/.github/workflows/build.yml +0 -16
  366. data/.github/workflows/lint.yml +0 -23
  367. data/.github/workflows/main.yml +0 -23
  368. data/.github/workflows/test.yml +0 -53
  369. data/app/assets/images/blacklight/list.svg +0 -1
  370. data/app/assets/images/blacklight/search.svg +0 -1
  371. data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +0 -37
  372. data/app/components/blacklight/content_areas_shim.rb +0 -13
  373. data/app/components/blacklight/search/per_page_component.html.erb +0 -2
  374. data/app/components/blacklight/search/per_page_component.rb +0 -50
  375. data/app/components/blacklight/search_context/server_item_pagination_component.html.erb +0 -10
  376. data/app/components/blacklight/search_context/server_item_pagination_component.rb +0 -15
  377. data/app/components/blacklight/system/dropdown_button_component.rb +0 -18
  378. data/app/controllers/concerns/blacklight/base.rb +0 -12
  379. data/app/controllers/concerns/blacklight/default_component_configuration.rb +0 -64
  380. data/app/controllers/concerns/blacklight/facet.rb +0 -69
  381. data/app/controllers/concerns/blacklight/search_fields.rb +0 -46
  382. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -27
  383. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -188
  384. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -97
  385. data/app/helpers/blacklight/suggest_helper_behavior.rb +0 -13
  386. data/app/javascript/blacklight/autocomplete.js +0 -36
  387. data/app/javascript/blacklight/facet_load.js +0 -22
  388. data/app/presenters/blacklight/search_bar_presenter.rb +0 -47
  389. data/app/views/catalog/_constraints_element.html.erb +0 -14
  390. data/app/views/catalog/_document_action.html.erb +0 -5
  391. data/app/views/catalog/_facet_group.html.erb +0 -5
  392. data/app/views/catalog/_facet_limit.html.erb +0 -3
  393. data/app/views/catalog/_index.html.erb +0 -1
  394. data/app/views/catalog/_index_header.html.erb +0 -22
  395. data/app/views/catalog/_previous_next_doc.html.erb +0 -2
  396. data/app/views/catalog/_show.html.erb +0 -6
  397. data/app/views/catalog/_show_header.html.erb +0 -2
  398. data/app/views/catalog/_thumbnail.html.erb +0 -1
  399. data/lib/blacklight/deprecations/engine_configuration.rb +0 -66
  400. data/lib/blacklight/deprecations/search_state_normalization.rb +0 -52
  401. data/spec/components/blacklight/header_component_spec.rb +0 -20
  402. data/spec/components/blacklight/icons/icon_component_spec.rb +0 -42
  403. data/spec/components/blacklight/response/pagination_component_spec.rb +0 -53
  404. data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +0 -35
  405. data/spec/controllers/blacklight/facet_spec.rb +0 -33
  406. data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
  407. data/spec/features/citation_spec.rb +0 -10
  408. data/spec/features/sitelinks_search_box_spec.rb +0 -13
  409. data/spec/features/sms_spec.rb +0 -12
  410. data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +0 -26
  411. data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +0 -92
  412. data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +0 -101
  413. data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
  414. data/spec/lib/blacklight/engine_spec.rb +0 -41
  415. data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
  416. data/spec/services/blacklight/field_retriever_spec.rb +0 -17
  417. data/spec/support/view_component_test_helpers.rb +0 -35
  418. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  419. data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
  420. data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
  421. data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
  422. data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
  423. data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
  424. data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
  425. data/spec/views/catalog/_thumbnail.html.erb_spec.rb +0 -38
@@ -8,14 +8,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
8
8
  allow(helper).to receive_messages(blacklight_config: blacklight_config)
9
9
  end
10
10
 
11
- describe "#index_fields" do
12
- it "passes through the configuration" do
13
- allow(Deprecation).to receive(:warn)
14
- allow(blacklight_config).to receive_messages(index_fields: config_value)
15
- expect(helper.index_fields).to eq config_value
16
- end
17
- end
18
-
19
11
  describe "#active_sort_fields" do
20
12
  it "restricts the configured sort fields to only those that should be displayed" do
21
13
  allow(blacklight_config).to receive_messages(sort_fields: { a: double(if: false, unless: false), b: double(if: true, unless: true) })
@@ -23,17 +15,9 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
23
15
  end
24
16
  end
25
17
 
26
- describe "#document_show_fields" do
27
- it "passes through the configuration" do
28
- allow(Deprecation).to receive(:warn)
29
- allow(blacklight_config).to receive_messages(show_fields: config_value)
30
- expect(helper.document_show_fields).to eq config_value
31
- end
32
- end
33
-
34
18
  describe "#default_document_index_view_type" do
35
19
  it "uses the first view with default set to true" do
36
- blacklight_config.view.a({})
20
+ blacklight_config.view.a
37
21
  blacklight_config.view.b(default: true)
38
22
  expect(helper.default_document_index_view_type).to eq :b
39
23
  end
@@ -71,62 +55,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
71
55
  end
72
56
  end
73
57
 
74
- describe "#has_alternative_views?" do
75
- subject { helper.has_alternative_views? }
76
-
77
- before do
78
- blacklight_config.view.clear
79
- end
80
-
81
- describe "with a single view defined" do
82
- it { is_expected.to be false }
83
- end
84
-
85
- describe "with multiple views defined" do
86
- before do
87
- blacklight_config.view.abc
88
- blacklight_config.view.xyz
89
- end
90
-
91
- it { is_expected.to be true }
92
- end
93
- end
94
-
95
- describe "#spell_check_max" do
96
- it "passes through the configuration" do
97
- allow(blacklight_config).to receive_messages(spell_max: config_value)
98
- expect(helper.spell_check_max).to eq config_value
99
- end
100
- end
101
-
102
- describe "#document_show_link_field" do
103
- let(:document) { SolrDocument.new id: 123, a: 1, b: 2, c: 3 }
104
-
105
- before do
106
- allow(Deprecation).to receive(:warn)
107
- end
108
-
109
- it "allows single values" do
110
- blacklight_config.index.title_field = :a
111
- f = helper.document_show_link_field document
112
- expect(f).to eq :a
113
- end
114
-
115
- it "retrieves the first field with data" do
116
- blacklight_config.index.title_field = [:zzz, :b]
117
- f = helper.document_show_link_field document
118
- expect(f).to eq :b
119
- end
120
- end
121
-
122
- describe "#view_label" do
123
- it "looks up the label to display for the view" do
124
- allow(blacklight_config).to receive(:view).and_return("my_view" => double(display_label: "some label"))
125
-
126
- helper.view_label "my_view"
127
- end
128
- end
129
-
130
58
  describe "#field_label" do
131
59
  it "looks up the label as an i18n string" do
132
60
  expect(helper).to receive(:t).with(:some_key, default: []).and_return "my label"
@@ -148,32 +76,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
148
76
  end
149
77
  end
150
78
 
151
- describe "#default_per_page" do
152
- before do
153
- expect(Deprecation).to receive(:warn)
154
- end
155
-
156
- context "when default_per_page is configured" do
157
- before do
158
- blacklight_config.default_per_page = 42
159
- end
160
-
161
- it "is the configured value" do
162
- expect(helper.default_per_page).to eq 42
163
- end
164
- end
165
-
166
- context "when default_per_page is not configured" do
167
- before do
168
- blacklight_config.per_page = [11, 22]
169
- end
170
-
171
- it "is the first per-page value if a default isn't set" do
172
- expect(helper.default_per_page).to eq 11
173
- end
174
- end
175
- end
176
-
177
79
  describe "#default_sort_field" do
178
80
  it "is the configured default field" do
179
81
  allow(helper).to receive_messages(blacklight_config: double(sort_fields: { a: double(default: nil), b: double(key: 'b', default: true) }))
@@ -203,11 +105,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
203
105
  describe "#should_render_field?" do
204
106
  let(:field_config) { double('field config', if: true, unless: false) }
205
107
 
206
- before do
207
- allow(Deprecation).to receive(:warn)
208
- allow(helper).to receive_messages(document_has_value?: true)
209
- end
210
-
211
108
  it "is true" do
212
109
  expect(helper.should_render_field?(field_config)).to be true
213
110
  end
@@ -223,39 +120,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
223
120
  end
224
121
  end
225
122
 
226
- describe "#search_field_options_for_select" do
227
- before do
228
- @config = Blacklight::Configuration.new do |config|
229
- config.default_solr_params = { qt: 'search' }
230
-
231
- config.add_search_field 'all_fields', label: 'All Fields'
232
- config.add_search_field 'title', qt: 'title_search'
233
- config.add_search_field 'author', qt: 'author_search'
234
- config.add_search_field 'subject', qt: 'subject_search'
235
- config.add_search_field 'no_display', qt: 'something', include_in_simple_select: false
236
- end
237
-
238
- allow(helper).to receive_messages(blacklight_config: @config)
239
- end
240
-
241
- it "returns proper options_for_select arguments" do
242
- select_arguments = helper.search_field_options_for_select
243
-
244
- select_arguments.each do |(label, key)|
245
- config_hash = @config.search_fields[key]
246
-
247
- expect(label).to eq config_hash.label
248
- expect(key).to eq config_hash.key
249
- end
250
- end
251
-
252
- it "does not include fields in select if :display_in_simple_search=>false" do
253
- select_arguments = helper.search_field_options_for_select
254
-
255
- expect(select_arguments).not_to include(["No Display", "no_display"])
256
- end
257
- end
258
-
259
123
  context 'labels' do
260
124
  let(:field_config) { { 'my-key' => double('field', display_label: 'My Field') } }
261
125
 
@@ -275,7 +139,7 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
275
139
  end
276
140
 
277
141
  it 'handles a missing field' do
278
- expect(helper.label_for_search_field(nil)).to eq nil
142
+ expect(helper.label_for_search_field(nil)).to be_nil
279
143
  end
280
144
  end
281
145
 
@@ -3,397 +3,10 @@
3
3
  RSpec.describe Blacklight::FacetsHelperBehavior do
4
4
  let(:blacklight_config) { Blacklight::Configuration.new }
5
5
 
6
- around { |test| Deprecation.silence(described_class) { test.call } }
7
-
8
6
  before do
9
7
  allow(helper).to receive(:blacklight_config).and_return blacklight_config
10
8
  end
11
9
 
12
- describe "has_facet_values?" do
13
- let(:empty) { double(items: [], name: 'empty') }
14
- let(:response) { instance_double(Blacklight::Solr::Response) }
15
-
16
- it "is true if there are any facets to display" do
17
- a = double(items: [1, 2], name: 'a')
18
- b = double(items: %w[b c], name: 'b')
19
- fields = [a, b, empty]
20
- expect(helper.has_facet_values?(fields, response)).to be true
21
- end
22
-
23
- it "is false if all facets are empty" do
24
- expect(helper.has_facet_values?([empty], response)).to be false
25
- end
26
-
27
- describe "different config" do
28
- let(:blacklight_config) { Blacklight::Configuration.new { |config| config.add_facet_field 'basic_field', if: false } }
29
-
30
- it "is false if no facets are displayable" do
31
- a = double(items: [1, 2], name: 'basic_field')
32
- expect(helper.has_facet_values?([a], response)).to be false
33
- end
34
- end
35
- end
36
-
37
- describe "should_render_facet?" do
38
- let(:blacklight_config) do
39
- Blacklight::Configuration.new do |config|
40
- config.add_facet_field 'basic_field'
41
- config.add_facet_field 'no_show', show: false
42
- config.add_facet_field 'helper_show', show: :my_custom_check
43
- config.add_facet_field 'helper_with_an_arg_show', show: :my_custom_check_with_an_arg
44
- config.add_facet_field 'lambda_show', show: ->(_context, _config, _field) { true }
45
- config.add_facet_field 'lambda_no_show', show: ->(_context, _config, _field) { false }
46
- end
47
- end
48
-
49
- it "renders facets with items" do
50
- a = double(items: [1, 2], name: 'basic_field')
51
- expect(helper.should_render_facet?(a)).to be true
52
- end
53
-
54
- it "does not render facets without items" do
55
- empty = double(items: [], name: 'basic_field')
56
- expect(helper.should_render_facet?(empty)).to be false
57
- end
58
-
59
- it "does not render facets where show is set to false" do
60
- a = double(items: [1, 2], name: 'no_show')
61
- expect(helper.should_render_facet?(a)).to be false
62
- end
63
-
64
- it "calls a helper to determine if it should render a field" do
65
- allow(controller).to receive_messages(my_custom_check: true)
66
- a = double(items: [1, 2], name: 'helper_show')
67
- expect(helper.should_render_facet?(a)).to be true
68
- end
69
-
70
- it "calls a helper to determine if it should render a field" do
71
- a = double(items: [1, 2], name: 'helper_with_an_arg_show')
72
- allow(controller).to receive(:my_custom_check_with_an_arg).with(blacklight_config.facet_fields['helper_with_an_arg_show'], a).and_return(true)
73
- expect(helper.should_render_facet?(a)).to be true
74
- end
75
-
76
- it "evaluates a Proc to determine if it should render a field" do
77
- a = double(items: [1, 2], name: 'lambda_show')
78
- expect(helper.should_render_facet?(a)).to be true
79
- a = double(items: [1, 2], name: 'lambda_no_show')
80
- expect(helper.should_render_facet?(a)).to be false
81
- end
82
- end
83
-
84
- describe "should_collapse_facet?" do
85
- let(:blacklight_config) do
86
- Blacklight::Configuration.new do |config|
87
- config.add_facet_field 'basic_field'
88
- config.add_facet_field 'no_collapse', collapse: false
89
- end
90
- end
91
-
92
- it "is collapsed by default" do
93
- expect(helper.should_collapse_facet?(blacklight_config.facet_fields['basic_field'])).to be true
94
- end
95
-
96
- it "does not be collapsed if the configuration says so" do
97
- expect(helper.should_collapse_facet?(blacklight_config.facet_fields['no_collapse'])).to be false
98
- end
99
-
100
- it "does not be collapsed if it is in the params" do
101
- params[:f] = ActiveSupport::HashWithIndifferentAccess.new(basic_field: [1], no_collapse: [2])
102
- expect(helper.should_collapse_facet?(blacklight_config.facet_fields['basic_field'])).to be false
103
- expect(helper.should_collapse_facet?(blacklight_config.facet_fields['no_collapse'])).to be false
104
- end
105
- end
106
-
107
- describe "facet_by_field_name" do
108
- around { |test| Deprecation.silence(Blacklight::Facet) { test.call } }
109
-
110
- it "retrieves the facet from the response given a string" do
111
- facet_config = double(query: nil, field: 'b', key: 'a')
112
- facet_field = double
113
- allow(helper).to receive(:facet_configuration_for_field).with('b').and_return(facet_config)
114
- response = instance_double(Blacklight::Solr::Response, aggregations: { 'b' => facet_field })
115
-
116
- expect(helper.facet_by_field_name('b', response)).to eq facet_field
117
- end
118
- end
119
-
120
- describe "render_facet_partials" do
121
- let(:a) { double(items: [1, 2]) }
122
- let(:b) { double(items: %w[b c]) }
123
- let(:response) { instance_double(Blacklight::Solr::Response) }
124
-
125
- it "tries to render all provided facets" do
126
- empty = double(items: [])
127
- fields = [a, b, empty]
128
- expect(helper).to receive(:render_facet_limit).with(a, {})
129
- expect(helper).to receive(:render_facet_limit).with(b, {})
130
- expect(helper).to receive(:render_facet_limit).with(empty, {})
131
- helper.render_facet_partials fields, response: response
132
- end
133
-
134
- it "defaults to the configured facets" do
135
- allow(Deprecation).to receive(:warn)
136
- expect(helper).to receive(:facet_field_names) { [a, b] }
137
- expect(helper).to receive(:render_facet_limit).with(a, {})
138
- expect(helper).to receive(:render_facet_limit).with(b, {})
139
- helper.render_facet_partials
140
- end
141
- end
142
-
143
- describe "render_facet_limit" do
144
- let(:blacklight_config) do
145
- Blacklight::Configuration.new do |config|
146
- config.add_facet_field 'basic_field'
147
- config.add_facet_field 'component_field', component: true
148
- config.add_facet_field 'non_rendering_component_field', component: true, if: false
149
- config.add_facet_field 'pivot_facet_field', pivot: %w[a b]
150
- config.add_facet_field 'my_pivot_facet_field_with_custom_partial', partial: 'custom_facet_partial', pivot: %w[a b]
151
- config.add_facet_field 'my_facet_field_with_custom_partial', partial: 'custom_facet_partial'
152
- end
153
- end
154
- let(:mock_custom_facet) { double(name: 'my_facet_field_with_custom_partial', items: [1, 2, 3]) }
155
-
156
- it "sets basic local variables" do
157
- mock_facet = double(name: 'basic_field', items: [1, 2, 3])
158
- expect(helper).to receive(:render).with(hash_including(partial: 'facet_limit',
159
- locals: {
160
- field_name: 'basic_field',
161
- facet_field: helper.blacklight_config.facet_fields['basic_field'],
162
- display_facet: mock_facet
163
- }))
164
- helper.render_facet_limit(mock_facet)
165
- end
166
-
167
- it "renders a facet _not_ declared in the configuration" do
168
- mock_facet = double(name: 'asdf', items: [1, 2, 3])
169
- expect(helper).to receive(:render).with(hash_including(partial: 'facet_limit'))
170
- helper.render_facet_limit(mock_facet)
171
- end
172
-
173
- it "gets the partial name from the configuration" do
174
- expect(helper).to receive(:render).with(hash_including(partial: 'custom_facet_partial'))
175
- helper.render_facet_limit(mock_custom_facet)
176
- end
177
-
178
- it "uses a partial layout for rendering the facet frame" do
179
- expect(helper).to receive(:render).with(hash_including(layout: 'facet_layout'))
180
- helper.render_facet_limit(mock_custom_facet)
181
- end
182
-
183
- it "allows the caller to opt-out of facet layouts" do
184
- expect(helper).to receive(:render).with(hash_including(layout: nil))
185
- helper.render_facet_limit(mock_custom_facet, layout: nil)
186
- end
187
-
188
- it "renders the facet_pivot partial for pivot facets" do
189
- mock_facet = double(name: 'pivot_facet_field', items: [1, 2, 3])
190
- expect(helper).to receive(:render).with(hash_including(partial: 'facet_pivot'))
191
- helper.render_facet_limit(mock_facet)
192
- end
193
-
194
- it "lets you override the rendered partial for pivot facets" do
195
- mock_facet = double(name: 'my_pivot_facet_field_with_custom_partial', items: [1, 2, 3])
196
- expect(helper).to receive(:render).with(hash_including(partial: 'custom_facet_partial'))
197
- helper.render_facet_limit(mock_facet)
198
- end
199
-
200
- it "lets you override the rendered partial for pivot facets" do
201
- mock_facet = double(name: 'component_field')
202
- expect(helper).to receive(:render).with(an_instance_of(Blacklight::FacetComponent))
203
- helper.render_facet_limit(mock_facet)
204
- end
205
-
206
- it "lets you override the rendered partial for pivot facets" do
207
- mock_facet = double(name: 'non_rendering_component_field')
208
- expect(helper.render_facet_limit(mock_facet)).to be_blank
209
- end
210
- end
211
-
212
- describe "render_facet_limit_list" do
213
- subject { helper.render_facet_limit_list(paginator, 'type_solr_field') }
214
-
215
- let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }
216
- let(:f2) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '65', value: 'Musical Score') }
217
- let(:paginator) { Blacklight::Solr::FacetPaginator.new([f1, f2], limit: 10) }
218
-
219
- before do
220
- allow(helper).to receive(:search_action_path) do |*args|
221
- search_catalog_path *args
222
- end
223
- end
224
-
225
- it "draws a list of elements" do
226
- expect(subject).to have_selector 'li', count: 2
227
- expect(subject).to have_selector 'li:first-child a.facet-select', text: 'Book'
228
- expect(subject).to have_selector 'li:nth-child(2) a.facet-select', text: 'Musical Score'
229
- end
230
-
231
- context "when one of the facet items is rendered as nil" do
232
- # An app may override render_facet_item to filter out some undesired facet items by returning nil.
233
- before do
234
- allow(helper.method(:render_facet_item)).to receive(:owner).and_return(self.class)
235
- # allow_any_instance_of(Blacklight::FacetItemComponent).to receive(:overridden_helper_methods?).and_return(true)
236
- allow(helper).to receive(:render_facet_item).and_return('<a class="facet-select">Book</a>'.html_safe, nil)
237
- end
238
-
239
- around { |test| Deprecation.silence(Blacklight::FacetItemComponent) { test.call } }
240
-
241
- it "draws a list of elements" do
242
- expect(subject).to have_selector 'li', count: 1
243
- expect(subject).to have_selector 'li:first-child a.facet-select', text: 'Book'
244
- end
245
- end
246
- end
247
-
248
- describe "facet_field_in_params?" do
249
- before do
250
- blacklight_config.add_facet_field "some-field"
251
- end
252
-
253
- it "checks if the facet field is selected in the user params" do
254
- allow(helper).to receive_messages(params: { f: { "some-field" => ["x"] } })
255
- expect(helper).to be_facet_field_in_params("some-field")
256
- expect(helper.facet_field_in_params?("other-field")).not_to be true
257
- end
258
- end
259
-
260
- describe "facet_params" do
261
- let(:facet_config) { ["some-field"] }
262
- let(:params) { { f: { "some-field" => ["x"] } } }
263
-
264
- before do
265
- blacklight_config.add_facet_field *facet_config
266
- allow(helper).to receive_messages(params: params)
267
- end
268
-
269
- it "extracts the facet parameters for a field" do
270
- expect(helper.facet_params("some-field")).to match_array ["x"]
271
- end
272
-
273
- context "a facet is not keyed by the field name" do
274
- let(:facet_config) { ["some-key", { field: "some-field" }] }
275
- let(:params) { { f: { "some-key" => ["x"] } } }
276
-
277
- it "uses the blacklight key to extract the right fields" do
278
- expect(helper.facet_params("some-key")).to match_array ["x"]
279
- end
280
-
281
- it "looks up facet params by configured field or key values" do
282
- expect(helper.facet_params("some-field")).to match_array ["x"]
283
- end
284
- end
285
- end
286
-
287
- describe "facet_field_in_params?" do
288
- let(:search_state) { double }
289
-
290
- before do
291
- allow(helper).to receive_messages(search_state: search_state)
292
- end
293
-
294
- it "checks if any value is selected for a given facet" do
295
- allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet')).and_return(true)
296
- expect(helper.facet_field_in_params?("some-facet")).to eq true
297
- end
298
-
299
- it "is false if no value for facet is selected" do
300
- allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet')).and_return(false)
301
- expect(helper.facet_field_in_params?("some-facet")).to eq false
302
- end
303
- end
304
-
305
- describe "facet_in_params?" do
306
- let(:search_state) { double }
307
-
308
- before do
309
- allow(helper).to receive_messages(search_state: search_state)
310
- allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet'), value: 'x').and_return(true)
311
- allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet'), value: 'y').and_return(false)
312
- end
313
-
314
- it "checks if a particular value is set in the facet params" do
315
- expect(helper.facet_in_params?("some-facet", "x")).to eq true
316
- expect(helper.facet_in_params?("some-facet", "y")).to eq false
317
- end
318
- end
319
-
320
- describe "render_facet_value" do
321
- let(:item) { double(value: 'A', hits: 10) }
322
- let(:search_state) { double(has_facet?: false, add_facet_params_and_redirect: { controller: 'catalog' }) }
323
-
324
- before do
325
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: nil, item_presenter: nil))
326
- allow(helper).to receive(:facet_display_value).and_return('Z')
327
- allow(helper).to receive(:search_state).and_return(search_state)
328
- allow(helper).to receive(:search_action_path) do |*args|
329
- search_catalog_path *args
330
- end
331
- end
332
-
333
- describe "simple case" do
334
- let(:expected_html) { '<span class="facet-label"><a class="facet-select" rel="nofollow" href="/catalog">Z</a></span><span class="facet-count">10</span>' }
335
-
336
- it "uses facet_display_value" do
337
- result = helper.render_facet_value('simple_field', item)
338
- expect(result).to be_equivalent_to(expected_html).respecting_element_order
339
- end
340
- end
341
-
342
- describe "when :url_method is set" do
343
- let(:expected_html) { '<span class="facet-label"><a class="facet-select" rel="nofollow" href="/blabla">Z</a></span><span class="facet-count">10</span>' }
344
-
345
- it "uses that method" do
346
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: :test_method, item_presenter: nil))
347
- allow(helper).to receive(:test_method).with('simple_field', item).and_return('/blabla')
348
- result = helper.render_facet_value('simple_field', item)
349
- expect(result).to be_equivalent_to(expected_html).respecting_element_order
350
- end
351
- end
352
-
353
- describe "when :suppress_link is set" do
354
- let(:expected_html) { '<span class="facet-label">Z</span><span class="facet-count">10</span>' }
355
-
356
- it "suppresses the link" do
357
- result = helper.render_facet_value('simple_field', item, suppress_link: true)
358
- expect(result).to be_equivalent_to(expected_html).respecting_element_order
359
- end
360
- end
361
- end
362
-
363
- describe "#facet_display_value" do
364
- it "justs be the facet value for an ordinary facet" do
365
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(query: nil, date: nil, helper_method: nil, url_method: nil, item_presenter: nil))
366
- expect(helper.facet_display_value('simple_field', 'asdf')).to eq 'asdf'
367
- end
368
-
369
- it "allows you to pass in a :helper_method argument to the configuration" do
370
- allow(helper).to receive(:facet_configuration_for_field).with('helper_field').and_return(double(query: nil, date: nil, url_method: nil, helper_method: :my_facet_value_renderer, item_presenter: nil))
371
- allow(helper).to receive(:my_facet_value_renderer).with('qwerty').and_return('abc')
372
- expect(helper.facet_display_value('helper_field', 'qwerty')).to eq 'abc'
373
- end
374
-
375
- it "extracts the configuration label for a query facet" do
376
- allow(helper).to receive(:facet_configuration_for_field).with('query_facet').and_return(double(query: { 'query_key' => { label: 'XYZ' } }, date: nil, helper_method: nil, url_method: nil, item_presenter: nil))
377
- expect(helper.facet_display_value('query_facet', 'query_key')).to eq 'XYZ'
378
- end
379
-
380
- it "localizes the label for date-type facets" do
381
- allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => true, :query => nil, :helper_method => nil, :url_method => nil, :item_presenter => nil))
382
- expect(helper.facet_display_value('date_facet', '2012-01-01')).to eq 'Sun, 01 Jan 2012 00:00:00 +0000'
383
- end
384
-
385
- it "localizes the label for date-type facets with the supplied localization options" do
386
- allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => { format: :short }, :query => nil, :helper_method => nil, :url_method => nil, :item_presenter => nil))
387
- expect(helper.facet_display_value('date_facet', '2012-01-01')).to eq '01 Jan 00:00'
388
- end
389
- end
390
-
391
- describe "#facet_field_id" do
392
- it "is the parameterized version of the facet field" do
393
- expect(helper.facet_field_id(double(key: 'some field'))).to eq "facet-some-field"
394
- end
395
- end
396
-
397
10
  describe '#facet_field_presenter' do
398
11
  let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'x').normalize! }
399
12
  let(:display_facet) { double }
@@ -11,5 +11,13 @@ RSpec.describe Blacklight::IconHelperBehavior do
11
11
  it 'adds classes to the wrappering element' do
12
12
  expect(icon).to have_css '.custom-class svg'
13
13
  end
14
+
15
+ context 'with backwards compatible arguments' do
16
+ subject(:icon) { helper.blacklight_icon(:search, aria_hidden: true, label: 'blah') }
17
+
18
+ it 'adds aria attributes' do
19
+ expect(icon).to have_css '[aria-hidden="true"][aria-label="blah"]'
20
+ end
21
+ end
14
22
  end
15
23
  end
@@ -30,26 +30,9 @@ RSpec.describe Blacklight::LayoutHelperBehavior do
30
30
  end
31
31
 
32
32
  describe '#container_classes' do
33
- before do
34
- allow(view).to receive(:blacklight_config).and_return(config)
35
- end
36
-
37
- context 'when not full-width' do
38
- let(:config) { Blacklight::Configuration.new }
39
-
40
- it 'returns a string of classe(s)' do
41
- expect(helper.container_classes).to be_an String
42
- expect(helper.container_classes).to eq 'container'
43
- end
44
- end
45
-
46
- context 'when full-width' do
47
- let(:config) { Blacklight::Configuration.new(full_width_layout: true) }
48
-
49
- it 'returns a string of classe(s)' do
50
- expect(helper.container_classes).to be_an String
51
- expect(helper.container_classes).to eq 'container-fluid'
52
- end
33
+ it 'returns a string of classe(s)' do
34
+ expect(helper.container_classes).to be_an String
35
+ expect(helper.container_classes).to eq 'container'
53
36
  end
54
37
  end
55
38
 
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe Blacklight::RenderPartialsHelperBehavior do
4
- around { |test| Deprecation.silence(described_class) { test.call } }
5
-
6
4
  describe "#type_field_to_partial_name" do
7
5
  subject { helper.send(:type_field_to_partial_name, document, value) }
8
6
 
@@ -58,7 +56,7 @@ RSpec.describe Blacklight::RenderPartialsHelperBehavior do
58
56
  let(:document) { SolrDocument.new }
59
57
 
60
58
  it "is the default value" do
61
- expect(helper.document_partial_name(document)).to eq 'default'
59
+ expect(helper.send(:document_partial_name, document)).to eq 'default'
62
60
  end
63
61
  end
64
62
 
@@ -70,11 +68,11 @@ RSpec.describe Blacklight::RenderPartialsHelperBehavior do
70
68
  end
71
69
 
72
70
  it "uses the value in the configured display type field" do
73
- expect(helper.document_partial_name(document)).to eq 'xyz'
71
+ expect(helper.send(:document_partial_name, document)).to eq 'xyz'
74
72
  end
75
73
 
76
74
  it "uses the value in the configured display type field if the action-specific field is empty" do
77
- expect(helper.document_partial_name(document, :some_action)).to eq 'xyz'
75
+ expect(helper.send(:document_partial_name, document, :some_action)).to eq 'xyz'
78
76
  end
79
77
  end
80
78
 
@@ -87,8 +85,8 @@ RSpec.describe Blacklight::RenderPartialsHelperBehavior do
87
85
  end
88
86
 
89
87
  it "uses the value in the action-specific fields" do
90
- expect(helper.document_partial_name(document, :media)).to eq 'xyz'
91
- expect(helper.document_partial_name(document, :metadata)).to eq 'abc'
88
+ expect(helper.send(:document_partial_name, document, :media)).to eq 'xyz'
89
+ expect(helper.send(:document_partial_name, document, :metadata)).to eq 'abc'
92
90
  end
93
91
  end
94
92
  end