hyrax 2.9.3 → 3.0.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (825) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +117 -175
  3. data/.gitignore +0 -1
  4. data/.travis.yml +33 -0
  5. data/README.md +14 -9
  6. data/app/actors/hyrax/actors/add_to_work_actor.rb +4 -23
  7. data/app/actors/hyrax/actors/attach_members_actor.rb +2 -9
  8. data/app/actors/hyrax/actors/collections_membership_actor.rb +11 -10
  9. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +1 -2
  10. data/app/actors/hyrax/actors/file_set_actor.rb +2 -2
  11. data/app/actors/hyrax/actors/transactional_request.rb +8 -8
  12. data/app/assets/javascripts/hyrax.js +0 -1
  13. data/app/assets/javascripts/hyrax/autocomplete.es6 +0 -29
  14. data/app/assets/javascripts/hyrax/collections/editor.es6 +2 -12
  15. data/app/assets/javascripts/hyrax/editor.es6 +10 -9
  16. data/app/assets/stylesheets/hyrax/_collections.scss +2 -16
  17. data/app/assets/stylesheets/hyrax/_featured.scss +4 -0
  18. data/app/assets/stylesheets/hyrax/_file-listing.scss +1 -2
  19. data/app/assets/stylesheets/hyrax/_forms.scss +0 -2
  20. data/app/assets/stylesheets/hyrax/_header.scss +1 -1
  21. data/app/assets/stylesheets/hyrax/_home-page.scss +13 -6
  22. data/app/assets/stylesheets/hyrax/_hyrax.scss +10 -10
  23. data/app/assets/stylesheets/hyrax/_login_signup.scss +20 -0
  24. data/app/assets/stylesheets/hyrax/_work-show.scss +42 -5
  25. data/app/controllers/concerns/hyrax/controller.rb +0 -14
  26. data/app/controllers/concerns/hyrax/local_file_downloads_controller_behavior.rb +1 -2
  27. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +7 -18
  28. data/app/controllers/hyrax/batch_edits_controller.rb +0 -7
  29. data/app/controllers/hyrax/dashboard/collections_controller.rb +2 -13
  30. data/app/controllers/hyrax/depositors_controller.rb +6 -4
  31. data/app/controllers/hyrax/downloads_controller.rb +1 -10
  32. data/app/controllers/hyrax/single_use_links_controller.rb +6 -6
  33. data/app/controllers/hyrax/single_use_links_viewer_controller.rb +5 -5
  34. data/app/controllers/hyrax/users_controller.rb +1 -1
  35. data/app/forms/hyrax/forms/workflow_responsibility_form.rb +3 -3
  36. data/app/helpers/hyrax/hyrax_helper_behavior.rb +0 -1
  37. data/app/indexers/hyrax/collection_indexer.rb +3 -1
  38. data/app/indexers/hyrax/deep_indexing_service.rb +12 -21
  39. data/app/indexers/hyrax/file_set_indexer.rb +0 -11
  40. data/app/jobs/import_url_job.rb +16 -9
  41. data/app/jobs/ingest_local_file_job.rb +0 -4
  42. data/app/models/concerns/hyrax/collection_behavior.rb +34 -8
  43. data/app/models/concerns/hyrax/solr_document/characterization.rb +1 -5
  44. data/app/models/concerns/hyrax/solr_document/metadata.rb +7 -9
  45. data/app/models/concerns/hyrax/solr_document_behavior.rb +0 -10
  46. data/app/models/concerns/hyrax/work_behavior.rb +0 -1
  47. data/app/models/hyrax/uploaded_file.rb +2 -0
  48. data/app/models/proxy_deposit_request.rb +12 -5
  49. data/app/models/single_use_link.rb +6 -3
  50. data/app/presenters/hyrax/collection_presenter.rb +1 -12
  51. data/app/presenters/hyrax/displays_image.rb +15 -41
  52. data/app/presenters/hyrax/file_set_presenter.rb +1 -6
  53. data/app/presenters/hyrax/member_presenter_factory.rb +7 -1
  54. data/app/presenters/hyrax/single_use_link_presenter.rb +2 -2
  55. data/app/search_builders/hyrax/catalog_search_builder.rb +28 -0
  56. data/app/search_builders/hyrax/embargo_search_builder.rb +1 -1
  57. data/app/search_builders/hyrax/lease_search_builder.rb +1 -1
  58. data/app/services/hyrax/batch_create_failure_service.rb +2 -2
  59. data/app/services/hyrax/batch_create_success_service.rb +2 -2
  60. data/app/services/hyrax/database_migrator.rb +0 -2
  61. data/app/services/hyrax/default_middleware_stack.rb +2 -4
  62. data/app/services/hyrax/file_set_csv_service.rb +0 -1
  63. data/app/services/hyrax/file_set_fixity_check_service.rb +0 -7
  64. data/app/services/hyrax/fixity_check_failure_service.rb +2 -2
  65. data/app/services/hyrax/import_url_failure_service.rb +1 -1
  66. data/app/services/hyrax/versioning_service.rb +0 -9
  67. data/app/services/hyrax/workflow/changes_required_notification.rb +4 -2
  68. data/app/services/hyrax/workflow/deposited_notification.rb +3 -2
  69. data/app/services/hyrax/workflow/pending_review_notification.rb +4 -2
  70. data/app/services/hyrax/workflow/workflow_schema.rb +32 -92
  71. data/app/views/catalog/_thumbnail_list_collection.html.erb +2 -3
  72. data/app/views/hyrax/admin/admin_sets/_form_participant_table.html.erb +2 -2
  73. data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +57 -52
  74. data/app/views/hyrax/base/_attribute_rows.html.erb +1 -1
  75. data/app/views/hyrax/base/_form.html.erb +2 -2
  76. data/app/views/hyrax/base/_form_progress.html.erb +0 -4
  77. data/app/views/hyrax/base/_guts4form.html.erb +1 -7
  78. data/app/views/hyrax/base/_items.html.erb +1 -1
  79. data/app/views/hyrax/base/_metadata.html.erb +2 -3
  80. data/app/views/hyrax/base/_relationships.html.erb +1 -2
  81. data/app/views/hyrax/base/_show_actions.html.erb +27 -22
  82. data/app/views/hyrax/base/_work_button_row.html.erb +49 -0
  83. data/app/views/hyrax/base/_work_title.erb +13 -18
  84. data/app/views/hyrax/base/_work_type.html.erb +2 -2
  85. data/app/views/hyrax/base/show.html.erb +26 -12
  86. data/app/views/hyrax/batch_uploads/_form.html.erb +1 -1
  87. data/app/views/hyrax/dashboard/_sidebar.html.erb +1 -1
  88. data/app/views/hyrax/dashboard/collections/_form_share.html.erb +67 -69
  89. data/app/views/hyrax/file_sets/_single_use_link_rows.html.erb +1 -1
  90. data/app/views/hyrax/homepage/_home_content.html.erb +4 -4
  91. data/app/views/hyrax/homepage/index.html.erb +21 -23
  92. data/config/features.rb +0 -4
  93. data/config/locales/hyrax.de.yml +40 -0
  94. data/config/locales/hyrax.en.yml +41 -1
  95. data/config/locales/hyrax.es.yml +40 -0
  96. data/config/locales/hyrax.fr.yml +40 -0
  97. data/config/locales/hyrax.it.yml +40 -0
  98. data/config/locales/hyrax.pt-BR.yml +51 -11
  99. data/config/locales/hyrax.zh.yml +40 -0
  100. data/hyrax.gemspec +19 -18
  101. data/lib/generators/hyrax/install_generator.rb +0 -1
  102. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +0 -5
  103. data/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +1 -1
  104. data/lib/generators/hyrax/templates/db/migrate/20180612002029_update_single_use_links_column_names.rb.erb +6 -0
  105. data/lib/generators/hyrax/templates/hyrax.scss +1 -0
  106. data/lib/hyrax.rb +0 -2
  107. data/lib/hyrax/configuration.rb +5 -27
  108. data/lib/hyrax/engine.rb +0 -1
  109. data/lib/hyrax/rails/routes.rb +0 -5
  110. data/lib/hyrax/specs/shared_specs.rb +0 -1
  111. data/lib/hyrax/version.rb +1 -1
  112. data/spec/.gitignore +1 -0
  113. data/spec/abilities/ability_spec.rb +183 -0
  114. data/spec/abilities/admin_ability_spec.rb +18 -0
  115. data/spec/abilities/admin_set_ability_spec.rb +177 -0
  116. data/spec/abilities/collection_ability_spec.rb +194 -0
  117. data/spec/abilities/collection_type_ability_spec.rb +72 -0
  118. data/spec/abilities/embargo_and_lease_ability_spec.rb +22 -0
  119. data/spec/abilities/file_set_abilities_spec.rb +70 -0
  120. data/spec/abilities/generic_work_abilities_spec.rb +63 -0
  121. data/spec/abilities/operation_ability_spec.rb +12 -0
  122. data/spec/abilities/permission_template_ability_spec.rb +145 -0
  123. data/spec/abilities/proxies_and_transfer_abilities_spec.rb +109 -0
  124. data/spec/abilities/solr_document_ability_spec.rb +27 -0
  125. data/spec/actors/hyrax/actors/apply_order_actor_spec.rb +92 -0
  126. data/spec/actors/hyrax/actors/apply_permission_template_actor_spec.rb +135 -0
  127. data/spec/actors/hyrax/actors/attach_members_actor_spec.rb +68 -0
  128. data/spec/actors/hyrax/actors/cleanup_file_sets_actor_spec.rb +24 -0
  129. data/spec/actors/hyrax/actors/cleanup_trophies_actor_spec.rb +25 -0
  130. data/spec/actors/hyrax/actors/collections_membership_actor_spec.rb +364 -0
  131. data/spec/actors/hyrax/actors/create_with_files_actor_spec.rb +60 -0
  132. data/spec/actors/hyrax/actors/create_with_files_ordered_members_actor_spec.rb +41 -0
  133. data/spec/actors/hyrax/actors/create_with_remote_files_actor_spec.rb +122 -0
  134. data/spec/actors/hyrax/actors/create_with_remote_files_ordered_members_actor_spec.rb +49 -0
  135. data/spec/actors/hyrax/actors/default_admin_set_actor_spec.rb +81 -0
  136. data/spec/actors/hyrax/actors/embargo_actor_spec.rb +37 -0
  137. data/spec/actors/hyrax/actors/featured_work_actor_spec.rb +38 -0
  138. data/spec/actors/hyrax/actors/file_actor_spec.rb +125 -0
  139. data/spec/actors/hyrax/actors/file_set_actor_spec.rb +347 -0
  140. data/spec/actors/hyrax/actors/file_set_ordered_members_actor_spec.rb +35 -0
  141. data/spec/actors/hyrax/actors/generic_work_actor_spec.rb +316 -0
  142. data/spec/actors/hyrax/actors/initialize_workflow_actor_spec.rb +35 -0
  143. data/spec/actors/hyrax/actors/interpret_visibility_actor_spec.rb +445 -0
  144. data/spec/actors/hyrax/actors/lease_actor_spec.rb +54 -0
  145. data/spec/actors/hyrax/actors/model_actor_spec.rb +24 -0
  146. data/spec/actors/hyrax/actors/optimistic_lock_validator_spec.rb +55 -0
  147. data/spec/actors/hyrax/actors/ordered_members_actor_spec.rb +59 -0
  148. data/spec/actors/hyrax/actors/transactional_request_spec.rb +44 -0
  149. data/spec/actors/hyrax/actors/transfer_request_actor_spec.rb +43 -0
  150. data/spec/authorities/qa/authorities/collections_spec.rb +68 -0
  151. data/spec/authorities/qa/authorities/find_works_spec.rb +52 -0
  152. data/spec/channels/hyrax/application_cable/channel_spec.rb +14 -0
  153. data/spec/channels/hyrax/application_cable/connection_spec.rb +37 -0
  154. data/spec/channels/hyrax/notifications_channel_spec.rb +45 -0
  155. data/spec/config/hyrax_events_spec.rb +44 -0
  156. data/spec/controllers/catalog_controller_spec.rb +135 -0
  157. data/spec/controllers/hyrax/accepts_batches_controller_spec.rb +67 -0
  158. data/spec/controllers/hyrax/admin/admin_sets_controller_spec.rb +284 -0
  159. data/spec/controllers/hyrax/admin/appearances_controller_spec.rb +66 -0
  160. data/spec/controllers/hyrax/admin/collection_type_participants_controller_spec.rb +152 -0
  161. data/spec/controllers/hyrax/admin/collection_types_controller_spec.rb +322 -0
  162. data/spec/controllers/hyrax/admin/features_controller_spec.rb +31 -0
  163. data/spec/controllers/hyrax/admin/permission_template_accesses_controller_spec.rb +101 -0
  164. data/spec/controllers/hyrax/admin/permission_templates_controller_spec.rb +71 -0
  165. data/spec/controllers/hyrax/admin/stats_controller_spec.rb +61 -0
  166. data/spec/controllers/hyrax/admin/strategies_controller_spec.rb +39 -0
  167. data/spec/controllers/hyrax/admin/users_controller_spec.rb +17 -0
  168. data/spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb +76 -0
  169. data/spec/controllers/hyrax/admin/workflows_controller_spec.rb +18 -0
  170. data/spec/controllers/hyrax/api/items_controller_spec.rb +404 -0
  171. data/spec/controllers/hyrax/api/zotero_controller_spec.rb +162 -0
  172. data/spec/controllers/hyrax/batch_edits_controller_spec.rb +232 -0
  173. data/spec/controllers/hyrax/batch_uploads_controller_spec.rb +131 -0
  174. data/spec/controllers/hyrax/citations_controller_spec.rb +61 -0
  175. data/spec/controllers/hyrax/collections_controller_spec.rb +126 -0
  176. data/spec/controllers/hyrax/contact_form_controller_spec.rb +96 -0
  177. data/spec/controllers/hyrax/content_blocks_controller_spec.rb +71 -0
  178. data/spec/controllers/hyrax/dashboard/collection_members_controller_spec.rb +408 -0
  179. data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +475 -0
  180. data/spec/controllers/hyrax/dashboard/nest_collections_controller_spec.rb +360 -0
  181. data/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb +155 -0
  182. data/spec/controllers/hyrax/dashboard/works_controller_spec.rb +13 -0
  183. data/spec/controllers/hyrax/dashboard_controller_spec.rb +42 -0
  184. data/spec/controllers/hyrax/depositors_controller_spec.rb +109 -0
  185. data/spec/controllers/hyrax/downloads_controller_spec.rb +145 -0
  186. data/spec/controllers/hyrax/embargoes_controller_spec.rb +147 -0
  187. data/spec/controllers/hyrax/featured_work_lists_controller_spec.rb +20 -0
  188. data/spec/controllers/hyrax/featured_works_controller_spec.rb +56 -0
  189. data/spec/controllers/hyrax/file_sets_controller_spec.rb +322 -0
  190. data/spec/controllers/hyrax/fixity_checks_controller_spec.rb +44 -0
  191. data/spec/controllers/hyrax/generic_works_controller_json_spec.rb +92 -0
  192. data/spec/controllers/hyrax/generic_works_controller_spec.rb +622 -0
  193. data/spec/controllers/hyrax/homepage_controller_spec.rb +138 -0
  194. data/spec/controllers/hyrax/leases_controller_spec.rb +117 -0
  195. data/spec/controllers/hyrax/my/collections_controller_spec.rb +36 -0
  196. data/spec/controllers/hyrax/my/highlights_controller_spec.rb +53 -0
  197. data/spec/controllers/hyrax/my/shares_controller_spec.rb +47 -0
  198. data/spec/controllers/hyrax/my/works_controller_spec.rb +54 -0
  199. data/spec/controllers/hyrax/notifications_controller_spec.rb +33 -0
  200. data/spec/controllers/hyrax/operations_controller_spec.rb +27 -0
  201. data/spec/controllers/hyrax/pages_controller_spec.rb +111 -0
  202. data/spec/controllers/hyrax/permissions_controller_spec.rb +56 -0
  203. data/spec/controllers/hyrax/resource_sync_controller_spec.rb +71 -0
  204. data/spec/controllers/hyrax/single_use_links_controller_spec.rb +100 -0
  205. data/spec/controllers/hyrax/single_use_links_viewer_controller_spec.rb +64 -0
  206. data/spec/controllers/hyrax/static_controller_spec.rb +28 -0
  207. data/spec/controllers/hyrax/stats_controller_spec.rb +73 -0
  208. data/spec/controllers/hyrax/transfers_controller_spec.rb +200 -0
  209. data/spec/controllers/hyrax/trophies_controller_spec.rb +40 -0
  210. data/spec/controllers/hyrax/uploads_controller_spec.rb +60 -0
  211. data/spec/controllers/hyrax/users_controller_spec.rb +151 -0
  212. data/spec/controllers/hyrax/workflow_actions_controller_spec.rb +54 -0
  213. data/spec/conversions/power_converters/polymorphic_type_spec.rb +22 -0
  214. data/spec/conversions/power_converters/sipity_action_name_spec.rb +32 -0
  215. data/spec/conversions/power_converters/sipity_action_spec.rb +43 -0
  216. data/spec/conversions/power_converters/sipity_agent_spec.rb +20 -0
  217. data/spec/conversions/power_converters/sipity_entity_spec.rb +53 -0
  218. data/spec/conversions/power_converters/sipity_role_spec.rb +31 -0
  219. data/spec/conversions/power_converters/sipity_workflow_id_spec.rb +28 -0
  220. data/spec/conversions/power_converters/sipity_workflow_state_spec.rb +20 -0
  221. data/spec/factories/admin_sets.rb +25 -0
  222. data/spec/factories/admin_sets_lw.rb +215 -0
  223. data/spec/factories/api_items.rb +91 -0
  224. data/spec/factories/collection_branding_infos.rb +11 -0
  225. data/spec/factories/collection_type_participants.rb +8 -0
  226. data/spec/factories/collection_types.rb +113 -0
  227. data/spec/factories/collections.rb +325 -0
  228. data/spec/factories/collections_factory.rb +134 -0
  229. data/spec/factories/content_blocks.rb +4 -0
  230. data/spec/factories/featured_works.rb +4 -0
  231. data/spec/factories/file_sets.rb +33 -0
  232. data/spec/factories/generic_works.rb +196 -0
  233. data/spec/factories/object_id.rb +6 -0
  234. data/spec/factories/operations.rb +21 -0
  235. data/spec/factories/permission_template_accesses.rb +16 -0
  236. data/spec/factories/permission_templates.rb +79 -0
  237. data/spec/factories/proxy_deposit_requests.rb +6 -0
  238. data/spec/factories/single_use_links.rb +13 -0
  239. data/spec/factories/sipity_entities.rb +7 -0
  240. data/spec/factories/uploaded_files.rb +5 -0
  241. data/spec/factories/users.rb +59 -0
  242. data/spec/factories/workflow_actions.rb +6 -0
  243. data/spec/factories/workflow_states.rb +6 -0
  244. data/spec/factories/workflows.rb +6 -0
  245. data/spec/factory_tests/adminsets_factory_spec.rb +132 -0
  246. data/spec/factory_tests/collections_factory_spec.rb +212 -0
  247. data/spec/features/admin_spec.rb +30 -0
  248. data/spec/features/batch_create_spec.rb +75 -0
  249. data/spec/features/batch_edit_spec.rb +119 -0
  250. data/spec/features/browse_catalog_spec.rb +59 -0
  251. data/spec/features/browse_dashboard_works_spec.rb +56 -0
  252. data/spec/features/catalog_search_spec.rb +72 -0
  253. data/spec/features/collection_multi_membership_spec.rb +205 -0
  254. data/spec/features/collection_spec.rb +122 -0
  255. data/spec/features/collection_type_spec.rb +393 -0
  256. data/spec/features/contact_form_spec.rb +16 -0
  257. data/spec/features/create_child_work_spec.rb +82 -0
  258. data/spec/features/create_work_admin_spec.rb +44 -0
  259. data/spec/features/create_work_spec.rb +124 -0
  260. data/spec/features/dashboard/all_works.rb +23 -0
  261. data/spec/features/dashboard/collection_spec.rb +918 -0
  262. data/spec/features/dashboard/display_admin_dashboard_spec.rb +29 -0
  263. data/spec/features/dashboard/display_dashboard_spec.rb +18 -0
  264. data/spec/features/delete_work_spec.rb +23 -0
  265. data/spec/features/edit_content_block_admin_spec.rb +62 -0
  266. data/spec/features/edit_file_spec.rb +23 -0
  267. data/spec/features/edit_work_spec.rb +61 -0
  268. data/spec/features/embargo_spec.rb +90 -0
  269. data/spec/features/homepage_spec.rb +43 -0
  270. data/spec/features/lease_spec.rb +35 -0
  271. data/spec/features/notifications_spec.rb +20 -0
  272. data/spec/features/ownership_transfer_spec.rb +101 -0
  273. data/spec/features/proxy_spec.rb +25 -0
  274. data/spec/features/search_spec.rb +62 -0
  275. data/spec/features/static_pages_spec.rb +7 -0
  276. data/spec/features/users_spec.rb +48 -0
  277. data/spec/features/work_generator_spec.rb +29 -0
  278. data/spec/features/work_show_spec.rb +145 -0
  279. data/spec/features/workflow_roles_spec.rb +46 -0
  280. data/spec/features/workflow_state_changes_spec.rb +59 -0
  281. data/spec/fixtures/1.5mb-avatar.jpg +0 -0
  282. data/spec/fixtures/4-20.png +0 -0
  283. data/spec/fixtures/Example.ogg +0 -0
  284. data/spec/fixtures/authorities/licenses.yml +13 -0
  285. data/spec/fixtures/charter.docx +0 -0
  286. data/spec/fixtures/config/schema_org.yml +7 -0
  287. data/spec/fixtures/config/schema_org_second.yml +7 -0
  288. data/spec/fixtures/countdown.avi +0 -0
  289. data/spec/fixtures/docx_fits.xml +21 -0
  290. data/spec/fixtures/dublin_core_rdf_descMetadata.nt +13 -0
  291. data/spec/fixtures/hyrax/.gitignore +1 -0
  292. data/spec/fixtures/hyrax/hyrax_test4.pdf +0 -0
  293. data/spec/fixtures/hyrax/hyrax_test5.mp3 +0 -0
  294. data/spec/fixtures/hyrax_generic_stub.txt +1 -0
  295. data/spec/fixtures/icons.zip +0 -0
  296. data/spec/fixtures/image.jp2 +0 -0
  297. data/spec/fixtures/image.jpg +0 -0
  298. data/spec/fixtures/image.png +0 -0
  299. data/spec/fixtures/jp2_fits.xml +36 -0
  300. data/spec/fixtures/jpg_fits.xml +43 -0
  301. data/spec/fixtures/mp3_fits.xml +32 -0
  302. data/spec/fixtures/pdf_fits.xml +43 -0
  303. data/spec/fixtures/piano_note.wav +0 -0
  304. data/spec/fixtures/png_fits.xml +29 -0
  305. data/spec/fixtures/sample_mpeg4.mp4 +0 -0
  306. data/spec/fixtures/small_file.txt +1 -0
  307. data/spec/fixtures/spoken-text.m4a +0 -0
  308. data/spec/fixtures/txt_fits.xml +29 -0
  309. data/spec/fixtures/world.png +0 -0
  310. data/spec/fixtures/xls_fits.xml +18 -0
  311. data/spec/fixtures/xml_fits.xml +37 -0
  312. data/spec/forms/hyrax/forms/admin/appearance_spec.rb +46 -0
  313. data/spec/forms/hyrax/forms/admin/collection_type_form_spec.rb +108 -0
  314. data/spec/forms/hyrax/forms/admin/collection_type_participant_form_spec.rb +10 -0
  315. data/spec/forms/hyrax/forms/admin_set_form_spec.rb +88 -0
  316. data/spec/forms/hyrax/forms/batch_edit_form_spec.rb +111 -0
  317. data/spec/forms/hyrax/forms/batch_upload_form_spec.rb +75 -0
  318. data/spec/forms/hyrax/forms/collection_form_spec.rb +196 -0
  319. data/spec/forms/hyrax/forms/dashboard/nest_collection_form_spec.rb +159 -0
  320. data/spec/forms/hyrax/forms/file_manager_form_spec.rb +19 -0
  321. data/spec/forms/hyrax/forms/file_set_edit_form_spec.rb +53 -0
  322. data/spec/forms/hyrax/forms/permission_template_form_spec.rb +599 -0
  323. data/spec/forms/hyrax/forms/work_form_spec.rb +346 -0
  324. data/spec/forms/hyrax/forms/workflow_action_form_spec.rb +129 -0
  325. data/spec/forms/hyrax/forms/workflow_responsibility_form_spec.rb +41 -0
  326. data/spec/forms/hyrax/generic_work_form_spec.rb +127 -0
  327. data/spec/helpers/blacklight_helper_spec.rb +137 -0
  328. data/spec/helpers/hyrax/ability_helper_spec.rb +61 -0
  329. data/spec/helpers/hyrax/batch_edits_helper_spec.rb +59 -0
  330. data/spec/helpers/hyrax/charts_helper_spec.rb +63 -0
  331. data/spec/helpers/hyrax/citations_behaviors/formatters/chicago_formatter_spec.rb +10 -0
  332. data/spec/helpers/hyrax/collections_helper_spec.rb +117 -0
  333. data/spec/helpers/hyrax/content_block_helper_spec.rb +44 -0
  334. data/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb +74 -0
  335. data/spec/helpers/hyrax/file_set_helper_spec.rb +65 -0
  336. data/spec/helpers/hyrax/iiif_helper_spec.rb +44 -0
  337. data/spec/helpers/hyrax/trophy_helper_spec.rb +37 -0
  338. data/spec/helpers/hyrax_helper_spec.rb +399 -0
  339. data/spec/hyrax/transactions/create_work_spec.rb +155 -0
  340. data/spec/hyrax/transactions/steps/apply_permission_template_spec.rb +72 -0
  341. data/spec/hyrax/transactions/steps/ensure_admin_set_spec.rb +25 -0
  342. data/spec/hyrax/transactions/steps/ensure_permission_template_spec.rb +33 -0
  343. data/spec/hyrax/transactions/steps/save_work_spec.rb +32 -0
  344. data/spec/hyrax/transactions/steps/set_default_admin_set_spec.rb +38 -0
  345. data/spec/hyrax/transactions/steps/set_modified_date_spec.rb +22 -0
  346. data/spec/hyrax/transactions/steps/set_uploaded_date_spec.rb +32 -0
  347. data/spec/indexers/hyrax/collection_indexer_spec.rb +43 -0
  348. data/spec/indexers/hyrax/file_set_indexer_spec.rb +125 -0
  349. data/spec/indexers/hyrax/generic_work_indexer_spec.rb +123 -0
  350. data/spec/indexers/hyrax/repository_reindexer_spec.rb +8 -0
  351. data/spec/inputs/controlled_vocabulary_input_spec.rb +57 -0
  352. data/spec/inputs/multifile_input_spec.rb +31 -0
  353. data/spec/javascripts/authority_select_spec.js +22 -0
  354. data/spec/javascripts/autocomplete_spec.js.coffee +199 -0
  355. data/spec/javascripts/batch_select_spec.js +15 -0
  356. data/spec/javascripts/charts_spec.coffee +10 -0
  357. data/spec/javascripts/checklist_item_spec.js +23 -0
  358. data/spec/javascripts/deposit_agreement_spec.js +70 -0
  359. data/spec/javascripts/file_manager_member_spec.coffee +88 -0
  360. data/spec/javascripts/file_manager_sorting_spec.coffee +23 -0
  361. data/spec/javascripts/fixtures/chart_example.html +1 -0
  362. data/spec/javascripts/fixtures/dashboard_batch_forms.html +11 -0
  363. data/spec/javascripts/fixtures/file_manager_member.html +40 -0
  364. data/spec/javascripts/fixtures/save_button.html +3 -0
  365. data/spec/javascripts/fixtures/sortable.html +182 -0
  366. data/spec/javascripts/fixtures/sul_table.html +29 -0
  367. data/spec/javascripts/grant_spec.js +43 -0
  368. data/spec/javascripts/helpers/jasmine-ajax.js +751 -0
  369. data/spec/javascripts/helpers/jasmine-jquery.js +838 -0
  370. data/spec/javascripts/helpers/test_fixtures.js.coffee +18 -0
  371. data/spec/javascripts/helpers/test_responses.js +12 -0
  372. data/spec/javascripts/jasmine_spec.rb +25 -0
  373. data/spec/javascripts/relationships_control_spec.js.coffee +27 -0
  374. data/spec/javascripts/required_field_spec.js +41 -0
  375. data/spec/javascripts/save_manager_spec.coffee +87 -0
  376. data/spec/javascripts/save_work_spec.js +262 -0
  377. data/spec/javascripts/settings_spec.js +74 -0
  378. data/spec/javascripts/single_use_links_spec.coffee +51 -0
  379. data/spec/javascripts/support/jasmine.yml +125 -0
  380. data/spec/javascripts/support/jasmine_helper.rb +14 -0
  381. data/spec/javascripts/tabs_spec.js.coffee +38 -0
  382. data/spec/javascripts/uploaded_files_spec.js +23 -0
  383. data/spec/javascripts/visibility_component_spec.js +531 -0
  384. data/spec/jobs/attach_files_to_work_job_spec.rb +80 -0
  385. data/spec/jobs/attach_files_to_work_with_ordered_members_job_spec.rb +13 -0
  386. data/spec/jobs/batch_create_job_spec.rb +79 -0
  387. data/spec/jobs/characterize_job_spec.rb +66 -0
  388. data/spec/jobs/content_delete_event_job_spec.rb +36 -0
  389. data/spec/jobs/content_deposit_event_job_spec.rb +25 -0
  390. data/spec/jobs/content_depositor_change_event_job_spec.rb +28 -0
  391. data/spec/jobs/content_new_version_event_job_spec.rb +21 -0
  392. data/spec/jobs/content_restored_version_event_job_spec.rb +28 -0
  393. data/spec/jobs/content_update_event_job_spec.rb +25 -0
  394. data/spec/jobs/create_derivatives_job_spec.rb +93 -0
  395. data/spec/jobs/create_work_job_spec.rb +60 -0
  396. data/spec/jobs/file_set_attached_event_job_spec.rb +34 -0
  397. data/spec/jobs/fixity_check_job_spec.rb +50 -0
  398. data/spec/jobs/hyrax/grant_edit_job_spec.rb +11 -0
  399. data/spec/jobs/hyrax/grant_edit_to_members_job_spec.rb +16 -0
  400. data/spec/jobs/hyrax/grant_read_job_spec.rb +11 -0
  401. data/spec/jobs/hyrax/grant_read_to_members_job_spec.rb +16 -0
  402. data/spec/jobs/hyrax/revoke_edit_from_members_job_spec.rb +16 -0
  403. data/spec/jobs/hyrax/revoke_edit_job_spec.rb +11 -0
  404. data/spec/jobs/import_export_job_spec.rb +28 -0
  405. data/spec/jobs/import_url_job_spec.rb +133 -0
  406. data/spec/jobs/ingest_local_file_job_spec.rb +16 -0
  407. data/spec/jobs/inherit_permissions_job_spec.rb +94 -0
  408. data/spec/jobs/stream_notifications_job_spec.rb +45 -0
  409. data/spec/jobs/user_edit_profile_event_job_spec.rb +17 -0
  410. data/spec/jobs/visibility_copy_job_spec.rb +53 -0
  411. data/spec/lib/hyrax/analytics_spec.rb +65 -0
  412. data/spec/lib/hyrax/arkivo/actor_spec.rb +78 -0
  413. data/spec/lib/hyrax/arkivo/create_subscription_job_spec.rb +50 -0
  414. data/spec/lib/hyrax/arkivo/metadata_munger_spec.rb +46 -0
  415. data/spec/lib/hyrax/arkivo/schema_validator_spec.rb +63 -0
  416. data/spec/lib/hyrax/arkivo_spec.rb +12 -0
  417. data/spec/lib/hyrax/collections/search_service_spec.rb +35 -0
  418. data/spec/lib/hyrax/configuration_spec.rb +85 -0
  419. data/spec/lib/hyrax/controlled_vocabulary/importer/downloader_spec.rb +33 -0
  420. data/spec/lib/hyrax/controlled_vocabulary/importer/language_spec.rb +24 -0
  421. data/spec/lib/hyrax/move_all_works_to_admin_set_spec.rb +13 -0
  422. data/spec/lib/hyrax/name_spec.rb +21 -0
  423. data/spec/lib/hyrax/redis_event_store_spec.rb +54 -0
  424. data/spec/lib/hyrax/resource_sync/capability_list_writer_spec.rb +33 -0
  425. data/spec/lib/hyrax/resource_sync/change_list_writer_spec.rb +64 -0
  426. data/spec/lib/hyrax/resource_sync/resource_list_writer_spec.rb +25 -0
  427. data/spec/lib/hyrax/resource_sync/source_description_writer_spec.rb +18 -0
  428. data/spec/lib/hyrax/role_registry_spec.rb +43 -0
  429. data/spec/lib/hyrax/search_state_spec.rb +26 -0
  430. data/spec/lib/hyrax/zotero/config_spec.rb +26 -0
  431. data/spec/lib/hyrax/zotero_spec.rb +9 -0
  432. data/spec/lib/hyrax_spec.rb +9 -0
  433. data/spec/models/admin_set_spec.rb +229 -0
  434. data/spec/models/batch_upload_item_spec.rb +7 -0
  435. data/spec/models/checksum_audit_log_spec.rb +162 -0
  436. data/spec/models/collection_branding_info_spec.rb +61 -0
  437. data/spec/models/collection_spec.rb +326 -0
  438. data/spec/models/concerns/hyrax/collection_nesting_spec.rb +83 -0
  439. data/spec/models/content_block_spec.rb +198 -0
  440. data/spec/models/featured_work_list_spec.rb +56 -0
  441. data/spec/models/featured_work_spec.rb +53 -0
  442. data/spec/models/file_download_stat_spec.rb +104 -0
  443. data/spec/models/file_set_spec.rb +668 -0
  444. data/spec/models/file_view_stat_spec.rb +81 -0
  445. data/spec/models/flipflop_spec.rb +49 -0
  446. data/spec/models/generic_work_spec.rb +117 -0
  447. data/spec/models/hyrax/batch_create_operation_spec.rb +59 -0
  448. data/spec/models/hyrax/collection_type_participant_spec.rb +43 -0
  449. data/spec/models/hyrax/collection_type_spec.rb +236 -0
  450. data/spec/models/hyrax/download_spec.rb +13 -0
  451. data/spec/models/hyrax/operation_spec.rb +123 -0
  452. data/spec/models/hyrax/pageview_spec.rb +13 -0
  453. data/spec/models/hyrax/permission_template_access_spec.rb +180 -0
  454. data/spec/models/hyrax/permission_template_spec.rb +291 -0
  455. data/spec/models/hyrax/permissions/readable_permissions_spec.rb +52 -0
  456. data/spec/models/hyrax/permissions/writable_permissions_spec.rb +12 -0
  457. data/spec/models/hyrax/uploaded_file_spec.rb +10 -0
  458. data/spec/models/hyrax/user_usage_stats_spec.rb +43 -0
  459. data/spec/models/hyrax/work_behavior_spec.rb +63 -0
  460. data/spec/models/job_io_wrapper_spec.rb +172 -0
  461. data/spec/models/proxy_deposit_request_spec.rb +170 -0
  462. data/spec/models/single_use_link_spec.rb +51 -0
  463. data/spec/models/sipity/agent_spec.rb +8 -0
  464. data/spec/models/sipity/comment_spec.rb +24 -0
  465. data/spec/models/sipity/entity_spec.rb +27 -0
  466. data/spec/models/sipity/entity_specific_responsibility_spec.rb +9 -0
  467. data/spec/models/sipity/notifiable_context_spec.rb +7 -0
  468. data/spec/models/sipity/notification_recipient_spec.rb +9 -0
  469. data/spec/models/sipity/notification_spec.rb +15 -0
  470. data/spec/models/sipity/role_spec.rb +40 -0
  471. data/spec/models/sipity/workflow_action_spec.rb +11 -0
  472. data/spec/models/sipity/workflow_responsibility_spec.rb +8 -0
  473. data/spec/models/sipity/workflow_role_spec.rb +8 -0
  474. data/spec/models/sipity/workflow_spec.rb +84 -0
  475. data/spec/models/sipity/workflow_state_action_permission_spec.rb +8 -0
  476. data/spec/models/sipity/workflow_state_action_spec.rb +8 -0
  477. data/spec/models/sipity/workflow_state_spec.rb +17 -0
  478. data/spec/models/solr_document_spec.rb +205 -0
  479. data/spec/models/trophy_spec.rb +19 -0
  480. data/spec/models/user_mailbox_spec.rb +134 -0
  481. data/spec/models/user_spec.rb +269 -0
  482. data/spec/models/work_view_stat_spec.rb +107 -0
  483. data/spec/presenters/hyrax/admin/dashboard_presenter_spec.rb +33 -0
  484. data/spec/presenters/hyrax/admin/repository_growth_presenter_spec.rb +25 -0
  485. data/spec/presenters/hyrax/admin/repository_object_presenter_spec.rb +24 -0
  486. data/spec/presenters/hyrax/admin/user_activity_presenter_spec.rb +20 -0
  487. data/spec/presenters/hyrax/admin/users_presenter_spec.rb +48 -0
  488. data/spec/presenters/hyrax/admin/workflow_role_presenter_spec.rb +12 -0
  489. data/spec/presenters/hyrax/admin/workflow_roles_presenter_spec.rb +16 -0
  490. data/spec/presenters/hyrax/admin_set_options_presenter_spec.rb +73 -0
  491. data/spec/presenters/hyrax/admin_set_presenter_spec.rb +143 -0
  492. data/spec/presenters/hyrax/admin_stats_presenter_spec.rb +143 -0
  493. data/spec/presenters/hyrax/collection_options_presenter_spec.rb +15 -0
  494. data/spec/presenters/hyrax/collection_presenter_spec.rb +461 -0
  495. data/spec/presenters/hyrax/dashboard/user_presenter_spec.rb +65 -0
  496. data/spec/presenters/hyrax/embargo_presenter_spec.rb +51 -0
  497. data/spec/presenters/hyrax/file_set_presenter_spec.rb +426 -0
  498. data/spec/presenters/hyrax/file_usage_spec.rb +162 -0
  499. data/spec/presenters/hyrax/fixity_status_presenter_spec.rb +55 -0
  500. data/spec/presenters/hyrax/homepage_presenter_spec.rb +42 -0
  501. data/spec/presenters/hyrax/inspect_work_presenter_spec.rb +59 -0
  502. data/spec/presenters/hyrax/lease_presenter_spec.rb +51 -0
  503. data/spec/presenters/hyrax/member_presenter_factory_spec.rb +26 -0
  504. data/spec/presenters/hyrax/menu_presenter_spec.rb +107 -0
  505. data/spec/presenters/hyrax/permission_badge_spec.rb +77 -0
  506. data/spec/presenters/hyrax/presenter_factory_spec.rb +53 -0
  507. data/spec/presenters/hyrax/presenter_renderer_spec.rb +30 -0
  508. data/spec/presenters/hyrax/select_collection_type_list_presenter_spec.rb +59 -0
  509. data/spec/presenters/hyrax/select_collection_type_presenter_spec.rb +10 -0
  510. data/spec/presenters/hyrax/select_type_list_presenter_spec.rb +37 -0
  511. data/spec/presenters/hyrax/select_type_presenter_spec.rb +74 -0
  512. data/spec/presenters/hyrax/single_use_link_presenter_spec.rb +41 -0
  513. data/spec/presenters/hyrax/transfers_presenter_spec.rb +44 -0
  514. data/spec/presenters/hyrax/trophy_presenter_spec.rb +53 -0
  515. data/spec/presenters/hyrax/twitter_presenter_spec.rb +27 -0
  516. data/spec/presenters/hyrax/user_profile_presenter_spec.rb +28 -0
  517. data/spec/presenters/hyrax/version_list_presenter_spec.rb +30 -0
  518. data/spec/presenters/hyrax/version_presenter_spec.rb +57 -0
  519. data/spec/presenters/hyrax/work_show_presenter_spec.rb +580 -0
  520. data/spec/presenters/hyrax/work_usage_spec.rb +144 -0
  521. data/spec/presenters/hyrax/workflow_presenter_spec.rb +75 -0
  522. data/spec/rails_helper.rb +2 -0
  523. data/spec/renderers/hyrax/renderers/attribute_renderer_spec.rb +118 -0
  524. data/spec/renderers/hyrax/renderers/date_attribute_renderer_spec.rb +39 -0
  525. data/spec/renderers/hyrax/renderers/external_link_attribute_renderer_spec.rb +22 -0
  526. data/spec/renderers/hyrax/renderers/faceted_attribute_renderer_spec.rb +35 -0
  527. data/spec/renderers/hyrax/renderers/license_attribute_renderer_spec.rb +21 -0
  528. data/spec/renderers/hyrax/renderers/linked_attribute_renderer_spec.rb +21 -0
  529. data/spec/renderers/hyrax/renderers/rights_statement_attribute_renderer_spec.rb +29 -0
  530. data/spec/requests/legacy_routing_spec.rb +7 -0
  531. data/spec/requests/riiif_spec.rb +32 -0
  532. data/spec/routing/admin_routes_spec.rb +29 -0
  533. data/spec/routing/api_route_spec.rb +89 -0
  534. data/spec/routing/citations_route_spec.rb +21 -0
  535. data/spec/routing/collection_permission_templates_routes_spec.rb +31 -0
  536. data/spec/routing/collection_types_routes.rb +35 -0
  537. data/spec/routing/dashboard_routes_spec.rb +37 -0
  538. data/spec/routing/featured_works_route_spec.rb +15 -0
  539. data/spec/routing/operations_spec.rb +9 -0
  540. data/spec/routing/ownership_transfers_route_spec.rb +43 -0
  541. data/spec/routing/resource_sync_spec.rb +19 -0
  542. data/spec/routing/route_spec.rb +205 -0
  543. data/spec/routing/single_use_link_spec.rb +27 -0
  544. data/spec/routing/stats_route_spec.rb +21 -0
  545. data/spec/search_builders/hyrax/abstract_type_relation_spec.rb +18 -0
  546. data/spec/search_builders/hyrax/admin_admin_set_member_search_builder_spec.rb +39 -0
  547. data/spec/search_builders/hyrax/admin_set_search_builder_spec.rb +78 -0
  548. data/spec/search_builders/hyrax/catalog_search_builder_spec.rb +86 -0
  549. data/spec/search_builders/hyrax/collection_member_search_builder_spec.rb +53 -0
  550. data/spec/search_builders/hyrax/collection_search_builder_spec.rb +74 -0
  551. data/spec/search_builders/hyrax/dashboard/collections_search_builder_spec.rb +103 -0
  552. data/spec/search_builders/hyrax/dashboard/nested_collections_search_builder_spec.rb +85 -0
  553. data/spec/search_builders/hyrax/dashboard/works_search_builder_spec.rb +44 -0
  554. data/spec/search_builders/hyrax/embargo_search_builder_spec.rb +17 -0
  555. data/spec/search_builders/hyrax/file_set_search_builder_spec.rb +28 -0
  556. data/spec/search_builders/hyrax/lease_search_builder_spec.rb +17 -0
  557. data/spec/search_builders/hyrax/my/collections_search_builder_spec.rb +35 -0
  558. data/spec/search_builders/hyrax/my/find_works_search_builder_spec.rb +63 -0
  559. data/spec/search_builders/hyrax/my/shares_search_builder_spec.rb +32 -0
  560. data/spec/search_builders/hyrax/my/works_search_builder_spec.rb +52 -0
  561. data/spec/search_builders/hyrax/parent_collection_search_builder_spec.rb +15 -0
  562. data/spec/search_builders/hyrax/single_admin_set_search_builder_spec.rb +20 -0
  563. data/spec/search_builders/hyrax/stats/work_status_search_builder_spec.rb +32 -0
  564. data/spec/search_builders/hyrax/work_relation_spec.rb +9 -0
  565. data/spec/search_builders/hyrax/work_search_builder_spec.rb +106 -0
  566. data/spec/search_builders/hyrax/works_search_builder_spec.rb +23 -0
  567. data/spec/services/hyrax/abstract_message_service_spec.rb +25 -0
  568. data/spec/services/hyrax/adapters/nesting_index_adapter_spec.rb +205 -0
  569. data/spec/services/hyrax/admin_set_create_service_spec.rb +114 -0
  570. data/spec/services/hyrax/admin_set_member_service_spec.rb +21 -0
  571. data/spec/services/hyrax/admin_set_service_spec.rb +171 -0
  572. data/spec/services/hyrax/batch_create_failure_service_spec.rb +18 -0
  573. data/spec/services/hyrax/batch_create_success_service_spec.rb +15 -0
  574. data/spec/services/hyrax/change_content_depositor_service_spec.rb +49 -0
  575. data/spec/services/hyrax/collection_member_service_spec.rb +19 -0
  576. data/spec/services/hyrax/collection_types/create_service_spec.rb +127 -0
  577. data/spec/services/hyrax/collection_types/permissions_service_spec.rb +297 -0
  578. data/spec/services/hyrax/collections/collection_member_service_spec.rb +49 -0
  579. data/spec/services/hyrax/collections/managed_collections_service_spec.rb +17 -0
  580. data/spec/services/hyrax/collections/migration_service_spec.rb +467 -0
  581. data/spec/services/hyrax/collections/nested_collection_persistence_service_spec.rb +28 -0
  582. data/spec/services/hyrax/collections/nested_collection_query_service_spec.rb +353 -0
  583. data/spec/services/hyrax/collections/permissions_create_service_spec.rb +64 -0
  584. data/spec/services/hyrax/collections/permissions_service_spec.rb +380 -0
  585. data/spec/services/hyrax/collections_service_spec.rb +62 -0
  586. data/spec/services/hyrax/curation_concern_spec.rb +18 -0
  587. data/spec/services/hyrax/database_migrator_spec.rb +20 -0
  588. data/spec/services/hyrax/default_middleware_stack_spec.rb +36 -0
  589. data/spec/services/hyrax/derivative_path_spec.rb +65 -0
  590. data/spec/services/hyrax/derivative_service_spec.rb +49 -0
  591. data/spec/services/hyrax/embargo_service_spec.rb +59 -0
  592. data/spec/services/hyrax/file_set_csv_service_spec.rb +83 -0
  593. data/spec/services/hyrax/file_set_derivatives_service_spec.rb +13 -0
  594. data/spec/services/hyrax/file_set_fixity_check_service_spec.rb +77 -0
  595. data/spec/services/hyrax/fixity_check_failure_service_spec.rb +30 -0
  596. data/spec/services/hyrax/graph_exporter_spec.rb +58 -0
  597. data/spec/services/hyrax/iiif_authorization_service_spec.rb +43 -0
  598. data/spec/services/hyrax/import_url_failure_service_spec.rb +23 -0
  599. data/spec/services/hyrax/lease_service_spec.rb +50 -0
  600. data/spec/services/hyrax/license_service_spec.rb +34 -0
  601. data/spec/services/hyrax/lock_manager_spec.rb +13 -0
  602. data/spec/services/hyrax/messenger_service_spec.rb +15 -0
  603. data/spec/services/hyrax/microdata_spec.rb +94 -0
  604. data/spec/services/hyrax/multiple_membership_checker_spec.rb +155 -0
  605. data/spec/services/hyrax/noid_spec.rb +37 -0
  606. data/spec/services/hyrax/permission_template_applicator_spec.rb +69 -0
  607. data/spec/services/hyrax/persist_derivatives_spec.rb +22 -0
  608. data/spec/services/hyrax/persist_directly_contained_output_file_service_spec.rb +20 -0
  609. data/spec/services/hyrax/qa_select_service_spec.rb +109 -0
  610. data/spec/services/hyrax/quick_classification_query_spec.rb +38 -0
  611. data/spec/services/hyrax/repository_fixity_check_service_spec.rb +16 -0
  612. data/spec/services/hyrax/resource_types_service_spec.rb +38 -0
  613. data/spec/services/hyrax/rights_statement_service_spec.rb +9 -0
  614. data/spec/services/hyrax/statistics/collections/over_time_spec.rb +17 -0
  615. data/spec/services/hyrax/statistics/depositors/summary_spec.rb +66 -0
  616. data/spec/services/hyrax/statistics/file_sets/by_format_spec.rb +29 -0
  617. data/spec/services/hyrax/statistics/query_service_spec.rb +112 -0
  618. data/spec/services/hyrax/statistics/system_stats_spec.rb +45 -0
  619. data/spec/services/hyrax/statistics/users/over_time_spec.rb +22 -0
  620. data/spec/services/hyrax/statistics/works/by_depositor_spec.rb +24 -0
  621. data/spec/services/hyrax/statistics/works/by_resource_type_spec.rb +21 -0
  622. data/spec/services/hyrax/statistics/works/count_spec.rb +33 -0
  623. data/spec/services/hyrax/statistics/works/over_time_spec.rb +17 -0
  624. data/spec/services/hyrax/thumbnail_path_service_spec.rb +55 -0
  625. data/spec/services/hyrax/tolerant_select_service_spec.rb +80 -0
  626. data/spec/services/hyrax/user_stat_importer_spec.rb +315 -0
  627. data/spec/services/hyrax/versioning_service_spec.rb +26 -0
  628. data/spec/services/hyrax/work_query_service_spec.rb +56 -0
  629. data/spec/services/hyrax/workflow/action_taken_service_spec.rb +74 -0
  630. data/spec/services/hyrax/workflow/activate_object_spec.rb +26 -0
  631. data/spec/services/hyrax/workflow/changes_required_notification_spec.rb +35 -0
  632. data/spec/services/hyrax/workflow/deactivate_object_spec.rb +26 -0
  633. data/spec/services/hyrax/workflow/deposited_notification_spec.rb +35 -0
  634. data/spec/services/hyrax/workflow/grant_edit_to_depositor_spec.rb +53 -0
  635. data/spec/services/hyrax/workflow/grant_read_to_depositor_spec.rb +48 -0
  636. data/spec/services/hyrax/workflow/method_generator_spec.rb +42 -0
  637. data/spec/services/hyrax/workflow/notification_configuration_parameter_spec.rb +24 -0
  638. data/spec/services/hyrax/workflow/notification_generator_spec.rb +27 -0
  639. data/spec/services/hyrax/workflow/notification_service_spec.rb +87 -0
  640. data/spec/services/hyrax/workflow/pending_review_notification_spec.rb +34 -0
  641. data/spec/services/hyrax/workflow/permission_generator_spec.rb +50 -0
  642. data/spec/services/hyrax/workflow/permission_query_spec.rb +206 -0
  643. data/spec/services/hyrax/workflow/revoke_edit_from_depositor_spec.rb +48 -0
  644. data/spec/services/hyrax/workflow/sipity_actions_generator_spec.rb +40 -0
  645. data/spec/services/hyrax/workflow/state_machine_generator_spec.rb +45 -0
  646. data/spec/services/hyrax/workflow/status_list_service_spec.rb +67 -0
  647. data/spec/services/hyrax/workflow/workflow_factory_spec.rb +26 -0
  648. data/spec/services/hyrax/workflow/workflow_importer_spec.rb +241 -0
  649. data/spec/services/hyrax/workflow/workflow_permissions_generator_spec.rb +39 -0
  650. data/spec/services/hyrax/workflow/workflow_schema_spec.rb +86 -0
  651. data/spec/services/hyrax/working_directory_spec.rb +12 -0
  652. data/spec/services/hyrax/works/managed_works_service_spec.rb +17 -0
  653. data/spec/spec_helper.rb +294 -0
  654. data/spec/strategies/hyrax/strategies/yaml_strategy_spec.rb +30 -0
  655. data/spec/support/controller_level_helpers.rb +27 -0
  656. data/spec/support/factory_helpers.rb +24 -0
  657. data/spec/support/fakes/fake_authority.rb +13 -0
  658. data/spec/support/features.rb +10 -0
  659. data/spec/support/features/batch_edit_actions.rb +28 -0
  660. data/spec/support/features/session_helpers.rb +14 -0
  661. data/spec/support/features/workflow.rb +9 -0
  662. data/spec/support/input_support.rb +11 -0
  663. data/spec/support/logging_formatter.rb +66 -0
  664. data/spec/support/matchers/api_responses.rb +26 -0
  665. data/spec/support/matchers/collection_type_property_matchers.rb +29 -0
  666. data/spec/support/matchers/response_matchers.rb +7 -0
  667. data/spec/support/optional_example.rb +16 -0
  668. data/spec/support/rake.rb +41 -0
  669. data/spec/support/selectors.rb +91 -0
  670. data/spec/support/spec_statistic.rb +23 -0
  671. data/spec/support/speedup.rb +6 -0
  672. data/spec/support/statistic_helper.rb +9 -0
  673. data/spec/tasks/rake_spec.rb +27 -0
  674. data/spec/test_app_templates/Gemfile.extra +6 -0
  675. data/spec/test_app_templates/disable_animations_in_test_environment.rb +54 -0
  676. data/spec/test_app_templates/lib/generators/test_app_generator.rb +125 -0
  677. data/spec/views/_flash_msg.html.erb_spec.rb +32 -0
  678. data/spec/views/_user_util_links.html.erb_spec.rb +44 -0
  679. data/spec/views/catalog/_index_list_default.html.erb_spec.rb +43 -0
  680. data/spec/views/catalog/_search_form.html.erb_spec.rb +16 -0
  681. data/spec/views/catalog/_thumbnail_list_collection.html.erb_spec.rb +10 -0
  682. data/spec/views/catalog/index.html.erb_spec.rb +50 -0
  683. data/spec/views/content_blocks/edit.html.erb_spec.rb +21 -0
  684. data/spec/views/hyrax/admin/admin_sets/_form.html.erb_spec.rb +29 -0
  685. data/spec/views/hyrax/admin/admin_sets/_form_participant_table.html.erb_spec.rb +128 -0
  686. data/spec/views/hyrax/admin/admin_sets/_form_participants.html.erb_spec.rb +19 -0
  687. data/spec/views/hyrax/admin/admin_sets/_form_visibility.html.erb_spec.rb +24 -0
  688. data/spec/views/hyrax/admin/admin_sets/_form_workflow.html.erb_spec.rb +22 -0
  689. data/spec/views/hyrax/admin/admin_sets/_show_actions.html.erb_spec.rb +68 -0
  690. data/spec/views/hyrax/admin/admin_sets/_show_document_list.html.erb_spec.rb +13 -0
  691. data/spec/views/hyrax/admin/admin_sets/_show_document_list_row.html.erb_spec.rb +28 -0
  692. data/spec/views/hyrax/admin/admin_sets/index.html.erb_spec.rb +40 -0
  693. data/spec/views/hyrax/admin/admin_sets/index.json.erb_spec.rb +29 -0
  694. data/spec/views/hyrax/admin/admin_sets/show.html.erb_spec.rb +21 -0
  695. data/spec/views/hyrax/admin/collection_types/_form.html.erb_spec.rb +45 -0
  696. data/spec/views/hyrax/admin/collection_types/_form_appearance.html.erb_spec.rb +22 -0
  697. data/spec/views/hyrax/admin/collection_types/_form_metadata.html.erb_spec.rb +27 -0
  698. data/spec/views/hyrax/admin/collection_types/_form_metadata_admin_set.html.erb_spec.rb +27 -0
  699. data/spec/views/hyrax/admin/collection_types/_form_participants.html.erb_spec.rb +24 -0
  700. data/spec/views/hyrax/admin/collection_types/_form_participants_table.html.erb_spec.rb +73 -0
  701. data/spec/views/hyrax/admin/collection_types/_form_settings.html.erb_spec.rb +86 -0
  702. data/spec/views/hyrax/admin/collection_types/index.html.erb_spec.rb +62 -0
  703. data/spec/views/hyrax/admin/features/index.html.erb_spec.rb +15 -0
  704. data/spec/views/hyrax/admin/stats/show.html.erb_spec.rb +54 -0
  705. data/spec/views/hyrax/admin/users/index.html.erb_spec.rb +45 -0
  706. data/spec/views/hyrax/admin/workflow_roles/index.html.erb_spec.rb +40 -0
  707. data/spec/views/hyrax/base/_attribute_rows.html.erb_spec.rb +30 -0
  708. data/spec/views/hyrax/base/_attributes.html.erb_spec.rb +35 -0
  709. data/spec/views/hyrax/base/_citations.html.erb_spec.rb +43 -0
  710. data/spec/views/hyrax/base/_form.html.erb_spec.rb +80 -0
  711. data/spec/views/hyrax/base/_form_child_work_relationships.html.erb_spec.rb +68 -0
  712. data/spec/views/hyrax/base/_form_files.html.erb_spec.rb +38 -0
  713. data/spec/views/hyrax/base/_form_metadata.html.erb_spec.rb +40 -0
  714. data/spec/views/hyrax/base/_form_progress.html.erb_spec.rb +131 -0
  715. data/spec/views/hyrax/base/_form_relationships.html.erb_spec.rb +48 -0
  716. data/spec/views/hyrax/base/_form_rendering.html.erb_spec.rb +22 -0
  717. data/spec/views/hyrax/base/_items.html.erb_spec.rb +55 -0
  718. data/spec/views/hyrax/base/_member.html.erb_spec.rb +43 -0
  719. data/spec/views/hyrax/base/_relationships.html.erb_spec.rb +92 -0
  720. data/spec/views/hyrax/base/_show_actions.html.erb_spec.rb +149 -0
  721. data/spec/views/hyrax/base/_social_media.html.erb_spec.rb +16 -0
  722. data/spec/views/hyrax/base/edit.html.erb_spec.rb +26 -0
  723. data/spec/views/hyrax/base/file_manager.html.erb_spec.rb +88 -0
  724. data/spec/views/hyrax/base/show.html.erb_spec.rb +201 -0
  725. data/spec/views/hyrax/base/show.json.jbuilder_spec.rb +23 -0
  726. data/spec/views/hyrax/base/unauthorized.html.erb_spec.rb +30 -0
  727. data/spec/views/hyrax/base/unavailable.html.erb_spec.rb +36 -0
  728. data/spec/views/hyrax/batch_edits/check_all_spec.rb +13 -0
  729. data/spec/views/hyrax/batch_edits/edit.html.erb_spec.rb +35 -0
  730. data/spec/views/hyrax/batch_uploads/_form.html.erb_spec.rb +24 -0
  731. data/spec/views/hyrax/citations/work.html.erb_spec.rb +175 -0
  732. data/spec/views/hyrax/collections/_show_descriptions.html.erb_spec.rb +32 -0
  733. data/spec/views/hyrax/collections/_show_document_list.html.erb_spec.rb +24 -0
  734. data/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb +35 -0
  735. data/spec/views/hyrax/collections/_show_parent_collections.html.erb_spec.rb +74 -0
  736. data/spec/views/hyrax/collections/_sort_and_per_page.html.erb_spec.rb +60 -0
  737. data/spec/views/hyrax/collections/_subcollection_list.html.erb_spec.rb +39 -0
  738. data/spec/views/hyrax/collections/show.html.erb_spec.rb +48 -0
  739. data/spec/views/hyrax/dashboard/_sidebar.html.erb_spec.rb +132 -0
  740. data/spec/views/hyrax/dashboard/collections/_default_group.html.erb_spec.rb +43 -0
  741. data/spec/views/hyrax/dashboard/collections/_form.html.erb_spec.rb +60 -0
  742. data/spec/views/hyrax/dashboard/collections/_form_branding.html.erb_spec.rb +23 -0
  743. data/spec/views/hyrax/dashboard/collections/_form_discovery.erb_spec.rb +67 -0
  744. data/spec/views/hyrax/dashboard/collections/_form_for_select_collection.html.erb_spec.rb +47 -0
  745. data/spec/views/hyrax/dashboard/collections/_form_share.erb_spec.rb +22 -0
  746. data/spec/views/hyrax/dashboard/collections/_form_share_table.html.erb_spec.rb +108 -0
  747. data/spec/views/hyrax/dashboard/collections/_list_collections.html.erb_spec.rb +51 -0
  748. data/spec/views/hyrax/dashboard/collections/_show_actions.html.erb_spec.rb +77 -0
  749. data/spec/views/hyrax/dashboard/collections/_show_add_items_actions.html.erb_spec.rb +46 -0
  750. data/spec/views/hyrax/dashboard/collections/_show_descriptions.html.erb_spec.rb +32 -0
  751. data/spec/views/hyrax/dashboard/collections/_show_document_list.html.erb_spec.rb +24 -0
  752. data/spec/views/hyrax/dashboard/collections/_show_document_list_menu.html.erb_spec.rb +31 -0
  753. data/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb +35 -0
  754. data/spec/views/hyrax/dashboard/collections/_show_parent_collection_row.html.erb_spec.rb +61 -0
  755. data/spec/views/hyrax/dashboard/collections/_show_parent_collections.html.erb_spec.rb +82 -0
  756. data/spec/views/hyrax/dashboard/collections/_show_subcollection_actions.html.erb_spec.rb +62 -0
  757. data/spec/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb_spec.rb +60 -0
  758. data/spec/views/hyrax/dashboard/collections/_subcollection_list.html.erb_spec.rb +75 -0
  759. data/spec/views/hyrax/dashboard/collections/_work_action_menu.html.erb_spec.rb +18 -0
  760. data/spec/views/hyrax/dashboard/collections/edit.html.erb_spec.rb +20 -0
  761. data/spec/views/hyrax/dashboard/collections/show.html.erb_spec.rb +116 -0
  762. data/spec/views/hyrax/dashboard/profiles/_trophy_edit.html.erb_spec.rb +36 -0
  763. data/spec/views/hyrax/dashboard/profiles/edit.html.erb_spec.rb +67 -0
  764. data/spec/views/hyrax/dashboard/profiles/show.html.erb_spec.rb +36 -0
  765. data/spec/views/hyrax/dashboard/show_user_spec.rb +61 -0
  766. data/spec/views/hyrax/depositors/index.html.erb_spec.rb +13 -0
  767. data/spec/views/hyrax/embargoes/index.html.erb_spec.rb +14 -0
  768. data/spec/views/hyrax/file_sets/_actions.html.erb_spec.rb +36 -0
  769. data/spec/views/hyrax/file_sets/_permission.html.erb_spec.rb +14 -0
  770. data/spec/views/hyrax/file_sets/_permission_form.html.erb_spec.rb +44 -0
  771. data/spec/views/hyrax/file_sets/_show_actions.html.erb_spec.rb +62 -0
  772. data/spec/views/hyrax/file_sets/_show_characterization_details.html.erb_spec.rb +29 -0
  773. data/spec/views/hyrax/file_sets/_single_use_links.html.erb_spec.rb +34 -0
  774. data/spec/views/hyrax/file_sets/_versioning.html.erb_spec.rb +15 -0
  775. data/spec/views/hyrax/file_sets/media_display/_audio.html.erb_spec.rb +29 -0
  776. data/spec/views/hyrax/file_sets/media_display/_default.html.erb_spec.rb +29 -0
  777. data/spec/views/hyrax/file_sets/media_display/_video.html.erb_spec.rb +29 -0
  778. data/spec/views/hyrax/file_sets/show.html.erb_spec.rb +47 -0
  779. data/spec/views/hyrax/file_sets/show.json.jbuilder_spec.rb +27 -0
  780. data/spec/views/hyrax/homepage/_announcement.html.erb_spec.rb +27 -0
  781. data/spec/views/hyrax/homepage/_featured_works.html.erb_spec.rb +40 -0
  782. data/spec/views/hyrax/homepage/_sortable_featured.html.erb_spec.rb +23 -0
  783. data/spec/views/hyrax/homepage/index.html.erb_spec.rb +129 -0
  784. data/spec/views/hyrax/leases/index.html.erb_spec.rb +14 -0
  785. data/spec/views/hyrax/my/_collection_action_menu.html.erb_spec.rb +65 -0
  786. data/spec/views/hyrax/my/_search_header.html.erb_spec.rb +34 -0
  787. data/spec/views/hyrax/my/_work_action_menu.html.erb_spec.rb +40 -0
  788. data/spec/views/hyrax/my/collections/_list_collections.html.erb_spec.rb +109 -0
  789. data/spec/views/hyrax/my/collections/index.html.erb_spec.rb +34 -0
  790. data/spec/views/hyrax/my/facet.html.erb_spec.rb +34 -0
  791. data/spec/views/hyrax/my/works/_list_works.html.erb_spec.rb +30 -0
  792. data/spec/views/hyrax/my/works/index.html.erb_spec.rb +69 -0
  793. data/spec/views/hyrax/permissions/confirm.html.erb_spec.rb +15 -0
  794. data/spec/views/hyrax/single_use_links_viewer/show.html.erb_spec.rb +17 -0
  795. data/spec/views/hyrax/single_use_links_viewer/single_use_error.html.erb_spec.rb +6 -0
  796. data/spec/views/hyrax/stats/file.html.erb_spec.rb +48 -0
  797. data/spec/views/hyrax/uploads/create.json.jbuilder_spec.rb +17 -0
  798. data/spec/views/hyrax/users/_user_info.html.erb_spec.rb +25 -0
  799. data/spec/views/hyrax/users/index.html.erb_spec.rb +25 -0
  800. data/spec/views/hyrax/users/show.html.erb_spec.rb +55 -0
  801. data/spec/views/layouts/error.html.erb_spec.rb +6 -0
  802. data/spec/views/pages/edit.html.erb_spec.rb +27 -0
  803. data/spec/views/pages/show.html.erb_spec.rb +17 -0
  804. data/spec/views/records/edit_fields/_based_near.html.erb_spec.rb +20 -0
  805. data/spec/views/records/edit_fields/_description.html.erb_spec.rb +67 -0
  806. data/spec/views/records/edit_fields/_language.html.erb_spec.rb +20 -0
  807. data/spec/views/records/edit_fields/_subject.html.erb_spec.rb +20 -0
  808. data/spec/views/shared/select_work_type_modal.html.erb_spec.rb +51 -0
  809. data/template.rb +1 -3
  810. metadata +1455 -151
  811. data/.regen +0 -1
  812. data/app/assets/javascripts/hyrax/skip_to_content.js +0 -15
  813. data/app/helpers/hyrax/work_form_helper.rb +0 -48
  814. data/app/jobs/embargo_expiry_job.rb +0 -15
  815. data/app/jobs/iiif_manifest_cache_prewarm_job.rb +0 -16
  816. data/app/jobs/lease_expiry_job.rb +0 -15
  817. data/app/models/concerns/hyrax/solr_document/ordered_members.rb +0 -46
  818. data/app/presenters/hyrax/iiif_manifest_presenter.rb +0 -232
  819. data/app/services/hyrax/caching_iiif_manifest_builder.rb +0 -53
  820. data/app/services/hyrax/collection_size_service.rb +0 -52
  821. data/app/services/hyrax/identifier/builder.rb +0 -45
  822. data/app/services/hyrax/identifier/dispatcher.rb +0 -61
  823. data/app/services/hyrax/identifier/registrar.rb +0 -41
  824. data/app/services/hyrax/manifest_builder_service.rb +0 -88
  825. data/lib/hyrax/specs/shared_specs/identifiers.rb +0 -27
