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
@@ -2,7 +2,16 @@
2
2
 
3
3
  RSpec.describe RecordMailer do
4
4
  let(:config) do
5
- Blacklight::Configuration.new
5
+ Blacklight::Configuration.new do |config|
6
+ config.email.title_field = 'title_tsim'
7
+ config.add_email_field 'title_tsim', label: 'Title'
8
+ config.add_email_field "author_tsim", label: 'Author'
9
+ config.add_email_field "language_ssim", label: 'Language'
10
+ config.add_email_field "format", label: 'Format'
11
+
12
+ config.add_sms_field 'title_tsim', label: 'Title'
13
+ config.add_sms_field "author_tsim", label: 'Author'
14
+ end
6
15
  end
7
16
 
8
17
  let(:document) do
@@ -11,37 +20,38 @@ RSpec.describe RecordMailer do
11
20
 
12
21
  before do
13
22
  allow(described_class).to receive(:default).and_return(from: 'no-reply@projectblacklight.org')
14
- SolrDocument.use_extension(Blacklight::Document::Email)
15
- SolrDocument.use_extension(Blacklight::Document::Sms)
16
23
  @documents = [document]
17
24
  end
18
25
 
19
26
  describe "email" do
20
- before do
21
- details = { to: 'test@test.com', message: "This is my message", config: config }
22
- @email = described_class.email_record(@documents, details, host: 'projectblacklight.org', protocol: 'https')
27
+ subject(:email) do
28
+ described_class.email_record(@documents, details, host: 'projectblacklight.org', protocol: 'https')
29
+ end
30
+
31
+ let(:details) do
32
+ { to: 'test@test.com', message: "This is my message", config: config }
23
33
  end
24
34
 
25
35
  it "receives the TO paramater and send the email to that address" do
26
- expect(@email.to).to include 'test@test.com'
36
+ expect(email.to).to include 'test@test.com'
27
37
  end
28
38
 
29
39
  it "starts the subject w/ Item Record:" do
30
- expect(@email.subject).to match /^Item Record:/
40
+ expect(email.subject).to match /^Item Record:/
31
41
  end
32
42
 
33
43
  it "puts the title of the item in the subject" do
34
- expect(@email.subject).to match /The horn/
44
+ expect(email.subject).to match /The horn/
35
45
  end
36
46
 
37
47
  it "has the correct from address (w/o the port number)" do
38
- expect(@email.from).to include "no-reply@projectblacklight.org"
48
+ expect(email.from).to include "no-reply@projectblacklight.org"
39
49
  end
40
50
 
41
51
  it "prints out the correct body" do
42
- expect(@email.body).to match /Title: The horn/
43
- expect(@email.body).to match /Author: Janetzky, Kurt/
44
- expect(@email.body).to match /projectblacklight.org/
52
+ expect(email.body).to match /Title: The horn/
53
+ expect(email.body).to match /Author: Janetzky, Kurt/
54
+ expect(email.body).to match /projectblacklight.org/
45
55
  end
46
56
 
47
57
  it "uses https URLs when protocol is set" do
@@ -53,28 +63,31 @@ RSpec.describe RecordMailer do
53
63
  context "email title_field is configured and multi valued" do
54
64
  let(:document) { SolrDocument.new(id: "123456", foo: ["Fizz Fizz", "Fuzz Fuzz"], format: ["book"], title_tsim: "The horn", language_ssim: "English", author_tsim: "Janetzky, Kurt") }
55
65
 
56
- it "uses configured email title_field" do
66
+ before do
57
67
  config.email.title_field = "foo"
58
- expect(@email.subject).to match("Fizz Fizz")
59
- expect(@email.subject).not_to match("Fuzz Fuzz")
60
- expect(@email.subject).not_to match("The horn")
68
+ end
69
+
70
+ it "uses configured email title_field" do
71
+ expect(email.subject).to eq 'Item Record: Fizz Fizz and Fuzz Fuzz'
61
72
  end
62
73
  end
63
74
 
64
75
  context "email title_field is configured and single valued" do
