blacklight-spotlight 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (367) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -8
  3. data/Rakefile +40 -39
  4. data/app/assets/javascripts/spotlight/blacklight_configuration.js +16 -0
  5. data/app/assets/javascripts/spotlight/blocks/resources_block.js +3 -1
  6. data/app/assets/stylesheets/spotlight/_blacklight_configuration.scss +2 -2
  7. data/app/assets/stylesheets/spotlight/_blacklight_overrides.scss +24 -0
  8. data/app/assets/stylesheets/spotlight/_header.scss +150 -47
  9. data/app/assets/stylesheets/spotlight/_pages.scss +62 -11
  10. data/app/assets/stylesheets/spotlight/_report_a_problem.scss +1 -0
  11. data/app/assets/stylesheets/spotlight/_spotlight.scss +1 -0
  12. data/app/builders/spotlight/bootstrap_breadcrumbs_builder.rb +28 -21
  13. data/app/controllers/spotlight/about_pages_controller.rb +25 -14
  14. data/app/controllers/spotlight/appearances_controller.rb +34 -30
  15. data/app/controllers/spotlight/application_controller.rb +2 -1
  16. data/app/controllers/spotlight/attachments_controller.rb +9 -7
  17. data/app/controllers/spotlight/browse_controller.rb +13 -9
  18. data/app/controllers/spotlight/catalog_controller.rb +179 -161
  19. data/app/controllers/spotlight/concerns/application_controller.rb +22 -20
  20. data/app/controllers/spotlight/concerns/catalog_search_context.rb +44 -0
  21. data/app/controllers/spotlight/confirmations_controller.rb +5 -2
  22. data/app/controllers/spotlight/contact_forms_controller.rb +13 -7
  23. data/app/controllers/spotlight/contacts_controller.rb +13 -4
  24. data/app/controllers/spotlight/custom_fields_controller.rb +48 -40
  25. data/app/controllers/spotlight/dashboards_controller.rb +17 -8
  26. data/app/controllers/spotlight/default_controller.rb +3 -1
  27. data/app/controllers/spotlight/exhibits_controller.rb +69 -62
  28. data/app/controllers/spotlight/feature_pages_controller.rb +21 -11
  29. data/app/controllers/spotlight/home_pages_controller.rb +6 -5
  30. data/app/controllers/spotlight/lock_controller.rb +3 -1
  31. data/app/controllers/spotlight/metadata_configurations_controller.rb +49 -0
  32. data/app/controllers/spotlight/pages_controller.rb +28 -18
  33. data/app/controllers/spotlight/resources/upload_controller.rb +53 -46
  34. data/app/controllers/spotlight/resources_controller.rb +9 -5
  35. data/app/controllers/spotlight/roles_controller.rb +26 -22
  36. data/app/controllers/spotlight/search_configurations_controller.rb +66 -0
  37. data/app/controllers/spotlight/searches_controller.rb +91 -82
  38. data/app/controllers/spotlight/solr_controller.rb +20 -13
  39. data/app/controllers/spotlight/tags_controller.rb +5 -3
  40. data/app/controllers/spotlight/versions_controller.rb +15 -12
  41. data/app/controllers/spotlight/view_configurations_controller.rb +17 -0
  42. data/app/helpers/spotlight/application_helper.rb +44 -32
  43. data/app/helpers/spotlight/browse_helper.rb +13 -1
  44. data/app/helpers/spotlight/crud_link_helpers.rb +22 -14
  45. data/app/helpers/spotlight/jcrop_helper.rb +4 -2
  46. data/app/helpers/spotlight/main_app_helpers.rb +45 -41
  47. data/app/helpers/spotlight/navbar_helper.rb +6 -0
  48. data/app/helpers/spotlight/pages_helper.rb +23 -15
  49. data/app/helpers/spotlight/roles_helper.rb +10 -4
  50. data/app/helpers/spotlight/search_configurations_helper.rb +22 -0
  51. data/app/helpers/spotlight/title_helper.rb +16 -13
  52. data/app/jobs/spotlight/add_uploads_from_csv.rb +13 -9
  53. data/app/jobs/spotlight/reindex_job.rb +9 -9
  54. data/app/jobs/spotlight/rename_sidecar_field_job.rb +3 -0
  55. data/app/mailers/spotlight/confirmation_mailer.rb +2 -0
  56. data/app/mailers/spotlight/indexing_complete_mailer.rb +4 -2
  57. data/app/models/ability.rb +3 -0
  58. data/app/models/concerns/spotlight/ar_light.rb +49 -25
  59. data/app/models/concerns/spotlight/blacklight_configuration_defaults.rb +25 -10
  60. data/app/models/concerns/spotlight/exhibit_analytics.rb +28 -0
  61. data/app/models/concerns/spotlight/image_derivatives.rb +25 -26
  62. data/app/models/concerns/spotlight/resources/open_graph.rb +23 -19
  63. data/app/models/concerns/spotlight/resources/web.rb +25 -24
  64. data/app/models/concerns/spotlight/solr_document.rb +40 -34
  65. data/app/models/concerns/spotlight/solr_document/active_model_concern.rb +29 -40
  66. data/app/models/concerns/spotlight/solr_document/atomic_updates.rb +22 -18
  67. data/app/models/concerns/spotlight/solr_document/finder.rb +23 -18
  68. data/app/models/concerns/spotlight/solr_document/spotlight_images.rb +43 -39
  69. data/app/models/concerns/spotlight/solr_document/uploaded_resource.rb +41 -29
  70. data/app/models/concerns/spotlight/user.rb +25 -19
  71. data/app/models/sir_trevor_rails/blocks/browse_block.rb +36 -30
  72. data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +24 -18
  73. data/app/models/sir_trevor_rails/blocks/oembed_block.rb +8 -4
  74. data/app/models/sir_trevor_rails/blocks/search_results_block.rb +29 -23
  75. data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +43 -42
  76. data/app/models/sir_trevor_rails/blocks/solr_documents_carousel_block.rb +16 -12
  77. data/app/models/sir_trevor_rails/blocks/solr_documents_embed_block.rb +7 -3
  78. data/app/models/sir_trevor_rails/blocks/solr_documents_features_block.rb +7 -3
  79. data/app/models/sir_trevor_rails/blocks/solr_documents_grid_block.rb +7 -3
  80. data/app/models/sir_trevor_rails/blocks/textable.rb +18 -18
  81. data/app/models/spotlight/ability.rb +32 -33
  82. data/app/models/spotlight/about_page.rb +3 -1
  83. data/app/models/spotlight/analytics/ga.rb +46 -27
  84. data/app/models/spotlight/attachment.rb +3 -1
  85. data/app/models/spotlight/blacklight_configuration.rb +146 -68
  86. data/app/models/spotlight/contact.rb +35 -30
  87. data/app/models/spotlight/contact_email.rb +6 -3
  88. data/app/models/spotlight/contact_form.rb +4 -3
  89. data/app/models/spotlight/custom_field.rb +41 -33
  90. data/app/models/spotlight/exhibit.rb +104 -130
  91. data/app/models/spotlight/feature_page.rb +9 -7
  92. data/app/models/spotlight/featured_image.rb +10 -10
  93. data/app/models/spotlight/field_metadata.rb +46 -0
  94. data/app/models/spotlight/home_page.rb +8 -5
  95. data/app/models/spotlight/lock.rb +4 -3
  96. data/app/models/spotlight/main_navigation.rb +9 -3
  97. data/app/models/spotlight/masthead.rb +17 -16
  98. data/app/models/spotlight/page.rb +16 -16
  99. data/app/models/spotlight/resource.rb +69 -22
  100. data/app/models/spotlight/resources/csv_upload.rb +8 -4
  101. data/app/models/spotlight/resources/upload.rb +68 -57
  102. data/app/models/spotlight/role.rb +30 -34
  103. data/app/models/spotlight/search.rb +74 -63
  104. data/app/models/spotlight/solr_document_sidecar.rb +17 -15
  105. data/app/serializers/spotlight/exhibit_export_serializer.rb +65 -29
  106. data/app/serializers/spotlight/page_representer.rb +10 -6
  107. data/app/uploaders/spotlight/attachment_uploader.rb +4 -6
  108. data/app/uploaders/spotlight/avatar_uploader.rb +4 -3
  109. data/app/uploaders/spotlight/featured_image_uploader.rb +15 -14
  110. data/app/uploaders/spotlight/item_uploader.rb +3 -1
  111. data/app/uploaders/spotlight/masthead_uploader.rb +4 -2
  112. data/app/views/catalog/_search_form.html.erb +24 -0
  113. data/app/views/shared/_browse_navbar.html.erb +1 -1
  114. data/app/views/shared/_exhibit_navbar.html.erb +1 -1
  115. data/app/views/spotlight/appearances/edit.html.erb +13 -45
  116. data/app/views/spotlight/catalog/_edit_default.html.erb +1 -1
  117. data/app/views/spotlight/custom_fields/_form.html.erb +1 -1
  118. data/app/views/spotlight/exhibits/edit.html.erb +4 -4
  119. data/app/views/spotlight/home_pages/_empty.html.erb +1 -3
  120. data/app/views/spotlight/home_pages/_page_options.html.erb +1 -1
  121. data/app/views/spotlight/{blacklight_configurations → metadata_configurations}/_metadata_field.html.erb +0 -0
  122. data/app/views/spotlight/{blacklight_configurations/edit_metadata_fields.html.erb → metadata_configurations/edit.html.erb} +1 -1
  123. data/app/views/spotlight/pages/show.html.erb +2 -2
  124. data/app/views/spotlight/search_configurations/_default_per_page.html.erb +5 -0
  125. data/app/views/spotlight/search_configurations/_document_index_view_types.html.erb +7 -0
  126. data/app/views/spotlight/search_configurations/_facets.html.erb +38 -0
  127. data/app/views/spotlight/search_configurations/_search_fields.html.erb +58 -0
  128. data/app/views/spotlight/search_configurations/_sort.html.erb +53 -0
  129. data/app/views/spotlight/search_configurations/edit.html.erb +46 -0
  130. data/app/views/spotlight/searches/_search.html.erb +1 -1
  131. data/app/views/spotlight/shared/_admin_sidebar.html.erb +0 -2
  132. data/app/views/spotlight/shared/_curation_sidebar.html.erb +2 -3
  133. data/app/views/spotlight/shared/_report_a_problem.html.erb +2 -2
  134. data/app/views/spotlight/sir_trevor/blocks/_oembed_block.html.erb +5 -1
  135. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +7 -5
  136. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +2 -2
  137. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb +7 -5
  138. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +2 -2
  139. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +14 -9
  140. data/config/locales/spotlight.en.yml +94 -49
  141. data/config/routes.rb +11 -20
  142. data/db/migrate/20150410180014_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
  143. data/db/migrate/20150410180015_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
  144. data/db/migrate/20150410180016_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +10 -0
  145. data/db/migrate/20150713160101_change_spotlight_searches_to_published.rb +5 -0
  146. data/db/migrate/20151016092343_remove_searchable_from_exhibit.rb +20 -0
  147. data/lib/blacklight/spotlight.rb +1 -1
  148. data/lib/generators/spotlight/install_generator.rb +27 -25
  149. data/lib/generators/spotlight/templates/catalog_controller.rb +7 -5
  150. data/lib/generators/spotlight/templates/jetty.rake +8 -2
  151. data/lib/generators/spotlight/templates/spotlight_helper.rb +3 -1
  152. data/lib/spotlight.rb +4 -2
  153. data/lib/spotlight/base.rb +21 -14
  154. data/lib/spotlight/catalog.rb +10 -9
  155. data/lib/spotlight/catalog/access_controls_enforcement.rb +30 -15
  156. data/lib/spotlight/config.rb +4 -2
  157. data/lib/spotlight/controller.rb +12 -11
  158. data/lib/spotlight/engine.rb +30 -22
  159. data/lib/spotlight/rails/routes.rb +7 -4
  160. data/lib/spotlight/version.rb +2 -1
  161. data/lib/tasks/spotlight_tasks.rake +56 -50
  162. data/spec/controllers/application_controller_spec.rb +13 -13
  163. data/spec/controllers/spotlight/about_pages_controller_spec.rb +63 -59
  164. data/spec/controllers/spotlight/appearances_controller_spec.rb +29 -24
  165. data/spec/controllers/spotlight/application_controller_spec.rb +3 -3
  166. data/spec/controllers/spotlight/attachments_controller_spec.rb +10 -10
  167. data/spec/controllers/spotlight/browse_controller_spec.rb +23 -25
  168. data/spec/controllers/spotlight/catalog_controller_spec.rb +82 -87
  169. data/spec/controllers/spotlight/confirmations_controller_spec.rb +13 -11
  170. data/spec/controllers/spotlight/contact_forms_controller_spec.rb +17 -12
  171. data/spec/controllers/spotlight/contacts_controller_spec.rb +36 -36
  172. data/spec/controllers/spotlight/custom_fields_controller_spec.rb +26 -26
  173. data/spec/controllers/spotlight/dashboards_controller_spec.rb +14 -14
  174. data/spec/controllers/spotlight/exhibits_controller_spec.rb +59 -54
  175. data/spec/controllers/spotlight/feature_pages_controller_spec.rb +59 -59
  176. data/spec/controllers/spotlight/home_pages_controller_spec.rb +28 -29
  177. data/spec/controllers/spotlight/metadata_configurations_controller_spec.rb +84 -0
  178. data/spec/controllers/spotlight/resources/upload_controller_spec.rb +42 -33
  179. data/spec/controllers/spotlight/resources_controller_spec.rb +25 -29
  180. data/spec/controllers/spotlight/roles_controller_spec.rb +37 -19
  181. data/spec/controllers/spotlight/search_configurations_controller_spec.rb +125 -0
  182. data/spec/controllers/spotlight/searches_controller_spec.rb +84 -63
  183. data/spec/controllers/spotlight/solr_controller_spec.rb +13 -14
  184. data/spec/controllers/spotlight/tags_controller_spec.rb +16 -16
  185. data/spec/controllers/spotlight/versions_controller_spec.rb +15 -18
  186. data/spec/controllers/spotlight/view_configurations_controller_spec.rb +31 -0
  187. data/spec/factories/contacts.rb +1 -3
  188. data/spec/factories/custom_fields.rb +2 -4
  189. data/spec/factories/exhibits.rb +4 -2
  190. data/spec/factories/pages.rb +8 -11
  191. data/spec/factories/resources.rb +4 -4
  192. data/spec/factories/searches.rb +10 -13
  193. data/spec/factories/tags.rb +0 -3
  194. data/spec/factories/users.rb +2 -4
  195. data/spec/features/about_page_spec.rb +19 -19
  196. data/spec/features/add_contacts_spec.rb +34 -34
  197. data/spec/features/add_custom_field_metadata_spec.rb +24 -26
  198. data/spec/features/add_item_bookmarklet_spec.rb +12 -12
  199. data/spec/features/browse_category_admin_spec.rb +39 -39
  200. data/spec/features/catalog_spec.rb +9 -10
  201. data/spec/features/confirm_email_spec.rb +10 -10
  202. data/spec/features/create_exhibit_spec.rb +18 -15
  203. data/spec/features/create_page_spec.rb +8 -8
  204. data/spec/features/curator_items.rb +3 -3
  205. data/spec/features/dashboard_spec.rb +15 -16
  206. data/spec/features/edit_contact_spec.rb +8 -10
  207. data/spec/features/edit_search_fields_spec.rb +79 -0
  208. data/spec/features/exhibits/add_tags_spec.rb +15 -16
  209. data/spec/features/exhibits/administration_spec.rb +25 -25
  210. data/spec/features/exhibits/custom_metadata_fields_spec.rb +41 -43
  211. data/spec/features/exhibits/edit_metadata_fields_spec.rb +19 -19
  212. data/spec/features/feature_page_spec.rb +49 -48
  213. data/spec/features/home_page_spec.rb +38 -38
  214. data/spec/features/import_exhibit_spec.rb +23 -20
  215. data/spec/features/item_admin_spec.rb +28 -29
  216. data/spec/features/javascript/about_page_admin_spec.rb +9 -9
  217. data/spec/features/javascript/block_controls_spec.rb +16 -18
  218. data/spec/features/javascript/blocks/featured_browse_categories_block_spec.rb +11 -12
  219. data/spec/features/javascript/blocks/featured_pages_block_spec.rb +12 -13
  220. data/spec/features/javascript/blocks/search_result_block_spec.rb +17 -17
  221. data/spec/features/javascript/blocks/solr_documents_block_spec.rb +67 -65
  222. data/spec/features/javascript/edit_in_place_spec.rb +30 -56
  223. data/spec/features/javascript/feature_page_admin_spec.rb +73 -59
  224. data/spec/features/javascript/home_page_edit_spec.rb +6 -6
  225. data/spec/features/javascript/metadata_admin_spec.rb +15 -15
  226. data/spec/features/javascript/multi_image_select_spec.rb +17 -18
  227. data/spec/features/javascript/preview_block_spec.rb +11 -12
  228. data/spec/features/javascript/rule_block_spec.rb +7 -7
  229. data/spec/features/javascript/search_config_admin_spec.rb +144 -0
  230. data/spec/features/javascript/search_context_spec.rb +41 -42
  231. data/spec/features/main_navigation_spec.rb +22 -22
  232. data/spec/features/metadata_admin_spec.rb +8 -8
  233. data/spec/features/multiple_exhibits_spec.rb +15 -17
  234. data/spec/features/report_a_problem_spec.rb +23 -17
  235. data/spec/features/site_masthead_spec.rb +46 -46
  236. data/spec/features/slideshow_spec.rb +8 -9
  237. data/spec/features/tags_admin_spec.rb +11 -11
  238. data/spec/features/upload_non_repository_item_spec.rb +32 -32
  239. data/spec/features/user_admin_spec.rb +7 -7
  240. data/spec/helpers/spotlight/application_helper_spec.rb +63 -56
  241. data/spec/helpers/spotlight/browse_helper_spec.rb +6 -6
  242. data/spec/helpers/spotlight/crud_link_helpers_spec.rb +58 -52
  243. data/spec/helpers/spotlight/main_app_helpers_spec.rb +44 -24
  244. data/spec/helpers/spotlight/navbar_helper_spec.rb +4 -4
  245. data/spec/helpers/spotlight/pages_helper_spec.rb +56 -37
  246. data/spec/helpers/spotlight/roles_helper_spec.rb +3 -3
  247. data/spec/helpers/spotlight/search_configurations_helper_spec.rb +24 -0
  248. data/spec/helpers/spotlight/title_helper_spec.rb +33 -35
  249. data/spec/jobs/spotlight/reindex_job_spec.rb +6 -6
  250. data/spec/jobs/spotlight/rename_sidecar_field_job_spec.rb +7 -7
  251. data/spec/lib/spotlight/catalog/access_controls_enforcement_spec.rb +41 -26
  252. data/spec/lib/spotlight/controller_spec.rb +10 -10
  253. data/spec/lib/spotlight/routes_spec.rb +4 -4
  254. data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +13 -13
  255. data/spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb +8 -8
  256. data/spec/models/{spotlight/sir_trevor_blocks → sir_trevor_rails/blocks}/textable_spec.rb +7 -8
  257. data/spec/models/solr_document_spec.rb +49 -50
  258. data/spec/models/spotlight/ability_spec.rb +17 -20
  259. data/spec/models/spotlight/about_page_spec.rb +6 -6
  260. data/spec/models/spotlight/analytics/ga_spec.rb +2 -2
  261. data/spec/models/spotlight/blacklight_configuration_spec.rb +196 -133
  262. data/spec/models/spotlight/contact_email_spec.rb +28 -24
  263. data/spec/models/spotlight/contact_spec.rb +6 -7
  264. data/spec/models/spotlight/custom_field_spec.rb +51 -52
  265. data/spec/models/spotlight/exhibit_spec.rb +102 -60
  266. data/spec/models/spotlight/feature_page_spec.rb +32 -32
  267. data/spec/models/spotlight/featured_image_spec.rb +5 -5
  268. data/spec/models/spotlight/field_metadata_spec.rb +78 -0
  269. data/spec/models/spotlight/home_page_spec.rb +11 -20
  270. data/spec/models/spotlight/{spotlight_image_derivatives_spec.rb → image_derivatives_spec.rb} +2 -2
  271. data/spec/models/spotlight/main_navigation_spec.rb +7 -9
  272. data/spec/models/spotlight/masthead_spec.rb +6 -6
  273. data/spec/models/spotlight/page_spec.rb +26 -29
  274. data/spec/models/spotlight/resource_spec.rb +56 -26
  275. data/spec/models/spotlight/resources/open_graph_spec.rb +16 -18
  276. data/spec/models/spotlight/resources/upload_spec.rb +32 -35
  277. data/spec/models/spotlight/resources/web_spec.rb +9 -11
  278. data/spec/models/spotlight/role_spec.rb +20 -20
  279. data/spec/models/spotlight/search_spec.rb +32 -15
  280. data/spec/models/spotlight/solr_document/atomic_updates_spec.rb +34 -0
  281. data/spec/models/spotlight/{solr_document_images_spec.rb → solr_document/spotlight_images_spec.rb} +18 -10
  282. data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +52 -0
  283. data/spec/models/spotlight/solr_document_sidecar_spec.rb +3 -4
  284. data/spec/routing/spotlight/exhibit_catalog_spec.rb +5 -5
  285. data/spec/routing/spotlight/pages_routing_spec.rb +24 -25
  286. data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +88 -68
  287. data/spec/spec_helper.rb +13 -22
  288. data/spec/support/features/test_features_helpers.rb +50 -46
  289. data/spec/support/views/test_view_helpers.rb +1 -1
  290. data/spec/test_app_templates/Gemfile.extra +0 -1
  291. data/spec/test_app_templates/carrierwave.rb +2 -2
  292. data/spec/test_app_templates/catalog_controller.rb +42 -42
  293. data/spec/test_app_templates/lib/generators/test_app_generator.rb +20 -11
  294. data/spec/test_app_templates/spotlight_test.rake +3 -3
  295. data/spec/uploaders/spotlight/item_uploader_spec.rb +68 -0
  296. data/spec/views/_user_util_links.html.erb_spec.rb +14 -14
  297. data/spec/views/shared/_analytics.html.erb_spec.rb +4 -6
  298. data/spec/views/shared/_exhibit_masthead.html.erb_spec.rb +19 -20
  299. data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +129 -131
  300. data/spec/views/shared/_footer.html.erb_spec.rb +6 -7
  301. data/spec/views/shared/_header_navbar.html.erb_spec.rb +5 -5
  302. data/spec/views/spotlight/about_pages/_empty.html.erb_spec.rb +4 -4
  303. data/spec/views/spotlight/about_pages/_sidebar.html.erb_spec.rb +9 -11
  304. data/spec/views/spotlight/about_pages/index.html.erb_spec.rb +31 -28
  305. data/spec/views/spotlight/browse/_search.html.erb_spec.rb +6 -6
  306. data/spec/views/spotlight/browse/_sort_and_per_page.html.erb_spec.rb +10 -12
  307. data/spec/views/spotlight/browse/index.html.erb_spec.rb +6 -6
  308. data/spec/views/spotlight/browse/show.html.erb_spec.rb +19 -20
  309. data/spec/views/spotlight/catalog/_edit_default.html.erb_spec.rb +7 -7
  310. data/spec/views/spotlight/catalog/admin.html.erb_spec.rb +7 -7
  311. data/spec/views/spotlight/catalog/edit.html.erb_spec.rb +3 -6
  312. data/spec/views/spotlight/catalog/new.html.erb_spec.rb +8 -10
  313. data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +8 -8
  314. data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +22 -22
  315. data/spec/views/spotlight/exhibits/edit.html.erb_spec.rb +7 -8
  316. data/spec/views/spotlight/feature_pages/_empty.html.erb_spec.rb +5 -5
  317. data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +24 -26
  318. data/spec/views/spotlight/home_pages/_empty.html.erb_spec.rb +13 -9
  319. data/spec/views/spotlight/home_pages/_sidebar.html.erb_spec.rb +6 -6
  320. data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +26 -0
  321. data/spec/views/spotlight/metadata_configurations/edit.html.erb_spec.rb +22 -0
  322. data/spec/views/spotlight/pages/edit.html.erb_spec.rb +16 -16
  323. data/spec/views/spotlight/pages/index.html.erb_spec.rb +19 -17
  324. data/spec/views/spotlight/pages/new.html.erb_spec.rb +6 -6
  325. data/spec/views/spotlight/pages/show.html.erb_spec.rb +27 -28
  326. data/spec/views/spotlight/roles/index.html.erb_spec.rb +6 -6
  327. data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +54 -0
  328. data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +28 -0
  329. data/spec/views/spotlight/searches/_search.html.erb_spec.rb +20 -10
  330. data/spec/views/spotlight/searches/edit.html.erb_spec.rb +12 -11
  331. data/spec/views/spotlight/searches/index.html.erb_spec.rb +12 -7
  332. data/spec/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb_spec.rb +7 -8
  333. data/spec/views/spotlight/sir_trevor/blocks/_rule_block.html.erb_spec.rb +4 -4
  334. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb_spec.rb +38 -0
  335. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb_spec.rb +7 -8
  336. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb_spec.rb +18 -13
  337. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb +14 -12
  338. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb_spec.rb +11 -12
  339. data/spec/views/spotlight/tags/index.html.erb_spec.rb +9 -9
  340. metadata +167 -83
  341. data/app/controllers/spotlight/blacklight_configurations_controller.rb +0 -101
  342. data/app/controllers/spotlight/resources/csv_controller.rb +0 -23
  343. data/app/forms/spotlight/appearance.rb +0 -86
  344. data/app/helpers/spotlight/attachments_helper.rb +0 -4
  345. data/app/helpers/spotlight/blacklight_configurations_helper.rb +0 -15
  346. data/app/jobs/spotlight/set_default_thumbnail_job.rb +0 -16
  347. data/app/models/spotlight/resources/csv.rb +0 -80
  348. data/app/uploaders/spotlight/csv_uploader.rb +0 -15
  349. data/app/views/spotlight/blacklight_configurations/edit_facet_fields.html.erb +0 -47
  350. data/app/views/spotlight/blacklight_configurations/edit_sort_fields.html.erb +0 -65
  351. data/app/views/spotlight/resources/csv/_form.html.erb +0 -17
  352. data/app/views/spotlight/resources/csv/new.html.erb +0 -3
  353. data/spec/controllers/spotlight/blacklight_configurations_controller_spec.rb +0 -167
  354. data/spec/features/edit_sort_fields_spec.rb +0 -42
  355. data/spec/features/exhibits/edit_facet_fields_spec.rb +0 -37
  356. data/spec/features/javascript/facet_admin_spec.rb +0 -36
  357. data/spec/features/search_facets_admin_spec.rb +0 -19
  358. data/spec/features/update_appearance_spec.rb +0 -58
  359. data/spec/helpers/spotlight/blacklight_configurations_helper_spec.rb +0 -12
  360. data/spec/models/spotlight/appearance_spec.rb +0 -33
  361. data/spec/models/spotlight/resources/csv_spec.rb +0 -101
  362. data/spec/models/spotlight/solr_document_atomic_updates_spec.rb +0 -29
  363. data/spec/models/spotlight/solr_document_uploaded_resource_spec.rb +0 -45
  364. data/spec/uploaders/item_uploader_spec.rb +0 -62
  365. data/spec/views/spotlight/blacklight_configuration/_metadata_field.html.erb_spec.rb +0 -27
  366. data/spec/views/spotlight/blacklight_configuration/edit_metadata_fields.html.erb_spec.rb +0 -23
  367. data/spec/views/spotlight/blacklight_configuration/edit_sort_fields.html.erb_spec.rb +0 -19
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe SolrDocument, :type => :model do
3
+ describe SolrDocument, type: :model do
4
4
  subject { ::SolrDocument.new(id: 'abcd123') }