@@ -0,0 +1,198 @@
1
+ RSpec.describe ContentBlock, type: :model do
2
+ describe '.for' do
3
+ context 'with a nil' do
4
+ it 'raises an ArgumentError' do
5
+ expect { described_class.for(nil) }.to raise_error(ArgumentError)
6
+ end
7
+ end
8
+ context 'with a non-whitelisted value' do
9
+ it 'raises an ArgumentError' do
10
+ expect { described_class.for(:destroy_all) }.to raise_error(ArgumentError)
11
+ end
12
+ end
13
+ context 'with a whitelisted value as a symbol' do
14
+ subject { described_class.for(:about) }
15
+
16
+ it 'returns a new instance' do
17
+ expect(described_class).to receive(:about_page).and_call_original
18
+ expect(subject).to be_instance_of ContentBlock
19
+ expect(subject).to be_persisted
20
+ end
21
+ end
22
+ context 'with a whitelisted value as a string' do
23
+ subject { described_class.for('about') }
24
+
25
+ it 'returns a new instance' do
26
+ expect(described_class).to receive(:about_page).and_call_original
27
+ expect(subject).to be_instance_of ContentBlock
28
+ expect(subject).to be_persisted
29
+ end
30
+ end
31
+ end
32
+
33
+ describe '.announcement_text' do
34
+ let!(:announcement) do
35
+ create(:content_block,
36
+ name: ContentBlock::NAME_REGISTRY[:announcement],
37
+ value: '<h1>Announcement Text</h1>')
38
+ end
39
+
40
+ subject { described_class.for(:announcement).value }
41
+
42
+ it { is_expected.to eq '<h1>Announcement Text</h1>' }
43
+ end
44
+
45
+ describe '.announcement_text=' do
46
+ let(:new_announcement) { '<h2>Foobar</h2>' }
47
+
48
+ it 'sets a new announcement_text' do
49
+ described_class.announcement_text = new_announcement
50
+ expect(described_class.for(:announcement).value).to eq new_announcement
51
+ end
52
+ end
53
+
54
+ describe '.marketing_text' do
55
+ let!(:marketing) do
56
+ create(:content_block,
57
+ name: ContentBlock::NAME_REGISTRY[:marketing],
58
+ value: '<h1>Marketing Text</h1>')
59
+ end
60
+
61
+ subject { described_class.for(:marketing).value }
62
+
63
+ it { is_expected.to eq '<h1>Marketing Text</h1>' }
64
+ end
65
+
66
+ describe '.marketing_text=' do
67
+ let(:new_marketing) { '<h2>Barbaz</h2>' }
68
+
69
+ it 'sets a new marketing_text' do
70
+ described_class.marketing_text = new_marketing
71
+ expect(described_class.for(:marketing).value).to eq new_marketing
72
+ end
73
+ end
74
+
75
+ describe '.featured_researcher' do
76
+ let!(:bilbo) do
77
+ create(:content_block,
78
+ name: ContentBlock::NAME_REGISTRY[:researcher],
79
+ value: '<h1>Bilbo Baggins</h1>',
80
+ created_at: Time.zone.now)
81
+ end
82
+
83
+ subject { described_class.for(:researcher) }
84
+
85
+ it 'returns entry for featured_researcher' do
86
+ expect(subject).to eq bilbo
87
+ end
88
+ end
89
+
90
+ describe '.featured_researcher=' do
91
+ let(:new_researcher) { '<h2>Baz Quux</h2>' }
92
+
93
+ it 'adds a new featured researcher' do
94
+ described_class.featured_researcher = new_researcher
95
+ expect(described_class.for(:researcher).value).to eq new_researcher
96
+ end
97
+ end
98
+
99
+ describe '.agreement_page' do
100
+ before do
101
+ allow(ApplicationController).to receive(:helpers).and_return(helper_module)
102
+ end
103
+ let(:helper_module) do
104
+ double('helpers',
105
+ application_name: 'TheBest',
106
+ institution_name: 'Foo E D U',
107
+ institution_name_full: 'Foolhardy Edutainment')
108
+ end
109
+
110
+ subject { described_class.for(:agreement) }
111
+
112
+ it 'defaults to text loaded from a template' do
113
+ expect(subject.value).to include 'TheBest Deposit Agreement'
114
+ end
115
+ end
116
+
117
+ describe '.agreement_page=' do
118
+ let(:new_agreement) { '<h2>Quuuuuuuuuux</h2>' }
119
+
120
+ it 'changes the agreement page value' do
121
+ described_class.agreement_page = new_agreement
122
+ expect(described_class.for(:agreement).value).to eq new_agreement
123
+ end
124
+ end
125
+
126
+ describe '.terms_page' do
127
+ before do
128
+ allow(ApplicationController).to receive(:helpers).and_return(helper_module)
129
+ end
130
+ let(:helper_module) do
131
+ double('helpers',
132
+ application_name: 'TheBest',
133
+ institution_name: 'Foo E D U',
134
+ institution_name_full: 'Foolhardy Edutainment')
135
+ end
136
+
137
+ subject { described_class.for(:terms) }
138
+
139
+ it 'defaults to text loaded from a template' do
140
+ expect(subject.value).to include 'Terms of Use for TheBest'
141
+ end
142
+ end
143
+
144
+ describe '.terms_page=' do
145
+ let(:new_terms) { '<h2>Fooooooob</h2>' }
146
+
147
+ it 'changes the terms page value' do
148
+ described_class.terms_page = new_terms
149
+ expect(described_class.for(:terms).value).to eq new_terms
150
+ end
151
+ end
152
+
153
+ context "the about page" do
154
+ before do
155
+ create(:content_block,
156
+ name: ContentBlock::NAME_REGISTRY[:about],
157
+ value: '<h1>About Page</h1>')
158
+ end
159
+
160
+ describe 'getter' do
161
+ subject { described_class.for(:about).value }
162
+
163
+ it { is_expected.to eq '<h1>About Page</h1>' }
164
+ end
165
+
166
+ describe 'setter' do
167
+ let(:new_about) { '<h2>Foobarfoo</h2>' }
168
+
169
+ it 'sets a new about_page' do
170
+ described_class.about_page = new_about
171
+ expect(described_class.for(:about).value).to eq new_about
172
+ end
173
+ end
174
+ end
175
+
176
+ context "the help page" do
177
+ before do
178
+ create(:content_block,
179
+ name: ContentBlock::NAME_REGISTRY[:help],
180
+ value: '<h1>Help Page</h1>')
181
+ end
182
+
183
+ describe 'getter' do
184
+ subject { described_class.for(:help).value }
185
+
186
+ it { is_expected.to eq '<h1>Help Page</h1>' }
187
+ end
188
+
189
+ describe 'setter' do
190
+ let(:new_help) { '<h2>Foobarfoo</h2>' }
191
+
192
+ it 'sets a new help_page' do
193
+ described_class.help_page = new_help
194
+ expect(described_class.for(:help).value).to eq new_help
195
+ end
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,56 @@
1
+ RSpec.describe FeaturedWorkList, type: :model do
2
+ let(:work1) { create(:generic_work) }
3
+ let(:work2) { create(:generic_work) }
4
+
5
+ describe 'featured_works' do
6
+ before do
7
+ create(:featured_work, work_id: work1.id)
8
+ create(:featured_work, work_id: work2.id)
9
+ end
10
+
11
+ it 'is a list of the featured work objects, each with the generic_work\'s solr_doc' do
12
+ expect(subject.featured_works.size).to eq 2
13
+ presenter = subject.featured_works.first.presenter
14
+ expect(presenter).to be_kind_of Hyrax::WorkShowPresenter
15
+ expect(presenter.id).to eq work1.id
16
+ end
17
+
18
+ context 'when one of the files is deleted' do
19
+ before do
20
+ work1.destroy
21
+ end
22
+
23
+ it 'is a list of the remaining featured work objects, each with the generic_work\'s solr_doc' do
24
+ expect(subject.featured_works.size).to eq 1
25
+ presenter = subject.featured_works.first.presenter
26
+ expect(presenter).to be_kind_of Hyrax::WorkShowPresenter
27
+ expect(presenter.id).to eq work2.id
28
+ end
29
+ end
30
+ end
31
+
32
+ describe '#featured_works_attributes=' do
33
+ # We don't need to persist the given work. This saves a few LDP calls.
34
+ let(:work_id) { 'no-need-to-persist' }
35
+ let(:featured_work) { create(:featured_work, work_id: work_id) }
36
+
37
+ let(:attributes) do
38
+ ActionController::Parameters.new(
39
+ "0" => {
40
+ "id" => featured_work.id,
41
+ "order" => "5"
42
+ }
43
+ ).permit!
44
+ end
45
+ let(:instance) { described_class.new }
46
+
47
+ subject { instance.featured_works_attributes = attributes }
48
+
49
+ it "sets order" do
50
+ subject
51
+ expect(featured_work.order).to eq 5
52
+ end
53
+ end
54
+
55
+ it { is_expected.to delegate_method(:empty?).to(:featured_works) }
56
+ end
@@ -0,0 +1,53 @@
1
+ RSpec.describe FeaturedWork, type: :model do
2
+ let(:feature) { described_class.create(work_id: "99") }
3
+
4
+ it "has a file" do
5
+ expect(feature.work_id).to eq "99"
6
+ end
7
+
8
+ it "does not allow six features" do
9
+ 5.times do |n|
10
+ expect(described_class.create(work_id: n.to_s)).not_to be_new_record
11
+ end
12
+ described_class.create(work_id: "6").tap do |sixth|
13
+ expect(sixth).to be_new_record
14
+ expect(sixth.errors.full_messages).to eq ["Limited to 5 featured works."]
15
+ end
16
+ expect(described_class.count).to eq 5
17
+ end
18
+
19
+ describe "can_create_another?" do
20
+ subject { described_class }
21
+
22
+ context "when none exist" do
23
+ describe '#can_create_another?' do
24
+ subject { super().can_create_another? }
25
+
26
+ it { is_expected.to be true }
27
+ end
28
+ end
29
+ context "when five exist" do
30
+ before do
31
+ 5.times do |n|
32
+ described_class.create(work_id: n.to_s)
33
+ end
34
+ end
35
+
36
+ describe '#can_create_another?' do
37
+ subject { super().can_create_another? }
38
+
39
+ it { is_expected.to be false }
40
+ end
41
+ end
42
+ end
43
+
44
+ describe "#order" do
45
+ subject { described_class.new(order: 5) }
46
+
47
+ describe '#order' do
48
+ subject { super().order }
49
+
50
+ it { is_expected.to eq 5 }
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,104 @@
1
+ RSpec.describe FileDownloadStat, type: :model do
2
+ let(:file_id) { file.id }
3
+ let(:date) { Time.current }
4
+ let(:file_stat) { described_class.new(downloads: "2", date: date, file_id: file_id) }
5
+ let(:file) { mock_model(FileSet, id: 99) }
6
+
7
+ it "has attributes" do
8
+ expect(file_stat).to respond_to(:downloads)
9
+ expect(file_stat).to respond_to(:date)
10
+ expect(file_stat).to respond_to(:file_id)
11
+ expect(file_stat.file_id).to eq("99")
12
+ expect(file_stat.date).to eq(date)
13
+ expect(file_stat.downloads).to eq(2)
14
+ end
15
+
16
+ describe ".ga_statistic" do
17
+ let(:start_date) { 2.days.ago }
18
+ let(:expected_path) { Rails.application.routes.url_helpers.hyrax_file_set_path(file) }
19
+
20
+ before do
21
+ allow(Hyrax::Analytics).to receive(:profile).and_return(profile)
22
+ end
23
+ context "when a profile is available" do
24
+ let(:views) { double }
25
+ let(:profile) { double(hyrax__download: views) }
26
+
27
+ it "calls the Legato method with the correct path" do
28
+ expect(views).to receive(:for_file).with(99)
29
+ described_class.ga_statistics(start_date, file)
30
+ end
31
+ end
32
+
33
+ context "when a profile not available" do
34
+ let(:profile) { nil }
35
+
36
+ it "calls the Legato method with the correct path" do
37
+ expect(described_class.ga_statistics(start_date, file)).to be_empty
38
+ end
39
+ end
40
+ end
41
+
42
+ describe "#statistics" do
43
+ let(:dates) do
44
+ ldates = []
45
+ 4.downto(0) { |idx| ldates << (Time.zone.today - idx.day) }
46
+ ldates
47
+ end
48
+ let(:date_strs) do
49
+ dates.map { |date| date.strftime("%Y%m%d") }
50
+ end
51
+
52
+ let(:download_output) do
53
+ [[statistic_date(dates[0]), 1], [statistic_date(dates[1]), 1], [statistic_date(dates[2]), 2], [statistic_date(dates[3]), 3]]
54
+ end
55
+
56
+ # This is what the data looks like that's returned from Google Analytics (GA) via the Legato gem
57
+ # Due to the nature of querying GA, testing this data in an automated fashion is problematc.
58
+ # Sample data structures were created by sending real events to GA from a test instance of
59
+ # Scholarsphere. The data below are essentially a "cut and paste" from the output of query
60
+ # results from the Legato gem.
61
+ let(:sample_download_statistics) do
62
+ [
63
+ SpecStatistic.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "hyrax:x920fw85p", date: date_strs[0], totalEvents: "1"),
64
+ SpecStatistic.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "hyrax:x920fw85p", date: date_strs[1], totalEvents: "1"),
65
+ SpecStatistic.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "hyrax:x920fw85p", date: date_strs[2], totalEvents: "2"),
66
+ SpecStatistic.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "hyrax:x920fw85p", date: date_strs[3], totalEvents: "3")
67
+ ]
68
+ end
69
+
70
+ describe "cache empty" do
71
+ let(:stats) do
72
+ expect(described_class).to receive(:ga_statistics).and_return(sample_download_statistics)
73
+ described_class.statistics(file, Time.zone.today - 4.days)
74
+ end
75
+
76
+ it "includes cached ga data" do
77
+ expect(stats.map(&:to_flot)).to include(*download_output)
78
+ end
79
+
80
+ it "caches data" do
81
+ expect(stats.map(&:to_flot)).to include(*download_output)
82
+
83
+ # at this point all data should be cached
84
+ allow(described_class).to receive(:ga_statistics).with(Time.zone.today, file).and_raise("We should not call Google Analytics All data should be cached!")
85
+
86
+ stats2 = described_class.statistics(file, Time.zone.today - 4.days)
87
+ expect(stats2.map(&:to_flot)).to include(*download_output)
88
+ end
89
+ end
90
+
91
+ describe "cache loaded" do
92
+ let!(:file_download_stat) { described_class.create(date: (Time.zone.today - 5.days).to_datetime, file_id: file_id, downloads: "25") }
93
+
94
+ let(:stats) do
95
+ expect(described_class).to receive(:ga_statistics).and_return(sample_download_statistics)
96
+ described_class.statistics(file, Time.zone.today - 5.days)
97
+ end
98
+
99
+ it "includes cached data" do
100
+ expect(stats.map(&:to_flot)).to include([file_download_stat.date.to_i * 1000, file_download_stat.downloads], *download_output)
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,668 @@
1
+ # This tests the FileSet model that is inserted into the host app by hyrax:models
2
+ # It includes the Hyrax::FileSetBehavior module and nothing else
3
+ # So this test covers both the FileSetBehavior module and the generated FileSet model
4
+ RSpec.describe FileSet do
5
+ include Hyrax::FactoryHelpers
6
+
7
+ let(:user) { create(:user) }
8
+
9
+ describe 'rdf type' do
10
+ subject { described_class.new.type }
11
+
12
+ it { is_expected.to include(Hydra::PCDM::Vocab::PCDMTerms.Object, Hydra::Works::Vocab::WorksTerms.FileSet) }
13
+ end
14
+
15
+ it 'is a Hydra::Works::FileSet' do
16
+ expect(subject).to be_file_set
17
+ end
18
+
19
+ it 'has depositor' do
20
+ subject.depositor = 'tess@example.com'
21
+ end
22
+
23
+ it 'updates attributes' do
24
+ subject.attributes = { title: ['My new Title'] }
25
+ expect(subject.title).to eq(['My new Title'])
26
+ end
27
+
28
+ context 'when it is initialized' do
29
+ it 'has empty arrays for the properties' do
30
+ expect(subject.title).to eq []
31
+ end
32
+ end
33
+
34
+ describe 'visibility' do
35
+ it "does not be changed when it's new" do
36
+ expect(subject).not_to be_visibility_changed
37
+ end
38
+ it 'is changed when it has been changed' do
39
+ subject.visibility = 'open'
40
+ expect(subject).to be_visibility_changed
41
+ end
42
+
43
+ it "does not be changed when it's set to its previous value" do
44
+ subject.visibility = 'restricted'
45
+ expect(subject).not_to be_visibility_changed
46
+ end
47
+ end
48
+
49
+ describe '#apply_depositor_metadata' do
50
+ before { subject.apply_depositor_metadata('jcoyne') }
51
+
52
+ it 'grants edit access and record the depositor' do
53
+ expect(subject.edit_users).to eq ['jcoyne']
54
+ expect(subject.depositor).to eq 'jcoyne'
55
+ end
56
+ end
57
+
58
+ describe 'attributes' do
59
+ it 'has a set of permissions' do
60
+ subject.read_groups = %w[group1 group2]
61
+ subject.edit_users = ['user1']
62
+ subject.read_users = %w[user2 user3]
63
+ expect(subject.permissions.map(&:to_hash)).to match_array [
64
+ { type: 'group', access: 'read', name: 'group1' },
65
+ { type: 'group', access: 'read', name: 'group2' },
66
+ { type: 'person', access: 'read', name: 'user2' },
67
+ { type: 'person', access: 'read', name: 'user3' },
68
+ { type: 'person', access: 'edit', name: 'user1' }
69
+ ]
70
+ end
71
+
72
+ it "has attached content" do
73
+ expect(subject.association(:original_file)).to be_kind_of ActiveFedora::Associations::DirectlyContainsOneAssociation
74
+ end
75
+ end
76
+
77
+ describe 'metadata' do
78
+ it 'has descriptive metadata' do
79
+ expect(subject).to respond_to(:relative_path)
80
+ expect(subject).to respond_to(:depositor)
81
+ expect(subject).to respond_to(:related_url)
82
+ expect(subject).to respond_to(:based_near)
83
+ expect(subject).to respond_to(:contributor)
84
+ expect(subject).to respond_to(:creator)
85
+ expect(subject).to respond_to(:title)
86
+ expect(subject).to respond_to(:description)
87
+ expect(subject).to respond_to(:publisher)
88
+ expect(subject).to respond_to(:date_created)
89
+ expect(subject).to respond_to(:date_uploaded)
90
+ expect(subject).to respond_to(:date_modified)
91
+ expect(subject).to respond_to(:subject)
92
+ expect(subject).to respond_to(:language)
93
+ expect(subject).to respond_to(:license)
94
+ expect(subject).to respond_to(:resource_type)
95
+ expect(subject).to respond_to(:identifier)
96
+ end
97
+ it 'has properties from characterization metadata' do
98
+ expect(subject).to respond_to(:format_label)
99
+ expect(subject).to respond_to(:mime_type)
100
+ expect(subject).to respond_to(:file_size)
101
+ expect(subject).to respond_to(:last_modified)
102
+ expect(subject).to respond_to(:filename)
103
+ expect(subject).to respond_to(:original_checksum)
104
+ expect(subject).to respond_to(:well_formed)
105
+ expect(subject).to respond_to(:page_count)
106
+ expect(subject).to respond_to(:file_title)
107
+ expect(subject).to respond_to(:duration)
108
+ expect(subject).to respond_to(:sample_rate)
109
+ # :creator is characterization metadata?
110
+ expect(subject).to respond_to(:creator)
111
+ end
112
+
113
+ it 'redefines to_param to make redis keys more recognizable' do
114
+ expect(subject.to_param).to eq subject.id
115
+ end
116
+
117
+ describe 'that have been saved' do
118
+ before { subject.apply_depositor_metadata('jcoyne') }
119
+
120
+ it 'is able to set values via delegated methods' do
121
+ subject.related_url = ['http://example.org/']
122
+ subject.creator = ['John Doe']
123
+ subject.title = ['New work']
124
+ subject.save
125
+ f = subject.reload
126
+ expect(f.related_url).to eq ['http://example.org/']
127
+ expect(f.creator).to eq ['John Doe']
128
+ expect(f.title).to eq ['New work']
129
+ end
130
+
131
+ it 'is able to be added to w/o unexpected graph behavior' do
132
+ subject.creator = ['John Doe']
133
+ subject.title = ['New work']
134
+ subject.save!
135
+ f = subject.reload
136
+ expect(f.creator).to eq ['John Doe']
137
+ expect(f.title).to eq ['New work']
138
+ f.creator = ['Jane Doe']
139
+ f.title += ['Newer work']
140
+ f.save
141
+ f = subject.reload
142
+ expect(f.creator).to eq ['Jane Doe']
143
+ # TODO: Is order important?
144
+ expect(f.title).to include('New work')
145
+ expect(f.title).to include('Newer work')
146
+ end
147
+ end
148
+ end
149
+
150
+ describe '#indexer' do
151
+ subject { described_class.indexer }
152
+
153
+ it { is_expected.to eq Hyrax::FileSetIndexer }
154
+
155
+ describe "setting" do
156
+ before do
157
+ class AltFile < ActiveFedora::Base
158
+ include Hyrax::FileSetBehavior
159
+ end
160
+ end
161
+ after do
162
+ Object.send(:remove_const, :AltFile)
163
+ end
164
+ let(:klass) { Class.new }
165
+
166
+ subject { AltFile.new }
167
+
168
+ it 'is settable' do
169
+ AltFile.indexer = klass
170
+ expect(AltFile.indexer).to eq klass
171
+ end
172
+ end
173
+ end
174
+
175
+ it 'supports multi-valued fields in solr' do
176
+ subject.keyword = %w[keyword1 keyword2]
177
+ expect { subject.save }.not_to raise_error
178
+ subject.delete
179
+ end
180
+
181
+ it 'supports setting and getting the relative_path value' do
182
+ subject.relative_path = 'documents/research/NSF/2010'
183
+ expect(subject.relative_path).to eq 'documents/research/NSF/2010'
184
+ end
185
+ describe 'create_thumbnail' do
186
+ let(:file_set) do
187
+ described_class.new do |f|
188
+ f.apply_depositor_metadata('mjg36')
189
+ end
190
+ end
191
+
192
+ describe 'with a video', if: Hyrax.config.enable_ffmpeg do
193
+ before do
194
+ allow(file_set).to receive(mime_type: 'video/quicktime') # Would get set by the characterization job
195
+ file_set.save
196
+ Hydra::Works::AddFileToFileSet.call(subject, File.open("#{fixture_path}/countdown.avi", 'rb'), :original_file)
197
+ end
198
+ it 'makes a png thumbnail' do
199
+ file_set.create_thumbnail
200
+ expect(file_set.thumbnail.content.size).to eq 4768 # this is a bad test. I just want to show that it did something.
201
+ expect(file_set.thumbnail.mime_type).to eq 'image/png'
202
+ end
203
+ end
204
+ end
205
+
206
+ describe '#related_files' do
207
+ let!(:f1) { described_class.new }
208
+
209
+ context 'when there are no related files' do
210
+ it 'returns an empty array' do
211
+ expect(f1.related_files).to eq []
212
+ end
213
+ end
214
+
215
+ context 'when there are related files' do
216
+ let(:parent_work) { create(:work_with_files) }
217
+ let(:f1) { parent_work.file_sets.first }
218
+ let(:f2) { parent_work.file_sets.last }
219
+
220
+ subject { f1.reload.related_files }
221
+
222
+ it 'returns all files contained in parent work(s) but excludes itself' do
223
+ expect(subject).to include(f2)
224
+ expect(subject).not_to include(f1)
225
+ end
226
+ end
227
+ end
228
+
229
+ describe 'noid integration', :clean_repo do
230
+ let(:service) { instance_double(::Noid::Rails::Service, mint: noid) }
231
+ let(:noid) { 'wd3763094' }
232
+ let!(:default) { Hyrax.config.enable_noids? }
233
+
234
+ before do
235
+ allow(::Noid::Rails::Service).to receive(:new).and_return(service)
236
+ end
237
+
238
+ after { Hyrax.config.enable_noids = default }
239
+
240
+ context 'with noids enabled' do
241
+ before { Hyrax.config.enable_noids = true }
242
+
243
+ it 'uses the noid service' do
244
+ expect(service).to receive(:mint).once
245
+ subject.assign_id
246
+ end
247
+
248
+ context "after saving" do
249
+ before { subject.save! }
250
+
251
+ it 'returns the expected identifier' do
252
+ expect(subject.id).to eq noid
253
+ end
254
+
255
+ it "has a treeified URL" do
256
+ expect(subject.uri.to_s).to end_with '/wd/37/63/09/wd3763094'
257
+ end
258
+ end
259
+
260
+ context 'when a url is provided' do
261
+ let(:url) { "#{ActiveFedora.fedora.host}/test/wd/37/63/09/wd3763094" }
262
+
263
+ it 'transforms the url into an id' do
264
+ expect(described_class.uri_to_id(url)).to eq 'wd3763094'
265
+ end
266
+ end
267
+ end
268
+
269
+ context 'with noids disabled' do
270
+ before { Hyrax.config.enable_noids = false }
271
+
272
+ it 'does not use the noid service' do
273
+ expect(service).not_to receive(:mint)
274
+ subject.assign_id
275
+ end
276
+ end
277
+ end
278
+
279
+ context 'with access control metadata' do
280
+ subject do
281
+ described_class.new do |m|
282
+ m.apply_depositor_metadata('jcoyne')
283
+ m.permissions_attributes = [{ type: 'person', access: 'read', name: 'person1' },
284
+ { type: 'person', access: 'read', name: 'person2' },
285
+ { type: 'group', access: 'read', name: 'group-6' },
286
+ { type: 'group', access: 'read', name: 'group-7' },
287
+ { type: 'group', access: 'edit', name: 'group-8' }]
288
+ end
289
+ end
290
+
291
+ it 'has read groups accessor' do
292
+ expect(subject.read_groups).to eq ['group-6', 'group-7']
293
+ end
294
+
295
+ it 'has read groups writer' do
296
+ subject.read_groups = ['group-2', 'group-3']
297
+ expect(subject.read_groups).to eq ['group-2', 'group-3']
298
+ end
299
+ end
300
+
301
+ describe 'permissions validation' do
302
+ before { subject.apply_depositor_metadata('mjg36') }
303
+
304
+ describe 'overriding' do
305
+ let(:asset) { SampleKlass.new }
306
+
307
+ before do
308
+ class SampleKlass < FileSet
309
+ def paranoid_edit_permissions
310
+ []
311
+ end
312
+ end
313
+ asset.apply_depositor_metadata('mjg36')
314
+ end
315
+ after do
316
+ Object.send(:remove_const, :SampleKlass)
317
+ end
318
+ context 'when the public has edit access' do
319
+ before { subject.edit_groups = ['public'] }
320
+
321
+ it 'is invalid' do
322
+ expect(subject).not_to be_valid
323
+ expect(subject.errors[:edit_groups]).to include('Public cannot have edit access')
324
+ end
325
+ end
326
+ end
327
+
328
+ describe '#paranoid_edit_permissions=' do
329
+ before do
330
+ subject.paranoid_edit_permissions =
331
+ [
332
+ { key: :edit_users, message: 'Depositor must have edit access', condition: ->(obj) { !obj.edit_users.include?(obj.depositor) } }
333
+ ]
334
+ subject.permissions = [Hydra::AccessControls::Permission.new(type: 'person', name: 'mjg36', access: 'read')]
335
+ end
336
+ it 'uses the user supplied configuration for validation' do
337
+ expect(subject).not_to be_valid
338
+ expect(subject.errors[:edit_users]).to include('Depositor must have edit access')
339
+ end
340
+ end
341
+
342
+ context 'when the public has edit access' do
343
+ before { subject.edit_groups = ['public'] }
344
+
345
+ it 'is invalid' do
346
+ expect(subject).not_to be_valid
347
+ expect(subject.errors[:edit_groups]).to include('Public cannot have edit access')
348
+ end
349
+ end
350
+
351
+ context 'when registered has edit access' do
352
+ before { subject.edit_groups = ['registered'] }
353
+
354
+ it 'is invalid' do
355
+ expect(subject).not_to be_valid
356
+ expect(subject.errors[:edit_groups]).to include('Registered cannot have edit access')
357
+ end
358
+ end
359
+
360
+ context 'everything is copacetic' do
361
+ it 'is valid' do
362
+ expect(subject).to be_valid
363
+ end
364
+ end
365
+ end
366
+
367
+ describe 'file content validation' do
368
+ subject { create(:file_set) }
369
+
370
+ let(:file_path) { fixture_path + '/small_file.txt' }
371
+
372
+ context 'when file contains a virus' do
373
+ before do
374
+ allow(subject).to receive(:warn) # suppress virus warnings
375
+ allow(Hydra::Works::VirusCheckerService).to receive(:file_has_virus?) { true }
376
+ # TODO: Test that this works with Hydra::Works::UploadFileToFileSet. see https://github.com/samvera/hydra-works/pull/139
377
+ # Hydra::Works::UploadFileToFileSet.call(subject, file_path, original_name: 'small_file.txt')
378
+ of = subject.build_original_file
379
+ of.content = File.open(file_path)
380
+ end
381
+
382
+ it 'populates the errors hash during validation' do
383
+ expect(subject).not_to be_valid
384
+ expect(subject.errors.messages[:base].first).to eq "Failed to verify uploaded file is not a virus"
385
+ end
386
+
387
+ it 'does not save the file or create a new version' do
388
+ original_version_count = subject.versions.count
389
+ subject.save
390
+ expect(subject.versions.count).to eq original_version_count
391
+ expect(subject.reload.original_file).to be_nil
392
+ end
393
+ end
394
+ end
395
+
396
+ describe '#where_digest_is', :clean_repo do
397
+ let(:file) { create(:file_set) }
398
+ let(:file_path) { fixture_path + '/small_file.txt' }
399
+ let(:digest_string) { '88fb4e88c15682c18e8b19b8a7b6eaf8770d33cf' }
400
+
401
+ before do
402
+ allow(file).to receive(:warn) # suppress virus warnings
403
+ of = file.build_original_file
404
+ of.content = File.open(file_path)
405
+ file.save
406
+ file.update_index
407
+ end
408
+ subject { described_class.where_digest_is(digest_string).first }
409
+
410
+ it { is_expected.to eq(file) }
411
+ end
412
+
413
+ describe 'to_solr' do
414
+ let(:indexer) { double(generate_solr_document: {}) }
415
+
416
+ before do
417
+ allow(Hyrax::FileSetIndexer).to receive(:new)
418
+ .with(subject).and_return(indexer)
419
+ end
420
+
421
+ it 'calls the indexer' do
422
+ expect(indexer).to receive(:generate_solr_document)
423
+ subject.to_solr
424
+ end
425
+
426
+ it 'has human readable type' do
427
+ expect(subject.to_solr.fetch('human_readable_type_tesim')).to eq 'File'
428
+ end
429
+ end
430
+
431
+ context 'with versions' do
432
+ it 'has versions' do
433
+ expect(subject.versions.count).to eq 0
434
+ end
435
+ end
436
+
437
+ describe 'public?' do
438
+ context 'when read group is set to public' do
439
+ before { subject.read_groups = ['public'] }
440
+
441
+ it { is_expected.to be_public }
442
+ end
443
+
444
+ context 'when read group is not set to public' do
445
+ before { subject.read_groups = ['foo'] }
446
+ it { is_expected.not_to be_public }
447
+ end
448
+ end
449
+
450
+ describe 'work associations' do
451
+ let(:work) { create(:work_with_one_file) }
452
+
453
+ subject { work.file_sets.first.reload }
454
+
455
+ it 'belongs to works' do
456
+ expect(subject.parents).to eq [work]
457
+ end
458
+ end
459
+
460
+ describe '#to_s' do
461
+ it 'uses the provided titles' do
462
+ # The title property would return the terms in random order, so stub the behavior:
463
+ subject.title = %w[Hello World]
464
+ expect(subject.to_s).to include 'Hello'
465
+ expect(subject.to_s).to include 'World'
466
+ end
467
+
468
+ it 'falls back on label if no titles are given' do
469
+ subject.title = []
470
+ subject.label = 'Spam'
471
+ expect(subject.to_s).to eq('Spam')
472
+ end
473
+
474
+ it 'with no label or titles it is "No Title"' do
475
+ subject.title = []
476
+ subject.label = nil
477
+ expect(subject.to_s).to eq('No Title')
478
+ end
479
+ end
480
+
481
+ describe 'to_solr record' do
482
+ subject do
483
+ described_class.new.tap do |f|
484
+ f.apply_depositor_metadata(depositor)
485
+ f.save
486
+ end
487
+ end
488
+
489
+ let(:depositor) { 'jcoyne' }
490
+ let(:depositor_key) { Solrizer.solr_name('depositor') }
491
+ let(:title_key) { Solrizer.solr_name('title', :stored_searchable, type: :string) }
492
+ let(:title) { ['abc123'] }
493
+ let(:no_terms) { described_class.find(subject.id).to_solr }
494
+ let(:terms) do
495
+ file = described_class.find(subject.id)
496
+ file.title = title
497
+ file.save
498
+ file.to_solr
499
+ end
500
+
501
+ context 'without terms' do
502
+ specify 'title is nil' do
503
+ expect(no_terms[title_key]).to be_nil
504
+ end
505
+ end
506
+
507
+ context 'with terms' do
508
+ specify 'depositor is set' do
509
+ expect(terms[depositor_key].first).to eql(depositor)
510
+ end
511
+ specify 'title is set' do
512
+ expect(terms[title_key]).to eql(title)
513
+ end
514
+ end
515
+ end
516
+
517
+ describe 'with a parent work' do
518
+ let(:parent) { create(:work_with_one_file) }
519
+ let(:parent_id) { parent.id }
520
+
521
+ describe '#related_files' do
522
+ let(:parent) { create(:work_with_files) }
523
+ let(:sibling) { parent.file_sets.last }
524
+
525
+ subject { parent.file_sets.first.reload }
526
+
527
+ it 'returns related files, but not itself' do
528
+ expect(subject.related_files).to eq([sibling])
529
+ expect(sibling.reload.related_files).to eq([subject])
530
+ end
531
+ end
532
+
533
+ describe '#remove_representative_relationship' do
534
+ subject { parent.file_sets.first.reload }
535
+
536
+ context 'it is not the representative' do
537
+ let(:some_other_id) { create(:file_set).id }
538
+
539
+ before do
540
+ parent.representative_id = some_other_id
541
+ parent.save!
542
+ end
543
+
544
+ it "doesn't update parent work when file is deleted" do
545
+ subject.destroy
546
+ expect(parent.representative_id).to eq some_other_id
547
+ end
548
+ end
549
+
550
+ context 'it is the representative' do
551
+ before do
552
+ parent.representative_id = subject.id
553
+ parent.save!
554
+ end
555
+
556
+ it 'updates the parent work when the file is deleted' do
557
+ subject.destroy
558
+ expect(parent.reload.representative_id).to be_nil
559
+ end
560
+ end
561
+ end
562
+ end
563
+
564
+ describe 'mime type recognition' do
565
+ let(:mock_file) { mock_file_factory(mime_type: mime_type) }
566
+
567
+ before { allow(subject).to receive(:original_file).and_return(mock_file) }
568
+
569
+ context '#image?' do
570
+ context 'when image/jp2' do
571
+ let(:mime_type) { 'image/jp2' }
572
+
573
+ it { is_expected.to be_image }
574
+ end
575
+ context 'when image/jpg' do
576
+ let(:mime_type) { 'image/jpg' }
577
+
578
+ it { is_expected.to be_image }
579
+ end
580
+ context 'when image/png' do
581
+ let(:mime_type) { 'image/png' }
582
+
583
+ it { is_expected.to be_image }
584
+ end
585
+ context 'when image/tiff' do
586
+ let(:mime_type) { 'image/tiff' }
587
+
588
+ it { is_expected.to be_image }
589
+ end
590
+ end
591
+
592
+ describe '#pdf?' do
593
+ let(:mime_type) { 'application/pdf' }
594
+
595
+ it { is_expected.to be_pdf }
596
+ end
597
+
598
+ describe '#audio?' do
599
+ context 'when x-wave' do
600
+ let(:mime_type) { 'audio/x-wave' }
601
+
602
+ it { is_expected.to be_audio }
603
+ end
604
+ context 'when x-wav' do
605
+ let(:mime_type) { 'audio/x-wav' }
606
+
607
+ it { is_expected.to be_audio }
608
+ end
609
+ context 'when mpeg' do
610
+ let(:mime_type) { 'audio/mpeg' }
611
+
612
+ it { is_expected.to be_audio }
613
+ end
614
+ context 'when mp3' do
615
+ let(:mime_type) { 'audio/mp3' }
616
+
617
+ it { is_expected.to be_audio }
618
+ end
619
+ context 'when ogg' do
620
+ let(:mime_type) { 'audio/ogg' }
621
+
622
+ it { is_expected.to be_audio }
623
+ end
624
+ end
625
+
626
+ describe '#video?' do
627
+ context 'should be true for avi' do
628
+ let(:mime_type) { 'video/avi' }
629
+
630
+ it { is_expected.to be_video }
631
+ end
632
+
633
+ context 'should be true for webm' do
634
+ let(:mime_type) { 'video/webm' }
635
+
636
+ it { is_expected.to be_video }
637
+ end
638
+ context 'should be true for mp4' do
639
+ let(:mime_type) { 'video/mp4' }
640
+
641
+ it { is_expected.to be_video }
642
+ end
643
+ context 'should be true for mpeg' do
644
+ let(:mime_type) { 'video/mpeg' }
645
+
646
+ it { is_expected.to be_video }
647
+ end
648
+ context 'should be true for quicktime' do
649
+ let(:mime_type) { 'video/quicktime' }
650
+
651
+ it { is_expected.to be_video }
652
+ end
653
+ context 'should be true for mxf' do
654
+ let(:mime_type) { 'application/mxf' }
655
+
656
+ it { is_expected.to be_video }
657
+ end
658
+ end
659
+ end
660
+
661
+ describe "#to_global_id", clean_repo: true do
662
+ let(:file_set) { described_class.new(id: '123') }
663
+
664
+ subject { file_set.to_global_id }
665
+
666
+ it { is_expected.to be_kind_of GlobalID }
667
+ end
668
+ end