65
76
  let(:document) { SolrDocument.new(id: "123456", foo: "Fizz Fizz", format: ["book"], title_tsim: "The horn", language_ssim: "English", author_tsim: "Janetzky, Kurt") }
66
77
 
67
- it "uses configured email title_field" do
78
+ before do
68
79
  config.email.title_field = "foo"
69
- expect(@email.subject).to match("Fizz Fizz")
70
- expect(@email.subject).not_to match("The horn")
80
+ end
81
+
82
+ it "uses configured email title_field" do
83
+ expect(email.subject).to eq 'Item Record: Fizz Fizz'
71
84
  end
72
85
  end
73
86
  end
74
87
 
75
88
  describe "SMS" do
76
89
  before do
77
- details = { to: '5555555555@txt.att.net' }
90
+ details = { to: '5555555555@txt.att.net', config: config }
78
91
  @sms = described_class.sms_record(@documents, details, host: 'projectblacklight.org:3000')
79
92
  end
80
93
 
@@ -91,8 +104,8 @@ RSpec.describe RecordMailer do
91
104
  end
92
105
 
93
106
  it "prints out the correct body" do
94
- expect(@sms.body).to match /The horn/
95
- expect(@sms.body).to match /by Janetzky, Kurt/
107
+ expect(@sms.body).to match /Title: The horn/
108
+ expect(@sms.body).to match /Author: Janetzky, Kurt/
96
109
  expect(@sms.body).to match /projectblacklight.org:3000/
97
110
  end
98
111
 
@@ -45,9 +45,11 @@ RSpec.describe SolrDocument, api: true do
45
45
 
46
46
  let(:doc_class) do
47
47
  Class.new(SolrDocument) do
48
- attribute :title, Blacklight::Types::String, 'title_tesim'
49
- attribute :author, Blacklight::Types::Array, 'author_tesim'
50
- attribute :date, Blacklight::Types::Date, 'date_dtsi'
48
+ attribute :title, :string, 'title_tesim'
49
+ attribute :author, :array, 'author_tesim', of: :string
50
+ attribute :first_author, :select, 'author_tesim', by: :min
51
+ attribute :date, :date, field: 'date_dtsi'
52
+ attribute :whatever, :string, default: ->(*) { 'default_value' }
51
53
  end
52
54
  end
53
55
  let(:document) do
@@ -60,7 +62,23 @@ RSpec.describe SolrDocument, api: true do
60
62
  it "casts the attributes" do
61
63
  expect(document.title).to eq 'Good Omens'
62
64
  expect(document.author).to eq ['Neil Gaiman', 'Terry Pratchett']
65
+ expect(document.first_author).to eq 'Neil Gaiman'
63
66
  expect(document.date).to eq Date.new(1990)
67
+ expect(document.whatever).to eq 'default_value'
68
+ end
69
+
70
+ context 'with missing data' do
71
+ let(:document) { doc_class.new(id: '123') }
72
+
73
+ it 'returns nil for scalar values' do
74
+ expect(document.title).to be_nil
75
+ expect(document.first_author).to be_nil
76
+ expect(document.date).to be_nil
77
+ end
78
+
79
+ it 'returns an array for array values' do
80
+ expect(document.author).to eq []
81
+ end
64
82
  end
65
83
  end
66
84
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe Blacklight::ClausePresenter, type: :presenter do
@@ -12,12 +12,13 @@ RSpec.describe Blacklight::DocumentPresenter do
12
12
 
13
13
  before do
14
14
  allow(request_context).to receive(:search_state).and_return(search_state)
15
+ allow(request_context).to receive(:action_name).and_return(:show)
15
16
  end
16
17
 
17
18
  describe '#fields_to_render' do
18
19
  subject { presenter.fields_to_render.to_a }
19
20
 
20
- let(:field_config) { Blacklight::Configuration::Field.new(field: 'asdf') }
21
+ let(:field_config) { Blacklight::Configuration::DisplayField.new(field: 'asdf') }
21
22
 
22
23
  context 'when all of the fields have values' do
23
24
  before do
@@ -30,7 +31,7 @@ RSpec.describe Blacklight::DocumentPresenter do
30
31
 