5
- its(:to_key) {should == ['abcd123']}
6
- its(:persisted?) {should be_truthy}
5
+ its(:to_key) { should == ['abcd123'] }
6
+ its(:persisted?) { should be_truthy }
7
7
  before do
8
8
  allow(subject).to receive_messages(reindex: nil)
9
9
  end
@@ -11,119 +11,119 @@ describe SolrDocument, :type => :model do
11
11
  let(:exhibit) { FactoryGirl.create(:exhibit) }
12
12
  let(:exhibit_alt) { FactoryGirl.create(:exhibit) }
13
13
 
14
- it "should have tags on the exhibit" do
14
+ it 'has tags on the exhibit' do
15
15
  expect(subject.tags_from(exhibit)).to be_empty
16
16
  end
17
17
 
18
- it "should be able to add tags" do
19
- expect {
20
- exhibit.tag(subject, with: "paris, normandy", on: :tags)
21
- }.to change { ActsAsTaggableOn::Tag.count}.by(2)
22
- expect(subject.tags_from(exhibit)).to eq ['paris', 'normandy']
18
+ it 'is able to add tags' do
19
+ expect do
20
+ exhibit.tag(subject, with: 'paris, normandy', on: :tags)
21
+ end.to change { ActsAsTaggableOn::Tag.count }.by(2)
22
+ expect(subject.tags_from(exhibit)).to eq %w(paris normandy)
23
23
  end
