blacklight 7.33.0 → 8.0.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 (427) hide show
  1. checksums.yaml +4 -4
  2. data/.env +3 -2
  3. data/.github/workflows/ruby.yml +38 -107
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +243 -2
  6. data/.rubocop_todo.yml +216 -270
  7. data/Gemfile +7 -6
  8. data/README.md +12 -4
  9. data/Rakefile +18 -0
  10. data/VERSION +1 -1
  11. data/app/assets/config/blacklight/manifest.js +3 -0
  12. data/app/assets/javascripts/blacklight/blacklight.esm.js +376 -0
  13. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
  14. data/app/assets/javascripts/blacklight/blacklight.js +332 -485
  15. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -0
  16. data/app/assets/stylesheets/blacklight/_autocomplete.scss +25 -0
  17. data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -1
  18. data/app/assets/stylesheets/blacklight/_bookmark.scss +16 -0
  19. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +8 -0
  20. data/app/assets/stylesheets/blacklight/_facets.scss +104 -49
  21. data/app/assets/stylesheets/blacklight/_header.scss +0 -15
  22. data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
  23. data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
  24. data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
  25. data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
  26. data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
  27. data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
  28. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
  29. data/app/builders/blacklight/action_builder.rb +18 -9
  30. data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
  31. data/app/components/blacklight/advanced_search_form_component.rb +7 -9
  32. data/app/components/blacklight/constraints_component.rb +27 -37
  33. data/app/components/blacklight/document/action_component.html.erb +2 -9
  34. data/app/components/blacklight/document/action_component.rb +26 -8
  35. data/app/components/blacklight/document/actions_component.rb +2 -2
  36. data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
  37. data/app/components/blacklight/document/bookmark_component.rb +4 -2
  38. data/app/components/blacklight/document/citation_component.rb +5 -3
  39. data/app/components/blacklight/document/group_component.rb +7 -3
  40. data/app/components/blacklight/document/show_tools_component.html.erb +12 -0
  41. data/app/components/blacklight/document/show_tools_component.rb +23 -0
  42. data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
  43. data/app/components/blacklight/document/sidebar_component.rb +16 -0
  44. data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
  45. data/app/components/blacklight/document/thumbnail_component.rb +1 -9
  46. data/app/components/blacklight/document_component.html.erb +4 -0
  47. data/app/components/blacklight/document_component.rb +54 -42
  48. data/app/components/blacklight/document_metadata_component.html.erb +4 -2
  49. data/app/components/blacklight/document_metadata_component.rb +11 -6
  50. data/app/components/blacklight/document_title_component.rb +4 -1
  51. data/app/components/blacklight/facet_component.rb +1 -1
  52. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +3 -3
  53. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  54. data/app/components/blacklight/facet_field_component.html.erb +5 -5
  55. data/app/components/blacklight/facet_field_component.rb +9 -2
  56. data/app/components/blacklight/facet_field_list_component.html.erb +3 -3
  57. data/app/components/blacklight/facet_field_list_component.rb +37 -5
  58. data/app/components/blacklight/facet_field_no_layout_component.rb +0 -2
  59. data/app/components/blacklight/facet_item_component.rb +1 -43
  60. data/app/components/blacklight/facet_item_pivot_component.rb +21 -23
  61. data/app/components/blacklight/header_component.html.erb +2 -0
  62. data/app/components/blacklight/header_component.rb +26 -0
  63. data/app/components/blacklight/hidden_search_state_component.rb +1 -2
  64. data/app/components/blacklight/icons/legacy_icon_component.rb +30 -0
  65. data/app/components/blacklight/icons/list_component.rb +16 -0
  66. data/app/components/blacklight/icons/search_component.rb +16 -0
  67. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  68. data/app/components/blacklight/metadata_field_component.rb +24 -8
  69. data/app/components/blacklight/metadata_field_layout_component.rb +7 -22
  70. data/app/components/blacklight/metadata_field_plain_text_layout_component.rb +17 -0
  71. data/app/components/blacklight/response/facet_group_component.html.erb +5 -6
  72. data/app/components/blacklight/response/facet_group_component.rb +29 -8
  73. data/app/components/blacklight/response/sort_component.rb +2 -2
  74. data/app/components/blacklight/response/spellcheck_component.rb +18 -7
  75. data/app/components/blacklight/response/view_type_button_component.rb +3 -7
  76. data/app/components/blacklight/response/view_type_component.rb +4 -6
  77. data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
  78. data/app/components/blacklight/search/sidebar_component.rb +17 -0
  79. data/app/components/blacklight/search_bar_component.html.erb +20 -15
  80. data/app/components/blacklight/search_bar_component.rb +2 -16
  81. data/app/components/blacklight/search_button_component.rb +3 -3
  82. data/app/components/blacklight/search_context/server_applied_params_component.html.erb +4 -0
  83. data/app/components/blacklight/search_context/server_applied_params_component.rb +13 -0
  84. data/app/components/blacklight/search_context/server_item_pagination_component.rb +71 -0
  85. data/app/components/blacklight/search_header_component.html.erb +2 -0
  86. data/app/components/blacklight/search_header_component.rb +6 -0
  87. data/app/components/blacklight/search_navbar_component.html.erb +5 -0
  88. data/app/components/blacklight/search_navbar_component.rb +34 -0
  89. data/app/components/blacklight/start_over_button_component.rb +5 -3
  90. data/app/components/blacklight/system/dropdown_component.rb +3 -3
  91. data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
  92. data/app/components/blacklight/system/flash_message_component.rb +12 -3
  93. data/app/components/blacklight/system/modal_component.html.erb +1 -1
  94. data/app/components/blacklight/system/modal_component.rb +1 -3
  95. data/app/components/blacklight/top_navbar_component.html.erb +12 -0
  96. data/app/components/blacklight/top_navbar_component.rb +17 -0
  97. data/app/controllers/bookmarks_controller.rb +1 -0
  98. data/app/controllers/catalog_controller.rb +1 -0
  99. data/app/controllers/concerns/blacklight/bookmarks.rb +11 -6
  100. data/app/controllers/concerns/blacklight/catalog.rb +21 -72
  101. data/app/controllers/concerns/blacklight/controller.rb +6 -43
  102. data/app/controllers/concerns/blacklight/search_context.rb +71 -13
  103. data/app/controllers/concerns/blacklight/search_history.rb +2 -0
  104. data/app/controllers/concerns/blacklight/searchable.rb +12 -1
  105. data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
  106. data/app/controllers/search_history_controller.rb +1 -0
  107. data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -400
  108. data/app/helpers/blacklight/catalog_helper_behavior.rb +40 -182
  109. data/app/helpers/blacklight/component_helper_behavior.rb +1 -63
  110. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -117
  111. data/app/helpers/blacklight/document_helper_behavior.rb +76 -0
  112. data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
  113. data/app/helpers/blacklight/icon_helper_behavior.rb +5 -4
  114. data/app/helpers/blacklight/layout_helper_behavior.rb +60 -0
  115. data/app/helpers/blacklight/render_partials_helper_behavior.rb +12 -30
  116. data/app/helpers/blacklight/url_helper_behavior.rb +21 -97
  117. data/app/helpers/blacklight_helper.rb +1 -0
  118. data/app/helpers/catalog_helper.rb +1 -0
  119. data/app/javascript/blacklight/bookmark_toggle.js +9 -22
  120. data/app/javascript/blacklight/button_focus.js +9 -7
  121. data/app/javascript/blacklight/checkbox_submit.js +68 -122
  122. data/app/javascript/blacklight/core.js +6 -5
  123. data/app/javascript/blacklight/index.js +14 -0
  124. data/app/javascript/blacklight/modal.js +100 -165
  125. data/app/javascript/blacklight/modalForm.js +60 -0
  126. data/app/javascript/blacklight/search_context.js +13 -29
  127. data/app/models/blacklight/facet_paginator.rb +3 -2
  128. data/app/models/blacklight/icon.rb +4 -2
  129. data/app/models/bookmark.rb +0 -2
  130. data/app/models/concerns/blacklight/configurable.rb +5 -4
  131. data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
  132. data/app/models/concerns/blacklight/document/attributes.rb +50 -0
  133. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  134. data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
  135. data/app/models/concerns/blacklight/document/export.rb +2 -1
  136. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  137. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  138. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
  139. data/app/models/concerns/blacklight/document.rb +23 -20
  140. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  141. data/app/models/concerns/blacklight/user.rb +17 -8
  142. data/app/models/record_mailer.rb +23 -18
  143. data/app/models/search.rb +0 -1
  144. data/app/models/solr_document.rb +1 -0
  145. data/app/presenters/blacklight/clause_presenter.rb +1 -1
  146. data/app/presenters/blacklight/document_presenter.rb +24 -30
  147. data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
  148. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
  149. data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
  150. data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
  151. data/app/presenters/blacklight/field_presenter.rb +1 -0
  152. data/app/presenters/blacklight/index_presenter.rb +2 -40
  153. data/app/presenters/blacklight/json_presenter.rb +7 -5
  154. data/app/presenters/blacklight/rendering/abstract_step.rb +4 -0
  155. data/app/presenters/blacklight/rendering/join.rb +7 -1
  156. data/app/presenters/blacklight/rendering/link_to_facet.rb +3 -6
  157. data/app/presenters/blacklight/rendering/microdata.rb +1 -1
  158. data/app/presenters/blacklight/show_presenter.rb +1 -9
  159. data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
  160. data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
  161. data/app/services/blacklight/field_retriever.rb +1 -8
  162. data/app/services/blacklight/search_service.rb +9 -7
  163. data/app/values/blacklight/types.rb +95 -11
  164. data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
  165. data/app/views/bookmarks/_tools.html.erb +7 -12
  166. data/app/views/catalog/_advanced_search_form.html.erb +0 -1
  167. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  168. data/app/views/catalog/_constraints.html.erb +1 -14
  169. data/app/views/catalog/_document.atom.builder +12 -14
  170. data/app/views/catalog/_document.html.erb +3 -6
  171. data/app/views/catalog/_document.rss.builder +2 -4
  172. data/app/views/catalog/_document_list.html.erb +2 -1
  173. data/app/views/catalog/_facet_layout.html.erb +2 -2
  174. data/app/views/catalog/_facets.html.erb +5 -4
  175. data/app/views/catalog/_home_text.html.erb +2 -14
  176. data/app/views/catalog/_search_form.html.erb +3 -3
  177. data/app/views/catalog/_search_header.html.erb +1 -2
  178. data/app/views/catalog/_search_results.html.erb +2 -2
  179. data/app/views/catalog/_search_sidebar.html.erb +5 -1
  180. data/app/views/catalog/_show_main_content.html.erb +8 -19
  181. data/app/views/catalog/_show_sidebar.html.erb +2 -2
  182. data/app/views/catalog/_show_tools.html.erb +1 -19
  183. data/app/views/catalog/_view_type_group.html.erb +1 -1
  184. data/app/views/catalog/email_success.html.erb +5 -6
  185. data/app/views/catalog/facet.html.erb +7 -5
  186. data/app/views/catalog/index.atom.builder +12 -14
  187. data/app/views/catalog/index.html.erb +7 -1
  188. data/app/views/catalog/index.json.jbuilder +19 -19
  189. data/app/views/catalog/index.rss.builder +1 -1
  190. data/app/views/catalog/opensearch.xml.builder +1 -1
  191. data/app/views/catalog/show.html.erb +1 -6
  192. data/app/views/catalog/sms_success.html.erb +5 -6
  193. data/app/views/catalog/suggest.html.erb +3 -0
  194. data/app/views/layouts/blacklight/base.html.erb +19 -9
  195. data/app/views/record_mailer/email_record.text.erb +4 -3
  196. data/app/views/record_mailer/sms_record.text.erb +4 -4
  197. data/app/views/search_history/index.html.erb +6 -2
  198. data/app/views/shared/_header_navbar.html.erb +1 -22
  199. data/app/views/shared/_modal.html.erb +3 -3
  200. data/blacklight.gemspec +8 -10
  201. data/config/importmap.rb +3 -0
  202. data/config/locales/blacklight.ar.yml +209 -233
  203. data/config/locales/blacklight.ca.yml +0 -7
  204. data/config/locales/blacklight.de.yml +197 -216
  205. data/config/locales/blacklight.en.yml +2 -7
  206. data/config/locales/blacklight.es.yml +196 -216
  207. data/config/locales/blacklight.fr.yml +196 -220
  208. data/config/locales/blacklight.hu.yml +193 -213
  209. data/config/locales/blacklight.it.yml +197 -216
  210. data/config/locales/blacklight.nl.yml +193 -213
  211. data/config/locales/blacklight.pt-BR.yml +195 -216
  212. data/config/locales/blacklight.sq.yml +193 -213
  213. data/config/locales/blacklight.zh.yml +194 -214
  214. data/config/routes.rb +3 -2
  215. data/db/migrate/20140202020201_create_searches.rb +1 -0
  216. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  217. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  218. data/docker-compose.yml +1 -0
  219. data/lib/blacklight/abstract_repository.rb +1 -0
  220. data/lib/blacklight/configuration/context.rb +4 -4
  221. data/lib/blacklight/configuration/display_field.rb +7 -9
  222. data/lib/blacklight/configuration/facet_field.rb +17 -11
  223. data/lib/blacklight/configuration/field.rb +1 -0
  224. data/lib/blacklight/configuration/fields.rb +12 -15
  225. data/lib/blacklight/configuration/index_field.rb +1 -0
  226. data/lib/blacklight/configuration/null_display_field.rb +17 -0
  227. data/lib/blacklight/configuration/search_field.rb +1 -0
  228. data/lib/blacklight/configuration/session_tracking_config.rb +45 -0
  229. data/lib/blacklight/configuration/show_field.rb +1 -0
  230. data/lib/blacklight/configuration/sort_field.rb +1 -0
  231. data/lib/blacklight/configuration/tool_config.rb +1 -0
  232. data/lib/blacklight/configuration/view_config.rb +16 -10
  233. data/lib/blacklight/configuration.rb +322 -341
  234. data/lib/blacklight/engine.rb +13 -15
  235. data/lib/blacklight/exceptions.rb +2 -2
  236. data/lib/blacklight/nested_open_struct_with_hash_access.rb +6 -12
  237. data/lib/blacklight/open_struct_with_hash_access.rb +19 -17
  238. data/lib/blacklight/parameters.rb +7 -21
  239. data/lib/blacklight/routes/exportable.rb +1 -0
  240. data/lib/blacklight/routes/searchable.rb +3 -1
  241. data/lib/blacklight/routes.rb +1 -0
  242. data/lib/blacklight/search_builder.rb +10 -10
  243. data/lib/blacklight/search_state/filter_field.rb +8 -25
  244. data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
  245. data/lib/blacklight/search_state.rb +23 -79
  246. data/lib/blacklight/solr/document.rb +1 -0
  247. data/lib/blacklight/solr/facet_paginator.rb +1 -0
  248. data/lib/blacklight/solr/repository.rb +1 -0
  249. data/lib/blacklight/solr/request.rb +3 -0
  250. data/lib/blacklight/solr/response/facets.rb +21 -5
  251. data/lib/blacklight/solr/response/group.rb +1 -0
  252. data/lib/blacklight/solr/response/group_response.rb +1 -0
  253. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  254. data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
  255. data/lib/blacklight/solr/response/params.rb +5 -4
  256. data/lib/blacklight/solr/response/response.rb +1 -0
  257. data/lib/blacklight/solr/response/spelling.rb +1 -0
  258. data/lib/blacklight/solr/response.rb +4 -3
  259. data/lib/blacklight/solr/search_builder_behavior.rb +16 -32
  260. data/lib/blacklight/solr.rb +1 -0
  261. data/lib/blacklight/version.rb +1 -0
  262. data/lib/blacklight.rb +8 -11
  263. data/lib/generators/blacklight/assets/importmap_generator.rb +56 -0
  264. data/lib/generators/blacklight/assets/propshaft_generator.rb +34 -0
  265. data/lib/generators/blacklight/assets/sprockets_generator.rb +68 -0
  266. data/lib/generators/blacklight/assets_generator.rb +14 -88
  267. data/lib/generators/blacklight/controller_generator.rb +3 -2
  268. data/lib/generators/blacklight/document_generator.rb +1 -0
  269. data/lib/generators/blacklight/install_generator.rb +7 -4
  270. data/lib/generators/blacklight/models_generator.rb +1 -0
  271. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  272. data/lib/generators/blacklight/solr_generator.rb +1 -1
  273. data/lib/generators/blacklight/templates/catalog_controller.rb +37 -7
  274. data/lib/generators/blacklight/templates/solr_document.rb +1 -7
  275. data/lib/generators/blacklight/test_support_generator.rb +4 -2
  276. data/lib/generators/blacklight/user_generator.rb +7 -9
  277. data/lib/railties/blacklight.rake +2 -3
  278. data/package.json +10 -10
  279. data/rollup.config.js +37 -0
  280. data/spec/components/blacklight/constraints_component_spec.rb +17 -13
  281. data/spec/components/blacklight/document_component_spec.rb +74 -33
  282. data/spec/components/blacklight/facet_component_spec.rb +2 -7
  283. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
  284. data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
  285. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +9 -7
  286. data/spec/components/blacklight/header_component_spec.rb +20 -0
  287. data/spec/components/blacklight/response/view_type_component_spec.rb +83 -0
  288. data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
  289. data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +29 -0
  290. data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +51 -0
  291. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
  292. data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
  293. data/spec/controllers/bookmarks_controller_spec.rb +2 -3
  294. data/spec/controllers/catalog_controller_spec.rb +24 -126
  295. data/spec/features/autocomplete_spec.rb +1 -1
  296. data/spec/features/axe_spec.rb +1 -1
  297. data/spec/features/bookmarks_spec.rb +1 -1
  298. data/spec/features/component_template_override_spec.rb +8 -0
  299. data/spec/features/facets_spec.rb +1 -1
  300. data/spec/features/modal_spec.rb +12 -0
  301. data/spec/features/search_context_spec.rb +4 -10
  302. data/spec/features/search_results_spec.rb +0 -33
  303. data/spec/features/sitelinks_search_box_spec.rb +13 -0
  304. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +2 -138
  305. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +0 -387
  306. data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +8 -0
  307. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +5 -7
  308. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +10 -132
  309. data/spec/helpers/blacklight_helper_spec.rb +3 -298
  310. data/spec/helpers/catalog_helper_spec.rb +60 -115
  311. data/spec/i18n_spec.rb +1 -0
  312. data/spec/integration/generators/blacklight/solr_generator_spec.rb +1 -1
  313. data/spec/lib/blacklight/configuration/facet_field_spec.rb +27 -16
  314. data/spec/lib/blacklight/configuration/field_spec.rb +1 -1
  315. data/spec/lib/blacklight/configuration/session_tracking_config_spec.rb +38 -0
  316. data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
  317. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +4 -4
  318. data/spec/lib/blacklight/parameters_spec.rb +1 -4
  319. data/spec/lib/blacklight/search_state/filter_field_spec.rb +4 -4
  320. data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +117 -0
  321. data/spec/lib/blacklight/search_state_spec.rb +80 -198
  322. data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
  323. data/spec/models/blacklight/configuration_spec.rb +41 -53
  324. data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
  325. data/spec/models/blacklight/icon_spec.rb +29 -15
  326. data/spec/models/blacklight/search_builder_spec.rb +12 -12
  327. data/spec/models/blacklight/solr/document_spec.rb +3 -3
  328. data/spec/models/blacklight/solr/request_spec.rb +2 -2
  329. data/spec/models/blacklight/solr/response/facets_spec.rb +27 -27
  330. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  331. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  332. data/spec/models/blacklight/solr/response_spec.rb +9 -2
  333. data/spec/models/blacklight/solr/search_builder_spec.rb +32 -23
  334. data/spec/models/blacklight/user_spec.rb +22 -0
  335. data/spec/models/record_mailer_spec.rb +36 -23
  336. data/spec/models/solr_document_spec.rb +21 -3
  337. data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
  338. data/spec/presenters/blacklight/document_presenter_spec.rb +3 -2
  339. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +85 -12
  340. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +1 -0
  341. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +14 -13
  342. data/spec/presenters/blacklight/field_presenter_spec.rb +2 -16
  343. data/spec/presenters/blacklight/index_presenter_spec.rb +3 -4
  344. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -0
  345. data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -2
  346. data/spec/presenters/blacklight/show_presenter_spec.rb +11 -25
  347. data/spec/presenters/pipeline_spec.rb +13 -2
  348. data/spec/presenters/thumbnail_presenter_spec.rb +1 -1
  349. data/spec/requests/load_suggestions_spec.rb +16 -0
  350. data/spec/routing/catalog_routing_spec.rb +6 -1
  351. data/spec/services/blacklight/search_service_spec.rb +31 -68
  352. data/spec/spec_helper.rb +4 -3
  353. data/spec/support/controller_level_helpers.rb +1 -2
  354. data/spec/support/features/search_helpers.rb +39 -0
  355. data/spec/support/features/session_helpers.rb +1 -0
  356. data/spec/support/features.rb +3 -0
  357. data/spec/support/view_component_test_helpers.rb +21 -0
  358. data/spec/test_app_templates/Gemfile.extra +4 -0
  359. data/spec/test_app_templates/lib/generators/test_app_generator.rb +17 -2
  360. data/spec/views/catalog/_document.html.erb_spec.rb +23 -33
  361. data/spec/views/catalog/_document_list.html.erb_spec.rb +7 -2
  362. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
  363. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  364. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  365. data/spec/views/catalog/_show_tools.html.erb_spec.rb +7 -54
  366. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
  367. data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
  368. data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
  369. data/spec/views/catalog/index.atom.builder_spec.rb +18 -11
  370. data/spec/views/catalog/index.html.erb_spec.rb +5 -6
  371. data/spec/views/catalog/index.json.jbuilder_spec.rb +3 -3
  372. data/spec/views/catalog/show.html.erb_spec.rb +3 -25
  373. data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
  374. data/tasks/blacklight.rake +7 -5
  375. metadata +95 -123
  376. data/.babelrc +0 -11
  377. data/app/assets/images/blacklight/list.svg +0 -1
  378. data/app/assets/images/blacklight/search.svg +0 -1
  379. data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +0 -37
  380. data/app/components/blacklight/content_areas_shim.rb +0 -13
  381. data/app/components/blacklight/search_context_component.rb +0 -34
  382. data/app/controllers/concerns/blacklight/base.rb +0 -7
  383. data/app/controllers/concerns/blacklight/default_component_configuration.rb +0 -64
  384. data/app/controllers/concerns/blacklight/facet.rb +0 -69
  385. data/app/controllers/concerns/blacklight/search_fields.rb +0 -46
  386. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -27
  387. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -188
  388. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -97
  389. data/app/helpers/blacklight/suggest_helper_behavior.rb +0 -13
  390. data/app/javascript/blacklight/autocomplete.js +0 -36
  391. data/app/javascript/blacklight/facet_load.js +0 -22
  392. data/app/models/concerns/blacklight/document/email.rb +0 -26
  393. data/app/models/concerns/blacklight/document/sms.rb +0 -24
  394. data/app/presenters/blacklight/search_bar_presenter.rb +0 -47
  395. data/app/views/catalog/_constraints_element.html.erb +0 -14
  396. data/app/views/catalog/_document_action.html.erb +0 -5
  397. data/app/views/catalog/_facet_group.html.erb +0 -5
  398. data/app/views/catalog/_facet_limit.html.erb +0 -3
  399. data/app/views/catalog/_index.html.erb +0 -1
  400. data/app/views/catalog/_index_header.html.erb +0 -22
  401. data/app/views/catalog/_previous_next_doc.html.erb +0 -2
  402. data/app/views/catalog/_show.html.erb +0 -6
  403. data/app/views/catalog/_show_header.html.erb +0 -2
  404. data/app/views/catalog/_thumbnail.html.erb +0 -1
  405. data/lib/blacklight/deprecations/engine_configuration.rb +0 -66
  406. data/lib/blacklight/deprecations/search_state_normalization.rb +0 -52
  407. data/spec/controllers/blacklight/facet_spec.rb +0 -33
  408. data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
  409. data/spec/features/sitelinks_search_box.rb +0 -13
  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 -108
  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/models/blacklight/document/email_spec.rb +0 -57
  416. data/spec/models/blacklight/document/sms_spec.rb +0 -58
  417. data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
  418. data/spec/support/view_component_capybara_test_helpers.rb +0 -8
  419. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  420. data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
  421. data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
  422. data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
  423. data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
  424. data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
  425. data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
  426. data/spec/views/catalog/_thumbnail.html.erb_spec.rb +0 -38
  427. /data/app/components/blacklight/{search_context_component.html.erb → search_context/server_item_pagination_component.html.erb} +0 -0