31
32
  describe '#field_value' do
32
33
  let(:field_presenter) { instance_double(Blacklight::FieldPresenter, render: 'xyz') }
33
- let(:field_config) { Blacklight::Configuration::Field.new }
34
+ let(:field_config) { Blacklight::Configuration::DisplayField.new }
34
35
  let(:options) { { a: 1 } }
35
36
 
36
37
  it 'calls the field presenter' do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe Blacklight::FacetFieldPresenter, type: :presenter do
@@ -44,11 +45,11 @@ RSpec.describe Blacklight::FacetFieldPresenter, type: :presenter do
44
45
  describe '#active?' do
45
46
  it "checks if any value is selected for a given facet" do
46
47
  search_state.params[:f] = ActiveSupport::HashWithIndifferentAccess.new(key: [1])
47
- expect(presenter.active?).to eq true
48
+ expect(presenter.active?).to be true
48
49
  end
49
50
 
50
51
  it "is false if no value for facet is selected" do
51
- expect(presenter.active?).to eq false
52
+ expect(presenter.active?).to be false
52
53
  end
53
54
  end
54
55
 
@@ -59,12 +60,12 @@ RSpec.describe Blacklight::FacetFieldPresenter, type: :presenter do
59
60
  end
60
61
 
61
62
  it 'is true' do
62
- expect(presenter.in_modal?).to eq true
63
+ expect(presenter.in_modal?).to be true
63
64
  end
64
65
  end
65
66
 
66
67
  it 'is false' do
67
- expect(presenter.in_modal?).to eq false
68
+ expect(presenter.in_modal?).to be false
68
69
  end
69
70
  end
70
71
 
@@ -72,7 +73,9 @@ RSpec.describe Blacklight::FacetFieldPresenter, type: :presenter do
72
73
  let(:paginator) { Blacklight::FacetPaginator.new([{}, {}], limit: 1) }
73
74
 
74
75
  before do
75
- allow(view_context).to receive(:facet_paginator).and_return(paginator)
76
+ # rubocop:disable RSpec/SubjectStub
77
+ allow(presenter).to receive(:paginator).and_return(paginator)
78
+ # rubocop:enable RSpec/SubjectStub
76
79
  end
77
80
 
78
81
  context 'with no additional data' do
@@ -97,13 +100,6 @@ RSpec.describe Blacklight::FacetFieldPresenter, type: :presenter do
97
100
  end
98
101
  end
99
102
 
100
- describe '#html_id' do
101
- it 'gets the id from a helper' do
102
- allow(view_context).to receive(:html_id).with('key').and_return('facet-key')
103
- expect(presenter.html_id).to eq 'facet-key'
104
- end
105
- end
106
-
107
103
  describe '#paginator' do
108
104
  subject(:paginator) { presenter.paginator }
109
105
 
@@ -112,4 +108,81 @@ RSpec.describe Blacklight::FacetFieldPresenter, type: :presenter do
112
108
  expect(paginator.total_count).to eq 0
113
109
  end
114
110
  end
