blacklight 7.36.2 → 8.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (399) hide show
  1. checksums.yaml +4 -4
  2. data/.env +2 -3
  3. data/.github/workflows/ruby.yml +33 -133
  4. data/.rubocop.yml +241 -2
  5. data/.rubocop_todo.yml +214 -270
  6. data/Gemfile +7 -10
  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 -489
  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/_facets.scss +72 -44
  18. data/app/assets/stylesheets/blacklight/_header.scss +0 -15
  19. data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
  20. data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
  21. data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
  22. data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
  23. data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
  24. data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
  25. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
  26. data/app/builders/blacklight/action_builder.rb +18 -9
  27. data/app/components/blacklight/advanced_search_form_component.html.erb +2 -2
  28. data/app/components/blacklight/advanced_search_form_component.rb +8 -10
  29. data/app/components/blacklight/constraints_component.rb +27 -37
  30. data/app/components/blacklight/document/action_component.rb +9 -9
  31. data/app/components/blacklight/document/actions_component.rb +2 -2
  32. data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
  33. data/app/components/blacklight/document/bookmark_component.rb +4 -2
  34. data/app/components/blacklight/document/citation_component.rb +5 -3
  35. data/app/components/blacklight/document/group_component.rb +7 -3
  36. data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
  37. data/app/components/blacklight/document/sidebar_component.rb +16 -0
  38. data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
  39. data/app/components/blacklight/document/thumbnail_component.rb +1 -9
  40. data/app/components/blacklight/document_component.html.erb +4 -0
  41. data/app/components/blacklight/document_component.rb +14 -53
  42. data/app/components/blacklight/document_metadata_component.html.erb +2 -4
  43. data/app/components/blacklight/document_metadata_component.rb +5 -10
  44. data/app/components/blacklight/document_title_component.rb +4 -1
  45. data/app/components/blacklight/facet_component.rb +1 -1
  46. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +3 -3
  47. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  48. data/app/components/blacklight/facet_field_component.html.erb +4 -4
  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/legacy_icon_component.rb +30 -0
  58. data/app/components/blacklight/icons/list_component.rb +16 -0
  59. data/app/components/blacklight/icons/search_component.rb +16 -0
  60. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  61. data/app/components/blacklight/metadata_field_component.rb +24 -8
  62. data/app/components/blacklight/metadata_field_layout_component.rb +4 -25
  63. data/app/components/blacklight/response/facet_group_component.html.erb +3 -5
  64. data/app/components/blacklight/response/facet_group_component.rb +29 -8
  65. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  66. data/app/components/blacklight/response/pagination_component.rb +1 -5
  67. data/app/components/blacklight/response/sort_component.rb +1 -1
  68. data/app/components/blacklight/response/spellcheck_component.rb +17 -6
  69. data/app/components/blacklight/response/view_type_button_component.rb +2 -6
  70. data/app/components/blacklight/response/view_type_component.rb +3 -5
  71. data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
  72. data/app/components/blacklight/search/sidebar_component.rb +17 -0
  73. data/app/components/blacklight/search_bar_component.html.erb +20 -15
  74. data/app/components/blacklight/search_bar_component.rb +2 -16
  75. data/app/components/blacklight/search_button_component.rb +3 -3
  76. data/app/components/blacklight/search_context_component.rb +43 -9
  77. data/app/components/blacklight/search_header_component.html.erb +2 -0
  78. data/app/components/blacklight/search_header_component.rb +6 -0
  79. data/app/components/blacklight/start_over_button_component.rb +5 -3
  80. data/app/components/blacklight/system/dropdown_component.rb +2 -2
  81. data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
  82. data/app/components/blacklight/system/flash_message_component.rb +11 -2
  83. data/app/components/blacklight/system/modal_component.html.erb +1 -1
  84. data/app/components/blacklight/system/modal_component.rb +0 -2
  85. data/app/components/blacklight/top_navbar_component.html.erb +1 -1
  86. data/app/components/blacklight/top_navbar_component.rb +0 -4
  87. data/app/controllers/bookmarks_controller.rb +1 -0
  88. data/app/controllers/catalog_controller.rb +1 -0
  89. data/app/controllers/concerns/blacklight/bookmarks.rb +10 -9
  90. data/app/controllers/concerns/blacklight/catalog.rb +21 -83
  91. data/app/controllers/concerns/blacklight/controller.rb +3 -41
  92. data/app/controllers/concerns/blacklight/search_context.rb +25 -7
  93. data/app/controllers/concerns/blacklight/search_history.rb +2 -0
  94. data/app/controllers/concerns/blacklight/searchable.rb +12 -1
  95. data/app/controllers/concerns/blacklight/token_based_user.rb +13 -1
  96. data/app/controllers/search_history_controller.rb +1 -0
  97. data/app/helpers/blacklight/blacklight_helper_behavior.rb +12 -310
  98. data/app/helpers/blacklight/catalog_helper_behavior.rb +22 -137
  99. data/app/helpers/blacklight/component_helper_behavior.rb +2 -53
  100. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -117
  101. data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
  102. data/app/helpers/blacklight/icon_helper_behavior.rb +5 -4
  103. data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
  104. data/app/helpers/blacklight/render_partials_helper_behavior.rb +11 -31
  105. data/app/helpers/blacklight/url_helper_behavior.rb +13 -97
  106. data/app/helpers/blacklight_helper.rb +1 -0
  107. data/app/helpers/catalog_helper.rb +1 -0
  108. data/app/javascript/blacklight/bookmark_toggle.js +13 -19
  109. data/app/javascript/blacklight/button_focus.js +12 -10
  110. data/app/javascript/blacklight/checkbox_submit.js +68 -122
  111. data/app/javascript/blacklight/core.js +6 -5
  112. data/app/javascript/blacklight/index.js +13 -0
  113. data/app/javascript/blacklight/modal.js +99 -164
  114. data/app/javascript/blacklight/modalForm.js +60 -0
  115. data/app/javascript/blacklight/search_context.js +45 -55
  116. data/app/models/blacklight/facet_paginator.rb +3 -2
  117. data/app/models/blacklight/icon.rb +4 -2
  118. data/app/models/bookmark.rb +0 -2
  119. data/app/models/concerns/blacklight/configurable.rb +5 -4
  120. data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -10
  121. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  122. data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
  123. data/app/models/concerns/blacklight/document/email.rb +1 -0
  124. data/app/models/concerns/blacklight/document/export.rb +2 -1
  125. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  126. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  127. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
  128. data/app/models/concerns/blacklight/document/sms.rb +1 -0
  129. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  130. data/app/models/concerns/blacklight/user.rb +17 -8
  131. data/app/models/record_mailer.rb +13 -12
  132. data/app/models/search.rb +1 -7
  133. data/app/models/solr_document.rb +1 -0
  134. data/app/presenters/blacklight/clause_presenter.rb +1 -1
  135. data/app/presenters/blacklight/document_presenter.rb +13 -21
  136. data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
  137. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
  138. data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
  139. data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
  140. data/app/presenters/blacklight/field_presenter.rb +1 -0
  141. data/app/presenters/blacklight/index_presenter.rb +2 -40
  142. data/app/presenters/blacklight/json_presenter.rb +7 -5
  143. data/app/presenters/blacklight/rendering/link_to_facet.rb +2 -5
  144. data/app/presenters/blacklight/show_presenter.rb +1 -9
  145. data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
  146. data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
  147. data/app/services/blacklight/field_retriever.rb +12 -21
  148. data/app/services/blacklight/search_service.rb +8 -7
  149. data/app/values/blacklight/types.rb +0 -4
  150. data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
  151. data/app/views/bookmarks/_tools.html.erb +7 -12
  152. data/app/views/catalog/_advanced_search_form.html.erb +0 -1
  153. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  154. data/app/views/catalog/_citation.html.erb +1 -1
  155. data/app/views/catalog/_constraints.html.erb +1 -14
  156. data/app/views/catalog/_document.atom.builder +12 -14
  157. data/app/views/catalog/_document.html.erb +5 -3
  158. data/app/views/catalog/_document.rss.builder +2 -4
  159. data/app/views/catalog/_facet_layout.html.erb +2 -2
  160. data/app/views/catalog/_facets.html.erb +5 -4
  161. data/app/views/catalog/_home_text.html.erb +2 -14
  162. data/app/views/catalog/_search_form.html.erb +2 -2
  163. data/app/views/catalog/_search_header.html.erb +1 -2
  164. data/app/views/catalog/_search_results.html.erb +2 -2
  165. data/app/views/catalog/_search_sidebar.html.erb +5 -1
  166. data/app/views/catalog/_show_main_content.html.erb +11 -16
  167. data/app/views/catalog/_show_sidebar.html.erb +2 -2
  168. data/app/views/catalog/_show_tools.html.erb +8 -14
  169. data/app/views/catalog/_view_type_group.html.erb +1 -1
  170. data/app/views/catalog/email.html.erb +2 -2
  171. data/app/views/catalog/email_success.html.erb +5 -6
  172. data/app/views/catalog/facet.html.erb +7 -5
  173. data/app/views/catalog/index.atom.builder +12 -14
  174. data/app/views/catalog/index.html.erb +4 -1
  175. data/app/views/catalog/index.json.jbuilder +19 -19
  176. data/app/views/catalog/index.rss.builder +1 -1
  177. data/app/views/catalog/opensearch.xml.builder +1 -1
  178. data/app/views/catalog/sms.html.erb +2 -2
  179. data/app/views/catalog/sms_success.html.erb +5 -6
  180. data/app/views/catalog/suggest.html.erb +3 -0
  181. data/app/views/layouts/blacklight/base.html.erb +13 -2
  182. data/app/views/search_history/index.html.erb +6 -2
  183. data/app/views/shared/_modal.html.erb +3 -3
  184. data/blacklight.gemspec +8 -9
  185. data/config/importmap.rb +3 -0
  186. data/config/locales/blacklight.ar.yml +0 -1
  187. data/config/locales/blacklight.ca.yml +0 -1
  188. data/config/locales/blacklight.de.yml +0 -1
  189. data/config/locales/blacklight.en.yml +0 -2
  190. data/config/locales/blacklight.es.yml +0 -1
  191. data/config/locales/blacklight.fr.yml +0 -1
  192. data/config/locales/blacklight.hu.yml +0 -1
  193. data/config/locales/blacklight.it.yml +0 -1
  194. data/config/locales/blacklight.nl.yml +0 -1
  195. data/config/locales/blacklight.pt-BR.yml +0 -1
  196. data/config/locales/blacklight.sq.yml +0 -1
  197. data/config/locales/blacklight.zh.yml +0 -1
  198. data/config/routes.rb +3 -2
  199. data/db/migrate/20140202020201_create_searches.rb +1 -0
  200. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  201. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  202. data/docker-compose.yml +0 -1
  203. data/lib/blacklight/abstract_repository.rb +1 -0
  204. data/lib/blacklight/configuration/context.rb +4 -4
  205. data/lib/blacklight/configuration/display_field.rb +7 -9
  206. data/lib/blacklight/configuration/facet_field.rb +17 -11
  207. data/lib/blacklight/configuration/field.rb +1 -0
  208. data/lib/blacklight/configuration/fields.rb +12 -15
  209. data/lib/blacklight/configuration/index_field.rb +1 -0
  210. data/lib/blacklight/configuration/null_display_field.rb +17 -0
  211. data/lib/blacklight/configuration/search_field.rb +1 -0
  212. data/lib/blacklight/configuration/show_field.rb +1 -0
  213. data/lib/blacklight/configuration/sort_field.rb +1 -0
  214. data/lib/blacklight/configuration/tool_config.rb +1 -0
  215. data/lib/blacklight/configuration/view_config.rb +16 -6
  216. data/lib/blacklight/configuration.rb +294 -358
  217. data/lib/blacklight/engine.rb +8 -24
  218. data/lib/blacklight/exceptions.rb +2 -2
  219. data/lib/blacklight/nested_open_struct_with_hash_access.rb +6 -12
  220. data/lib/blacklight/open_struct_with_hash_access.rb +19 -17
  221. data/lib/blacklight/parameters.rb +7 -21
  222. data/lib/blacklight/routes/exportable.rb +1 -0
  223. data/lib/blacklight/routes/searchable.rb +2 -1
  224. data/lib/blacklight/routes.rb +1 -0
  225. data/lib/blacklight/search_builder.rb +10 -10
  226. data/lib/blacklight/search_state/filter_field.rb +8 -25
  227. data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
  228. data/lib/blacklight/search_state.rb +23 -79
  229. data/lib/blacklight/solr/document.rb +1 -0
  230. data/lib/blacklight/solr/facet_paginator.rb +1 -0
  231. data/lib/blacklight/solr/repository.rb +3 -14
  232. data/lib/blacklight/solr/request.rb +1 -0
  233. data/lib/blacklight/solr/response/facets.rb +21 -5
  234. data/lib/blacklight/solr/response/group.rb +1 -0
  235. data/lib/blacklight/solr/response/group_response.rb +1 -0
  236. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  237. data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
  238. data/lib/blacklight/solr/response/params.rb +5 -4
  239. data/lib/blacklight/solr/response/response.rb +1 -0
  240. data/lib/blacklight/solr/response/spelling.rb +1 -0
  241. data/lib/blacklight/solr/response.rb +4 -3
  242. data/lib/blacklight/solr/search_builder_behavior.rb +17 -34
  243. data/lib/blacklight/solr.rb +1 -0
  244. data/lib/blacklight/version.rb +1 -0
  245. data/lib/blacklight.rb +7 -10
  246. data/lib/generators/blacklight/assets/importmap_generator.rb +55 -0
  247. data/lib/generators/blacklight/assets/propshaft_generator.rb +25 -0
  248. data/lib/generators/blacklight/assets/sprockets_generator.rb +66 -0
  249. data/lib/generators/blacklight/assets_generator.rb +13 -89
  250. data/lib/generators/blacklight/controller_generator.rb +3 -2
  251. data/lib/generators/blacklight/document_generator.rb +1 -0
  252. data/lib/generators/blacklight/install_generator.rb +4 -3
  253. data/lib/generators/blacklight/models_generator.rb +1 -0
  254. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  255. data/lib/generators/blacklight/solr_generator.rb +1 -1
  256. data/lib/generators/blacklight/templates/catalog_controller.rb +34 -8
  257. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -69
  258. data/lib/generators/blacklight/test_support_generator.rb +4 -2
  259. data/lib/generators/blacklight/user_generator.rb +7 -9
  260. data/lib/railties/blacklight.rake +6 -7
  261. data/package.json +10 -13
  262. data/rollup.config.js +27 -0
  263. data/spec/components/blacklight/constraints_component_spec.rb +17 -13
  264. data/spec/components/blacklight/document_component_spec.rb +23 -82
  265. data/spec/components/blacklight/facet_component_spec.rb +3 -18
  266. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
  267. data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
  268. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +10 -9
  269. data/spec/components/blacklight/response/view_type_component_spec.rb +66 -0
  270. data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
  271. data/spec/components/blacklight/search_context_component_spec.rb +40 -0
  272. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
  273. data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
  274. data/spec/controllers/bookmarks_controller_spec.rb +2 -3
  275. data/spec/controllers/catalog_controller_spec.rb +13 -135
  276. data/spec/features/advanced_search_spec.rb +0 -56
  277. data/spec/features/autocomplete_spec.rb +1 -1
  278. data/spec/features/axe_spec.rb +1 -6
  279. data/spec/features/bookmarks_spec.rb +1 -1
  280. data/spec/features/facets_spec.rb +1 -1
  281. data/spec/features/search_context_spec.rb +4 -10
  282. data/spec/features/search_results_spec.rb +0 -33
  283. data/spec/features/sitelinks_search_box.rb +13 -0
  284. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +2 -138
  285. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +0 -387
  286. data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +8 -0
  287. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +5 -7
  288. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +9 -131
  289. data/spec/helpers/blacklight_helper_spec.rb +8 -252
  290. data/spec/helpers/catalog_helper_spec.rb +7 -118
  291. data/spec/i18n_spec.rb +1 -0
  292. data/spec/integration/generators/blacklight/solr_generator_spec.rb +1 -1
  293. data/spec/lib/blacklight/configuration/facet_field_spec.rb +27 -16
  294. data/spec/lib/blacklight/configuration/field_spec.rb +1 -1
  295. data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
  296. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +2 -2
  297. data/spec/lib/blacklight/parameters_spec.rb +1 -4
  298. data/spec/lib/blacklight/search_state/filter_field_spec.rb +4 -4
  299. data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +117 -0
  300. data/spec/lib/blacklight/search_state_spec.rb +80 -198
  301. data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
  302. data/spec/models/blacklight/configuration_spec.rb +17 -51
  303. data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
  304. data/spec/models/blacklight/icon_spec.rb +31 -15
  305. data/spec/models/blacklight/search_builder_spec.rb +9 -9
  306. data/spec/models/blacklight/solr/document_spec.rb +3 -3
  307. data/spec/models/blacklight/solr/repository_spec.rb +0 -27
  308. data/spec/models/blacklight/solr/response/facets_spec.rb +27 -27
  309. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  310. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  311. data/spec/models/blacklight/solr/response_spec.rb +9 -2
  312. data/spec/models/blacklight/solr/search_builder_spec.rb +24 -31
  313. data/spec/models/blacklight/user_spec.rb +22 -0
  314. data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
  315. data/spec/presenters/blacklight/document_presenter_spec.rb +2 -2
  316. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +85 -12
  317. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +1 -0
  318. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +14 -13
  319. data/spec/presenters/blacklight/field_presenter_spec.rb +0 -14
  320. data/spec/presenters/blacklight/index_presenter_spec.rb +2 -4
  321. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -0
  322. data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -2
  323. data/spec/presenters/blacklight/show_presenter_spec.rb +20 -29
  324. data/spec/presenters/thumbnail_presenter_spec.rb +1 -1
  325. data/spec/requests/load_suggestions_spec.rb +16 -0
  326. data/spec/routing/catalog_routing_spec.rb +2 -1
  327. data/spec/services/blacklight/search_service_spec.rb +31 -68
  328. data/spec/spec_helper.rb +6 -32
  329. data/spec/support/controller_level_helpers.rb +1 -2
  330. data/spec/support/features/search_helpers.rb +39 -0
  331. data/spec/support/features/session_helpers.rb +1 -0
  332. data/spec/support/features.rb +3 -0
  333. data/spec/support/view_component_capybara_test_helpers.rb +8 -0
  334. data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -2
  335. data/spec/views/catalog/_document.html.erb_spec.rb +3 -34
  336. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
  337. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  338. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  339. data/spec/views/catalog/_show_tools.html.erb_spec.rb +5 -66
  340. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
  341. data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
  342. data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
  343. data/spec/views/catalog/index.atom.builder_spec.rb +18 -11
  344. data/spec/views/catalog/index.html.erb_spec.rb +5 -6
  345. data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
  346. data/spec/views/catalog/show.html.erb_spec.rb +3 -25
  347. data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
  348. data/tasks/blacklight.rake +6 -4
  349. metadata +81 -134
  350. data/.babelrc +0 -11
  351. data/app/assets/images/blacklight/list.svg +0 -1
  352. data/app/assets/images/blacklight/search.svg +0 -1
  353. data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +0 -37
  354. data/app/components/blacklight/content_areas_shim.rb +0 -13
  355. data/app/controllers/concerns/blacklight/base.rb +0 -12
  356. data/app/controllers/concerns/blacklight/default_component_configuration.rb +0 -64
  357. data/app/controllers/concerns/blacklight/facet.rb +0 -69
  358. data/app/controllers/concerns/blacklight/search_fields.rb +0 -46
  359. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -27
  360. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -188
  361. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -97
  362. data/app/helpers/blacklight/suggest_helper_behavior.rb +0 -13
  363. data/app/javascript/blacklight/autocomplete.js +0 -36
  364. data/app/javascript/blacklight/facet_load.js +0 -22
  365. data/app/presenters/blacklight/search_bar_presenter.rb +0 -47
  366. data/app/views/catalog/_constraints_element.html.erb +0 -14
  367. data/app/views/catalog/_document_action.html.erb +0 -5
  368. data/app/views/catalog/_facet_group.html.erb +0 -5
  369. data/app/views/catalog/_facet_limit.html.erb +0 -3
  370. data/app/views/catalog/_index.html.erb +0 -1
  371. data/app/views/catalog/_index_header.html.erb +0 -22
  372. data/app/views/catalog/_previous_next_doc.html.erb +0 -2
  373. data/app/views/catalog/_show.html.erb +0 -6
  374. data/app/views/catalog/_show_header.html.erb +0 -2
  375. data/app/views/catalog/_thumbnail.html.erb +0 -1
  376. data/lib/blacklight/deprecations/engine_configuration.rb +0 -66
  377. data/lib/blacklight/deprecations/search_state_normalization.rb +0 -52
  378. data/spec/components/blacklight/header_component_spec.rb +0 -20
  379. data/spec/controllers/blacklight/facet_spec.rb +0 -33
  380. data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
  381. data/spec/features/citation_spec.rb +0 -10
  382. data/spec/features/sitelinks_search_box_spec.rb +0 -13
  383. data/spec/features/sms_spec.rb +0 -12
  384. data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +0 -26
  385. data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +0 -92
  386. data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +0 -101
  387. data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
  388. data/spec/lib/blacklight/engine_spec.rb +0 -41
  389. data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
  390. data/spec/services/blacklight/field_retriever_spec.rb +0 -17
  391. data/spec/support/view_component_test_helpers.rb +0 -35
  392. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  393. data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
  394. data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
  395. data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
  396. data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
  397. data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
  398. data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
  399. data/spec/views/catalog/_thumbnail.html.erb_spec.rb +0 -38
@@ -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
 
@@ -310,7 +188,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
310
188
 
311
189
  it "uses the track_search_session configuration to determine whether to track the search session" do
312
190
  blacklight_config.track_search_session = false
313
- expect(helper.session_tracking_path(document, x: 1)).to eq nil
191
+ expect(helper.session_tracking_path(document, x: 1)).to be_nil
314
192
  end
315
193
  end
316
194
  end