@@ -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
@@ -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
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe Blacklight::UrlHelperBehavior do
4
- around { |test| Deprecation.silence(described_class) { test.call } }
5
-
6
4
  let(:blacklight_config) do
7
5
  Blacklight::Configuration.new.configure do |config|
8
6
  config.index.title_field = 'title_tsim'
@@ -14,6 +12,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
14
12
 
15
13
  before do
16
14
  allow(controller).to receive(:controller_name).and_return('test')
15
+ allow(controller).to receive(:search_state_class).and_return(Blacklight::SearchState)
17
16
  allow(helper).to receive(:search_action_path) do |*args|
18
17
  search_catalog_url *args
19
18
  end
@@ -23,54 +22,6 @@ RSpec.describe Blacklight::UrlHelperBehavior do
23
22
  allow(helper).to receive(:search_session).and_return({})
24
23
  end
25
24
 
26
- describe "url_for_document" do
27
- let(:controller_class) { ::CatalogController.new }
28
- let(:doc) { SolrDocument.new }
29
-
30
- before do
31
- allow(helper).to receive_messages(controller: controller_class)
32
- allow(helper).to receive_messages(controller_name: controller_class.controller_name)
33
- allow(helper).to receive_messages(params: parameter_class.new)
34
- end
35
-
36
- it "is a polymorphic routing-ready object" do
37
- expect(helper.url_for_document(doc)).to eq doc
38
- end
39
-
40
- it "allows for custom show routes" do
41
- helper.blacklight_config.show.route = { controller: 'catalog' }
42
- expect(helper.url_for_document(doc)).to eq(controller: 'catalog', action: :show, id: doc)
43
- end
44
-
45
- context "within bookmarks" do
46
- let(:controller_class) { ::BookmarksController.new }
47
-
48
- it "uses polymorphic routing" do
49
- expect(helper.url_for_document(doc)).to eq doc
50
- end
51
- end
52
-
53
- context "within an alternative catalog controller" do
54
- let(:controller_class) { ::AlternateController.new }
55
-
56
- before do
57
- helper.blacklight_config.show.route = { controller: :current }
58
- allow(helper).to receive(:params).and_return(parameter_class.new(controller: 'alternate'))
59
- end
60
-
61
- it "supports the :current controller configuration" do
62
- expect(helper.url_for_document(doc)).to eq(controller: 'alternate', action: :show, id: doc)
63
- end
64
- end
65
-
66
- it "is a polymorphic route if the solr document responds to #to_model with a non-SolrDocument" do
67
- some_model = double
68
- doc = SolrDocument.new
69
- allow(doc).to receive_messages(to_model: some_model)
70
- expect(helper.url_for_document(doc)).to eq doc
71
- end
72
- end
73
-
74
25
  describe "link_back_to_catalog" do
