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,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe BlacklightHelper do
4
+ # include ApplicationHelper
5
+
6
+ it "should include HydraHelper" do
7
+ BlacklightHelper.included_modules.should include(HydraHelper)
8
+ end
9
+
10
+ describe "Application Name Sanity Check" do
11
+ it "should have the application correct name" do
12
+ helper.application_name.should == "A Hydra Head"
13
+ end
14
+ end
15
+
16
+ describe "Overridden blacklight methods" do
17
+ describe "render_head_content" do
18
+ before (:each) do
19
+ helper.expects(:content_for).with(:head).returns("My added content")
20
+ end
21
+ it "adds the content of content_for(:head) to the output" do
22
+ helper.render_head_content.should == "My added content"
23
+ end
24
+ end
25
+ describe "link_to_document" do
26
+ before(:each)do
27
+ @mock_doc = mock('mock doc')
28
+ @mock_doc.expects(:[]).with(:id).returns("123456")
29
+ end
30
+ it "passes on the title attribute to the link_to_with_data method" do
31
+ helper.link_to_document(@mock_doc,:label=>"Some crazy long label...",:title=>"Some crazy longer label").should match(/title=\"Some crazy longer label\"/)
32
+ end
33
+ it "doesn't add an erroneous title attribute if one isn't provided" do
34
+ helper.link_to_document(@mock_doc,:label=>"Some crazy long label...").should_not match(/title=/)
35
+ end
36
+ end
37
+
38
+ describe "link back to catalog" do
39
+ it "should return the view parameter in the link back to catalog method if there is one in the users previous search session" do
40
+ session[:search] = {:view=>"list"}
41
+ helper.link_back_to_catalog.should match(/\?view=list/)
42
+ end
43
+ it "should not return the view parameter if it wasn't provided" do
44
+ session[:search] = {}
45
+ helper.link_back_to_catalog.should_not match(/\?view=/)
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "SALT methods" do
51
+ describe "get_data_with_linked_label" do
52
+ before(:each) do
53
+ @doc = {"field"=>["Item1","Item2","Item3"]}
54
+ end
55
+ it "should return a string representing the collection of items with the suplied delimiter" do
56
+ helper.get_data_with_linked_label(@doc,"Items","field",{:delimiter=>", "}).should match(/, /)
57
+ end
58
+ it "should return a string representing the collection of items with the default <br/> delimiter" do
59
+ helper.get_data_with_linked_label(@doc,"Items","field").should match(/<br\/>/)
60
+ end
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,107 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Hydra::FileAssetsHelper do
4
+ describe "create_and_save_file_asset_from_params" do
5
+ it "should create the file asset, add posted blob to it and save the file asset" do
6
+ helper.stubs(:params).returns( { :Filedata => "" } )
7
+ mock_fa = mock("file asset")
8
+ mock_fa.expects(:save)
9
+ helper.expects(:create_asset_from_params).returns(mock_fa)
10
+ helper.expects(:add_posted_blob_to_asset)
11
+ helper.create_and_save_file_asset_from_params
12
+ end
13
+ end
14
+
15
+ describe "add_posted_blob_to_asset" do
16
+ it "should set object title and label" do
17
+ mock_file = mock("File")
18
+ file_name = "Posted Filename.foo"
19
+ helper.stubs(:params).returns( :Filedata=>mock_file, :Filename=>file_name, "container_id"=>"hydrangea:2973" )
20
+ mock_fa = mock("file asset")
21
+ mock_fa.expects(:add_file_datastream).with(mock_file, :label=>file_name, :mimeType=>"mymimetype")
22
+ mock_fa.expects(:set_title_and_label).with( file_name, :only_if_blank=>true )
23
+ helper.expects(:mime_type).with(file_name).returns("mymimetype")
24
+ helper.add_posted_blob_to_asset(mock_fa)
25
+ end
26
+
27
+ it "should support submissions from swfupload" do
28
+ mock_file = mock("File")
29
+ file_name = "Posted Filename.foo"
30
+ helper.stubs(:params).returns( :Filedata=>mock_file, :Filename=>file_name, "container_id"=>"hydrangea:2973" )
31
+ mock_fa = mock("file asset")
32
+ mock_fa.expects(:add_file_datastream).with(mock_file, :label=>file_name, :mimeType=>"mymimetype")
33
+ mock_fa.stubs(:set_title_and_label)
34
+ helper.expects(:mime_type).with(file_name).returns("mymimetype")
35
+ helper.add_posted_blob_to_asset(mock_fa)
36
+ end
37
+ it "should support submissions from single-file uploader" do
38
+ mock_file = mock("File")
39
+ file_name = "Posted Filename.foo"
40
+ helper.expects(:filename_from_params).returns(file_name)
41
+ helper.stubs(:params).returns( :Filedata=>mock_file, :container_id=>"hydrangea:2973" )
42
+ mock_fa = mock("file asset")
43
+ helper.expects(:mime_type).with(file_name).returns("mymimetype")
44
+ mock_fa.expects(:add_file_datastream).with(mock_file, :label=>file_name, :mimeType=>"mymimetype")
45
+ mock_fa.stubs(:set_title_and_label)
46
+ helper.add_posted_blob_to_asset(mock_fa)
47
+ end
48
+ end
49
+
50
+ describe "create_asset_from_params" do
51
+ it "should create a new file asset and set the label from params[:Filename]" do
52
+ helper.stubs(:params).returns( { :Filename => "Test Filename" } )
53
+ result = helper.create_asset_from_params
54
+ result.should be_kind_of FileAsset
55
+ result.label.should == "Test Filename"
56
+ end
57
+ it "should choose model by filename" do
58
+ pending "this is currently disabled"
59
+ helper.expects(:choose_model_by_filename)
60
+ helper.create_asset_from_params
61
+ end
62
+ end
63
+
64
+ describe "posted_file" do
65
+ it "should return the posted file" do
66
+ helper.expects(:params).returns(:Filedata=>"test posted file")
67
+ helper.posted_file.should == "test posted file"
68
+ end
69
+ it "should return nil if no file was posted" do
70
+ helper.posted_file.should == nil
71
+ end
72
+ end
73
+
74
+ describe "filename_from_params" do
75
+ it "should return the value of params[:Filename] if it was submitted" do
76
+ helper.stubs(:params).returns(:Filename => "Test Filename")
77
+ helper.filename_from_params.should == "Test Filename"
78
+ end
79
+ it "should default to using the original filename of the posted file" do
80
+ helper.stubs(:params).returns({})
81
+ helper.expects(:posted_file).returns(mock("File", :original_filename=>"Test Original Filename"))
82
+ helper.filename_from_params.should == "Test Original Filename"
83
+ end
84
+ end
85
+
86
+ describe "choose_model_by_filename" do
87
+ it "should return model classes based on filename extensions" do
88
+ pending "This can only be enabled if/when we adopt replacements for ImageAsset, AudioAsset, etc. as default primitives."
89
+
90
+ ["filename.wav","filename.mp3","filename.aiff"].each do |fn|
91
+ helper.choose_model_by_filename(fn).should == AudioAsset
92
+ end
93
+
94
+ ["filename.mov","filename.flv","filename.mp4", "filename.m4v"].each do |fn|
95
+ helper.choose_model_by_filename(fn).should == VideoAsset
96
+ end
97
+
98
+ ["filename.jpeg","filename.jpg","filename.gif", "filename.png"].each do |fn|
99
+ helper.choose_model_by_filename(fn).should == ImageAsset
100
+ end
101
+
102
+ ["filename.doc","filename.pdf","filename.jp2", "filename.zip"].each do |fn|
103
+ helper.choose_model_by_filename(fn).should == FileAsset
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,32 @@
1
+ require File.expand_path( File.join( 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 Hydra::RepositoryController do
12
+
13
+ describe "load_document_from_params" do
14
+ it "should choose which model to use based on submitted params" do
15
+ mock_model_class = mock("model class")
16
+ mock_model_class.expects(:find).with("object id")
17
+ helper.stubs(:params).returns( {:content_type => "preferred model", :id => "object id"} )
18
+ helper.expects(:retrieve_af_model).with("preferred model").returns(mock_model_class)
19
+ helper.load_document_from_params
20
+ end
21
+ end
22
+
23
+ describe "format_pid" do
24
+ it "convert pids into XHTML safe strings" do
25
+ pid = helper.format_pid("hydra:123")
26
+ pid.should match(/hydra_123/)
27
+ end
28
+ end
29
+
30
+
31
+
32
+ end
@@ -0,0 +1,195 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe HydraAssetsHelper do
4
+ include HydraAssetsHelper
5
+
6
+ describe "link_to_create_asset" do
7
+ it "should generate login links with redirect params if user is not logged in" do
8
+ helper.expects(:current_user).returns User.new
9
+ helper.link_to_create_asset("Create a foo", "foo_model").should == "<a href=\"/assets/new?content_type=foo_model\" class=\"create_asset\">Create a foo</a>"
10
+ end
11
+ it "should generate login links with redirect params if user is not logged in" do
12
+ helper.expects(:current_user).returns false
13
+ helper.link_to_create_asset("Create a foo", "foo_model").should == "<a href=\"/users/sign_in?redirect_params[action]=new&amp;redirect_params[content_type]=foo_model&amp;redirect_params[controller]=assets\" class=\"create_asset\">Create a foo</a>"
14
+ end
15
+ end
16
+
17
+ describe "delete_asset_link" do
18
+ it "should generate a delete link and confirmation dialog" do
19
+ generated_html = helper.delete_asset_link("__PID__", "whizbang")
20
+ generated_html.should have_selector "a.delete_asset[href='/catalog/__PID__/delete']", :content=> "Delete this whizbang"
21
+ generated_html.should be_html_safe
22
+ # generated_html.should have_tag 'a.inline[href=#delete_dialog]', "Delete this whizbang"
23
+ # generated_html.should have_tag 'div#delete_dialog' do
24
+ # with_tag "p", "Do you want to permanently delete this article from the repository?"
25
+ # with_tag "form[action=?]", url_for(:action => "destroy", :controller => "assets", :id => "__PID__", :method => "delete") do
26
+ # with_tag "input[type=hidden][name=_method][value=delete]"
27
+ # with_tag "input[type=submit]"
28
+ # end
29
+ # end
30
+ end
31
+ end
32
+
33
+ describe "get_person_from_role" do
34
+ before(:all) do
35
+ @single_person_doc = {"person_0_role_t" => ["creator"], "person_0_first_name_t" => "GIVEN NAME", "person_0_last_name_t" => "FAMILY NAME"}
36
+ @multiple_persons_doc = {"person_0_role_t" => ["contributor","owner"], "person_0_first_name_t" => "CONTRIBUTOR GIVEN NAME", "person_0_last_name_t" => "CONTRIBUTOR FAMILY NAME",
37
+ "person_1_role_t" => ["creator"], "person_1_first_name_t" => "CREATOR GIVEN NAME", "person_1_last_name_t" => "CREATOR FAMILY NAME"}
38
+ end
39
+ it "should return the appropriate when 1 is available" do
40
+ person = get_person_from_role(@single_person_doc,"creator")
41
+ person[:first].should == "GIVEN NAME" and
42
+ person[:last].should == "FAMILY NAME"
43
+ end
44
+ it "should return the appririate person when there is multiple users" do
45
+ person = get_person_from_role(@multiple_persons_doc,"creator")
46
+ person[:first].should == "CREATOR GIVEN NAME" and
47
+ person[:last].should == "CREATOR FAMILY NAME"
48
+ end
49
+ it "should return the appropriate person when they have multiple roles" do
50
+ person = get_person_from_role(@multiple_persons_doc,"owner")
51
+ person[:first].should == "CONTRIBUTOR GIVEN NAME" and
52
+ person[:last].should == "CONTRIBUTOR FAMILY NAME"
53
+ end
54
+ it "should return nil when there is no user for the given role" do
55
+ get_person_from_role(@multiple_persons_doc,"bad_role").should be_nil
56
+ end
57
+ end
58
+
59
+ describe "get_file_asset_count" do
60
+ before(:each) do
61
+ #setup objects for following cases
62
+ #
63
+ #outbound has_collection_member
64
+ #outbound has_collection_member + inbound is_part_of
65
+ #outbound has_collection_member + outbound has_part + inbound is_part_of
66
+ #outbound has_part
67
+ #outbound has_part + inbound is_part_of
68
+ #inbound is_part_of
69
+ #none
70
+ @asset_object1 = ActiveFedora::Base.new
71
+ @asset_object2 = ActiveFedora::Base.new
72
+ @asset_object3 = ActiveFedora::Base.new
73
+ @asset_object4 = ActiveFedora::Base.new
74
+ @asset_object5 = ActiveFedora::Base.new
75
+ @asset_object6 = ActiveFedora::Base.new
76
+ @asset_object7 = ActiveFedora::Base.new
77
+ @file_object1 = ActiveFedora::Base.new
78
+ @file_object2 = ActiveFedora::Base.new
79
+ @file_object3 = ActiveFedora::Base.new
80
+ @file_object4 = ActiveFedora::Base.new
81
+
82
+ @asset_object1.collection_members_append(@file_object1)
83
+ @asset_object1.collection_members_append(@file_object2)
84
+
85
+ @asset_object2.collection_members_append(@file_object1)
86
+ @asset_object2.collection_members_append(@file_object2)
87
+ @asset_object2.add_relationship(:has_part,@file_object3)
88
+
89
+ @asset_object3.collection_members_append(@file_object1)
90
+ @asset_object3.collection_members_append(@file_object2)
91
+ @asset_object3.add_relationship(:has_part,@file_object3)
92
+ @file_object4.part_of_append(@asset_object3)
93
+
94
+ @asset_object4.add_relationship(:has_part,@file_object1)
95
+ @asset_object5.add_relationship(:has_part,@file_object1)
96
+ @file_object2.part_of_append(@asset_object5)
97
+ @file_object1.part_of_append(@asset_object6)
98
+
99
+ @asset_object1.save
100
+ @asset_object2.save
101
+ @asset_object3.save
102
+ @asset_object4.save
103
+ @asset_object5.save
104
+ @asset_object6.save
105
+ @asset_object7.save
106
+ @file_object1.save
107
+ @file_object2.save
108
+ @file_object3.save
109
+ @file_object4.save
110
+ end
111
+
112
+ after(:each) do
113
+ begin
114
+ @asset_object1.delete
115
+ rescue
116
+ end
117
+ begin
118
+ @asset_object2.delete
119
+ rescue
120
+ end
121
+ begin
122
+ @asset_object3.delete
123
+ rescue
124
+ end
125
+ begin
126
+ @asset_object4.delete
127
+ rescue
128
+ end
129
+ begin
130
+ @asset_object5.delete
131
+ rescue
132
+ end
133
+ begin
134
+ @asset_object6.delete
135
+ rescue
136
+ end
137
+ begin
138
+ @asset_object7.delete
139
+ rescue
140
+ end
141
+ begin
142
+ @file_object1.delete
143
+ rescue
144
+ end
145
+ begin
146
+ @file_object2.delete
147
+ rescue
148
+ end
149
+ begin
150
+ @file_object3.delete
151
+ rescue
152
+ end
153
+ begin
154
+ @file_object4.delete
155
+ rescue
156
+ end
157
+ end
158
+
159
+ it "should return the correct number of assets with either has_collection_member file assets or parts" do
160
+
161
+ #cases are
162
+ #outbound has_collection_member
163
+ #outbound has_collection_member + inbound is_part_of
164
+ #outbound has_collection_member + outbound has_part + inbound is_part_of
165
+ #outbound has_part
166
+ #outbound has_part + inbound is_part_of
167
+ #inbound is_part_of
168
+ #none
169
+
170
+ result = ActiveFedora::Base.find_by_solr(@asset_object1.pid)
171
+ doc = result.hits.first
172
+ get_file_asset_count(doc).should == 2
173
+ result = ActiveFedora::Base.find_by_solr(@asset_object2.pid)
174
+ doc = result.hits.first
175
+ get_file_asset_count(doc).should == 3
176
+ result = ActiveFedora::Base.find_by_solr(@asset_object3.pid)
177
+ doc = result.hits.first
178
+ get_file_asset_count(doc).should == 4
179
+ result = ActiveFedora::Base.find_by_solr(@asset_object4.pid)
180
+ doc = result.hits.first
181
+ get_file_asset_count(doc).should == 1
182
+ result = ActiveFedora::Base.find_by_solr(@asset_object5.pid)
183
+ doc = result.hits.first
184
+ get_file_asset_count(doc).should == 2
185
+ result = ActiveFedora::Base.find_by_solr(@asset_object6.pid)
186
+ doc = result.hits.first
187
+ get_file_asset_count(doc).should == 1
188
+
189
+ result = ActiveFedora::Base.find_by_solr(@asset_object7.pid)
190
+ doc = result.hits.first
191
+ get_file_asset_count(doc).should == 0
192
+ end
193
+ end
194
+
195
+ end
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ include HydraDjatokaHelper
3
+
4
+
5
+ describe HydraDjatokaHelper do
6
+
7
+ describe "hydra_djatoka_url_for" do
8
+ it "should return the url for retrieving the given document's canonical jp2 url" do
9
+ mock_doc = mock("document")
10
+ mock_doc.expects(:kind_of?).with(SolrDocument).returns(true)
11
+ mock_doc.expects(:id).returns("myPid")
12
+
13
+ hydra_djatoka_url_for(mock_doc).should == "/get/myPid.jp2?image_server=true"
14
+ end
15
+ it "should work with a mash as the document" do
16
+ mock_doc = mock("document")
17
+ mock_doc.expects(:kind_of?).with(SolrDocument).returns(false)
18
+ mock_doc.expects(:kind_of?).with(Mash).returns(true)
19
+ mock_doc.expects(:[]).with(:id).returns("myPid")
20
+
21
+ hydra_djatoka_url_for(mock_doc).should == "/get/myPid.jp2?image_server=true"
22
+ end
23
+ it "should accept scale arguments" do
24
+ mock_doc = mock("document")
25
+ mock_doc.expects(:kind_of?).with(SolrDocument).returns(true)
26
+ mock_doc.expects(:id).returns("myPid")
27
+
28
+ hydra_djatoka_url_for(mock_doc, :scale=>"90").should == "/get/myPid.jp2?image_server[scale]=90"
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,215 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe HydraFedoraMetadataHelper do
4
+
5
+ before(:all) do
6
+ # @mock_ng_ds = mock("nokogiri datastream")
7
+ # @mock_ng_ds.stubs(:kind_of?).with(ActiveFedora::NokogiriDatastream).returns(true)
8
+ # @mock_ng_ds.stubs(:class).returns(ActiveFedora::NokogiriDatastream)
9
+ # @mock_md_ds = stub(:stream_values=>"value")
10
+ # datastreams = {"ng_ds"=>@mock_ng_ds,"simple_ds"=>@mock_md_ds}
11
+ @resource = mock("fedora object")
12
+ # @resource.stubs(:datastreams).returns(datastreams)
13
+ # @resource.stubs(:datastreams_in_memory).returns(datastreams)
14
+
15
+ @resource.stubs(:get_values_from_datastream).with("simple_ds", "subject", "").returns( ["topic1","topic2"] )
16
+
17
+ @resource.stubs(:get_values_from_datastream).with("ng_ds", [:title, :main_title], "").returns( ["My Title"] )
18
+ @resource.stubs(:get_values_from_datastream).with("ng_ds", [{:person=>1}, :given_name], "").returns( ["Bob"] )
19
+
20
+ @resource.stubs(:get_values_from_datastream).with("empty_ds", "something", "").returns( [""] )
21
+ end
22
+
23
+ describe "fedora_text_field" do
24
+ it "should generate a text field input with values from the given datastream" do
25
+ generated_html = helper.fedora_text_field(@resource,"ng_ds",[:title, :main_title])
26
+ generated_html.should have_selector "#title_main_title_0-container.editable-container" do |container|
27
+ container.should have_selector "span#title_main_title_0-text.editable-text.text", "My Title"
28
+ container.should have_selector "input#title_main_title_0.editable-edit.edit" do |input|
29
+ input.should have_selector "[value=?]", "My Title"
30
+ input.should have_selector "[name=?]", "asset[ng_ds][title_main_title][0]"
31
+ input.should have_selector "[data-datastream-name=?]", "ng_ds"
32
+ input.should have_selector "[rel=?]", "title_main_title"
33
+ end
34
+ end
35
+ end
36
+ it "should generate an ordered list of text field inputs" do
37
+ generated_html = helper.fedora_text_field(@resource,"simple_ds","subject")
38
+ generated_html.should have_selector "ol[rel=subject]" do |tag|
39
+ tag.should have_selector "li#subject_0-container.editable-container.field" do |tag|
40
+ tag.should have_selector "a.destructive.field"
41
+ tag.should have_selector "span#subject_0-text.editable-text.text", "topic1"
42
+ tag.should have_selector "input#subject_0.editable-edit.edit" do |tag|
43
+ tag.should have_selector "[value=?]", "topic1"
44
+ tag.should have_selector "[name=?]", "asset[simple_ds][subject][0]"
45
+ end
46
+ end
47
+ tag.should have_selector "li#subject_1-container.editable-container.field" do |tag|
48
+ tag.should have_selector "a.destructive.field"
49
+ tag.should have_selector "span#subject_1-text.editable-text.text", "topic2"
50
+ tag.should have_selector "input#subject_1.editable-edit.edit" do |tag|
51
+ tag.should have_selector "[value=?]", "topic2"
52
+ tag.should have_selector "[name=?]", "asset[simple_ds][subject][1]"
53
+ end
54
+ end
55
+ end
56
+ generated_html.should have_selector "input", :class=>"editable-edit", :id=>"subject_1", :name=>"asset[simple_ds][subject_1]", :value=>"topic9"
57
+ generated_html.should be_html_safe
58
+ end
59
+ it "should render an empty control if the field has no values" do
60
+ helper.fedora_text_field(@resource,"empty_ds","something").should have_selector "li#something_0-container.editable-container" do |tag|
61
+ tag.should have_selector "#something_0-text.editable-text.text", ""
62
+ end
63
+ end
64
+ it "should limit to single-value output with no ordered list if :multiple=>false" do
65
+ generated_html = helper.fedora_text_field(@resource,"simple_ds","subject", :multiple=>false)
66
+ generated_html.should_not have_selector "ol"
67
+ generated_html.should_not have_selector "li"
68
+
69
+ generated_html.should have_selector "span#subject-container.editable-container.field" do |tag|
70
+ tag.should have_selector "span#subject-text.editable-text.text", "topic1"
71
+ tag.should have_selector "input#subject.editable-edit.edit[value=topic1]" do |tag|
72
+ tag.should have_selector "[name=?]", "asset[simple_ds][subject][0]"
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ describe "fedora_text_area" do
79
+ it "should generate an ordered list of textile-enabled text area with values from the given datastream" do
80
+ helper.fedora_text_area(@resource,"simple_ds","subject").should have_selector "ol[rel=subject]" do |tag|
81
+ tag.should have_selector "li#subject_0-container.field" do |tag|
82
+ tag.should_not have_selector "a.destructive.field"
83
+ tag.should have_selector "span#subject_0-text.editable-text.text[style=display:none;]", "topic1"
84
+ tag.should have_selector "textarea#subject_0.editable-edit.edit", "topic1"
85
+ end
86
+ tag.should have_selector "li#subject_1-container.field" do |tag|
87
+ tag.should have_selector "span#subject_1-text.editable-text.text[style=display:none;]","topic2"
88
+ tag.should have_selector "textarea#subject_1.editable-edit.edit", "topic2"
89
+ end
90
+ end
91
+ end
92
+ it "should render an empty control if the field has no values" do
93
+ helper.fedora_text_area(@resource,"empty_ds","something").should have_selector "li#something_0-container.field" do |tag|
94
+ tag.should have_selector "span#something_0-text.editable-text.text[style=display:none;]", ""
95
+ tag.should have_selector "textarea#something_0.editable-edit.edit", ""
96
+ end
97
+ end
98
+ it "should limit to single-value output if :multiple=>false" do
99
+ generated_html = helper.fedora_text_area(@resource,"simple_ds","subject", :multiple=>false)
100
+ generated_html.should_not have_selector "ol"
101
+ generated_html.should_not have_selector "li"
102
+ generated_html.should have_selector "span#subject-container.field" do |tag|
103
+ tag.should have_selector "span#subject-text.editable-text.text[style=display:none;]", "topic1"
104
+ tag.should have_selector "textarea#subject.editable-edit.edit", "topic1"
105
+ end
106
+ generated_html.should be_html_safe
107
+ end
108
+ end
109
+
110
+ describe "fedora_select" do
111
+ it "should generate a select with values from the given datastream" do
112
+ generated_html = helper.fedora_select(@resource,"simple_ds","subject", :choices=>["topic1","topic2", "topic3"])
113
+ generated_html.should have_selector "select.metadata-dd[name='asset[simple_ds][subject][0]']" do |tag|
114
+ tag.should have_selector "[rel=?]", "subject"
115
+ tag.should have_selector "option[value=topic1][selected=selected]"
116
+ tag.should have_selector "option[value=topic2][selected=selected]"
117
+ tag.should have_selector "option[value=topic3]"
118
+ end
119
+ end
120
+ it "should return the product of fedora_text_field if :choices is not set" do
121
+ helper.expects(:fedora_text_field).returns("fake response")
122
+ generated_html = helper.fedora_select(@resource,"simple_ds","subject")
123
+ generated_html.should == "fake response"
124
+ end
125
+ end
126
+
127
+ describe "fedora_date_select" do
128
+ it "should generate a date picker with values from the given datastream" do
129
+ generated_html = helper.fedora_date_select(@resource,"simple_ds","subject")
130
+ generated_html.should have_selector ".date-select[name='asset[simple_ds][subject]']" do |tag|
131
+ tag.should have_selector "[rel=?]", "subject"
132
+ tag.should have_selector "input#subject-sel-y.controlled-date-part.w4em"
133
+ tag.should have_selector "select#subject-sel-mm.controlled-date-part" do |tag|
134
+ tag.should have_selector "option[value=01]", "January"
135
+ tag.should have_selector "option[value=12]", "December"
136
+ end
137
+ tag.should have_selector "select#subject-sel-dd.controlled-date-part" do |tag|
138
+ tag.should have_selector "option[value=01]", "01"
139
+ tag.should have_selector "option[value=31]", "31"
140
+ end
141
+
142
+ end
143
+ end
144
+ end
145
+
146
+ describe "fedora_checkbox" do
147
+ it "should generate a set of checkboxes with values from the given datastream"
148
+ end
149
+
150
+ describe "all field generators" do
151
+ it "should include any necessary field_selector info" do
152
+ field_selectors_regexp = helper.field_selectors_for("ng_ds",[:title, :main_title]).gsub('/','\/').gsub(']','\]').gsub('[','\[')
153
+ ["fedora_text_field", "fedora_text_area", "fedora_select", "fedora_date_select"].each do |method|
154
+ generated_html = eval("helper.#{method}(@resource,\"ng_ds\",[:title, :main_title])")
155
+ generated_html.should match( field_selectors_regexp )
156
+ end
157
+ generated_html = helper.fedora_select(@resource,"ng_ds",[:title, :main_title], :choices=>["choice1"])
158
+ generated_html.should match( field_selectors_regexp )
159
+ end
160
+ end
161
+
162
+ describe "fedora_text_field_insert_link" do
163
+ it "should generate a link for inserting a fedora_text_field into the page" do
164
+ helper.fedora_text_field_insert_link("ng_ds",[:title, :main_title]).should have_selector "a.addval.textfield[href='#']"
165
+ end
166
+ end
167
+
168
+ describe "fedora_text_area_insert_link" do
169
+ it "should generate a link for inserting a fedora_text_area into the page" do
170
+ helper.fedora_text_area_insert_link("ng_ds",[:title, :main_title]).should have_selector "a.addval.textarea[href='#']"
171
+ end
172
+
173
+ end
174
+
175
+ describe "fedora_field_label" do
176
+ it "should generate a label with appropriate @for attribute" do
177
+ helper.fedora_field_label("ng_ds",[:title, :main_title], "Title:").should have_selector "label[for=title_main_title]", :content => "Title:"
178
+ end
179
+ it "should display the field name if no label is provided" do
180
+ helper.fedora_field_label("ng_ds",[:title, :main_title]).should have_selector "label[for=title_main_title]", :content=>"title_main_title"
181
+ end
182
+ end
183
+
184
+ describe "field_selectors_for" do
185
+ it "should generate any necessary field_selector values for the given field" do
186
+ generated_html = helper.field_selectors_for("myDsName", [{:name => 3}, :name_part])
187
+ generated_html.should have_selector "input.fieldselector[type=hidden][name='field_selectors[myDsName][name_3_name_part][][name]']" do |tag|
188
+ tag.should have_selector "[rel=name_3_name_part]"
189
+ tag.should have_selector "[value=3]"
190
+ end
191
+ generated_html.should have_selector "input.fieldselector[type=hidden][name='field_selectors[myDsName][name_3_name_part][]']" do |tag|
192
+ tag.should have_selector "[rel=name_3_name_part]"
193
+ tag.should have_selector "[value=name_part]"
194
+ end
195
+ # ordering is important. this next line makes sure that the inputs are in the correct order
196
+ # (tried using CSS3 nth-of-type selectors in have_selector but it didn't work)
197
+ generated_html.should match(/<input.*name="field_selectors\[myDsName\]\[name_3_name_part\]\[\]\[name\]".*\/><input.*name="field_selectors\[myDsName\]\[name_3_name_part\]\[\].*value="name_part" .*\/>/)
198
+ end
199
+ it "should not generate any field selectors if the field key is not an array" do
200
+ helper.field_selectors_for("myDsName", :description).should == ""
201
+ end
202
+ end
203
+
204
+ describe "hydra_form_for" do
205
+ it "should generate an entire form" do
206
+ pending
207
+ eval_erb(%(
208
+ <% hydra_form_for @resource do |h| %>
209
+ <h2>Hello</h2>
210
+ <%= h.fedora_text_field %>
211
+ <% end %>
212
+ )).should match_html("<h2>Hello</h2> blah blah blah ")
213
+ end
214
+ end
215
+ end