hydra-head 3.0.0pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (366) hide show
  1. data/.gitignore +71 -0
  2. data/.gitmodules +6 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +257 -0
  5. data/README.textile +150 -0
  6. data/README_RAILS3_CHANGES.textile +42 -0
  7. data/Rakefile +5 -0
  8. data/TESTING.textile +85 -0
  9. data/app/controllers/assets_controller.rb +117 -0
  10. data/app/controllers/contributors_controller.rb +54 -0
  11. data/app/controllers/file_assets_controller.rb +152 -0
  12. data/app/controllers/permissions_controller.rb +137 -0
  13. data/app/controllers/user_sessions_controller.rb +14 -0
  14. data/app/helpers/article_metadata_helper.rb +80 -0
  15. data/app/helpers/blacklight_helper.rb +192 -0
  16. data/app/helpers/downloads_helper.rb +19 -0
  17. data/app/helpers/generic_content_objects_helper.rb +16 -0
  18. data/app/helpers/hydra_assets_helper.rb +75 -0
  19. data/app/helpers/hydra_djatoka_helper.rb +23 -0
  20. data/app/helpers/hydra_fedora_metadata_helper.rb +365 -0
  21. data/app/helpers/hydra_helper.rb +155 -0
  22. data/app/helpers/hydra_uploader_helper.rb +18 -0
  23. data/app/helpers/inline_editable_metadata_helper.rb +15 -0
  24. data/app/helpers/javascript_includes_helper.rb +93 -0
  25. data/app/helpers/release_process_helper.rb +32 -0
  26. data/app/models/audio_asset.rb +8 -0
  27. data/app/models/file_asset.rb +111 -0
  28. data/app/models/generic_content.rb +21 -0
  29. data/app/models/generic_image.rb +62 -0
  30. data/app/models/image_asset.rb +8 -0
  31. data/app/models/mods_asset.rb +6 -0
  32. data/app/models/role_mapper.rb +22 -0
  33. data/app/models/superuser.rb +6 -0
  34. data/app/models/video_asset.rb +8 -0
  35. data/app/views/_add_assets_links.html.erb +13 -0
  36. data/app/views/_brown_sidebar.html +15 -0
  37. data/app/views/_user_util_links.html.erb +31 -0
  38. data/app/views/catalog/_citation.html.erb +11 -0
  39. data/app/views/catalog/_constraints_element.html.erb +34 -0
  40. data/app/views/catalog/_delete_partials/_default.html.erb +29 -0
  41. data/app/views/catalog/_document_list.html.erb +11 -0
  42. data/app/views/catalog/_edit_partials/_default.html.erb +64 -0
  43. data/app/views/catalog/_edit_partials/_default_details.html.erb +15 -0
  44. data/app/views/catalog/_email_form.html.erb +9 -0
  45. data/app/views/catalog/_facets.html.erb +37 -0
  46. data/app/views/catalog/_flash_msg.html.erb +17 -0
  47. data/app/views/catalog/_home.html.erb +6 -0
  48. data/app/views/catalog/_home_text.html.erb +10 -0
  49. data/app/views/catalog/_index_partials/_default.html.erb +20 -0
  50. data/app/views/catalog/_index_partials/_default_details.html.erb +11 -0
  51. data/app/views/catalog/_index_partials/_default_group.html.erb +15 -0
  52. data/app/views/catalog/_search_form.html.erb +12 -0
  53. data/app/views/catalog/_show_partials/_default.html.erb +23 -0
  54. data/app/views/catalog/_show_partials/_default_details.html.erb +12 -0
  55. data/app/views/catalog/_show_partials/_facets.html.erb +52 -0
  56. data/app/views/catalog/_sms_form.html.erb +21 -0
  57. data/app/views/catalog/_sort_and_per_page.html.erb +22 -0
  58. data/app/views/catalog/_uva_tabs.html.erb +10 -0
  59. data/app/views/catalog/about.html.erb +0 -0
  60. data/app/views/catalog/show.html.erb +48 -0
  61. data/app/views/contributors/_add_contributor_split_button.html.erb +10 -0
  62. data/app/views/contributors/_edit_conference.html.erb +29 -0
  63. data/app/views/contributors/_edit_organization.html.erb +29 -0
  64. data/app/views/contributors/_edit_person.html.erb +42 -0
  65. data/app/views/contributors/_index.html.erb +12 -0
  66. data/app/views/contributors/_new.html.erb +10 -0
  67. data/app/views/contributors/_show_conference.html.erb +22 -0
  68. data/app/views/contributors/_show_organization.html.erb +29 -0
  69. data/app/views/contributors/_show_person.html.erb +17 -0
  70. data/app/views/contributors/new.html.erb +13 -0
  71. data/app/views/downloads/index.html.erb +1 -0
  72. data/app/views/file_assets/_deletable_result.html.erb +5 -0
  73. data/app/views/file_assets/_index.html.erb +15 -0
  74. data/app/views/file_assets/_new.html.erb +2 -0
  75. data/app/views/file_assets/_result.html.erb +16 -0
  76. data/app/views/file_assets/index.html.erb +5 -0
  77. data/app/views/fluid_infusion/_uploader.html.erb +81 -0
  78. data/app/views/fluid_infusion/_uploader_generic_content_objects.js.erb +38 -0
  79. data/app/views/fluid_infusion/_uploader_js.erb +45 -0
  80. data/app/views/generic_content_objects/_edit_description.html.erb +50 -0
  81. data/app/views/generic_content_objects/_new.html.erb +0 -0
  82. data/app/views/generic_content_objects/_show_description.html.erb +68 -0
  83. data/app/views/generic_content_objects/contributors/_edit_conference.html.erb +29 -0
  84. data/app/views/generic_content_objects/contributors/_edit_organization.html.erb +29 -0
  85. data/app/views/generic_content_objects/contributors/_edit_person.html.erb +37 -0
  86. data/app/views/generic_content_objects/contributors/_new.html.erb +10 -0
  87. data/app/views/generic_content_objects/contributors/_show_conference.html.erb +22 -0
  88. data/app/views/generic_content_objects/contributors/_show_organization.html.erb +22 -0
  89. data/app/views/generic_content_objects/contributors/_show_person.html.erb +38 -0
  90. data/app/views/generic_contents/_edit.html.erb +59 -0
  91. data/app/views/generic_contents/_index.html.erb +23 -0
  92. data/app/views/generic_contents/_show.html.erb +18 -0
  93. data/app/views/generic_contents/_show_content.html.erb +4 -0
  94. data/app/views/generic_images/_edit.html.erb +59 -0
  95. data/app/views/generic_images/_index.html.erb +24 -0
  96. data/app/views/generic_images/_show.html.erb +18 -0
  97. data/app/views/generic_images/_show_all.html.erb +14 -0
  98. data/app/views/generic_images/_show_content.html.erb +7 -0
  99. data/app/views/layouts/application.html.erb +57 -0
  100. data/app/views/layouts/hydra-head.html.erb +12 -0
  101. data/app/views/mods_assets/_edit.html.erb +49 -0
  102. data/app/views/mods_assets/_edit_description.html.erb +82 -0
  103. data/app/views/mods_assets/_edit_journal.html.erb +72 -0
  104. data/app/views/mods_assets/_index.html.erb +1 -0
  105. data/app/views/mods_assets/_index_list.html.erb +37 -0
  106. data/app/views/mods_assets/_index_table.html.erb +7 -0
  107. data/app/views/mods_assets/_progress_box.html.erb +82 -0
  108. data/app/views/mods_assets/_show.html.erb +44 -0
  109. data/app/views/mods_assets/_show_description.html.erb +44 -0
  110. data/app/views/mods_assets/_show_journal.html.erb +42 -0
  111. data/app/views/mods_assets/_show_permissions.html.erb +14 -0
  112. data/app/views/permissions/_edit_person_permissions.html.erb +35 -0
  113. data/app/views/permissions/_index.html.erb +55 -0
  114. data/app/views/permissions/_new.html.erb +18 -0
  115. data/app/views/permissions/index.html.erb +1 -0
  116. data/app/views/permissions/new.html.erb +1 -0
  117. data/app/views/shared/_delete_asset_confirmation.html.erb +17 -0
  118. data/app/views/user_sessions/_login_form.html.erb +10 -0
  119. data/app/views/user_sessions/logged_out.html.erb +1 -0
  120. data/config/routes.rb +12 -0
  121. data/fedora_conf/conf/fedora.fcfg +1021 -0
  122. data/hydra-head.gemspec +70 -0
  123. data/lib/application_controller.rb +25 -0
  124. data/lib/application_helper.rb +2 -0
  125. data/lib/engine.rb +30 -0
  126. data/lib/generators/hydra/head_generator.rb +152 -0
  127. data/lib/generators/hydra/templates/config/fedora.yml +17 -0
  128. data/lib/generators/hydra/templates/config/initializers/blacklight_config.rb +246 -0
  129. data/lib/generators/hydra/templates/config/initializers/fedora_config.rb +23 -0
  130. data/lib/generators/hydra/templates/config/initializers/hydra_config.rb +29 -0
  131. data/lib/generators/hydra/templates/config/role_map_cucumber.yml +10 -0
  132. data/lib/generators/hydra/templates/config/role_map_development.yml +12 -0
  133. data/lib/generators/hydra/templates/config/role_map_production.yml +2 -0
  134. data/lib/generators/hydra/templates/config/role_map_test.yml +15 -0
  135. data/lib/generators/hydra/templates/config/solr.yml +10 -0
  136. data/lib/generators/hydra/templates/config/solr_mappings.yml +22 -0
  137. data/lib/generators/hydra/templates/fedora_conf/conf/fedora.fcfg +1021 -0
  138. data/lib/generators/hydra/templates/migrations/add_user_attributes_table.rb +15 -0
  139. data/lib/generators/hydra/templates/migrations/create_superusers.rb +12 -0
  140. data/lib/generators/hydra/templates/solr_conf/conf/schema.xml +118 -0
  141. data/lib/generators/hydra/templates/solr_conf/conf/solrconfig.xml +332 -0
  142. data/lib/generators/hydra/templates/solr_conf/solr.xml +35 -0
  143. data/lib/hydra-head.rb +29 -0
  144. data/lib/hydra-head/engine.rb +9 -0
  145. data/lib/hydra-head/routes.rb +87 -0
  146. data/lib/hydra-head/version.rb +4 -0
  147. data/lib/hydra.rb +22 -0
  148. data/lib/hydra/access_controls_enforcement.rb +236 -0
  149. data/lib/hydra/access_controls_evaluation.rb +97 -0
  150. data/lib/hydra/assets_controller_helper.rb +144 -0
  151. data/lib/hydra/catalog.rb +64 -0
  152. data/lib/hydra/common_mods_index_methods.rb +42 -0
  153. data/lib/hydra/controller.rb +7 -0
  154. data/lib/hydra/file_assets_helper.rb +144 -0
  155. data/lib/hydra/fixtures.rb +43 -0
  156. data/lib/hydra/generic_content.rb +113 -0
  157. data/lib/hydra/generic_image.rb +100 -0
  158. data/lib/hydra/image.rb +177 -0
  159. data/lib/hydra/model_methods.rb +95 -0
  160. data/lib/hydra/model_mixins.rb +2 -0
  161. data/lib/hydra/model_mixins/common_metadata.rb +24 -0
  162. data/lib/hydra/model_mixins/mods_object.rb +16 -0
  163. data/lib/hydra/mods_article.rb +505 -0
  164. data/lib/hydra/mods_dataset.rb +165 -0
  165. data/lib/hydra/mods_generic_content.rb +494 -0
  166. data/lib/hydra/mods_image.rb +494 -0
  167. data/lib/hydra/repository_controller.rb +102 -0
  168. data/lib/hydra/rights_metadata.rb +189 -0
  169. data/lib/hydra/superuser_attributes.rb +12 -0
  170. data/lib/hydra/testing_server.rb +183 -0
  171. data/lib/hydra/user.rb +22 -0
  172. data/lib/mediashelf/active_fedora_helper.rb +72 -0
  173. data/lib/railties/all_tests.rake +23 -0
  174. data/lib/railties/hydra-fixtures.rake +184 -0
  175. data/lib/railties/hydra_jetty.rake +79 -0
  176. data/lib/railties/hyhead_cucumber.rake +127 -0
  177. data/lib/railties/hyhead_rspec.rake +137 -0
  178. data/lib/stanford/searchworks_helper.rb +1338 -0
  179. data/lib/stanford/solr_helper.rb +108 -0
  180. data/lib/uva/mods_index_methods.rb +24 -0
  181. data/solr_conf/conf/schema.xml +122 -0
  182. data/solr_conf/conf/solrconfig.xml +332 -0
  183. data/solr_conf/solr.xml +35 -0
  184. data/tasks/hydra-head-fixtures.rake +54 -0
  185. data/tasks/hydra-head.rake +247 -0
  186. data/tasks/hydra_jetty.rake +79 -0
  187. data/tasks/replicator.rake +27 -0
  188. data/tasks/solrizer-fedora.rake +53 -0
  189. data/tasks/solrizer.rake +13 -0
  190. data/test_support/etc/Gemfile +29 -0
  191. data/test_support/etc/rvmrc +32 -0
  192. data/test_support/features/button_add_assets.feature +22 -0
  193. data/test_support/features/button_add_generic_content.feature +11 -0
  194. data/test_support/features/button_add_image.feature +11 -0
  195. data/test_support/features/button_add_mods_asset.feature +11 -0
  196. data/test_support/features/contributor_add.feature +39 -0
  197. data/test_support/features/file_assets_list.feature +32 -0
  198. data/test_support/features/file_upload.feature +40 -0
  199. data/test_support/features/home_page.feature +9 -0
  200. data/test_support/features/html_validity.feature +47 -0
  201. data/test_support/features/mods_asset_contributors_edit.feature +80 -0
  202. data/test_support/features/mods_asset_create.feature +12 -0
  203. data/test_support/features/mods_asset_edit.feature +33 -0
  204. data/test_support/features/mods_asset_edit_without_permission.feature +10 -0
  205. data/test_support/features/mods_asset_search_result.feature +13 -0
  206. data/test_support/features/mods_asset_show.feature +39 -0
  207. data/test_support/features/permissions_add.feature +15 -0
  208. data/test_support/features/permissions_edit.feature +63 -0
  209. data/test_support/features/step_definitions/catalog_index_steps.rb +14 -0
  210. data/test_support/features/step_definitions/create_asset_steps.rb +7 -0
  211. data/test_support/features/step_definitions/edit_metadata_steps.rb +73 -0
  212. data/test_support/features/step_definitions/file_list_steps.rb +28 -0
  213. data/test_support/features/step_definitions/hydra_metadata_steps.rb +3 -0
  214. data/test_support/features/step_definitions/hydra_steps.rb +8 -0
  215. data/test_support/features/step_definitions/inline_editable_edit_steps.rb +77 -0
  216. data/test_support/features/step_definitions/search_steps.rb +88 -0
  217. data/test_support/features/step_definitions/searching_steps.rb +22 -0
  218. data/test_support/features/step_definitions/show_document_steps.rb +85 -0
  219. data/test_support/features/step_definitions/user_steps.rb +36 -0
  220. data/test_support/features/step_definitions/web_steps.rb +219 -0
  221. data/test_support/features/support/env.rb +55 -0
  222. data/test_support/features/support/paths.rb +80 -0
  223. data/test_support/features/switch_users.feature +14 -0
  224. data/test_support/features/view_catalog_index.feature +18 -0
  225. data/test_support/fixtures/empty_file.txt +0 -0
  226. data/test_support/fixtures/hydrangea_fixture_archivist_only_mods_article.foxml.xml +1212 -0
  227. data/test_support/fixtures/hydrangea_fixture_file_asset1.foxml.xml +4946 -0
  228. data/test_support/fixtures/hydrangea_fixture_mods_article1.foxml.xml +234 -0
  229. data/test_support/fixtures/hydrangea_fixture_mods_article2.foxml.xml +177 -0
  230. data/test_support/fixtures/hydrangea_fixture_mods_article3.foxml.xml +170 -0
  231. data/test_support/fixtures/hydrangea_fixture_mods_dataset1.foxml.xml +187 -0
  232. data/test_support/fixtures/hydrangea_fixture_uploaded_svg1.foxml.xml +676 -0
  233. data/test_support/fixtures/image.jp2 +0 -0
  234. data/test_support/fixtures/libra-oa_1.foxml.xml +2324 -0
  235. data/test_support/fixtures/libra-oa_2.foxml.xml +2422 -0
  236. data/test_support/spec/controllers/assets_controller_spec.rb +113 -0
  237. data/test_support/spec/controllers/catalog_controller_spec.rb +148 -0
  238. data/test_support/spec/controllers/catalog_controller_viewing_context_spec.rb +62 -0
  239. data/test_support/spec/controllers/contributors_controller_spec.rb +47 -0
  240. data/test_support/spec/controllers/file_assets_controller_spec.rb +189 -0
  241. data/test_support/spec/controllers/hydra_controller_spec.rb +15 -0
  242. data/test_support/spec/controllers/permissions_controller_spec.rb +80 -0
  243. data/test_support/spec/controllers/user_sessions_controller_spec.rb +35 -0
  244. data/test_support/spec/generators/hydra-head_generator_spec.rb +14 -0
  245. data/test_support/spec/helpers/access_controls_enforcement_spec.rb +212 -0
  246. data/test_support/spec/helpers/access_controls_evaluation_spec.rb +35 -0
  247. data/test_support/spec/helpers/assets_controller_helper_spec.rb +71 -0
  248. data/test_support/spec/helpers/blacklight_helper_spec.rb +64 -0
  249. data/test_support/spec/helpers/file_assets_helper_spec.rb +107 -0
  250. data/test_support/spec/helpers/hydra-repository_controller_spec.rb +32 -0
  251. data/test_support/spec/helpers/hydra_assets_helper_spec.rb +195 -0
  252. data/test_support/spec/helpers/hydra_djatoka_helper_spec.rb +32 -0
  253. data/test_support/spec/helpers/hydra_fedora_metadata_helper_spec.rb +215 -0
  254. data/test_support/spec/helpers/hydra_helper_spec.rb +73 -0
  255. data/test_support/spec/helpers/hydra_model_methods_spec.rb +95 -0
  256. data/test_support/spec/helpers/hydra_uploader_helper_spec.rb +18 -0
  257. data/test_support/spec/helpers/javascript_includes_helper_spec.rb +43 -0
  258. data/test_support/spec/integration/file_asset_spec.rb +150 -0
  259. data/test_support/spec/lib/active_fedora_helper_spec.rb +56 -0
  260. data/test_support/spec/lib/catalog_spec.rb +16 -0
  261. data/test_support/spec/lib/common_mods_index_methods_spec.rb +28 -0
  262. data/test_support/spec/models/audio_asset_spec.rb +23 -0
  263. data/test_support/spec/models/file_asset_spec.rb +42 -0
  264. data/test_support/spec/models/generic_content_spec.rb +29 -0
  265. data/test_support/spec/models/generic_image_spec.rb +58 -0
  266. data/test_support/spec/models/hydra_rights_metadata_spec.rb +162 -0
  267. data/test_support/spec/models/image_asset_spec.rb +23 -0
  268. data/test_support/spec/models/mods_asset_spec.rb +29 -0
  269. data/test_support/spec/models/role_mapper_spec.rb +22 -0
  270. data/test_support/spec/models/user_spec.rb +52 -0
  271. data/test_support/spec/models/video_asset_spec.rb +23 -0
  272. data/test_support/spec/rcov.opts +3 -0
  273. data/test_support/spec/spec.opts +4 -0
  274. data/test_support/spec/spec_helper.rb +44 -0
  275. data/test_support/spec/support/matchers/helper_matcher.rb +14 -0
  276. data/test_support/spec/support/matchers/solr_matchers.rb +60 -0
  277. data/test_support/spec/unit/hydra-head-engine_spec.rb +8 -0
  278. data/test_support/spec/unit/hydra-head_spec.rb +8 -0
  279. data/test_support/spec/utilities/hydra_testing_server_spec.rb +49 -0
  280. data/test_support/spec/views/uploader.html.erb_spec.rb +30 -0
  281. data/vendor/cache/RedCloth-4.2.3.gem +0 -0
  282. data/vendor/cache/abstract-1.0.0.gem +0 -0
  283. data/vendor/cache/actionmailer-3.0.9.gem +0 -0
  284. data/vendor/cache/actionpack-3.0.9.gem +0 -0
  285. data/vendor/cache/active-fedora-2.3.3.gem +0 -0
  286. data/vendor/cache/activemodel-3.0.9.gem +0 -0
  287. data/vendor/cache/activerecord-3.0.9.gem +0 -0
  288. data/vendor/cache/activeresource-3.0.9.gem +0 -0
  289. data/vendor/cache/activesupport-3.0.9.gem +0 -0
  290. data/vendor/cache/arel-2.0.10.gem +0 -0
  291. data/vendor/cache/blacklight-3.0.0.gem +0 -0
  292. data/vendor/cache/block_helpers-0.3.3.gem +0 -0
  293. data/vendor/cache/builder-2.1.2.gem +0 -0
  294. data/vendor/cache/capybara-1.0.0.gem +0 -0
  295. data/vendor/cache/childprocess-0.2.0.gem +0 -0
  296. data/vendor/cache/columnize-0.3.4.gem +0 -0
  297. data/vendor/cache/crack-0.1.8.gem +0 -0
  298. data/vendor/cache/cucumber-1.0.2.gem +0 -0
  299. data/vendor/cache/cucumber-rails-1.0.2.gem +0 -0
  300. data/vendor/cache/curb-0.7.15.gem +0 -0
  301. data/vendor/cache/daemons-1.1.4.gem +0 -0
  302. data/vendor/cache/database_cleaner-0.6.7.gem +0 -0
  303. data/vendor/cache/diff-lcs-1.1.2.gem +0 -0
  304. data/vendor/cache/equivalent-xml-0.2.7.gem +0 -0
  305. data/vendor/cache/erubis-2.6.6.gem +0 -0
  306. data/vendor/cache/facets-2.8.4.gem +0 -0
  307. data/vendor/cache/factory_girl-1.3.3.gem +0 -0
  308. data/vendor/cache/fastercsv-1.5.4.gem +0 -0
  309. data/vendor/cache/ffi-1.0.9.gem +0 -0
  310. data/vendor/cache/gherkin-2.4.5.gem +0 -0
  311. data/vendor/cache/haml-3.1.2.gem +0 -0
  312. data/vendor/cache/httparty-0.7.8.gem +0 -0
  313. data/vendor/cache/i18n-0.5.0.gem +0 -0
  314. data/vendor/cache/jettywrapper-0.0.10.gem +0 -0
  315. data/vendor/cache/json-1.5.3.gem +0 -0
  316. data/vendor/cache/json_pure-1.5.3.gem +0 -0
  317. data/vendor/cache/kaminari-0.12.4.gem +0 -0
  318. data/vendor/cache/launchy-2.0.3.gem +0 -0
  319. data/vendor/cache/linecache-0.46.gem +0 -0
  320. data/vendor/cache/logger-1.2.8.gem +0 -0
  321. data/vendor/cache/mail-2.2.19.gem +0 -0
  322. data/vendor/cache/marc-0.4.3.gem +0 -0
  323. data/vendor/cache/mediashelf-loggable-0.4.2.gem +0 -0
  324. data/vendor/cache/mime-types-1.16.gem +0 -0
  325. data/vendor/cache/mocha-0.9.12.gem +0 -0
  326. data/vendor/cache/multipart-post-1.1.2.gem +0 -0
  327. data/vendor/cache/nokogiri-1.5.0.gem +0 -0
  328. data/vendor/cache/om-1.2.5.gem +0 -0
  329. data/vendor/cache/polyglot-0.3.1.gem +0 -0
  330. data/vendor/cache/rack-1.2.3.gem +0 -0
  331. data/vendor/cache/rack-mount-0.6.14.gem +0 -0
  332. data/vendor/cache/rack-test-0.5.7.gem +0 -0
  333. data/vendor/cache/rails-3.0.9.gem +0 -0
  334. data/vendor/cache/railties-3.0.9.gem +0 -0
  335. data/vendor/cache/rake-0.9.2.gem +0 -0
  336. data/vendor/cache/rbx-require-relative-0.0.5.gem +0 -0
  337. data/vendor/cache/rcov-0.9.9.gem +0 -0
  338. data/vendor/cache/rdoc-3.8.gem +0 -0
  339. data/vendor/cache/rsolr-1.0.2.gem +0 -0
  340. data/vendor/cache/rsolr-ext-1.0.3.gem +0 -0
  341. data/vendor/cache/rspec-2.6.0.gem +0 -0
  342. data/vendor/cache/rspec-core-2.6.4.gem +0 -0
  343. data/vendor/cache/rspec-expectations-2.6.0.gem +0 -0
  344. data/vendor/cache/rspec-mocks-2.6.0.gem +0 -0
  345. data/vendor/cache/rspec-rails-2.6.1.gem +0 -0
  346. data/vendor/cache/ruby-debug-0.10.4.gem +0 -0
  347. data/vendor/cache/ruby-debug-base-0.10.4.gem +0 -0
  348. data/vendor/cache/rubyzip-0.9.4.gem +0 -0
  349. data/vendor/cache/sanitize-2.0.3.gem +0 -0
  350. data/vendor/cache/selenium-webdriver-0.2.2.gem +0 -0
  351. data/vendor/cache/solr-ruby-0.0.8.gem +0 -0
  352. data/vendor/cache/solrizer-1.1.0.gem +0 -0
  353. data/vendor/cache/solrizer-fedora-1.1.0.gem +0 -0
  354. data/vendor/cache/sqlite3-ruby-1.2.5.gem +0 -0
  355. data/vendor/cache/stomp-1.1.9.gem +0 -0
  356. data/vendor/cache/term-ansicolor-1.0.5.gem +0 -0
  357. data/vendor/cache/thor-0.14.6.gem +0 -0
  358. data/vendor/cache/treetop-1.4.9.gem +0 -0
  359. data/vendor/cache/trollop-1.16.2.gem +0 -0
  360. data/vendor/cache/tzinfo-0.3.29.gem +0 -0
  361. data/vendor/cache/unicode-0.4.0.gem +0 -0
  362. data/vendor/cache/will_paginate-2.3.15.gem +0 -0
  363. data/vendor/cache/xml-simple-1.1.0.gem +0 -0
  364. data/vendor/cache/xpath-0.1.4.gem +0 -0
  365. data/vendor/cache/yard-0.7.2.gem +0 -0
  366. metadata +1110 -0
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+
4
+ describe Hydra::Controller do
5
+ before(:all) do
6
+ class HydraControllerTest
7
+ end
8
+ end
9
+
10
+ it "should add the necessary helpers to classes that include it" do
11
+ HydraControllerTest.expects(:helper).with(:hydra_assets)
12
+ HydraControllerTest.expects(:helper).with(:hydra_fedora_metadata)
13
+ HydraControllerTest.send(:include, Hydra::Controller)
14
+ end
15
+ end
@@ -0,0 +1,80 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+
4
+ # See cucumber tests (ie. /features/edit_document.feature) for more tests, including ones that test the edit method & view
5
+ # You can run the cucumber tests with
6
+ #
7
+ # cucumber --tags @edit
8
+ # or
9
+ # rake cucumber
10
+
11
+ describe PermissionsController do
12
+ describe "index" do
13
+ it "should retrieve the object's rightsMetadata datastream as a Hydra::RightsMetadata object and render the _index partial" do
14
+ end
15
+ end
16
+ describe "show" do
17
+ it"should render different partial based on the permission type" do
18
+ pending
19
+ renders "permissions/edit_individual"
20
+ renders "permissions/edit_group"
21
+ end
22
+ end
23
+ describe "edit" do
24
+ end
25
+ describe "new" do
26
+ it "should render the _new partial"
27
+ end
28
+ describe "create" do
29
+ it "should create a new permissions entry" do
30
+ stub_solrizer = stub("solrizer", :solrize)
31
+ Solrizer::Fedora::Solrizer.stubs(:new).returns(stub_solrizer)
32
+ mock_ds = mock("Datastream")
33
+ Hydra::RightsMetadata.stubs(:from_xml).returns(mock_ds)
34
+ mock_ds.expects(:permissions).with({"person" => "_person_id_"}, "read")
35
+ # mock_ds.expects(:update_permissions).with({"person"=>{"_person_id_"=>"read"}})
36
+ mock_ds.stubs(:content)
37
+ mock_ds.stubs(:pid=)
38
+ mock_ds.stubs(:dsid=)
39
+ mock_ds.stubs(:save)
40
+ mock_object = mock("object")
41
+ mock_object.stubs(:datastreams_in_memory).returns({"rightsMetadata"=>mock_ds})
42
+
43
+ ActiveFedora::Base.expects(:load_instance).with("_pid_").returns(mock_object)
44
+
45
+ post :create, :asset_id=>"_pid_", :permission => {"actor_id"=>"_person_id_","actor_type"=>"person","access_level"=>"read"}
46
+ # post :create, :asset_id=>"_pid_", :permission => {"person"=>"_person_id_","level"=>"read"}
47
+ end
48
+ it "should rely on .update method"
49
+ end
50
+ describe "update" do
51
+ it "should call Hydra::RightsMetadata properties setter" do
52
+ stub_solrizer = stub("solrizer", :solrize)
53
+ Solrizer::Fedora::Solrizer.stubs(:new).returns(stub_solrizer)
54
+ mock_ds = mock("Datastream")
55
+ Hydra::RightsMetadata.stubs(:from_xml).returns(mock_ds)
56
+ mock_ds.expects(:update_permissions).with({"group" => {"_group_id_"=>"discover"}})
57
+ mock_ds.stubs(:content)
58
+ mock_ds.stubs(:pid=)
59
+ mock_ds.stubs(:dsid=)
60
+ mock_ds.stubs(:save)
61
+ mock_object = mock("object")
62
+ mock_object.stubs(:datastreams_in_memory).returns({"rightsMetadata"=>mock_ds})
63
+
64
+ ActiveFedora::Base.expects(:load_instance).with("_pid_").returns(mock_object)
65
+ # must define new routes that can handle url like this
66
+ # /assets/_pid_/permissions/group/_group_id_
67
+ # /assets/:asset_id/permissions/:actor_type/:actor_id
68
+
69
+ # this is what currently works
70
+ # post :update, :asset_id=>"_pid_", :actor_type=>"group", :actor_id=>"_group_id_", :permission => {"group"=>"_group_id_","level"=>"discover"}
71
+
72
+ post :update, :asset_id=>"_pid_", :permission => {"group"=>{"_group_id_"=>"discover"}}
73
+ end
74
+ it "should add a rightsMetadata datastream if it doesn't exist"
75
+ it "should not cause the metadata to be indexed twice" do
76
+ # should load the object as ActiveFedora::Base, initialize the rightsMetadata datastream as Hydra::RightsMetadata, update the datastream, save the datastream, and tell Solrizer to re-index the object from pid
77
+ # re-indexing from pid rather than passing in the current object prevents double-indexing of the edited metadatata datastream
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,35 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe UserSessionsController do
4
+
5
+ before(:each) do
6
+ @user = mock("User")
7
+ @user.stubs(:can_be_superuser?).returns true
8
+ @user2 = mock("User")
9
+ @user2.stubs(:can_be_superuser?).returns false
10
+ end
11
+
12
+ it "should allow for toggling on and off session[:superuser_mode]" do
13
+ controller.stubs(:current_user).returns(@user)
14
+ request.env["HTTP_REFERER"] = ""
15
+ get :superuser
16
+ session[:superuser_mode].should be_true
17
+ get :superuser
18
+ session[:superuser_mode].should be_nil
19
+ end
20
+
21
+ it "should not allow superuser_mode to be set in session if current_user is not a superuser" do
22
+ controller.stubs(:current_user).returns(@user2)
23
+ request.env["HTTP_REFERER"] = ""
24
+ get :superuser
25
+ session[:superuser_mode].should be_nil
26
+ end
27
+
28
+ it "should redirect to the referer" do
29
+ controller.stubs(:current_user).returns(@user)
30
+ request.env["HTTP_REFERER"] = file_assets_path
31
+ get :superuser
32
+ response.should redirect_to(file_assets_path)
33
+ end
34
+
35
+ end
@@ -0,0 +1,14 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
+ require "generators/hydra/head_generator"
4
+ require "generators/blacklight/blacklight_generator"
5
+
6
+ describe Hydra::HeadGenerator do
7
+
8
+ it "should be tested, but it's not clear how..."
9
+ it "should inject Hydra behaviors into User model by adding include Hydra::User" do
10
+ pending "Not sure how to test this..."
11
+ end
12
+
13
+ end
14
+
@@ -0,0 +1,212 @@
1
+ # Need way to find way to stub current_user and RoleMapper in order to run these tests
2
+ require File.expand_path( File.join( File.dirname(__FILE__),'..','spec_helper') )
3
+
4
+ describe Hydra::AccessControlsEnforcement do
5
+ before(:each) do
6
+ @extra_controller_params = {}
7
+ end
8
+
9
+ describe "enforce_access_controls" do
10
+ describe "[index]" do
11
+ it "should trigger enforce_index_permissions" do
12
+ helper.params[:action] = "index"
13
+ helper.expects(:enforce_index_permissions)
14
+ helper.enforce_access_controls
15
+ end
16
+ end
17
+ describe "[show]" do
18
+ it "should trigger enforce_show_permissions" do
19
+ helper.params[:action] = "show"
20
+ helper.expects(:enforce_show_permissions)
21
+ helper.enforce_access_controls
22
+ end
23
+ end
24
+
25
+ describe "[edit]" do
26
+ it "should trigger enforce_edit_permissions" do
27
+ helper.params[:action] = "edit"
28
+ helper.expects(:enforce_edit_permissions)
29
+ helper.enforce_access_controls
30
+ end
31
+ end
32
+ describe "[update]" do
33
+ it "should trigger enforce_update_permissions" do
34
+ helper.params[:action] = "update"
35
+ helper.expects(:enforce_update_permissions)
36
+ helper.enforce_access_controls
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ describe "add_access_controls_to_solr_params" do
43
+ it "should set up gated discovery" do
44
+ stub_solr_params = {}
45
+ helper.stubs(:reader?).returns(false)
46
+ helper.stubs(:params).returns({:action=>:index})
47
+ helper.expects(:apply_gated_discovery).with(stub_solr_params, {})
48
+ helper.send(:add_access_controls_to_solr_params, stub_solr_params, {})
49
+ end
50
+ it "should make blacklight use the :public_qt response handler if user does not have read permissions" do
51
+ stub_solr_params = {}
52
+ helper.stubs(:solr_parameters).returns(stub_solr_params)
53
+ helper.stubs(:reader?).returns(false)
54
+ helper.stubs(:params).returns({:action=>:index})
55
+ helper.stubs(:apply_gated_discovery)
56
+ helper.send(:add_access_controls_to_solr_params, stub_solr_params, {})
57
+ stub_solr_params[:qt].should == Blacklight.config[:public_qt]
58
+ end
59
+ end
60
+
61
+ describe "enforce_index_permissions" do
62
+ it "should be defined but do nothing (currently enforce_index_permissions doesn't do anything but it's there if you want to override)" do
63
+ # just ensure that calling the method does not raise an error
64
+ helper.send(:enforce_index_permissions)
65
+ end
66
+ end
67
+
68
+ describe "enforce_show_permissions" do
69
+ it "should deny access to documents if role does not have read permissions" do
70
+ helper.stubs(:reader?).returns(false)
71
+ helper.stubs(:params).returns({:action=>:show,:id=>"hydrangea:fixture_mods_article1"}) # the permissions from this are not actually used because we stub the :reader? method
72
+ helper.expects(:redirect_to).with(:f => nil, :q => nil, :action => 'index')
73
+ helper.send(:enforce_show_permissions)
74
+ flash[:notice].should == "You do not have sufficient access privileges to read this document, which has been marked private."
75
+ end
76
+ end
77
+ describe "enforce_edit_permissions" do
78
+ it "should deny access to documents if role does not have edit permissions" do
79
+ helper.stubs(:editor?).returns(false)
80
+ helper.stubs(:params).returns({:action=>:edit,:id=>"hydrangea:fixture_mods_article1"} ) # the permissions from this are not actually used because we stub the :editor? method
81
+ helper.expects(:redirect_to).with(:action => :show)
82
+ helper.send(:enforce_edit_permissions)
83
+ flash[:notice].should == "You do not have sufficient privileges to edit this document. You have been redirected to the read-only view."
84
+ end
85
+ end
86
+ describe "enforce_update_permissions" do
87
+ it "should deny access to documents if role does not have update permissions" do
88
+ helper.stubs(:editor?).returns(false)
89
+ helper.stubs(:params).returns({:action=>:edit,:id=>"hydrangea:fixture_mods_article1"} ) # the permissions from this are not actually used because we stub the :editor? method
90
+ helper.expects(:redirect_to).with(:action => :show)
91
+ helper.send(:enforce_update_permissions)
92
+ flash[:notice].should == "You do not have sufficient privileges to edit this document. You have been redirected to the read-only view."
93
+ end
94
+ end
95
+ describe "apply_gated_discovery" do
96
+ it "should set the query using build_lucene_query" do
97
+ stub_solr_params = {}
98
+ helper.stubs(:solr_parameters).returns(stub_solr_params)
99
+ user_query = "my important query"
100
+ helper.stubs(:params).returns({:q=>user_query} )
101
+ helper.expects(:build_lucene_query).with(user_query).returns("stub lucene query")
102
+ helper.send(:apply_gated_discovery, stub_solr_params, {})
103
+ stub_solr_params[:q].should == "stub lucene query"
104
+ end
105
+ end
106
+
107
+ describe "build_lucene_query" do
108
+
109
+ it "should return fields for all roles the user is a member of checking against the discover, access, read fields" do
110
+ stub_user = User.new
111
+ stub_user.stubs(:is_being_superuser?).returns false
112
+ stub_user.stubs(:login).returns "archivist1@example.com"
113
+ helper.stubs(:current_user).returns(stub_user)
114
+ # This example assumes that archivist1 is in the archivist and researcher groups.
115
+ # Tried stubbing RoleMapper.roles instead, but that broke 26 other tests because mocha fails to release the expectation.
116
+ # RoleMapper.stubs(:roles).with(stub_user.login).returns(["archivist", "researcher"])
117
+ query = helper.send(:build_lucene_query, "string")
118
+
119
+ ["discover","edit","read"].each do |type|
120
+ query.should match(/_query_\:\"#{type}_access_group_t\:archivist/) and
121
+ query.should match(/_query_\:\"#{type}_access_group_t\:researcher/)
122
+ end
123
+ end
124
+ it "should return fields for all the person specific discover, access, read fields" do
125
+ stub_user = User.new
126
+ stub_user.stubs(:is_being_superuser?).returns false
127
+ helper.stubs(:current_user).returns(stub_user)
128
+ query = helper.send(:build_lucene_query, "string")
129
+ ["discover","edit","read"].each do |type|
130
+ query.should match(/_query_\:\"#{type}_access_person_t\:#{stub_user.login}/)
131
+ end
132
+ end
133
+ describe "for superusers" do
134
+ it "should return superuser access level" do
135
+ stub_user = User.new
136
+ stub_user.stubs(:is_being_superuser?).returns true
137
+ helper.stubs(:current_user).returns(stub_user)
138
+ query = helper.send(:build_lucene_query, "string")
139
+ ["discover","edit","read"].each do |type|
140
+ query.should match(/_query_\:\"#{type}_access_person_t\:\[\* TO \*\]/)
141
+ end
142
+ end
143
+ it "should not return superuser access to non-superusers" do
144
+ stub_user = User.new
145
+ stub_user.stubs(:is_being_superuser?).returns false
146
+ helper.stubs(:current_user).returns(stub_user)
147
+ query = helper.send(:build_lucene_query, "string")
148
+ ["discover","edit","read"].each do |type|
149
+ query.should_not match(/_query_\:\"#{type}_access_person_t\:\[\* TO \*\]/)
150
+ end
151
+ end
152
+ end
153
+ end
154
+
155
+ it "should have necessary fieldnames from initializer" do
156
+ Hydra.config[:permissions][:catchall].should_not be_nil
157
+ Hydra.config[:permissions][:discover][:group].should_not be_nil
158
+ Hydra.config[:permissions][:discover][:individual].should_not be_nil
159
+ Hydra.config[:permissions][:read][:group].should_not be_nil
160
+ Hydra.config[:permissions][:read][:individual].should_not be_nil
161
+ Hydra.config[:permissions][:edit][:group].should_not be_nil
162
+ Hydra.config[:permissions][:edit][:individual].should_not be_nil
163
+ Hydra.config[:permissions][:owner].should_not be_nil
164
+ Hydra.config[:permissions][:embargo_release_date].should_not be_nil
165
+ end
166
+
167
+ # SPECS FOR SINGLE DOCUMENT REQUESTS
168
+ describe 'Get Document Permissions By Id' do
169
+ before(:each) do
170
+ @doc_id = 'hydrangea:fixture_mods_article1'
171
+ @bad_id = "redrum"
172
+ @response2, @document = helper.get_permissions_solr_response_for_doc_id(@doc_id)
173
+ end
174
+
175
+ it "should raise Blacklight::InvalidSolrID for an unknown id" do
176
+ lambda {
177
+ helper.get_permissions_solr_response_for_doc_id(@bad_id)
178
+ }.should raise_error(Blacklight::Exceptions::InvalidSolrID)
179
+ end
180
+
181
+ it "should raise Blacklight::InvalidSolrID for nil id" do
182
+ lambda {
183
+ helper.get_permissions_solr_response_for_doc_id(nil)
184
+ }.should raise_error(Blacklight::Exceptions::InvalidSolrID)
185
+ end
186
+
187
+ it "should have a non-nil result for a known id" do
188
+ @document.should_not == nil
189
+ end
190
+ it "should have a single document in the response for a known id" do
191
+ @response2.docs.size.should == 1
192
+ end
193
+ it 'should have the expected value in the id field' do
194
+ @document.id.should == @doc_id
195
+ end
196
+ it 'should have non-nil values for permissions fields that are set on the object' do
197
+ @document.get(Hydra.config[:permissions][:catchall]).should_not be_nil
198
+ @document.get(Hydra.config[:permissions][:discover][:group]).should_not be_nil
199
+ @document.get(Hydra.config[:permissions][:edit][:group]).should_not be_nil
200
+ @document.get(Hydra.config[:permissions][:edit][:individual]).should_not be_nil
201
+ @document.get(Hydra.config[:permissions][:read][:group]).should_not be_nil
202
+
203
+ # @document.get(Hydra.config[:permissions][:discover][:individual]).should_not be_nil
204
+ # @document.get(Hydra.config[:permissions][:read][:individual]).should_not be_nil
205
+ # @document.get(Hydra.config[:permissions][:owner]).should_not be_nil
206
+ # @document.get(Hydra.config[:permissions][:embargo_release_date]).should_not be_nil
207
+ end
208
+ end
209
+
210
+ end
211
+
212
+
@@ -0,0 +1,35 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Hydra::AccessControlsEvaluation do
4
+
5
+ describe "test_permission" do
6
+ it "should automatically add logged-in users to 'registered' group" do
7
+ mock_user = mock("User", :login => "logged_in_person")
8
+ helper.stubs(:read_groups).returns(["registered"])
9
+ helper.stubs(:current_user).returns(nil)
10
+ helper.test_permission(:read).should == false
11
+ helper.stubs(:current_user).returns(mock_user)
12
+ helper.test_permission(:read).should == true
13
+ end
14
+ end
15
+
16
+ describe "editor?" do
17
+ it "should return true if current_user.is_being_superuser? is true" do
18
+ mock_user = mock("User", :login => "BigWig")
19
+ mock_user.stubs(:is_being_superuser?).returns true
20
+ helper.stubs(:current_user).returns mock_user
21
+ helper.editor?.should be_true
22
+ end
23
+ it "should return false if the session[:user] is not logged in" do
24
+ helper.stubs(:current_user).returns(nil)
25
+ helper.editor?.should be_false
26
+ end
27
+ it "should return false if the session[:user] does not have an editor role" do
28
+ mock_user = mock("User", :login=>"nobody_special")
29
+ mock_user.stubs(:is_being_superuser?).returns(false)
30
+ helper.stubs(:current_user).returns(mock_user)
31
+ helper.editor?.should be_false
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,71 @@
1
+ require File.expand_path( File.join( File.dirname(__FILE__),'..','spec_helper') )
2
+
3
+ describe Hydra::AssetsControllerHelper do
4
+
5
+ describe "prep_updater_method_args" do
6
+ it "should parse the input params" do
7
+ sample_params = {"content_type"=>"mods_asset",
8
+ "action"=>"update",
9
+ "_method"=>"put",
10
+ "field_selectors"=>{"descMetadata"=>{"person_0_computing_id"=>[{"person"=>"0"}, "computing_id"], "journal_0_issue_start_page"=>[{"journal"=>"0"}, "issue", "start_page"], "person_1_description"=>[{"person"=>"1"}, "description"], "person_1_institution"=>[{"person"=>"1"}, "institution"], "journal_0_origin_info_publisher"=>[{"journal"=>"0"}, "origin_info", "publisher"], "abstract"=>["abstract"], "person_0_last_name"=>[{"person"=>"0"}, "last_name"], "person_0_description"=>[{"person"=>"0"}, "description"], "journal_0_issue_volume"=>[{"journal"=>"0"}, "issue", "volume"], "title_info_main_title"=>["title_info", "main_title"], "location_url"=>["location", "url"], "note"=>["note"], "person_1_last_name"=>[{"person"=>"1"}, "last_name"], "subject_topic"=>["subject", "topic"], "person_0_institution"=>[{"person"=>"0"}, "institution"], "person_1_first_name"=>[{"person"=>"1"}, "first_name"], "person_1"=>[{"person"=>"1"}], "journal_0_title_info_main_title"=>[{"journal"=>"0"}, "title_info", "main_title"], "journal_0_issue_level"=>[{"journal"=>"0"}, "issue", "level"], "journal_0_issue_end_page"=>[{"journal"=>"0"}, "issue", "end_page"], "peer_reviewed"=>["peer_reviewed"], "person_0_first_name"=>[{"person"=>"0"}, "first_name"], "person_1_computing_id"=>[{"person"=>"1"}, "computing_id"], "journal_0_issn"=>[{"journal"=>"0"}, "issn"], "journal_0_issue_publication_date"=>[{"journal"=>"0"}, "issue", "publication_date"]}, "rightsMetadata"=>{"embargo_embargo_release_date"=>["embargo", "embargo_release_date"]}, "properties"=>{"release_to"=>["release_to"]}},
11
+ "id"=>"hydrangea:fixture_mods_article3",
12
+ "controller"=>"assets",
13
+ "asset"=>{"descMetadata"=>{"person_0_computing_id"=>{"0"=>""}, "journal_0_issue_start_page"=>{"0"=>"195"}, "person_1_description"=>{"0"=>""}, "person_1_institution"=>{"0"=>"Baltimore"}, "journal_0_origin_info_publisher"=>{"0"=>"PUBLISHER"}, "abstract"=>{"0"=>"ABSTRACT"}, "person_0_last_name"=>{"0"=>"Smith"}, "person_0_description"=>{"0"=>""}, "journal_0_issue_volume"=>{"0"=>"2 "}, "title_info_main_title"=>{"0"=>"Test Article"}, "location_url"=>{"0"=>"http://example.com/foo"}, "note"=>{"0"=>""}, "person_1_last_name"=>{"0"=>"Lacks"}, "subject_topic"=>{"0"=>"TOPIC 1", "1"=>"TOPIC 2", "2"=>"CONTROLLED TERM"}, "person_0_institution"=>{"0"=>"FACULTY, UNIVERSITY"}, "person_1_first_name"=>{"0"=>"Henrietta"}, "journal_0_title_info_main_title"=>{"0"=>"The Journal of Mock Object"}, "journal_0_issue_level"=>{"0"=>""}, "journal_0_issue_end_page"=>{"0"=>"230"}, "person_0_first_name"=>{"0"=>"John"}, "person_1_computing_id"=>{"0"=>""}, "journal_0_issn"=>{"0"=>"1234-5678"}, "journal_0_issue_publication_date"=>{"0"=>"FEB. 2007"}}, "rightsMetadata"=>{"embargo_embargo_release_date"=>{"0"=>""}}, "properties"=>{"released"=>{"0"=>"true"}, "release_to"=>{"0"=>"public"}}}}
14
+ helper.stubs(:params).returns(sample_params)
15
+ helper.prep_updater_method_args[:params].should == {[{:journal=>0}, :issn]=>{"0"=>"1234-5678"}, [{:person=>0}, :description]=>{"0"=>""}, [:abstract]=>{"0"=>"ABSTRACT"}, [{:person=>0}, :last_name]=>{"0"=>"Smith"}, [{:journal=>0}, :issue, :level]=>{"0"=>""}, [:release_to]=>{"0"=>"public"}, [{:person=>1}, :computing_id]=>{"0"=>""}, [{:journal=>0}, :title_info, :main_title]=>{"0"=>"The Journal of Mock Object"}, [:subject, :topic]=>{"0"=>"TOPIC 1", "1"=>"TOPIC 2", "2"=>"CONTROLLED TERM"}, [{:person=>1}, :first_name]=>{"0"=>"Henrietta"}, [{:journal=>0}, :issue, :volume]=>{"0"=>"2 "}, [{:person=>1}, :institution]=>{"0"=>"Baltimore"}, [{:journal=>0}, :origin_info, :publisher]=>{"0"=>"PUBLISHER"}, [{:person=>0}, :computing_id]=>{"0"=>""}, [{:person=>0}, :first_name]=>{"0"=>"John"}, [:title_info, :main_title]=>{"0"=>"Test Article"}, [{:person=>0}, :institution]=>{"0"=>"FACULTY, UNIVERSITY"}, [{:journal=>0}, :issue, :end_page]=>{"0"=>"230"}, [:location, :url]=>{"0"=>"http://example.com/foo"}, [{:person=>1}, :description]=>{"0"=>""}, [{:person=>1}, :last_name]=>{"0"=>"Lacks"}, :released=>{"0"=>"true"}, [:embargo, :embargo_release_date]=>{"0"=>""}, [{:journal=>0}, :issue, :publication_date]=>{"0"=>"FEB. 2007"}, [:note]=>{"0"=>""}, [{:journal=>0}, :issue, :start_page]=>{"0"=>"195"}}
16
+ helper.prep_updater_method_args[:opts].should == {:datastreams=>"properties"}
17
+ end
18
+ end
19
+
20
+ describe "sanitize_update_params" do
21
+ it "should create a hash appropriate for passing into ActiveFedora::Base.update_datastream_attributes" do
22
+ sample_params = {
23
+ "content_type"=>"mods_asset",
24
+ "action"=>"update",
25
+ "_method"=>"put",
26
+ "field_selectors"=>{
27
+ "descMetadata"=>{"person_0_computing_id"=>[{"person"=>"0"}, "computing_id"], "journal_0_issue_start_page"=>[{"journal"=>"0"}, "issue", "start_page"], "person_1_description"=>[{"person"=>"1"}, "description"], "person_1_institution"=>[{"person"=>"1"}, "institution"], "journal_0_origin_info_publisher"=>[{"journal"=>"0"}, "origin_info", "publisher"], "abstract"=>["abstract"], "person_0_last_name"=>[{"person"=>"0"}, "last_name"], "person_0_description"=>[{"person"=>"0"}, "description"], "journal_0_issue_volume"=>[{"journal"=>"0"}, "issue", "volume"], "title_info_main_title"=>["title_info", "main_title"], "location_url"=>["location", "url"], "note"=>["note"], "person_1_last_name"=>[{"person"=>"1"}, "last_name"], "subject_topic"=>["subject", "topic"], "person_0_institution"=>[{"person"=>"0"}, "institution"], "person_1_first_name"=>[{"person"=>"1"}, "first_name"], "person_1"=>[{"person"=>"1"}], "journal_0_title_info_main_title"=>[{"journal"=>"0"}, "title_info", "main_title"], "journal_0_issue_level"=>[{"journal"=>"0"}, "issue", "level"], "journal_0_issue_end_page"=>[{"journal"=>"0"}, "issue", "end_page"], "peer_reviewed"=>["peer_reviewed"], "person_0_first_name"=>[{"person"=>"0"}, "first_name"], "person_1_computing_id"=>[{"person"=>"1"}, "computing_id"], "journal_0_issn"=>[{"journal"=>"0"}, "issn"], "journal_0_issue_publication_date"=>[{"journal"=>"0"}, "issue", "publication_date"]},
28
+ "rightsMetadata"=>{"embargo_embargo_release_date"=>["embargo", "embargo_release_date"]},
29
+ "properties"=>{"release_to"=>["release_to"]}
30
+ },
31
+ "id"=>"hydrangea:fixture_mods_article3",
32
+ "controller"=>"assets",
33
+ "asset"=>{"descMetadata"=>{"person_0_computing_id"=>{"0"=>""}, "journal_0_issue_start_page"=>{"0"=>"195"}, "person_1_description"=>{"0"=>""}, "person_1_institution"=>{"0"=>"Baltimore"}, "journal_0_origin_info_publisher"=>{"0"=>"PUBLISHER"}, "abstract"=>{"0"=>"ABSTRACT"}, "person_0_last_name"=>{"0"=>"Smith"}, "person_0_description"=>{"0"=>""}, "journal_0_issue_volume"=>{"0"=>"2 "}, "title_info_main_title"=>{"0"=>"Test Article"}, "location_url"=>{"0"=>"http://example.com/foo"}, "note"=>{"0"=>""}, "person_1_last_name"=>{"0"=>"Lacks"}, "subject_topic"=>{"0"=>"TOPIC 1", "1"=>"TOPIC 2", "2"=>"CONTROLLED TERM"}, "person_0_institution"=>{"0"=>"FACULTY, UNIVERSITY"}, "person_1_first_name"=>{"0"=>"Henrietta"}, "journal_0_title_info_main_title"=>{"0"=>"The Journal of Mock Object"}, "journal_0_issue_level"=>{"0"=>""}, "journal_0_issue_end_page"=>{"0"=>"230"}, "person_0_first_name"=>{"0"=>"John"}, "person_1_computing_id"=>{"0"=>""}, "journal_0_issn"=>{"0"=>"1234-5678"}, "journal_0_issue_publication_date"=>{"0"=>"FEB. 2007"}}, "rightsMetadata"=>{"embargo_embargo_release_date"=>{"0"=>""}}, "properties"=>{"released"=>{"0"=>"true"}, "release_to"=>{"0"=>"public"}}}
34
+ }
35
+
36
+ expected_sane_params = {
37
+ "descMetadata"=>{[{:person=>0}, :institution]=>{"0"=>"FACULTY, UNIVERSITY"}, [{:journal=>0}, :title_info, :main_title]=>{"0"=>"The Journal of Mock Object"}, [{:journal=>0}, :issue, :volume]=>{"0"=>"2 "}, [{:journal=>0}, :issn]=>{"0"=>"1234-5678"}, [{:person=>1}, :first_name]=>{"0"=>"Henrietta"}, [{:person=>0}, :last_name]=>{"0"=>"Smith"}, [:location, :url]=>{"0"=>"http://example.com/foo"}, [:subject, :topic]=>{"0"=>"TOPIC 1", "1"=>"TOPIC 2", "2"=>"CONTROLLED TERM"}, [{:person=>0}, :first_name]=>{"0"=>"John"}, [{:person=>1}, :computing_id]=>{"0"=>""}, [{:journal=>0}, :issue, :end_page]=>{"0"=>"230"}, [:note]=>{"0"=>""}, [:title_info, :main_title]=>{"0"=>"Test Article"}, [{:journal=>0}, :issue, :publication_date]=>{"0"=>"FEB. 2007"}, [{:person=>1}, :description]=>{"0"=>""}, [:abstract]=>{"0"=>"ABSTRACT"}, [{:journal=>0}, :issue, :level]=>{"0"=>""}, [{:person=>1}, :institution]=>{"0"=>"Baltimore"}, [{:person=>0}, :computing_id]=>{"0"=>""}, [{:person=>1}, :last_name]=>{"0"=>"Lacks"}, [{:journal=>0}, :issue, :start_page]=>{"0"=>"195"}, [{:person=>0}, :description]=>{"0"=>""}, [{:journal=>0}, :origin_info, :publisher]=>{"0"=>"PUBLISHER"}}, "rightsMetadata"=>{[:embargo, :embargo_release_date]=>{"0"=>""}},
38
+ "properties"=>{[:release_to]=>{"0"=>"public"}, :released=>{"0"=>"true"}}
39
+ }
40
+ helper.stubs(:params).returns(sample_params)
41
+ sanitized_params = helper.sanitize_update_params
42
+ sanitized_params.should == expected_sane_params
43
+ sanitized_params["descMetadata"].should == expected_sane_params["descMetadata"]
44
+ end
45
+ end
46
+
47
+ describe "tidy_response_from_update" do
48
+ it "should put response values into an array with fieldname / index / value Hash for each field updated" do
49
+ sample_input = {"descMetadata"=>{"journal_0_issue_start_page"=>{"0"=>"195"}, "person_0_computing_id"=>{"-1"=>""}, "journal_0_origin_info_publisher"=>{"0"=>"PUBLISHER"}, "person_1_institution"=>{"0"=>"Baltimore"}, "person_1_description"=>{"-1"=>""}, "abstract"=>{"0"=>"ABSTRACT"}, "person_0_description"=>{"-1"=>""}, "person_0_last_name"=>{"0"=>"Smith"}, "journal_0_issue_volume"=>{"0"=>"2 "}, "title_info_main_title"=>{"0"=>"Matt's Test Article! Again!?"}, "note"=>{"-1"=>""}, "location_url"=>{"0"=>"http://example.com/foo"}, "person_1_last_name"=>{"0"=>"Lacks"}, "subject_topic"=>{"0"=>"TOPIC 1", "1"=>"TOPIC 2", "2"=>"CONTROLLED TERM"}, "journal_0_issue_level"=>{"0"=>"55 "}, "journal_0_issue_end_page"=>{"0"=>"230"}, "person_1_first_name"=>{"0"=>"Henrietta"}, "person_0_institution"=>{"0"=>"FACULTY, UNIVERSITY"}, "journal_0_title_info_main_title"=>{"0"=>"The Journal of Mock Object"}, "journal_0_issue_publication_date"=>{"0"=>"FEB. 2007"}, "person_1_computing_id"=>{"-1"=>""}, "person_0_first_name"=>{"0"=>"John"}, "journal_0_issn"=>{"0"=>"1234-5678"}}, "rightsMetadata"=>{"embargo_embargo_release_date"=>{"-1"=>""}}, "properties"=>{:released=>{"0"=>"true"}, :release_to=>{"0"=>"public"}, [:release_to]=>{}}}
50
+ expected_output = {"updated"=>[{"value"=>{"0"=>"195"}, "index"=>"journal_0_issue_start_page", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"person_0_computing_id", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"PUBLISHER"}, "index"=>"journal_0_origin_info_publisher", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"Baltimore"}, "index"=>"person_1_institution", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"person_1_description", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"ABSTRACT"}, "index"=>"abstract", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"person_0_description", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"Smith"}, "index"=>"person_0_last_name", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"2 "}, "index"=>"journal_0_issue_volume", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"Matt's Test Article! Again!?"}, "index"=>"title_info_main_title", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"note", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"http://example.com/foo"}, "index"=>"location_url", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"Lacks"}, "index"=>"person_1_last_name", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"TOPIC 1", "1"=>"TOPIC 2", "2"=>"CONTROLLED TERM"}, "index"=>"subject_topic", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"55 "}, "index"=>"journal_0_issue_level", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"230"}, "index"=>"journal_0_issue_end_page", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"Henrietta"}, "index"=>"person_1_first_name", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"FACULTY, UNIVERSITY"}, "index"=>"person_0_institution", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"The Journal of Mock Object"}, "index"=>"journal_0_title_info_main_title", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"FEB. 2007"}, "index"=>"journal_0_issue_publication_date", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"person_1_computing_id", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"John"}, "index"=>"person_0_first_name", "field_name"=>"descMetadata"}, {"value"=>{"0"=>"1234-5678"}, "index"=>"journal_0_issn", "field_name"=>"descMetadata"}, {"value"=>{"-1"=>""}, "index"=>"embargo_embargo_release_date", "field_name"=>"rightsMetadata"}, {"value"=>{"0"=>"true"}, "index"=>:released, "field_name"=>"properties"}, {"value"=>{"0"=>"public"}, "index"=>:release_to, "field_name"=>"properties"}, {"value"=>{}, "index"=>[:release_to], "field_name"=>"properties"}]}
51
+ result = helper.tidy_response_from_update(sample_input)
52
+ (expected_output["updated"] - result["updated"]).should == []
53
+ end
54
+ it "if handling submission from jeditable (which will only submit one value at a time), return the value it submitted" do
55
+ sample_input = {"descMetadata"=>{"journal_0_issue_start_page"=>{"0"=>"195"}} }
56
+ expected_output = {"0"=>"195"}
57
+ helper.stubs(:params).returns({:field_id => "my field id"})
58
+ helper.tidy_response_from_update(sample_input).should == expected_output
59
+ end
60
+ end
61
+
62
+ describe "update_document" do
63
+ it "should update the document with the provided params" do
64
+ sample_params = "sample params"
65
+ mock_document = mock("document")
66
+ mock_document.expects(:update_datastream_attributes).with(sample_params)
67
+ helper.update_document(mock_document, sample_params)
68
+ end
69
+ end
70
+
71
+ end