111
+
112
+ describe "#facet_limit" do
113
+ subject(:facet_limit) { presenter.facet_limit }
114
+
115
+ let(:search_state) { Blacklight::SearchState.new({}, blacklight_config, controller) }
116
+ let(:blacklight_config) { CatalogController.blacklight_config }
117
+ let(:facet_field) { blacklight_config.facet_fields['subject_ssim'] }
118
+ let(:display_facet) do
119
+ instance_double(Blacklight::Solr::Response::Facets::FacetField, items: items, limit: nil, sort: :index, offset: 0, prefix: nil)
120
+ end
121
+ # let(:facet_field) { Blacklight::Configuration::FacetField.new(key: 'key') }
122
+ # let(:display_facet) do
123
+ # instance_double(Blacklight::Solr::Response::Facets::FacetField, items: items, sort: :index, offset: 0, prefix: nil)
124
+ # end
125
+
126
+ it "returns specified value for facet_field specified" do
127
+ expect(facet_limit).to eq facet_field.limit
128
+ end
129
+
130
+ describe "for 'true' configured values" do
131
+ let(:blacklight_config) do
132
+ Blacklight::Configuration.new do |config|
133
+ config.add_facet_field "language_facet", limit: true
134
+ end
135
+ end
136
+ let(:facet_field) { blacklight_config.facet_fields['language_facet'] }
137
+
138
+ context 'when the limit in the response is nil' do
139
+ let(:display_facet) do
140
+ instance_double(Blacklight::Solr::Response::Facets::FacetField, items: items, limit: nil, sort: :index, offset: 0, prefix: nil)
141
+ end
142
+
143
+ it "uses the config setting" do
144
+ blacklight_config.facet_fields['language_facet'].limit = 10
145
+ expect(facet_limit).to eq 10
146
+ end
147
+ end
148
+
149
+ context 'when the limit in the response is provided' do
150
+ let(:display_facet) do
151
+ instance_double(Blacklight::Solr::Response::Facets::FacetField, items: items, limit: 16, sort: :index, offset: 0, prefix: nil)
152
+ end
153
+
154
+ it "gets the limit from the facet field in @response" do
155
+ expect(facet_limit).to eq 15
156
+ end
157
+ end
158
+
159
+ context 'when not in the display_facet' do
160
+ let(:display_facet) { nil }
161
+
162
+ it "defaults to 10" do
163
+ expect(facet_limit).to eq 10
164
+ end
165
+ end
166
+ end
167
+
168
+ context 'for facet fields with a key that is different from the field name' do
169
+ before do
170
+ allow(controller).to receive(:blacklight_config).and_return(blacklight_config)
171
+ end
172
+
173
+ let(:blacklight_config) do
174
+ Blacklight::Configuration.new do |config|
175
+ config.add_facet_field 'some_key', field: 'x', limit: true
176
+ end
177
+ end
178
+ let(:facet_field) { blacklight_config.facet_fields['some_key'] }
179
+ let(:display_facet) do
180
+ instance_double(Blacklight::Solr::Response::Facets::FacetField, items: items, limit: 16, sort: :index, offset: 0, prefix: nil)
181
+ end
182
+
183
+ it 'gets the limit from the facet field in the @response' do
184
+ expect(facet_limit).to eq 15
185
+ end
186
+ end
187
+ end
115
188
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe Blacklight::FacetGroupedItemPresenter, type: :presenter do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe Blacklight::FacetItemPresenter, type: :presenter do
@@ -7,22 +8,22 @@ RSpec.describe Blacklight::FacetItemPresenter, type: :presenter do
7
8
  end
8
9
 
9
10
  let(:facet_item) { instance_double(Blacklight::Solr::Response::Facets::FacetItem) }
11
+ let(:filter_field) { instance_double(Blacklight::SearchState::FilterField, include?: true) }
10
12
  let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'key') }
11
13
  let(:facet_field) { instance_double(Blacklight::Solr::Response::Facets::FacetField) }
12
14
  let(:view_context) { controller.view_context }
13
- let(:search_state) { instance_double(Blacklight::SearchState) }
15
+ let(:search_state) { instance_double(Blacklight::SearchState, filter: filter_field) }
14
16
 
15
17
  describe '#selected?' do
16
- it 'works' do
17
- allow(search_state).to receive(:has_facet?).and_return(true)
18
- expect(presenter.selected?).to be true
19
- end
18
+ subject { presenter.selected? }
19
+
20
+ it { is_expected.to be true }
20
21
  end
21
22
 
22
23
  describe '#label' do
23
- it "is the facet value for an ordinary facet" do
24
+ it "is the stringified facet value for an ordinary facet" do
24
25
  allow(facet_config).to receive_messages(query: nil, date: nil, helper_method: nil, url_method: nil)
25
- expect(presenter.label).to eq facet_item
26
+ expect(presenter.label).to eq facet_item.to_s
26
27
  end
27
28
 
28
29
  it "allows you to pass in a :helper_method argument to the configuration" do
@@ -63,9 +64,7 @@ RSpec.describe Blacklight::FacetItemPresenter, type: :presenter do
63
64
  end