24
24
 
25
- it "should have find" do
26
- expect(::SolrDocument.find('dq287tq6352')).to be_kind_of SolrDocument
25
+ it 'has find' do
26
+ expect(::SolrDocument.find('dq287tq6352')).to be_kind_of described_class
27
27
  end
28
28
 
29
- it "should have ==" do
29
+ it 'has ==' do
30
30
  expect(::SolrDocument.find('dq287tq6352')).to eq ::SolrDocument.find('dq287tq6352')
31
31
  end
32
32
 
33
33
  describe 'GlobalID' do
34
34
  let(:doc_id) { 'dq287tq6352' }
35
- it 'should respond to #to_global_id' do
35
+ it 'responds to #to_global_id' do
36
36
  expect(::SolrDocument.find(doc_id).to_global_id.to_s).to eq "gid://internal/SolrDocument/#{doc_id}"
37
37
  end
38
- it 'should be able to locate SolrDocuments by their GlobalID' do
38
+ it 'is able to locate SolrDocuments by their GlobalID' do
39
39
  expect(GlobalID::Locator.locate(
40
40
  ::SolrDocument.find(doc_id).to_global_id
41
41
  )['id']).to eq doc_id
42
42
  end
43
43
  end
44
44
 
45
- describe "#sidecar" do
46
- it "should return a sidecar for adding exhibit-specific fields" do
45
+ describe '#sidecar' do
46
+ it 'returns a sidecar for adding exhibit-specific fields' do
47
47
  expect(subject.sidecar(exhibit)).to be_kind_of Spotlight::SolrDocumentSidecar