75
26
  let(:query_params) { { q: "query", f: "facets", controller: 'catalog' } }
76
27
  let(:bookmarks_query_params) { { controller: 'bookmarks' } }
@@ -148,61 +99,6 @@ RSpec.describe Blacklight::UrlHelperBehavior do
148
99
  end
149
100
  end
150
101
 
151
- describe "link_to_previous_document" do
152
- context "when the argument is nil" do
153
- subject { helper.link_to_previous_document(nil) }
154
-
155
- it { is_expected.to eq '<span class="previous">&laquo; Previous</span>' }
156
- end
157
- end
158
-
159
- describe "link_to_query" do
160
- it "builds a link tag to catalog using query string (no other params)" do
161
- query = "brilliant"
162
- allow(helper).to receive_messages(params: parameter_class.new)
163
- tag = helper.link_to_query(query)
164
- expect(tag).to match /q=#{query}/
165
- expect(tag).to match %r{>#{query}</a>}
166
- end
167
-
168
- it "builds a link tag to catalog using query string and other existing params" do
169
- query = "wonderful"
170
- allow(helper).to receive_messages(params: parameter_class.new(qt: "title_search", per_page: "50"))
171
- tag = helper.link_to_query(query)
172
- expect(tag).to match /qt=title_search/
173
- expect(tag).to match /per_page=50/
174
- end
175
-
176
- it "ignores existing :page param" do
177
- query = "yes"
178
- allow(helper).to receive_messages(params: parameter_class.new(page: "2", qt: "author_search"))
179
- tag = helper.link_to_query(query)
180
- expect(tag).to match /qt=author_search/
181
- expect(tag).not_to match /page/
182
- end
183
-
184
- it "is html_safe" do
185
- query = "brilliant"
186
- allow(helper).to receive_messages(params: parameter_class.new(page: "2", qt: "author_search"))
187
- tag = helper.link_to_query(query)
188
- expect(tag).to be_html_safe
189
- end
190
- end
191
-
192
- describe "start_over_path" do
193
- it 'is the catalog path with the current view type' do
194
- allow(blacklight_config).to receive(:view).and_return(list: nil, abc: nil)
195
- allow(helper).to receive_messages(blacklight_config: blacklight_config)
196
- expect(helper.start_over_path(view: 'abc')).to eq search_catalog_url(view: 'abc')
197
- end
198
-
199
- it 'does not include the current view type if it is the default' do
200
- allow(blacklight_config).to receive(:view).and_return(list: nil, asdf: nil)
201
- allow(helper).to receive_messages(blacklight_config: blacklight_config)
202
- expect(helper.start_over_path(view: 'list')).to eq search_catalog_url
203
- end
204
- end
205
-
206
102
  describe "link_to_document" do
207
103
  let(:title_tsim) { '654321' }
208
104
  let(:id) { '123456' }
@@ -216,30 +112,22 @@ RSpec.describe Blacklight::UrlHelperBehavior do
216
112
  end
217
113
 
218
114
  it "consists of the document title wrapped in a <a>" do
219
- allow(Deprecation).to receive(:warn)
220
- expect(helper.link_to_document(document, :title_tsim)).to have_selector("a", text: '654321', count: 1)
115
+ expect(helper.link_to_document(document)).to have_selector("a", text: '654321', count: 1)
221
116
  end
222
117
 
223
118
  it "accepts and returns a string label" do
224
119
  expect(helper.link_to_document(document, 'This is the title')).to have_selector("a", text: 'This is the title', count: 1)
225
120
  end
226
121
 
227
- it "accepts and returns a Proc" do
228
- allow(Deprecation).to receive(:warn)
229
- expect(helper.link_to_document(document, proc { |doc, _opts| doc[:id] + ": " + doc.first(:title_tsim) })).to have_selector("a", text: '123456: 654321', count: 1)
230
- end
231
-
232
122
  context 'when label is missing' do
233
123
  let(:data) { { 'id' => id } }
234
124
 
235
125
  it "returns id" do
236
- allow(Deprecation).to receive(:warn)
237
- expect(helper.link_to_document(document, :title_tsim)).to have_selector("a", text: '123456', count: 1)
126
+ expect(helper.link_to_document(document)).to have_selector("a", text: '123456', count: 1)
238
127
  end
239
128
 
240
129
  it "is html safe" do
241
- allow(Deprecation).to receive(:warn)
242
- expect(helper.link_to_document(document, :title_tsim)).to be_html_safe
130
+ expect(helper.link_to_document(document)).to be_html_safe
243
131
  end
244
132
 
245
133
  it "passes on the title attribute to the link_to_with_data method" do
@@ -253,15 +141,14 @@ RSpec.describe Blacklight::UrlHelperBehavior do
253
141
  context "with an integer id" do
254
142
  let(:id) { 123_456 }
255
143
 
256
- it "works" do
144
+ it "has a link" do
257
145
  expect(helper.link_to_document(document)).to have_selector("a")
258
146
  end
259
147
  end
260
148
  end
261
149
 
262
150
  it "converts the counter parameter into a data- attribute" do
263
- allow(Deprecation).to receive(:warn)
264
- expect(helper.link_to_document(document, :title_tsim, counter: 5)).to include 'data-context-href="tracking url"'
151
+ expect(helper.link_to_document(document, 'foo', counter: 5)).to include 'data-context-href="tracking url"'
265
152
  expect(helper.main_app).to have_received(:track_test_path).with(hash_including(id: have_attributes(id: '123456'), counter: 5))
266
153
  end
267
154
 
@@ -279,19 +166,10 @@ RSpec.describe Blacklight::UrlHelperBehavior do
279
166
  end
280
167
 
281
168
  describe "link_to_previous_search" do
282
- let(:params) { {} }
169
+ let(:params) { { q: 'search query' } }
283
170
 
284
171
  it "links to the given search parameters" do
285
- allow(helper).to receive(:render_search_to_s).with(params).and_return "link text"
286
- expect(helper.link_to_previous_search({})).to eq helper.link_to("link text", helper.search_action_path)
287
- end
288
- end
289
-
290
- describe "#bookmarks_export_url" do
291
- it "is the bookmark url with an encrypted user token" do
292
- allow(helper).to receive_messages(encrypt_user_id: 'xyz', current_or_guest_user: double(id: 123))
293
- url = helper.bookmarks_export_url(:html)
294
- expect(url).to eq helper.bookmarks_url(format: :html, encrypted_user_id: 'xyz')
172
+ expect(helper.link_to_previous_search(params)).to have_link(href: helper.search_action_path(params)).and(have_text('search query'))
295
173
  end
296
174
  end
297
175
 
@@ -309,8 +187,8 @@ RSpec.describe Blacklight::UrlHelperBehavior do
309
187
  end
310
188
 
311
189
  it "uses the track_search_session configuration to determine whether to track the search session" do
312
- blacklight_config.track_search_session = false
313
- expect(helper.session_tracking_path(document, x: 1)).to eq nil
190
+ blacklight_config.track_search_session.storage = false
191
+ expect(helper.session_tracking_path(document, x: 1)).to be_nil
314
192
  end
315
193
  end
316
194
  end