64
65
 
65
66
  describe '#href' do
66
- before do
67
- allow(search_state).to receive(:has_facet?).and_return(false)
68
- end
67
+ let(:filter_field) { instance_double(Blacklight::SearchState::FilterField, include?: false) }
69
68
 
70
69
  it 'is the url to apply the facet' do
71
70
  allow(search_state).to receive(:add_facet_params_and_redirect).with('key', facet_item).and_return(f: 'x')
@@ -87,11 +86,13 @@ RSpec.describe Blacklight::FacetItemPresenter, type: :presenter do
87
86
  end
88
87
 
89
88
  context 'with a selected facet' do
90
- it 'is the url to remove the facet' do
91
- allow(search_state).to receive(:has_facet?).and_return(true)
92
- allow(search_state).to receive(:remove_facet_params).with('key', facet_item).and_return({})
89
+ let(:filter_field) { instance_double(Blacklight::SearchState::FilterField, include?: true, remove: {}) }
90
+
91
+ before do
93
92
  allow(view_context).to receive(:search_action_path).with({}).and_return('/catalog')
93
+ end
94
94
 
95
+ it 'is the url to remove the facet' do
95
96
  expect(presenter.href).to eq '/catalog'
96
97
  end
97
98
  end
@@ -36,7 +36,6 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
36
36
  config.add_index_field 'solr_doc_accessor', accessor: true
37
37
  config.add_index_field 'explicit_accessor', accessor: :solr_doc_accessor
38
38
  config.add_index_field 'explicit_array_accessor', accessor: [:solr_doc_accessor, :some_method]
39
- config.add_index_field 'explicit_values', values: ->(_config, _doc) { ['some-value'] }
40
39
  config.add_index_field 'explicit_values_with_context', values: ->(_config, _doc, view_context) { [view_context.params[:x]] }
41
40
  config.add_index_field 'alias', field: 'qwer'
42
41
  config.add_index_field 'with_default', default: 'value'
@@ -52,13 +51,13 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
52
51
  context 'when an explicit html value is provided' do
53
52
  let(:options) { { value: '<b>val1</b>' } }
54
53
 
55
- it { is_expected.to eq '&lt;b&gt;val1&lt;/b&gt;' }
54
+ it { is_expected.not_to be_html_safe }
56
55
  end
57
56
 
58
57
  context 'when an explicit array value with unsafe characters is provided' do
59
58
  let(:options) { { value: ['<a', 'b'] } }
60
59
 
61
- it { is_expected.to eq '&lt;a and b' }
60
+ it { is_expected.to eq('&lt;a and b').and be_html_safe }
62
61
  end
63
62
 
64
63
  context 'when an explicit array value is provided' do
@@ -162,15 +161,6 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
162
161
  end
163
162
  end
164
163
 
165
- context 'when the values lambda is provided' do
166
- let(:field_name) { 'explicit_values' }
167
-
168
- it 'calls the accessors on the return of the preceeding' do
169
- allow(Deprecation).to receive(:warn)
170
- expect(subject).to eq 'some-value'
171
- end
172
- end
173
-
174
164
  context 'when the values lambda is provided and accepts the view contexts' do
175
165
  let(:field_name) { 'explicit_values_with_context' }
176
166
 
@@ -241,10 +231,6 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
241
231
 
242
232
  let(:field_config) { double('field config', if: true, unless: false, except_operations: nil) }
243
233
 
244
- before do
245
- allow(presenter).to receive_messages(document_has_value?: true)
246
- end
247
-
248
234
  it { is_expected.to be true }
249
235
 
250
236
  context 'when the view context says not to render the field' do
@@ -22,17 +22,16 @@ RSpec.describe Blacklight::IndexPresenter, api: true do
22
22
 
23
23
  before do
24
24
  allow(request_context).to receive(:search_state).and_return(search_state)
25
+ allow(request_context).to receive(:action_name).and_return(:index)
25
26
  end
26
27
 
27
28
  describe '#fields' do
28
- let(:field) { instance_double(Blacklight::Configuration::Field) }
29
-
30
29
  before do