48
48
  expect(subject.sidecar(exhibit).exhibit).to eq exhibit
49
49
  end
50
-
51
- it "should keep distinct sidecars for each exhibit" do
50
+
51
+ it 'keeps distinct sidecars for each exhibit' do
52
52
  expect(subject.sidecar(exhibit).exhibit).to eq exhibit
53
53
  expect(subject.sidecar(exhibit_alt).exhibit).to eq exhibit_alt
54
54
  end
55
55
  end
56
56
 
57
- describe "#update" do
58
- it "should store sidecar data on the sidecar object" do
57
+ describe '#update' do
58
+ it 'stores sidecar data on the sidecar object' do
59
59
  mock_sidecar = double
60
60
  allow(subject).to receive_messages(sidecar: mock_sidecar)
61
61
  expect(mock_sidecar).to receive(:update).with(data: { 'a' => 1 })
62
- subject.update exhibit, sidecar: { data: { 'a' => 1 }}
62
+ subject.update exhibit, sidecar: { data: { 'a' => 1 } }
63
63
  end
64
- it "should store tags" do
65
- subject.update exhibit, exhibit_tag_list: "paris, normandy"
66
- expect(subject.tags_from(exhibit)).to eq ['paris', 'normandy']
64
+ it 'stores tags' do
65
+ subject.update exhibit, exhibit_tag_list: 'paris, normandy'
66
+ expect(subject.tags_from(exhibit)).to eq %w(paris normandy)
67
67
  end
68
68
  end
69
69
 
70
- describe "#to_solr" do
70
+ describe '#to_solr' do
71
71
  before do
72
72
  Spotlight::SolrDocumentSidecar.create! document: subject, exhibit: exhibit,
73
- data: {'a_tesim' => 1, 'b_tesim' => 2, 'c_tesim' => 3 }
73
+ data: { 'a_tesim' => 1, 'b_tesim' => 2, 'c_tesim' => 3 }
74
74
  end
75
75
 
76
- it "should include the doc id" do
77
- expect(subject.to_solr[:id]).to eq 'abcd123'
76
+ it 'includes the doc id' do
77
+ expect(subject.to_solr[:id]).to eq 'abcd123'
78
78
  end
79
79
 
80
- it "should include exhibit-specific tags" do
80
+ it 'includes exhibit-specific tags' do
81
81
  exhibit.tag(subject, with: 'paris', on: :tags)
82
82
 
83
83
  expect(subject.to_solr).to include :exhibit_1_tags_ssim
84
84
  expect(subject.to_solr[:exhibit_1_tags_ssim]).to include 'paris'
85
85
  end
86
86
 
87
- it "should include placeholders for all exhibits' tags" do
87
+ it "includes placeholders for all exhibits' tags" do
88
88
  expect(subject.to_solr).to include :exhibit_1_tags_ssim
89
89
  expect(subject.to_solr[:exhibit_1_tags_ssim]).to eq nil
90
90
  end
91
91
 
92
- it "should include sidecar fields" do
92
+ it 'includes sidecar fields' do
93
93
  expect(subject.to_solr).to include('a_tesim' => 1, 'b_tesim' => 2, 'c_tesim' => 3)
94
94
  end
95
95
  end
96
96
 
97
- describe "#public?" do
98
- it "should default to public" do
97
+ describe '#public?' do
98
+ it 'defaults to public' do
99
99
  expect(subject).to be_public exhibit
100
100
  end
101
101
  end
102
102
 
103
- describe "#private?" do
104
- it "should default to public" do
103
+ describe '#private?' do
104
+ it 'defaults to public' do
105
105
  expect(subject).not_to be_private exhibit
106
106
  end
107
107
  end
108
108
 
109
- describe "#make_public!" do
110
- it "should set the object to public" do
109
+ describe '#make_public!' do
110
+ it 'sets the object to public' do
111
111
  allow(subject).to receive(:reindex)
112
112
  subject.make_public! exhibit
113
113
  expect(subject).not_to be_private exhibit
114
114
  end
115
115
 
116
- it "should augment existing sidecar data" do
116
+ it 'augments existing sidecar data' do
117
117
  allow(subject).to receive(:reindex)
118
118
 
119
- subject.update exhibit, sidecar: { data: { a: 1}}
119
+ subject.update exhibit, sidecar: { data: { a: 1 } }
120
120
  subject.make_public! exhibit
121
121
  expect(subject.sidecar(exhibit).data[:a]).to eq 1
122
122
  end
123
123
  end
124
124
 
125
- describe "#make_private!" do
126
- it "should set the object to private" do
125
+ describe '#make_private!' do
126
+ it 'sets the object to private' do
127
127
  allow(subject).to receive(:reindex)
128
128
  subject.make_private! exhibit
129
129
  expect(subject).to be_private exhibit
@@ -131,25 +131,24 @@ describe SolrDocument, :type => :model do
131
131
  end
132
132
 
133
133
  describe 'uploaded resources' do
134
- let(:uploaded_resource) {
135
- SolrDocument.new(
136
- spotlight_resource_type_ssim: "spotlight/resources/uploads"
134
+ let(:uploaded_resource) do
135
+ described_class.new(
136
+ spotlight_resource_type_ssim: 'spotlight/resources/uploads'
137
137
  )
138
- }
139
- it 'should not include Spotlight::SolrDocument::UploadedResource when the correct fields are present' do
138
+ end
139
+ it 'does not include Spotlight::SolrDocument::UploadedResource when the correct fields are present' do
140
140
  expect(subject).to_not be_kind_of Spotlight::SolrDocument::UploadedResource
141
141
  end
142
- it 'should include Spotlight::SolrDocument::UploadedResource when the correct fields are present' do
142
+ it 'includes Spotlight::SolrDocument::UploadedResource when the correct fields are present' do
143
143
  expect(uploaded_resource).to be_kind_of Spotlight::SolrDocument::UploadedResource
144
144
  end
145
145
  describe '#uploaded_resource?' do
146
- it 'should return false if the correct fields are not present' do
146
+ it 'returns false if the correct fields are not present' do
147
147
  expect(subject).to_not be_uploaded_resource
148
148
  end
149
- it 'should return true when the correct fields are present' do
149
+ it 'returns true when the correct fields are present' do
150
150
  expect(uploaded_resource).to be_uploaded_resource
151
151
  end
152
152
  end
153
153
  end
154
-
155
154
  end
@@ -1,17 +1,17 @@
1
1
  require 'spec_helper'
2
2
  require 'cancan/matchers'
3
3
 
4
- describe Spotlight::Ability, :type => :model do
4
+ describe Spotlight::Ability, type: :model do
5
5
  before do
6
- allow_any_instance_of(Spotlight::Search).to receive(:default_featured_image)
6
+ allow_any_instance_of(Spotlight::Search).to receive(:set_default_featured_image)
7
7
  end
8
8
  let(:exhibit) { FactoryGirl.create(:exhibit) }
9
- let(:search) {FactoryGirl.create(:published_search, exhibit: exhibit)}
10
- let(:unpublished_search) {FactoryGirl.create(:search, exhibit: exhibit)}
11
- let(:page) {FactoryGirl.create(:feature_page, exhibit: exhibit)}
9
+ let(:search) { FactoryGirl.create(:published_search, exhibit: exhibit) }
10
+ let(:unpublished_search) { FactoryGirl.create(:search, exhibit: exhibit) }
11
+ let(:page) { FactoryGirl.create(:feature_page, exhibit: exhibit) }
12
12
  subject { Ability.new(user) }
13
13
 
14
- describe "a user with no roles" do
14
+ describe 'a user with no roles' do
15
15
  let(:user) { nil }
16
16
  it { is_expected.not_to be_able_to(:create, exhibit) }
17
17
  it { is_expected.to be_able_to(:read, exhibit) }
@@ -22,33 +22,31 @@ describe Spotlight::Ability, :type => :model do
22
22
  it { is_expected.not_to be_able_to(:tag, exhibit) }
23
23
  end
24
24
 
25
- describe "a superadmin" do
25
+ describe 'a superadmin' do
26
26
  let(:user) { FactoryGirl.create(:site_admin) }
27
27
 
28
- it { is_expected.to be_able_to(:create, Spotlight::Exhibit) }
29
-
28
+ it { is_expected.to be_able_to(:create, Spotlight::Exhibit) }
30
29
  end
31
30
 
32
- describe "a user with admin role" do
31
+ describe 'a user with admin role' do
33
32
  let(:user) { FactoryGirl.create(:exhibit_admin, exhibit: exhibit) }
34
33
  let(:role) { FactoryGirl.create(:role, exhibit: exhibit) }
35
34
 
36
35
  it { is_expected.to be_able_to(:update, exhibit) }
37
36
 
38
- it { is_expected.to be_able_to(:index, role) }
37
+ it { is_expected.to be_able_to(:index, role) }
39
38
  it { is_expected.to be_able_to(:destroy, role) }
40
- it { is_expected.to be_able_to(:update, role) }
41
- it { is_expected.to be_able_to(:create, Spotlight::Role) }
42
- it { is_expected.not_to be_able_to(:create, Spotlight::Exhibit) }
43
- it { is_expected.to be_able_to(:import, exhibit) }
44
- it { is_expected.to be_able_to(:process_import, exhibit) }
45
- it { is_expected.to be_able_to(:destroy, exhibit) }
39
+ it { is_expected.to be_able_to(:update, role) }
40
+ it { is_expected.to be_able_to(:create, Spotlight::Role) }
41
+ it { is_expected.not_to be_able_to(:create, Spotlight::Exhibit) }
42
+ it { is_expected.to be_able_to(:import, exhibit) }
43
+ it { is_expected.to be_able_to(:process_import, exhibit) }
44
+ it { is_expected.to be_able_to(:destroy, exhibit) }
46
45
 
47
46
  let(:blacklight_config) { role.exhibit.blacklight_configuration }
48
- it { is_expected.to be_able_to(:edit, Spotlight::Appearance.new(blacklight_config)) }
49
47
  end
50
48
 
51
- describe "a user with curate role" do
49
+ describe 'a user with curate role' do
52
50
  let(:user) { FactoryGirl.create(:exhibit_curator, exhibit: exhibit) }
53
51
 
54
52
  it { is_expected.not_to be_able_to(:update, exhibit) }
@@ -76,6 +74,5 @@ describe Spotlight::Ability, :type => :model do
76
74
 
77
75
  let(:role) { FactoryGirl.create(:role, exhibit: user.roles.first.exhibit) }
78
76
  let(:blacklight_config) { role.exhibit.blacklight_configuration }
79
- it { is_expected.not_to be_able_to(:edit, Spotlight::Appearance.new(blacklight_config)) }
80
77
  end
81
78
  end
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spotlight::AboutPage, :type => :model do
4
- let(:page) { Spotlight::AboutPage.create! exhibit: FactoryGirl.create(:exhibit) }
5
- it {is_expected.not_to be_feature_page}
6
- it {is_expected.to be_about_page}
7
- it "should display the sidebar" do
3
+ describe Spotlight::AboutPage, type: :model do
4
+ let(:page) { described_class.create! exhibit: FactoryGirl.create(:exhibit) }
5
+ it { is_expected.not_to be_feature_page }
6
+ it { is_expected.to be_about_page }
7
+ it 'displays the sidebar' do
8
8
  expect(page.display_sidebar?).to be_truthy
9
9
  end
10
- it "should force the sidebar to display (we do not provide an interface for setting this to false)" do
10
+ it 'forces the sidebar to display (we do not provide an interface for setting this to false)' do
11
11
  expect(page.display_sidebar?).to be_truthy
12
12
  page.display_sidebar = false
13
13
  page.save
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Spotlight::Analytics::Ga do
4
- it "should not be enabled without configuration" do
4
+ it 'does not be enabled without configuration' do
5
5
  expect(described_class.enabled?).to be_falsey
6
6
  end
7
- end
7
+ end
@@ -1,46 +1,46 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spotlight::BlacklightConfiguration, :type => :model do
4
- subject { Spotlight::BlacklightConfiguration.new }
3
+ describe Spotlight::BlacklightConfiguration, type: :model do
4
+ subject { described_class.new }
5
5
  let(:blacklight_config) { Blacklight::Configuration.new }
6
6
 
7
7
  before :each do
8
8
  blacklight_config.configure do |config|
9
- config.add_sort_field 'relevance', sort: 'score desc, sort_title_ssi asc', :label => 'Relevance'
10
- config.add_sort_field 'title', sort: 'sort_title_ssi asc', :label => 'Title'
11
- config.add_sort_field 'type', sort: 'sort_type_ssi asc', :label => 'Type'
12
- config.add_sort_field 'date', sort: 'sort_date_dtsi asc', :label => 'Date'
13
- config.add_sort_field 'source', sort: 'sort_source_ssi asc', :label => 'Source'
14
- config.add_sort_field 'identifier', sort: 'id asc', :label => 'Identifier'
9
+ config.add_sort_field 'relevance', sort: 'score desc, sort_title_ssi asc', label: 'Relevance'
10
+ config.add_sort_field 'title', sort: 'sort_title_ssi asc', label: 'Title'
11
+ config.add_sort_field 'type', sort: 'sort_type_ssi asc', label: 'Type'
12
+ config.add_sort_field 'date', sort: 'sort_date_dtsi asc', label: 'Date'
13
+ config.add_sort_field 'source', sort: 'sort_source_ssi asc', label: 'Source'
14
+ config.add_sort_field 'identifier', sort: 'id asc', label: 'Identifier'
15
15
  end
16
16
  allow(subject).to receive_messages default_blacklight_config: blacklight_config
17
17
  subject.exhibit = FactoryGirl.create(:exhibit)
18
18
  end
19
19
 
20
- it "should touch the exhibit" do
20
+ it 'touches the exhibit' do
21
21
  expect(subject.exhibit).to receive :touch
22
22
  subject.save!
23
23
  end
24
24
 
25
- it "should add a default thumbnail field" do
25
+ it 'adds a default thumbnail field' do
26
26
  expect(subject.blacklight_config.index.thumbnail_field).to eq Spotlight::Engine.config.thumbnail_field
27
27
  end
28
28
 
29
- describe "facet fields" do
30
- it "should have facet fields" do
29
+ describe 'facet fields' do
30
+ it 'has facet fields' do
31
31
  expect(subject.facet_fields).to be_empty
32
- subject.facet_fields["title_facet"] = {}
33
- subject.facet_fields["author_facet"] = {}
34
- expect(subject.facet_fields.keys).to eq ['title_facet', 'author_facet']
32
+ subject.facet_fields['title_facet'] = {}
33
+ subject.facet_fields['author_facet'] = {}
34
+ expect(subject.facet_fields.keys).to eq %w(title_facet author_facet)
35
35
  end
36
36
 
37
- it "should filter blank values" do
38
- subject.facet_fields["title_facet"] = { something: "" }
37
+ it 'filters blank values' do
38
+ subject.facet_fields['title_facet'] = { something: '' }
39
39
  subject.valid?
40
- expect(subject.facet_fields["title_facet"].keys).to_not include :something
40
+ expect(subject.facet_fields['title_facet'].keys).to_not include :something
41
41
  end
42
42
 
43
- it "should filter the upstream blacklight config" do
43
+ it 'filters the upstream blacklight config' do
44
44
  subject.facet_fields['a'] = { show: true }
45
45
  subject.facet_fields['b'] = { show: false }
46
46
  subject.facet_fields['d'] = { show: true }
@@ -56,8 +56,7 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
56
56
  expect(subject.blacklight_config.facet_fields['d']).to be_nil
57
57
  end
58
58
 
59
- it "should order the fields by weight" do
60
-
59
+ it 'orders the fields by weight' do
61
60
  subject.facet_fields['a'] = { show: true, weight: 3 }
62
61
  subject.facet_fields['b'] = { show: true, weight: 5 }
63
62
  subject.facet_fields['c'] = { show: true, weight: 1 }
@@ -66,45 +65,43 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
66
65
  blacklight_config.add_facet_field 'b'
67
66
  blacklight_config.add_facet_field 'c'
68
67
 
69
- expect(subject.blacklight_config.facet_fields.keys).to eq ['c', 'a', 'b']
68
+ expect(subject.blacklight_config.facet_fields.keys).to eq %w(c a b)
70
69
  end
71
70
 
72
- context "custom fields" do
73
- it "should include any custom fields" do
71
+ context 'custom fields' do
72
+ it 'includes any custom fields' do
74
73
  allow(subject).to receive_messages(custom_facet_fields: { 'a' => double(if: nil, :if= => true, merge!: true, validate!: true, normalize!: true) })
75
74
  expect(subject.blacklight_config.facet_fields).to include('a')
76
75
  end
77
76
 
78
- it "should default to not showing a custom field in the facets" do
77
+ it 'defaults to not showing a custom field in the facets' do
79
78
  allow(subject).to receive_messages(custom_facet_fields: { 'a' => Blacklight::Configuration::IndexField.new(field: 'a') })
80
79
  expect(subject.blacklight_config.facet_fields).to include('a')
81
80
  expect(subject.blacklight_config.facet_fields['a'].show).to be_falsey
82
81
  end
83
82
  end
84
83
 
85
- context "exhibit fields" do
84
+ context 'exhibit fields' do
86
85
  before do
87
86
  # undo the stubbing we've used elsewhere..
88
87
  allow(subject).to receive(:default_blacklight_config).and_call_original
89
88
  allow(Spotlight::Engine).to receive_messages blacklight_config: blacklight_config
90
89
  end
91
- it "should inject a tags facet" do
92
- expect(subject.blacklight_config.facet_fields).to include "exhibit_tags"
90
+ it 'injects a tags facet' do
91
+ expect(subject.blacklight_config.facet_fields).to include 'exhibit_tags'
93
92
  end
94
93
  end
95
94
  end
96
95
 
97
- describe "index fields" do
98
-
99
- it "should have index fields" do
96
+ describe 'index fields' do
97
+ it 'has index fields' do
100
98
  expect(subject.index_fields).to be_empty
101
99
  subject.index_fields['title'] = {}
102
100
  subject.index_fields['author'] = {}
103
- expect(subject.index_fields.keys).to eq ['title', 'author']
101
+ expect(subject.index_fields.keys).to eq %w(title author)
104
102
  end
105
103
 
106
- it "should default to displaying all index fields if no exhibit-specific configuration is set " do
107
-
104
+ it 'defaults to displaying all index fields if no exhibit-specific configuration is set' do
108
105
  blacklight_config.add_index_field 'a'
109
106
  blacklight_config.add_index_field 'b'
110
107
  blacklight_config.add_index_field 'c'
@@ -117,18 +114,18 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
117
114
  expect(subject.blacklight_config.index_fields['c'].list).to be_truthy
118
115
  end
119
116
 
120
- it "should filter upstream fields that are always disabled" do
117
+ it 'filters upstream fields that are always disabled' do
121
118
  blacklight_config.add_index_field 'a', if: false
122
119
  expect(subject.blacklight_config.index_fields).not_to have_key 'a'
123
120
  end
124
121
 
125
- it "should filter blank values" do
126
- subject.index_fields['title'] = { something: "" }
122
+ it 'filters blank values' do
123
+ subject.index_fields['title'] = { something: '' }
127
124
  subject.valid?
128
- expect(subject.index_fields["title"].keys).to_not include :something
125
+ expect(subject.index_fields['title'].keys).to_not include :something
129
126
  end
130
127
 
131
- it "should filter the upstream blacklight config" do
128
+ it 'filters the upstream blacklight config' do
132
129
  subject.index_fields['a'] = { enabled: true, list: true }
133
130
  subject.index_fields['c'] = { enabled: false, list: false }
134
131
  subject.index_fields['d'] = { enabled: true, list: true }
@@ -144,20 +141,20 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
144
141
  expect(subject.blacklight_config.index_fields['d']).to be_nil
145
142
  end
146
143
 
147
- it "should include configured show fields, but disable them for index views" do
144
+ it 'includes configured show fields, but disable them for index views' do
148
145
  blacklight_config.add_show_field 'a'
149
146
  expect(subject.blacklight_config.index_fields).to have_key 'a'
150
147
  expect(subject.blacklight_config.index_fields['a'].enabled).to be_truthy
151
148
  expect(subject.blacklight_config.index_fields['a'].show).to be_truthy
152
149
  expect(subject.blacklight_config.index_fields['a'].list).to be_falsey
153
150
  end
154
-
155
- it "should filter show fields that are always disabled" do
151
+
152
+ it 'filters show fields that are always disabled' do
156
153
  blacklight_config.add_show_field 'a', if: false
157
154
  expect(subject.blacklight_config.index_fields).not_to have_key 'a'
158
155
  end
159
156
 
160
- it "should include persisted configurations for show fields" do
157
+ it 'includes persisted configurations for show fields' do
161
158
  subject.index_fields['a'] = { enabled: true, list: true }
162
159
  blacklight_config.add_show_field 'a'
163
160
  expect(subject.blacklight_config.index_fields).to have_key 'a'
@@ -165,21 +162,21 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
165
162
  expect(subject.blacklight_config.index_fields['a'].list).to be_truthy
166
163
  end
167
164
 
168
- context "custom fields" do
169
- it "should include any custom fields" do
165
+ context 'custom fields' do
166
+ it 'includes any custom fields' do
170
167
  subject.index_fields['a'] = { enabled: true, list: true }
171
168
  allow(subject).to receive_messages(custom_index_fields: { 'a' => double(if: nil, :if= => true, merge!: true, validate!: true, normalize!: true) })
172
169
  expect(subject.blacklight_config.index_fields).to include('a')
173
170
  end
174
171
 
175
- it "should default to showing a custom field on the show view" do
172
+ it 'defaults to showing a custom field on the show view' do
176
173
  allow(subject).to receive_messages(custom_index_fields: { 'a' => Blacklight::Configuration::IndexField.new(field: 'a') })
177
174
  expect(subject.blacklight_config.index_fields).to include('a')
178
175
  expect(subject.blacklight_config.index_fields['a'].show).to be_truthy
179
176
  expect(subject.blacklight_config.index_fields['a'].enabled).to be_truthy
180
177
  end
181
178
 
182
- it "should use explicit configuration to override custom field defaults" do
179
+ it 'uses explicit configuration to override custom field defaults' do
183
180
  subject.index_fields['a'] = { show: false }
184
181
  allow(subject).to receive_messages(custom_index_fields: { 'a' => Blacklight::Configuration::IndexField.new(field: 'a') })
185
182
  expect(subject.blacklight_config.index_fields).to include('a')
@@ -187,13 +184,13 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
187
184
  end
188
185
  end
189
186
 
190
- it "should prefer the label stored in index fields" do
187
+ it 'prefers the label stored in index fields' do
191
188
  subject.index_fields['a'] = { enabled: true, list: true, label: 'updated val' }
192
- allow(subject).to receive_messages(custom_index_fields: { 'a' => Blacklight::Configuration::IndexField.new(:field => 'a', label: "Initial value") })
189
+ allow(subject).to receive_messages(custom_index_fields: { 'a' => Blacklight::Configuration::IndexField.new(field: 'a', label: 'Initial value') })
193
190
  expect(subject.blacklight_config.index_fields['a'].label).to eq 'updated val'
194
191
  end
195
192
 
196
- it "should filter the upstream blacklight config with respect for view types" do
193
+ it 'filters the upstream blacklight config with respect for view types' do
197
194
  subject.index_fields['a'] = { enabled: true, list: true, gallery: false }
198
195
  subject.index_fields['b'] = { enabled: true, list: false, gallery: true }
199
196
  subject.index_fields['c'] = { enabled: false, list: true, gallery: false }
@@ -205,16 +202,16 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
205
202
  blacklight_config.add_index_field 'c'
206
203
  blacklight_config.add_index_field 'd'
207
204
 
208
- expect(subject.blacklight_config.index_fields.select { |k,x| x.list }).to include('a')
209
- expect(subject.blacklight_config.index_fields.select { |k,x| x.gallery }).to include('b', 'd')
210
- expect(subject.blacklight_config.index_fields.select { |k,x| x.list }).to_not include('b', 'd')
211
- expect(subject.blacklight_config.index_fields.select { |k,x| x.gallery }).to_not include('a', 'c')
212
- expect(subject.blacklight_config.index_fields.select { |k,x| x.list }).to have(2).fields
213
- expect(subject.blacklight_config.index_fields.select { |k,x| x.list && x.enabled }).to have(1).fields
214
- expect(subject.blacklight_config.index_fields.select { |k,x| x.gallery }).to have(2).fields
205
+ expect(subject.blacklight_config.index_fields.select { |_k, x| x.list }).to include('a')
206
+ expect(subject.blacklight_config.index_fields.select { |_k, x| x.gallery }).to include('b', 'd')
207
+ expect(subject.blacklight_config.index_fields.select { |_k, x| x.list }).to_not include('b', 'd')
208
+ expect(subject.blacklight_config.index_fields.select { |_k, x| x.gallery }).to_not include('a', 'c')
209
+ expect(subject.blacklight_config.index_fields.select { |_k, x| x.list }).to have(2).fields
210
+ expect(subject.blacklight_config.index_fields.select { |_k, x| x.list && x.enabled }).to have(1).fields
211
+ expect(subject.blacklight_config.index_fields.select { |_k, x| x.gallery }).to have(2).fields
215
212
  end
216
213
 
217
- it "should filter the upstream blacklight config for show fields" do
214
+ it 'filters the upstream blacklight config for show fields' do
218
215
  subject.index_fields['a'] = { enabled: true, show: true }
219
216
  subject.index_fields['c'] = { enabled: false, show: false }
220
217
  subject.index_fields['d'] = { enabled: true, show: false }
@@ -223,12 +220,12 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
223
220
  blacklight_config.add_index_field 'b'
224
221
  blacklight_config.add_index_field 'c'
225
222
 
226
- expect(subject.blacklight_config.show_fields.select { |k,x| x.show && x.enabled }).to include('a')
227
- expect(subject.blacklight_config.show_fields.select { |k,x| x.show && x.enabled }).to_not include('b', 'd')
228
- expect(subject.blacklight_config.show_fields.select { |k,x| x.show && x.enabled }).to have(1).fields
223
+ expect(subject.blacklight_config.show_fields.select { |_k, x| x.show && x.enabled }).to include('a')
224
+ expect(subject.blacklight_config.show_fields.select { |_k, x| x.show && x.enabled }).to_not include('b', 'd')
225
+ expect(subject.blacklight_config.show_fields.select { |_k, x| x.show && x.enabled }).to have(1).fields
229
226
  end
230
227
 
231
- it "should include any custom fields" do
228
+ it 'includes any custom fields' do
232
229
  subject.index_fields['a'] = { enabled: true, show: true }
233
230
 
234
231
  allow(subject).to receive_messages(custom_index_fields: { 'a' => double(if: nil, :if= => true, merge!: true, validate!: true, normalize!: true) })
@@ -236,8 +233,7 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
236
233
  expect(subject.blacklight_config.show_fields).to include('a')
237
234
  end
238
235
 
239
- it "should order the fields by weight" do
240
-
236
+ it 'orders the fields by weight' do
241
237
  subject.index_fields['a'] = { enabled: true, weight: 3, list: true }
242
238
  subject.index_fields['b'] = { enabled: true, weight: 5, list: true }
243
239
  subject.index_fields['c'] = { enabled: true, weight: 1, list: true }
@@ -246,11 +242,10 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
246
242
  blacklight_config.add_index_field 'b'
247
243
  blacklight_config.add_index_field 'c'
248
244
 
249
- expect(subject.blacklight_config.index_fields.keys).to eq ['c', 'a', 'b']
245
+ expect(subject.blacklight_config.index_fields.keys).to eq %w(c a b)
250
246
  end
251
247
 
252
- it "should order the fields by weight" do
253
-
248
+ it 'orders the fields by weight' do
254
249
  subject.index_fields['a'] = { enabled: true, weight: 3, show: true }
255
250
  subject.index_fields['b'] = { enabled: true, weight: 5, show: true }
256
251
  subject.index_fields['c'] = { enabled: true, weight: 1, show: true }
@@ -259,43 +254,48 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
259
254
  blacklight_config.add_index_field 'b'
260
255
  blacklight_config.add_index_field 'c'
261
256
 
262
- expect(subject.blacklight_config.show_fields.keys).to eq ['c', 'a', 'b']
257
+ expect(subject.blacklight_config.show_fields.keys).to eq %w(c a b)
263
258
  end
264
259
  end
265
260
 
266
- describe "a newly created instance" do
261
+ describe 'a newly created instance' do
267
262
  before do
268
263
  subject.save!
269
264
  end
270
- describe "should have default values" do
271
- its(:sort_fields) { should eq({
272
- "identifier" => {:show=>true},
273
- "relevance" => {:show=>true},
274
- "date" => {:show=>true},
275
- "source" => {:show=>true},
276
- "title" => {:show=>true},
277
- "type" => {:show=>true}
278
- })}
265
+ describe 'should have default values' do
266
+ its(:sort_fields) do
267
+ should eq('identifier' => { enabled: true },
268
+ 'relevance' => { enabled: true },
269
+ 'date' => { enabled: true },
270
+ 'source' => { enabled: true },
271
+ 'title' => { enabled: true },
272
+ 'type' => { enabled: true })
273
+ end
274
+ its(:search_fields) do
275
+ should eq('all_fields' => { enabled: true },
276
+ 'title' => { enabled: true },
277
+ 'author' => { enabled: true })
278
+ end
279
279
  its(:default_per_page) { should eq 10 }
280
- its(:document_index_view_types) { should match_array ::CatalogController.blacklight_config.view.keys.map { |x| x.to_s } }
280
+ its(:document_index_view_types) { should match_array ::CatalogController.blacklight_config.view.keys.map(&:to_s) }
281
281
  end
282
282
  end
283
283
 
284
- describe "sort fields" do
285
- it "should have sort fields" do
284
+ describe 'sort fields' do
285
+ it 'has sort fields' do
286
286
  expect(subject.sort_fields).to be_empty
287
287
  subject.sort_fields['title'] = {}
288
288
  subject.sort_fields['author'] = {}
289
- expect(subject.sort_fields.keys).to eq ['title', 'author']
289
+ expect(subject.sort_fields.keys).to eq %w(title author)
290
290
  end
291
291
 
292
- it "should filter blank values" do
293
- subject.sort_fields['title'] = { something: "" }
292
+ it 'filters blank values' do
293
+ subject.sort_fields['title'] = { something: '' }
294
294
  subject.valid?
295
295
  expect(subject.sort_fields['title'].keys).to_not include :something
296
296
  end
297
297
 
298
- it "should filter the upstream blacklight config" do
298
+ it 'filters the upstream blacklight config' do
299
299
  subject.sort_fields['a'] = { enabled: true }
300
300
  subject.sort_fields['c'] = { enabled: true }
301
301
  subject.sort_fields['d'] = { enabled: true }
@@ -304,118 +304,145 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
304
304
  blacklight_config.add_sort_field 'b'
305
305
  blacklight_config.add_sort_field 'c'
306
306
 
307
- expect(subject.blacklight_config.sort_fields.select { |k,v| v.enabled == true}).to include('a', 'c')
308
- expect(subject.blacklight_config.sort_fields.select { |k,v| v.enabled == true}).not_to include('b', 'd')
307
+ expect(subject.blacklight_config.sort_fields.select { |_k, v| v.enabled == true }).to include('a', 'c')
308
+ expect(subject.blacklight_config.sort_fields.select { |_k, v| v.enabled == true }).not_to include('b', 'd')
309
+ end
310
+ end
311
+
312
+ describe 'search fields' do
313
+ it 'has search fields' do
314
+ expect(subject.search_fields).to be_empty
315
+ subject.search_fields['title'] = {}
316
+ subject.search_fields['author'] = {}
317
+ expect(subject.search_fields.keys).to eq %w(title author)
318
+ end
319
+
320
+ it 'filters blank values' do
321
+ subject.search_fields['title'] = { something: '' }
322
+ subject.valid?
323
+ expect(subject.search_fields['title'].keys).to_not include :something
324
+ end
325
+
326
+ it 'filters the upstream blacklight config' do
327
+ subject.search_fields['a'] = { enabled: true }
328
+ subject.search_fields['c'] = { enabled: true }
329
+ subject.search_fields['d'] = { enabled: true }
330
+
331
+ blacklight_config.add_search_field 'a'
332
+ blacklight_config.add_search_field 'b'
333
+ blacklight_config.add_search_field 'c'
334
+
335
+ expect(subject.blacklight_config.search_fields.select { |_k, v| v.enabled == true }).to include('a', 'c')
336
+ expect(subject.blacklight_config.search_fields.select { |_k, v| v.enabled == true }).not_to include('b', 'd')
309
337
  end
310
338
  end
311
339
 
312
- describe "per page" do
313
- it "should have per page configuration" do
340
+ describe 'per page' do
341
+ it 'has per page configuration' do
314
342
  expect(subject.per_page).to be_empty
315
343
  subject.per_page << 10 << 50
316
344
  expect(subject.per_page).to eq [10, 50]
317
345
  end
318
346
 
319
- it "should filter blank values" do
320
- subject.per_page << ""
347
+ it 'filters blank values' do
348
+ subject.per_page << ''
321
349
  subject.valid?
322
- expect(subject.per_page).to_not include ""
350
+ expect(subject.per_page).to_not include ''
323
351
  end
324
352
 
325
- it "should filter the upstream blacklight config" do
353
+ it 'filters the upstream blacklight config' do
326
354
  subject.per_page = [10, 50, 1000]
327
355
  blacklight_config.per_page = [1, 10, 50, 100]
328
356
 
329
357
  expect(subject.blacklight_config.per_page).to eq [10, 50]
330
358
  end
331
-
332
- it "should prepend the default per page" do
359
+
360
+ it 'prepends the default per page' do
333
361
  blacklight_config.per_page = [1, 10, 50, 100]
334
362
  subject.default_per_page = 50
335
363
  expect(subject.blacklight_config.per_page.first).to eq 50
336
364
  end
337
365
  end
338
366
 
339
- describe "document_index_view_types" do
340
-
341
- it "should have index view configuration" do
367
+ describe 'document_index_view_types' do
368
+ it 'has index view configuration' do
342
369
  expect(subject.document_index_view_types).to be_empty
343
370
  subject.document_index_view_types << 'list' << 'gallery'
344
- expect(subject.document_index_view_types).to eq ['list', 'gallery']
371
+ expect(subject.document_index_view_types).to eq %w(list gallery)
345
372
  end
346
373
 
347
- it "should filter blank values" do
348
- subject.document_index_view_types << ""
374
+ it 'filters blank values' do
375
+ subject.document_index_view_types << ''
349
376
  subject.valid?
350
- expect(subject.document_index_view_types).to_not include ""
377
+ expect(subject.document_index_view_types).to_not include ''
351
378
  end
352
379
 
353
- it "should filter the upstream blacklight config" do
354
- subject.document_index_view_types = ['list', 'gallery', 'unknown']
380
+ it 'filters the upstream blacklight config' do
381
+ subject.document_index_view_types = %w(list gallery unknown)
355
382
  blacklight_config.view.list
356
383
  blacklight_config.view.gallery
357
384
  blacklight_config.view.something
358
385
 
359
386
  expect(subject.blacklight_config.view.keys).to include :list, :gallery, :something
360
- expect(subject.blacklight_config.view.all? { |k,v| v.key == k and v.if == :enabled_in_spotlight_view_type_configuration? }).to be_truthy
387
+ expect(subject.blacklight_config.view.all? { |k, v| v.key == k && v.if == :enabled_in_spotlight_view_type_configuration? }).to be_truthy
361
388
  end
362
389
 
363
- it "should pass through the blacklight configuration when not set" do
390
+ it 'passes through the blacklight configuration when not set' do
364
391
  blacklight_config.view.list
365
392
  blacklight_config.view.gallery
366
393
  blacklight_config.view.something
367
- expect(subject.blacklight_config.view.keys).to include *blacklight_config.view.keys
394
+ expect(subject.blacklight_config.view.keys).to include(*blacklight_config.view.keys)
368
395
  end
369
396
  end
370
397
 
371
- describe "default_solr_params" do
372
- it "should have default solr params configuration" do
398
+ describe 'default_solr_params' do
399
+ it 'has default solr params configuration' do
373
400
  expect(subject.default_solr_params).to be_empty
374
401
  subject.default_solr_params[:qt] = 'custom_request_handler'
375
402
  expect(subject.default_solr_params[:qt]).to eq 'custom_request_handler'
376
403
  end
377
404
 
378
- it "should merge with the blacklight config" do
379
- blacklight_config.default_solr_params = { :qt => 'xyz', :rows => 10 }
405
+ it 'merges with the blacklight config' do
406
+ blacklight_config.default_solr_params = { qt: 'xyz', rows: 10 }
380
407
  subject.default_solr_params[:qt] = 'abc'
381
408
  expect(subject.blacklight_config.default_solr_params).to include(:qt, :rows)
382
409
  expect(subject.blacklight_config.default_solr_params[:qt]).to eq 'abc'
383
410
  end
384
411
  end
385
412
 
386
- describe "show" do
387
- it "should have show view configuration" do
413
+ describe 'show' do
414
+ it 'has show view configuration' do
388
415
  expect(subject.show).to be_empty
389
416
  subject.show[:key] = 'some value'
390
417
  expect(subject.show[:key]).to eq 'some value'
391
418
  end
392
419
 
393
- it "should merge with the blacklight config" do
420
+ it 'merges with the blacklight config' do
394
421
  blacklight_config.show.title_field = 'xyz'
395
422
  subject.show[:title_field] = 'abc'
396
423
  expect(subject.blacklight_config.show.title_field).to eq 'abc'
397
424
  end
398
425
  end
399
426
 
400
- describe "index" do
401
- it "should have index view configuration" do
427
+ describe 'index' do
428
+ it 'has index view configuration' do
402
429
  expect(subject.index).to be_empty
403
430
  subject.index[:key] = 'some value'
404
431
  expect(subject.index[:key]).to eq 'some value'
405
432
  end
406
433
 
407
- it "should merge with the blacklight config" do
434
+ it 'merges with the blacklight config' do
408
435
  blacklight_config.index.title_field = 'xyz'
409
436
  subject.index[:title_field] = 'abc'
410
437
  expect(subject.blacklight_config.index.title_field).to eq 'abc'
411
438
  end
412
439
  end
413
440
 
414
- describe "#custom_index_fields" do
415
- it "should convert exhibit-specific fields to Blacklight configurations" do
441
+ describe '#custom_index_fields' do
442
+ it 'converts exhibit-specific fields to Blacklight configurations' do
416
443
  allow(subject).to receive_messages(exhibit: double(custom_fields: [
417
- stub_model(Spotlight::CustomField, field: "abc", configuration: { a: 1}),
418
- stub_model(Spotlight::CustomField, field: "xyz", configuration: { x: 2})
444
+ stub_model(Spotlight::CustomField, field: 'abc', configuration: { a: 1 }),
445
+ stub_model(Spotlight::CustomField, field: 'xyz', configuration: { x: 2 })
419
446
  ]))
420
447
 
421
448
  expect(subject.custom_index_fields).to include 'abc', 'xyz'
@@ -424,36 +451,72 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
424
451
  end
425
452
  end
426
453
 
427
- describe "autocomplete configuration" do
454
+ describe 'autocomplete configuration' do
428
455
  before do
429
456
  # undo the stubbing we've used elsewhere..
430
457
  allow(subject).to receive(:default_blacklight_config).and_call_original
431
- blacklight_config.show.title_field = "x"
458
+ blacklight_config.show.title_field = 'x'
432
459
  allow(Spotlight::Engine).to receive_messages blacklight_config: blacklight_config.deep_copy
433
460
  end
434
461
 
435
- context "with the default search field" do
462
+ context 'with the default search field' do
436
463
  let(:search_field) do
437
464
  subject.blacklight_config.search_fields[Spotlight::Engine.config.autocomplete_search_field]
438
465
  end
439
466
 
440
- it "should be hidden from the search field selector" do
467
+ it 'is hidden from the search field selector' do
441
468
  expect(search_field.if).to eq false
442
469
  end
443
470
 
444
- it "should use the engine's autocomplete parameters" do
471
+ it "uses the engine's autocomplete parameters" do
445
472
  expect(search_field.solr_parameters).to include Spotlight::Engine.config.default_autocomplete_params
446
473
  end
447
474
 
448
- it "should include the relevant fields" do
449
- Spotlight::Engine.blacklight_config.show.title_field = "some_field"
475
+ it 'includes the relevant fields' do
476
+ Spotlight::Engine.blacklight_config.show.title_field = 'some_field'
450
477
  expect(search_field.solr_parameters).to have_key :fl
451
- expect(search_field.solr_parameters[:fl]).to include "id"
452
- expect(search_field.solr_parameters[:fl]).to include "some_field"
453
- expect(search_field.solr_parameters[:fl]).to include "full_image_url_ssm"
454
- expect(search_field.solr_parameters[:fl]).to include "thumbnail_url_ssm"
455
- expect(search_field.solr_parameters[:fl]).to include "thumbnail_square_url_ssm"
478
+ expect(search_field.solr_parameters[:fl]).to include 'id'
479
+ expect(search_field.solr_parameters[:fl]).to include 'some_field'
480
+ expect(search_field.solr_parameters[:fl]).to include 'full_image_url_ssm'
481
+ expect(search_field.solr_parameters[:fl]).to include 'thumbnail_url_ssm'
482
+ expect(search_field.solr_parameters[:fl]).to include 'thumbnail_square_url_ssm'
456
483
  end
457
484
  end
458
485
  end
486
+
487
+ describe '#document_index_view_types' do
488
+ it 'passes arrays through' do
489
+ array = [1, 2, 3]
490
+ subject.document_index_view_types = array
491
+ expect(subject.document_index_view_types).to match_array array
492
+ end
493
+
494
+ it 'is simplified from a hash to an array' do
495
+ checkboxes_from_form = { 'list' => '1', 'gallery' => '1', 'map' => '0' }
496
+ subject.document_index_view_types = checkboxes_from_form
497
+ expect(subject.document_index_view_types).to match_array %w(list gallery)
498
+ end
499
+ end
500
+
501
+ describe '#document_index_view_types_selected_hash' do
502
+ before do
503
+ subject.default_blacklight_config.view.list
504
+ subject.default_blacklight_config.view.gallery
505
+ subject.default_blacklight_config.view.map
506
+ subject.default_blacklight_config.view.rss.if = false
507
+ subject.document_index_view_types = %w(list gallery rss)
508
+ end
509
+
510
+ it 'includes selected view types as the value true' do
511
+ expect(subject.document_index_view_types_selected_hash.to_h).to include list: true, gallery: true
512
+ end
513
+
514
+ it 'disabled view types are not included' do
515
+ expect(subject.document_index_view_types_selected_hash.to_h).not_to include :map
516
+ end
517
+
518
+ it 'excludes view types disabled by configuration (not by curator settings)' do
519
+ expect(subject.document_index_view_types_selected_hash.to_h).not_to include :rss
520
+ end
521
+ end
459
522
  end