31
- allow(config).to receive(:index_fields_for).and_return(title: field)
30
+ config.add_index_field 'title'
32
31
  end
33
32
 
34
33
  it 'returns the list from the configs' do
35
- expect(subject.send(:fields)).to eq(title: field)
34
+ expect(subject.send(:fields).keys).to eq ['title']
36
35
  end
37
36
  end
38
37
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe Blacklight::JsonPresenter, api: true do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe Blacklight::LinkAlternatePresenter do
@@ -25,8 +26,8 @@ RSpec.describe Blacklight::LinkAlternatePresenter do
25
26
 
26
27
  let(:expected_html) do
27
28
  '<link rel="alternate" title="xml" type="application/xml" href="http://test.host/catalog/9999.xml" />' \
28
- '<link rel="alternate" title="dc_xml" type="text/xml" href="http://test.host/catalog/9999.dc_xml" />' \
29
- '<link rel="alternate" title="oai_dc_xml" type="text/xml" href="http://test.host/catalog/9999.oai_dc_xml" />'
29
+ '<link rel="alternate" title="dc_xml" type="text/xml" href="http://test.host/catalog/9999.dc_xml" />' \
30
+ '<link rel="alternate" title="oai_dc_xml" type="text/xml" href="http://test.host/catalog/9999.oai_dc_xml" />'
30
31
  end
31
32
 
32
33
  it { is_expected.to be_equivalent_to expected_html }
@@ -14,14 +14,12 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
14
14
  let(:search_state) { Blacklight::SearchState.new(params, config, controller) }
15
15
 
16
16
  let(:document) do
17
- SolrDocument.new(id: 1,
18
- 'link_to_facet_true' => 'x',
19
- 'link_to_facet_named' => 'x',
20
- 'qwer' => 'document qwer value')
17
+ SolrDocument.new(id: 'xyz', some_field: 'value')
21
18
  end
22
19
 
23
20
  before do
24
21
  allow(request_context).to receive(:search_state).and_return(search_state)
22
+ allow(request_context).to receive(:action_name).and_return(:show)
25
23
  end
26
24
 
27
25
  describe "link_rel_alternates" do
@@ -108,43 +106,36 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
108
106
  end
109
107
 
110
108
  describe '#fields' do
111
- let(:field) { instance_double(Blacklight::Configuration::Field) }
112
-
113
109
  before do
114
- allow(config).to receive(:show_fields_for).and_return(title: field)
110
+ config.add_show_field 'title'
115
111
  end
116
112
 
117
113
  it 'returns the list from the configs' do
118
- expect(subject.send(:fields)).to eq(title: field)
114
+ expect(subject.send(:fields).keys).to eq ['title']
119
115
  end
120
116
  end
121
117
 
122
118
  describe "#heading" do
123
119
  it "falls back to an id" do
124
- allow(document).to receive(:[]).with('id').and_return "xyz"
125
120
  expect(subject.heading).to eq document.id
126
121
  end
127
122
 
128
123
  it "returns the value of the field" do
129
- config.show.title_field = :x
130
- allow(document).to receive(:has?).with(:x).and_return(true)
131
- allow(document).to receive(:fetch).with(:x, nil).and_return("value")
124
+ config.show.title_field = 'some_field'
132
125
  expect(subject.heading).to eq "value"
133
126
  end
134
127
 
135
128
  it "returns the first present value" do
136
- config.show.title_field = [:x, :y]
137
- allow(document).to receive(:fetch).with(:x, nil).and_return(nil)
138
- allow(document).to receive(:fetch).with(:y, nil).and_return("value")
129
+ config.show.title_field = %w[a_field_that_doesnt_exist some_field]
139
130
  expect(subject.heading).to eq "value"
140
131
  end
141
132
 
142
133
  it "can use explicit field configuration" do
143
- config.show.title_field = Blacklight::Configuration::Field.new(field: 'x', values: ->(*_) { 'hardcoded' })
134
+ config.show.title_field = Blacklight::Configuration::DisplayField.new(field: 'x', values: ->(*_) { 'hardcoded' })
144
135
  expect(subject.heading).to eq 'hardcoded'
145
136
  end
146
137
 
147
- context "when empty document" do
138
+ context "with an empty document" do
148
139
  let(:document) { SolrDocument.new({}) }
149
140
 
150
141
  it "returns an empty string as the heading" do
@@ -155,26 +146,21 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
155
146
 
156
147
  describe "#html_title" do
157
148
  it "falls back to an id" do
158
- allow(document).to receive(:[]).with('id').and_return "xyz"
159
149
  expect(subject.html_title).to eq document.id
160
150
  end
161
151
 
162
152
  it "returns the value of the field" do
163
- config.show.html_title_field = :x
164
- allow(document).to receive(:has?).with(:x).and_return(true)
165
- allow(document).to receive(:fetch).with(:x, nil).and_return("value")
153
+ config.show.html_title_field = 'some_field'
166
154
  expect(subject.html_title).to eq "value"
167
155
  end
168
156
 
169
157
  it "returns the first present value" do
170
- config.show.html_title_field = [:x, :y]
171
- allow(document).to receive(:fetch).with(:x, nil).and_return(nil)
172
- allow(document).to receive(:fetch).with(:y, nil).and_return("value")
158
+ config.show.html_title_field = %w[a_field_that_doesnt_exist some_field]
173
159
  expect(subject.html_title).to eq "value"
174
160
  end
175
161
 
176
162
  it "can use explicit field configuration" do
177
- config.show.html_title_field = Blacklight::Configuration::Field.new(field: 'x', values: ->(*_) { 'hardcoded' })
163
+ config.show.html_title_field = Blacklight::Configuration::DisplayField.new(field: 'x', values: ->(*_) { 'hardcoded' })
178
164
  expect(subject.html_title).to eq 'hardcoded'
179
165
  end
180
166
  end
@@ -4,10 +4,10 @@ RSpec.describe Blacklight::Rendering::Pipeline do
4
4
  include Capybara::RSpecMatchers
5
5
  let(:document) { instance_double(SolrDocument) }
6
6
  let(:context) { double }
7
- let(:options) { double('options') }
7
+ let(:options) { {} }
8
8
 
9
9
  describe '.render' do
10
- subject { described_class.render(values, field_config, document, context, options) }
10
+ subject(:rendered) { described_class.render(values, field_config, document, context, options) }
11
11
 
12
12
  let(:values) { %w[a b] }
13
13
  let(:field_config) { Blacklight::Configuration::NullField.new }
@@ -35,6 +35,17 @@ RSpec.describe Blacklight::Rendering::Pipeline do
35
35
  expect(described_class).to have_received(:new)
36
36
  .with(values, field_config, document, context, described_class.operations, options)
37
37
  end
38
+
39
+ context 'outside of an HTML context' do
40
+ let(:options) { { format: 'text' } }
41
+
42
+ let(:values) { ['"blah"', "<notatag>"] }
43
+ let(:field_config) { Blacklight::Configuration::NullField.new itemprop: 'some-prop' }
44
+
45
+ it 'does not HTML escape values or inject HTML tags' do
46
+ expect(rendered).to eq '"blah" and <notatag>'
47
+ end
48
+ end
38
49
  end
39
50
 
40
51
  describe '.operations' do
@@ -95,7 +95,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
95
95
  allow(view_context).to receive_messages(xyz: nil)
96
96
  end
97
97
 
98
- it { is_expected.to be nil }
98
+ it { is_expected.to be_nil }
99
99
  end
100
100
  end
101
101
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe 'GET /catalog/suggest' do
6
+ it 'returns suggestions' do
7
+ get '/catalog/suggest?q=new'
8
+ expect(response.body).to eq <<-RESULT
9
+ <li role="option"><span>new jersey</span></li>
10
+ <li role="option"><span>new jersey bridgeton biography</span></li>
11
+ <li role="option"><span>new jersey bridgeton history</span></li>
12
+ <li role="option"><span>new york</span></li>
13
+ <li role="option"><span>nuwākshūṭ</span></li>
14
+ RESULT
15
+ end
16
+ end