hydra-head 3.0.0pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +71 -0
- data/.gitmodules +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +257 -0
- data/README.textile +150 -0
- data/README_RAILS3_CHANGES.textile +42 -0
- data/Rakefile +5 -0
- data/TESTING.textile +85 -0
- data/app/controllers/assets_controller.rb +117 -0
- data/app/controllers/contributors_controller.rb +54 -0
- data/app/controllers/file_assets_controller.rb +152 -0
- data/app/controllers/permissions_controller.rb +137 -0
- data/app/controllers/user_sessions_controller.rb +14 -0
- data/app/helpers/article_metadata_helper.rb +80 -0
- data/app/helpers/blacklight_helper.rb +192 -0
- data/app/helpers/downloads_helper.rb +19 -0
- data/app/helpers/generic_content_objects_helper.rb +16 -0
- data/app/helpers/hydra_assets_helper.rb +75 -0
- data/app/helpers/hydra_djatoka_helper.rb +23 -0
- data/app/helpers/hydra_fedora_metadata_helper.rb +365 -0
- data/app/helpers/hydra_helper.rb +155 -0
- data/app/helpers/hydra_uploader_helper.rb +18 -0
- data/app/helpers/inline_editable_metadata_helper.rb +15 -0
- data/app/helpers/javascript_includes_helper.rb +93 -0
- data/app/helpers/release_process_helper.rb +32 -0
- data/app/models/audio_asset.rb +8 -0
- data/app/models/file_asset.rb +111 -0
- data/app/models/generic_content.rb +21 -0
- data/app/models/generic_image.rb +62 -0
- data/app/models/image_asset.rb +8 -0
- data/app/models/mods_asset.rb +6 -0
- data/app/models/role_mapper.rb +22 -0
- data/app/models/superuser.rb +6 -0
- data/app/models/video_asset.rb +8 -0
- data/app/views/_add_assets_links.html.erb +13 -0
- data/app/views/_brown_sidebar.html +15 -0
- data/app/views/_user_util_links.html.erb +31 -0
- data/app/views/catalog/_citation.html.erb +11 -0
- data/app/views/catalog/_constraints_element.html.erb +34 -0
- data/app/views/catalog/_delete_partials/_default.html.erb +29 -0
- data/app/views/catalog/_document_list.html.erb +11 -0
- data/app/views/catalog/_edit_partials/_default.html.erb +64 -0
- data/app/views/catalog/_edit_partials/_default_details.html.erb +15 -0
- data/app/views/catalog/_email_form.html.erb +9 -0
- data/app/views/catalog/_facets.html.erb +37 -0
- data/app/views/catalog/_flash_msg.html.erb +17 -0
- data/app/views/catalog/_home.html.erb +6 -0
- data/app/views/catalog/_home_text.html.erb +10 -0
- data/app/views/catalog/_index_partials/_default.html.erb +20 -0
- data/app/views/catalog/_index_partials/_default_details.html.erb +11 -0
- data/app/views/catalog/_index_partials/_default_group.html.erb +15 -0
- data/app/views/catalog/_search_form.html.erb +12 -0
- data/app/views/catalog/_show_partials/_default.html.erb +23 -0
- data/app/views/catalog/_show_partials/_default_details.html.erb +12 -0
- data/app/views/catalog/_show_partials/_facets.html.erb +52 -0
- data/app/views/catalog/_sms_form.html.erb +21 -0
- data/app/views/catalog/_sort_and_per_page.html.erb +22 -0
- data/app/views/catalog/_uva_tabs.html.erb +10 -0
- data/app/views/catalog/about.html.erb +0 -0
- data/app/views/catalog/show.html.erb +48 -0
- data/app/views/contributors/_add_contributor_split_button.html.erb +10 -0
- data/app/views/contributors/_edit_conference.html.erb +29 -0
- data/app/views/contributors/_edit_organization.html.erb +29 -0
- data/app/views/contributors/_edit_person.html.erb +42 -0
- data/app/views/contributors/_index.html.erb +12 -0
- data/app/views/contributors/_new.html.erb +10 -0
- data/app/views/contributors/_show_conference.html.erb +22 -0
- data/app/views/contributors/_show_organization.html.erb +29 -0
- data/app/views/contributors/_show_person.html.erb +17 -0
- data/app/views/contributors/new.html.erb +13 -0
- data/app/views/downloads/index.html.erb +1 -0
- data/app/views/file_assets/_deletable_result.html.erb +5 -0
- data/app/views/file_assets/_index.html.erb +15 -0
- data/app/views/file_assets/_new.html.erb +2 -0
- data/app/views/file_assets/_result.html.erb +16 -0
- data/app/views/file_assets/index.html.erb +5 -0
- data/app/views/fluid_infusion/_uploader.html.erb +81 -0
- data/app/views/fluid_infusion/_uploader_generic_content_objects.js.erb +38 -0
- data/app/views/fluid_infusion/_uploader_js.erb +45 -0
- data/app/views/generic_content_objects/_edit_description.html.erb +50 -0
- data/app/views/generic_content_objects/_new.html.erb +0 -0
- data/app/views/generic_content_objects/_show_description.html.erb +68 -0
- data/app/views/generic_content_objects/contributors/_edit_conference.html.erb +29 -0
- data/app/views/generic_content_objects/contributors/_edit_organization.html.erb +29 -0
- data/app/views/generic_content_objects/contributors/_edit_person.html.erb +37 -0
- data/app/views/generic_content_objects/contributors/_new.html.erb +10 -0
- data/app/views/generic_content_objects/contributors/_show_conference.html.erb +22 -0
- data/app/views/generic_content_objects/contributors/_show_organization.html.erb +22 -0
- data/app/views/generic_content_objects/contributors/_show_person.html.erb +38 -0
- data/app/views/generic_contents/_edit.html.erb +59 -0
- data/app/views/generic_contents/_index.html.erb +23 -0
- data/app/views/generic_contents/_show.html.erb +18 -0
- data/app/views/generic_contents/_show_content.html.erb +4 -0
- data/app/views/generic_images/_edit.html.erb +59 -0
- data/app/views/generic_images/_index.html.erb +24 -0
- data/app/views/generic_images/_show.html.erb +18 -0
- data/app/views/generic_images/_show_all.html.erb +14 -0
- data/app/views/generic_images/_show_content.html.erb +7 -0
- data/app/views/layouts/application.html.erb +57 -0
- data/app/views/layouts/hydra-head.html.erb +12 -0
- data/app/views/mods_assets/_edit.html.erb +49 -0
- data/app/views/mods_assets/_edit_description.html.erb +82 -0
- data/app/views/mods_assets/_edit_journal.html.erb +72 -0
- data/app/views/mods_assets/_index.html.erb +1 -0
- data/app/views/mods_assets/_index_list.html.erb +37 -0
- data/app/views/mods_assets/_index_table.html.erb +7 -0
- data/app/views/mods_assets/_progress_box.html.erb +82 -0
- data/app/views/mods_assets/_show.html.erb +44 -0
- data/app/views/mods_assets/_show_description.html.erb +44 -0
- data/app/views/mods_assets/_show_journal.html.erb +42 -0
- data/app/views/mods_assets/_show_permissions.html.erb +14 -0
- data/app/views/permissions/_edit_person_permissions.html.erb +35 -0
- data/app/views/permissions/_index.html.erb +55 -0
- data/app/views/permissions/_new.html.erb +18 -0
- data/app/views/permissions/index.html.erb +1 -0
- data/app/views/permissions/new.html.erb +1 -0
- data/app/views/shared/_delete_asset_confirmation.html.erb +17 -0
- data/app/views/user_sessions/_login_form.html.erb +10 -0
- data/app/views/user_sessions/logged_out.html.erb +1 -0
- data/config/routes.rb +12 -0
- data/fedora_conf/conf/fedora.fcfg +1021 -0
- data/hydra-head.gemspec +70 -0
- data/lib/application_controller.rb +25 -0
- data/lib/application_helper.rb +2 -0
- data/lib/engine.rb +30 -0
- data/lib/generators/hydra/head_generator.rb +152 -0
- data/lib/generators/hydra/templates/config/fedora.yml +17 -0
- data/lib/generators/hydra/templates/config/initializers/blacklight_config.rb +246 -0
- data/lib/generators/hydra/templates/config/initializers/fedora_config.rb +23 -0
- data/lib/generators/hydra/templates/config/initializers/hydra_config.rb +29 -0
- data/lib/generators/hydra/templates/config/role_map_cucumber.yml +10 -0
- data/lib/generators/hydra/templates/config/role_map_development.yml +12 -0
- data/lib/generators/hydra/templates/config/role_map_production.yml +2 -0
- data/lib/generators/hydra/templates/config/role_map_test.yml +15 -0
- data/lib/generators/hydra/templates/config/solr.yml +10 -0
- data/lib/generators/hydra/templates/config/solr_mappings.yml +22 -0
- data/lib/generators/hydra/templates/fedora_conf/conf/fedora.fcfg +1021 -0
- data/lib/generators/hydra/templates/migrations/add_user_attributes_table.rb +15 -0
- data/lib/generators/hydra/templates/migrations/create_superusers.rb +12 -0
- data/lib/generators/hydra/templates/solr_conf/conf/schema.xml +118 -0
- data/lib/generators/hydra/templates/solr_conf/conf/solrconfig.xml +332 -0
- data/lib/generators/hydra/templates/solr_conf/solr.xml +35 -0
- data/lib/hydra-head.rb +29 -0
- data/lib/hydra-head/engine.rb +9 -0
- data/lib/hydra-head/routes.rb +87 -0
- data/lib/hydra-head/version.rb +4 -0
- data/lib/hydra.rb +22 -0
- data/lib/hydra/access_controls_enforcement.rb +236 -0
- data/lib/hydra/access_controls_evaluation.rb +97 -0
- data/lib/hydra/assets_controller_helper.rb +144 -0
- data/lib/hydra/catalog.rb +64 -0
- data/lib/hydra/common_mods_index_methods.rb +42 -0
- data/lib/hydra/controller.rb +7 -0
- data/lib/hydra/file_assets_helper.rb +144 -0
- data/lib/hydra/fixtures.rb +43 -0
- data/lib/hydra/generic_content.rb +113 -0
- data/lib/hydra/generic_image.rb +100 -0
- data/lib/hydra/image.rb +177 -0
- data/lib/hydra/model_methods.rb +95 -0
- data/lib/hydra/model_mixins.rb +2 -0
- data/lib/hydra/model_mixins/common_metadata.rb +24 -0
- data/lib/hydra/model_mixins/mods_object.rb +16 -0
- data/lib/hydra/mods_article.rb +505 -0
- data/lib/hydra/mods_dataset.rb +165 -0
- data/lib/hydra/mods_generic_content.rb +494 -0
- data/lib/hydra/mods_image.rb +494 -0
- data/lib/hydra/repository_controller.rb +102 -0
- data/lib/hydra/rights_metadata.rb +189 -0
- data/lib/hydra/superuser_attributes.rb +12 -0
- data/lib/hydra/testing_server.rb +183 -0
- data/lib/hydra/user.rb +22 -0
- data/lib/mediashelf/active_fedora_helper.rb +72 -0
- data/lib/railties/all_tests.rake +23 -0
- data/lib/railties/hydra-fixtures.rake +184 -0
- data/lib/railties/hydra_jetty.rake +79 -0
- data/lib/railties/hyhead_cucumber.rake +127 -0
- data/lib/railties/hyhead_rspec.rake +137 -0
- data/lib/stanford/searchworks_helper.rb +1338 -0
- data/lib/stanford/solr_helper.rb +108 -0
- data/lib/uva/mods_index_methods.rb +24 -0
- data/solr_conf/conf/schema.xml +122 -0
- data/solr_conf/conf/solrconfig.xml +332 -0
- data/solr_conf/solr.xml +35 -0
- data/tasks/hydra-head-fixtures.rake +54 -0
- data/tasks/hydra-head.rake +247 -0
- data/tasks/hydra_jetty.rake +79 -0
- data/tasks/replicator.rake +27 -0
- data/tasks/solrizer-fedora.rake +53 -0
- data/tasks/solrizer.rake +13 -0
- data/test_support/etc/Gemfile +29 -0
- data/test_support/etc/rvmrc +32 -0
- data/test_support/features/button_add_assets.feature +22 -0
- data/test_support/features/button_add_generic_content.feature +11 -0
- data/test_support/features/button_add_image.feature +11 -0
- data/test_support/features/button_add_mods_asset.feature +11 -0
- data/test_support/features/contributor_add.feature +39 -0
- data/test_support/features/file_assets_list.feature +32 -0
- data/test_support/features/file_upload.feature +40 -0
- data/test_support/features/home_page.feature +9 -0
- data/test_support/features/html_validity.feature +47 -0
- data/test_support/features/mods_asset_contributors_edit.feature +80 -0
- data/test_support/features/mods_asset_create.feature +12 -0
- data/test_support/features/mods_asset_edit.feature +33 -0
- data/test_support/features/mods_asset_edit_without_permission.feature +10 -0
- data/test_support/features/mods_asset_search_result.feature +13 -0
- data/test_support/features/mods_asset_show.feature +39 -0
- data/test_support/features/permissions_add.feature +15 -0
- data/test_support/features/permissions_edit.feature +63 -0
- data/test_support/features/step_definitions/catalog_index_steps.rb +14 -0
- data/test_support/features/step_definitions/create_asset_steps.rb +7 -0
- data/test_support/features/step_definitions/edit_metadata_steps.rb +73 -0
- data/test_support/features/step_definitions/file_list_steps.rb +28 -0
- data/test_support/features/step_definitions/hydra_metadata_steps.rb +3 -0
- data/test_support/features/step_definitions/hydra_steps.rb +8 -0
- data/test_support/features/step_definitions/inline_editable_edit_steps.rb +77 -0
- data/test_support/features/step_definitions/search_steps.rb +88 -0
- data/test_support/features/step_definitions/searching_steps.rb +22 -0
- data/test_support/features/step_definitions/show_document_steps.rb +85 -0
- data/test_support/features/step_definitions/user_steps.rb +36 -0
- data/test_support/features/step_definitions/web_steps.rb +219 -0
- data/test_support/features/support/env.rb +55 -0
- data/test_support/features/support/paths.rb +80 -0
- data/test_support/features/switch_users.feature +14 -0
- data/test_support/features/view_catalog_index.feature +18 -0
- data/test_support/fixtures/empty_file.txt +0 -0
- data/test_support/fixtures/hydrangea_fixture_archivist_only_mods_article.foxml.xml +1212 -0
- data/test_support/fixtures/hydrangea_fixture_file_asset1.foxml.xml +4946 -0
- data/test_support/fixtures/hydrangea_fixture_mods_article1.foxml.xml +234 -0
- data/test_support/fixtures/hydrangea_fixture_mods_article2.foxml.xml +177 -0
- data/test_support/fixtures/hydrangea_fixture_mods_article3.foxml.xml +170 -0
- data/test_support/fixtures/hydrangea_fixture_mods_dataset1.foxml.xml +187 -0
- data/test_support/fixtures/hydrangea_fixture_uploaded_svg1.foxml.xml +676 -0
- data/test_support/fixtures/image.jp2 +0 -0
- data/test_support/fixtures/libra-oa_1.foxml.xml +2324 -0
- data/test_support/fixtures/libra-oa_2.foxml.xml +2422 -0
- data/test_support/spec/controllers/assets_controller_spec.rb +113 -0
- data/test_support/spec/controllers/catalog_controller_spec.rb +148 -0
- data/test_support/spec/controllers/catalog_controller_viewing_context_spec.rb +62 -0
- data/test_support/spec/controllers/contributors_controller_spec.rb +47 -0
- data/test_support/spec/controllers/file_assets_controller_spec.rb +189 -0
- data/test_support/spec/controllers/hydra_controller_spec.rb +15 -0
- data/test_support/spec/controllers/permissions_controller_spec.rb +80 -0
- data/test_support/spec/controllers/user_sessions_controller_spec.rb +35 -0
- data/test_support/spec/generators/hydra-head_generator_spec.rb +14 -0
- data/test_support/spec/helpers/access_controls_enforcement_spec.rb +212 -0
- data/test_support/spec/helpers/access_controls_evaluation_spec.rb +35 -0
- data/test_support/spec/helpers/assets_controller_helper_spec.rb +71 -0
- data/test_support/spec/helpers/blacklight_helper_spec.rb +64 -0
- data/test_support/spec/helpers/file_assets_helper_spec.rb +107 -0
- data/test_support/spec/helpers/hydra-repository_controller_spec.rb +32 -0
- data/test_support/spec/helpers/hydra_assets_helper_spec.rb +195 -0
- data/test_support/spec/helpers/hydra_djatoka_helper_spec.rb +32 -0
- data/test_support/spec/helpers/hydra_fedora_metadata_helper_spec.rb +215 -0
- data/test_support/spec/helpers/hydra_helper_spec.rb +73 -0
- data/test_support/spec/helpers/hydra_model_methods_spec.rb +95 -0
- data/test_support/spec/helpers/hydra_uploader_helper_spec.rb +18 -0
- data/test_support/spec/helpers/javascript_includes_helper_spec.rb +43 -0
- data/test_support/spec/integration/file_asset_spec.rb +150 -0
- data/test_support/spec/lib/active_fedora_helper_spec.rb +56 -0
- data/test_support/spec/lib/catalog_spec.rb +16 -0
- data/test_support/spec/lib/common_mods_index_methods_spec.rb +28 -0
- data/test_support/spec/models/audio_asset_spec.rb +23 -0
- data/test_support/spec/models/file_asset_spec.rb +42 -0
- data/test_support/spec/models/generic_content_spec.rb +29 -0
- data/test_support/spec/models/generic_image_spec.rb +58 -0
- data/test_support/spec/models/hydra_rights_metadata_spec.rb +162 -0
- data/test_support/spec/models/image_asset_spec.rb +23 -0
- data/test_support/spec/models/mods_asset_spec.rb +29 -0
- data/test_support/spec/models/role_mapper_spec.rb +22 -0
- data/test_support/spec/models/user_spec.rb +52 -0
- data/test_support/spec/models/video_asset_spec.rb +23 -0
- data/test_support/spec/rcov.opts +3 -0
- data/test_support/spec/spec.opts +4 -0
- data/test_support/spec/spec_helper.rb +44 -0
- data/test_support/spec/support/matchers/helper_matcher.rb +14 -0
- data/test_support/spec/support/matchers/solr_matchers.rb +60 -0
- data/test_support/spec/unit/hydra-head-engine_spec.rb +8 -0
- data/test_support/spec/unit/hydra-head_spec.rb +8 -0
- data/test_support/spec/utilities/hydra_testing_server_spec.rb +49 -0
- data/test_support/spec/views/uploader.html.erb_spec.rb +30 -0
- data/vendor/cache/RedCloth-4.2.3.gem +0 -0
- data/vendor/cache/abstract-1.0.0.gem +0 -0
- data/vendor/cache/actionmailer-3.0.9.gem +0 -0
- data/vendor/cache/actionpack-3.0.9.gem +0 -0
- data/vendor/cache/active-fedora-2.3.3.gem +0 -0
- data/vendor/cache/activemodel-3.0.9.gem +0 -0
- data/vendor/cache/activerecord-3.0.9.gem +0 -0
- data/vendor/cache/activeresource-3.0.9.gem +0 -0
- data/vendor/cache/activesupport-3.0.9.gem +0 -0
- data/vendor/cache/arel-2.0.10.gem +0 -0
- data/vendor/cache/blacklight-3.0.0.gem +0 -0
- data/vendor/cache/block_helpers-0.3.3.gem +0 -0
- data/vendor/cache/builder-2.1.2.gem +0 -0
- data/vendor/cache/capybara-1.0.0.gem +0 -0
- data/vendor/cache/childprocess-0.2.0.gem +0 -0
- data/vendor/cache/columnize-0.3.4.gem +0 -0
- data/vendor/cache/crack-0.1.8.gem +0 -0
- data/vendor/cache/cucumber-1.0.2.gem +0 -0
- data/vendor/cache/cucumber-rails-1.0.2.gem +0 -0
- data/vendor/cache/curb-0.7.15.gem +0 -0
- data/vendor/cache/daemons-1.1.4.gem +0 -0
- data/vendor/cache/database_cleaner-0.6.7.gem +0 -0
- data/vendor/cache/diff-lcs-1.1.2.gem +0 -0
- data/vendor/cache/equivalent-xml-0.2.7.gem +0 -0
- data/vendor/cache/erubis-2.6.6.gem +0 -0
- data/vendor/cache/facets-2.8.4.gem +0 -0
- data/vendor/cache/factory_girl-1.3.3.gem +0 -0
- data/vendor/cache/fastercsv-1.5.4.gem +0 -0
- data/vendor/cache/ffi-1.0.9.gem +0 -0
- data/vendor/cache/gherkin-2.4.5.gem +0 -0
- data/vendor/cache/haml-3.1.2.gem +0 -0
- data/vendor/cache/httparty-0.7.8.gem +0 -0
- data/vendor/cache/i18n-0.5.0.gem +0 -0
- data/vendor/cache/jettywrapper-0.0.10.gem +0 -0
- data/vendor/cache/json-1.5.3.gem +0 -0
- data/vendor/cache/json_pure-1.5.3.gem +0 -0
- data/vendor/cache/kaminari-0.12.4.gem +0 -0
- data/vendor/cache/launchy-2.0.3.gem +0 -0
- data/vendor/cache/linecache-0.46.gem +0 -0
- data/vendor/cache/logger-1.2.8.gem +0 -0
- data/vendor/cache/mail-2.2.19.gem +0 -0
- data/vendor/cache/marc-0.4.3.gem +0 -0
- data/vendor/cache/mediashelf-loggable-0.4.2.gem +0 -0
- data/vendor/cache/mime-types-1.16.gem +0 -0
- data/vendor/cache/mocha-0.9.12.gem +0 -0
- data/vendor/cache/multipart-post-1.1.2.gem +0 -0
- data/vendor/cache/nokogiri-1.5.0.gem +0 -0
- data/vendor/cache/om-1.2.5.gem +0 -0
- data/vendor/cache/polyglot-0.3.1.gem +0 -0
- data/vendor/cache/rack-1.2.3.gem +0 -0
- data/vendor/cache/rack-mount-0.6.14.gem +0 -0
- data/vendor/cache/rack-test-0.5.7.gem +0 -0
- data/vendor/cache/rails-3.0.9.gem +0 -0
- data/vendor/cache/railties-3.0.9.gem +0 -0
- data/vendor/cache/rake-0.9.2.gem +0 -0
- data/vendor/cache/rbx-require-relative-0.0.5.gem +0 -0
- data/vendor/cache/rcov-0.9.9.gem +0 -0
- data/vendor/cache/rdoc-3.8.gem +0 -0
- data/vendor/cache/rsolr-1.0.2.gem +0 -0
- data/vendor/cache/rsolr-ext-1.0.3.gem +0 -0
- data/vendor/cache/rspec-2.6.0.gem +0 -0
- data/vendor/cache/rspec-core-2.6.4.gem +0 -0
- data/vendor/cache/rspec-expectations-2.6.0.gem +0 -0
- data/vendor/cache/rspec-mocks-2.6.0.gem +0 -0
- data/vendor/cache/rspec-rails-2.6.1.gem +0 -0
- data/vendor/cache/ruby-debug-0.10.4.gem +0 -0
- data/vendor/cache/ruby-debug-base-0.10.4.gem +0 -0
- data/vendor/cache/rubyzip-0.9.4.gem +0 -0
- data/vendor/cache/sanitize-2.0.3.gem +0 -0
- data/vendor/cache/selenium-webdriver-0.2.2.gem +0 -0
- data/vendor/cache/solr-ruby-0.0.8.gem +0 -0
- data/vendor/cache/solrizer-1.1.0.gem +0 -0
- data/vendor/cache/solrizer-fedora-1.1.0.gem +0 -0
- data/vendor/cache/sqlite3-ruby-1.2.5.gem +0 -0
- data/vendor/cache/stomp-1.1.9.gem +0 -0
- data/vendor/cache/term-ansicolor-1.0.5.gem +0 -0
- data/vendor/cache/thor-0.14.6.gem +0 -0
- data/vendor/cache/treetop-1.4.9.gem +0 -0
- data/vendor/cache/trollop-1.16.2.gem +0 -0
- data/vendor/cache/tzinfo-0.3.29.gem +0 -0
- data/vendor/cache/unicode-0.4.0.gem +0 -0
- data/vendor/cache/will_paginate-2.3.15.gem +0 -0
- data/vendor/cache/xml-simple-1.1.0.gem +0 -0
- data/vendor/cache/xpath-0.1.4.gem +0 -0
- data/vendor/cache/yard-0.7.2.gem +0 -0
- metadata +1110 -0
|
@@ -0,0 +1,113 @@
|
|
|
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 AssetsController do
|
|
12
|
+
|
|
13
|
+
before do
|
|
14
|
+
request.env['WEBAUTH_USER']='bob'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should use DocumentController" do
|
|
18
|
+
controller.should be_an_instance_of(AssetsController)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "update" do
|
|
22
|
+
it "should update the object with the attributes provided" do
|
|
23
|
+
mock_document = mock("document")
|
|
24
|
+
mock_document.stubs(:update_from_computing_id).returns(nil)
|
|
25
|
+
controller.expects(:check_embargo_date_format).returns(nil)
|
|
26
|
+
|
|
27
|
+
ModsAsset.expects(:find).with("_PID_").returns(mock_document)
|
|
28
|
+
|
|
29
|
+
simple_request_params = {"asset"=>{
|
|
30
|
+
"descMetadata"=>{
|
|
31
|
+
"subject"=>{"0"=>"subject1", "1"=>"subject2", "2"=>"subject3"}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
mock_document.expects(:update_datastream_attributes).with("descMetadata"=>{"subject"=>{"0"=>"subject1", "1"=>"subject2", "2"=>"subject3"}}).returns({"subject"=>{"2"=>"My Topic"}})
|
|
37
|
+
mock_document.expects(:save)
|
|
38
|
+
controller.stubs(:display_release_status_notice)
|
|
39
|
+
put :update, {:id=>"_PID_"}.merge(simple_request_params)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should support updating OM::XML datastreams" do
|
|
43
|
+
mock_document = mock("document")
|
|
44
|
+
mock_document.stubs(:update_from_computing_id).returns(nil)
|
|
45
|
+
ModsAsset.expects(:find).with("_PID_").returns(mock_document)
|
|
46
|
+
|
|
47
|
+
update_method_args = [ "descMetadata" => { [{:person=>0}, :role] => {"0"=>"role1","1"=>"role2","2"=>"role3"} } ]
|
|
48
|
+
mock_document.expects(:update_datastream_attributes).with( *update_method_args ).returns({"person_0_role"=>{"0"=>"role1","1"=>"role2","2"=>"role3"}})
|
|
49
|
+
mock_document.expects(:save)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
nokogiri_request_params = {
|
|
53
|
+
"id"=>"_PID_",
|
|
54
|
+
"content_type"=>"mods_asset",
|
|
55
|
+
"field_selectors"=>{
|
|
56
|
+
"descMetadata"=>{
|
|
57
|
+
"person_0_role"=>[{":person"=>"0"}, "role"]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"asset"=>{
|
|
61
|
+
"descMetadata"=>{
|
|
62
|
+
"person_0_role"=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
controller.stubs(:display_release_status_notice)
|
|
67
|
+
put :update, nokogiri_request_params
|
|
68
|
+
# put :update, :id=>"_PID_", "content_type"=>"mods_asset", "datastream"=>"descMetadata", "field_name"=>"person_0_last_name","parent_select"=>[{":person"=>"0"}, ":last_name"], "child_index"=>"0", "value"=>"Sample New Value"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should handle complete updates of many fields in many datastreams" do
|
|
72
|
+
pending("This is failing intermittently. See https://jira.duraspace.org/browse/HYDRUS-166 for more info")
|
|
73
|
+
request_params = {"id"=>"hydrangea:fixture_mods_article3", "content_type"=>"mods_asset", "action"=>"update", "_method"=>"put"}
|
|
74
|
+
request_params["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"]}}
|
|
75
|
+
request_params["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"}}}
|
|
76
|
+
expected_response = {"descMetadata"=>{"journal_0_issue_start_page"=>{"0"=>"195"}, "person_0_computing_id"=>{"-1"=>""}, "abstract"=>{"0"=>"ABSTRACT"}, "journal_0_origin_info_publisher"=>{"0"=>"PUBLISHER"}, "person_1_description"=>{"-1"=>""}, "person_1_institution"=>{"0"=>"Baltimore"}, "journal_0_issue_volume"=>{"0"=>"2 "}, "person_0_description"=>{"-1"=>""}, "person_0_last_name"=>{"0"=>"Smith"}, "title_info_main_title"=>{"0"=>"Test Article"}, "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_end_page"=>{"0"=>"230"}, "journal_0_title_info_main_title"=>{"0"=>"The Journal of Mock Object"}, "journal_0_issue_level"=>{"-1"=>""}, "person_1_first_name"=>{"0"=>"Henrietta"}, "person_0_institution"=>{"0"=>"FACULTY, UNIVERSITY"}, "journal_0_issn"=>{"0"=>"1234-5678"}, "person_0_first_name"=>{"0"=>"John"}, "person_1_computing_id"=>{"-1"=>""}, "journal_0_issue_publication_date"=>{"0"=>"FEB. 2007"}}, "rightsMetadata"=>{"embargo_embargo_release_date"=>{"-1"=>""}}, "properties"=>{:released=>{"0"=>"true"}, [:release_to]=>{}, :release_to=>{"0"=>"public"}}}
|
|
77
|
+
|
|
78
|
+
post :update, request_params
|
|
79
|
+
expected_response.each_pair do |datastream_name, fields|
|
|
80
|
+
fields.each_pair do |field_pointer, value|
|
|
81
|
+
assigns[:response][datastream_name][field_pointer].should == value
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe "destroy" do
|
|
88
|
+
it "should delete the asset identified by pid" do
|
|
89
|
+
mock_obj = mock("asset", :delete)
|
|
90
|
+
mock_obj.expects(:destroy_child_assets).returns([])
|
|
91
|
+
ActiveFedora::Base.expects(:load_instance_from_solr).with("__PID__").returns(mock_obj)
|
|
92
|
+
ActiveFedora::ContentModel.expects(:known_models_for).with(mock_obj).returns([ModsAsset])
|
|
93
|
+
ModsAsset.expects(:load_instance_from_solr).with("__PID__").returns(mock_obj)
|
|
94
|
+
delete(:destroy, :id => "__PID__")
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# withdraw is a conditional destroy, with the conditions dependant on the project requirements.
|
|
99
|
+
# Currently, the widthdraw method is an alias for destroy, should behave as such
|
|
100
|
+
describe "withdraw" do
|
|
101
|
+
it "should withdraw the asset identified by pid" do
|
|
102
|
+
mock_obj = mock("asset", :delete)
|
|
103
|
+
mock_obj.expects(:destroy_child_assets).returns([])
|
|
104
|
+
ActiveFedora::Base.expects(:load_instance_from_solr).with("__PID__").returns(mock_obj)
|
|
105
|
+
ActiveFedora::ContentModel.expects(:known_models_for).with(mock_obj).returns([ModsAsset])
|
|
106
|
+
ModsAsset.expects(:load_instance_from_solr).with("__PID__").returns(mock_obj)
|
|
107
|
+
delete(:withdraw, :id => "__PID__")
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
require 'mocha'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# See cucumber tests (ie. /features/edit_document.feature) for more tests, including ones that test the edit method & view
|
|
6
|
+
# You can run the cucumber tests with
|
|
7
|
+
#
|
|
8
|
+
# cucumber --tags @edit
|
|
9
|
+
# or
|
|
10
|
+
# rake cucumber
|
|
11
|
+
|
|
12
|
+
describe CatalogController do
|
|
13
|
+
|
|
14
|
+
before do
|
|
15
|
+
#controller.stubs(:protect_from_forgery).returns("meh")
|
|
16
|
+
session[:user]='bob'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should use CatalogController" do
|
|
20
|
+
controller.should be_an_instance_of(CatalogController)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
describe "Paths Generated by Custom Routes:" do
|
|
25
|
+
# paths generated by custom routes
|
|
26
|
+
it "should map {:controller=>'catalog', :action=>'index'} to GET /catalog" do
|
|
27
|
+
{ :get => "/catalog" }.should route_to(:controller => 'catalog', :action => 'index')
|
|
28
|
+
end
|
|
29
|
+
it "should map {:controller=>'catalog', :action=>'show', :id=>'test:3'} to GET /catalog/test:3" do
|
|
30
|
+
{ :get => "/catalog/test:3" }.should route_to(:controller => 'catalog', :action => 'show', :id=>'test:3')
|
|
31
|
+
end
|
|
32
|
+
it "should map {:controller=>'catalog', :action=>'edit', :id=>'test:3'} to GET /catalog/test:3" do
|
|
33
|
+
{ :get => "/catalog/test:3/edit" }.should route_to(:controller => 'catalog', :action => 'edit', :id=>'test:3')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should map catalog_path" do
|
|
37
|
+
# catalog_path.should == '/catalog'
|
|
38
|
+
catalog_path("test:3").should == '/catalog/test:3'
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should not choke on objects with periods in ids (ie Fedora system objects)" do
|
|
43
|
+
pending "Need to override blacklight routes"
|
|
44
|
+
|
|
45
|
+
## We could do something like this to remove the catalog/show route and replace it with a route that allows dots (e.g. resources :catalog, :id=> /.+/)
|
|
46
|
+
# def add_route
|
|
47
|
+
# new_route = ActionController::Routing::Routes.builder.build(name, route_options)
|
|
48
|
+
# ActionController::Routing::Routes.routes.insert(0, new_route)
|
|
49
|
+
# end
|
|
50
|
+
|
|
51
|
+
# def remove_route
|
|
52
|
+
# ActionController::Routing::Routes.routes.reject! { |r| r.instance_variable_get(:@requirements)[:slug_id] == id }
|
|
53
|
+
# end
|
|
54
|
+
|
|
55
|
+
catalog_path("fedora-system:FedoraObject-3.0").should == '/catalog/fedora-system:FedoraObject-3.0'
|
|
56
|
+
{ :get => "/catalog/fedora-system:FedoraObject-3.0" }.should route_to(:controller => 'catalog', :action => 'show', :id=>'fedora-system:FedoraObject-3.0')
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "index" do
|
|
60
|
+
|
|
61
|
+
describe "access controls" do
|
|
62
|
+
before(:all) do
|
|
63
|
+
@public_only_results = Blacklight.solr.find Hash[:phrases=>{:access_t=>"public"}]
|
|
64
|
+
@private_only_results = Blacklight.solr.find Hash[:phrases=>{:access_t=>"private"}]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should only return public documents if role does not have permissions" do
|
|
68
|
+
controller.stubs(:current_user).returns(nil)
|
|
69
|
+
get :index
|
|
70
|
+
assigns("response").docs.count.should == @public_only_results.docs.count
|
|
71
|
+
end
|
|
72
|
+
it "should return all documents if role does have permissions" do
|
|
73
|
+
User.any_instance.stubs(:login).returns("BigWig")
|
|
74
|
+
mock_user = User.new
|
|
75
|
+
session[:superuser_mode] = true
|
|
76
|
+
controller.stubs(:current_user).returns(mock_user)
|
|
77
|
+
get :index
|
|
78
|
+
assigns["response"].docs.count.should > @public_only_results.docs.count
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
describe "load_fedora_document" do
|
|
85
|
+
|
|
86
|
+
it "should load @document_fedora and @file_assets" do
|
|
87
|
+
controller.stubs(:params).returns({:id=>"foo:id"})
|
|
88
|
+
stub_base_object = stub("Base Object")
|
|
89
|
+
ActiveFedora::ContentModel.expects(:known_models_for).with( stub_base_object ).returns( [ModsAsset] )
|
|
90
|
+
stub_mods_asset = stub("MODS Asset")
|
|
91
|
+
stub_mods_asset.expects(:file_objects).with(:response_format=>:solr).returns("file assets response")
|
|
92
|
+
|
|
93
|
+
# Note: Had to stub Fedora::Repository.instance.find_model rather than stubbing ActiveFedora::Base.load_instance and ModsAsset.load_instance because
|
|
94
|
+
# Mocha was not unstubbing the ModsAsset class
|
|
95
|
+
#
|
|
96
|
+
# ActiveFedora::Base.stubs(:load_instance).with("foo:id").returns( stub_base_object )
|
|
97
|
+
# ModsAsset.stubs(:load_instance).with("foo:id").returns( stub_mods_asset )
|
|
98
|
+
Fedora::Repository.instance.expects(:find_model).with("foo:id", ActiveFedora::Base).returns( stub_base_object )
|
|
99
|
+
Fedora::Repository.instance.expects(:find_model).with("foo:id", ModsAsset).returns( stub_mods_asset )
|
|
100
|
+
|
|
101
|
+
controller.load_fedora_document
|
|
102
|
+
|
|
103
|
+
assigns[:document_fedora].should == stub_mods_asset
|
|
104
|
+
assigns[:file_assets].should == "file assets response"
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe "edit" do
|
|
109
|
+
|
|
110
|
+
it "should trigger show action" do
|
|
111
|
+
controller.expects(:show)
|
|
112
|
+
controller.stubs(:enforce_access_controls)
|
|
113
|
+
controller.stubs(:load_fedora_document)
|
|
114
|
+
get :edit, :id=>'hydrangea:fixture_mods_article1'
|
|
115
|
+
end
|
|
116
|
+
it "should render show template (which then delegates to edit partials)" do
|
|
117
|
+
controller.stubs(:enforce_access_controls)
|
|
118
|
+
controller.stubs(:load_fedora_document)
|
|
119
|
+
get :edit, :id=>'hydrangea:fixture_mods_article1'
|
|
120
|
+
response.should render_template("show")
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe "filters" do
|
|
125
|
+
describe "index" do
|
|
126
|
+
it "should trigger enforce_index_permissions" do
|
|
127
|
+
controller.expects(:add_access_controls_to_solr_params)
|
|
128
|
+
controller.expects(:enforce_index_permissions)
|
|
129
|
+
get :index
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
describe "show" do
|
|
133
|
+
it "should trigger enforce_show_permissions and load_fedora_document" do
|
|
134
|
+
controller.expects(:load_fedora_document)
|
|
135
|
+
controller.expects(:enforce_show_permissions)
|
|
136
|
+
get :show, :id=>'test:3'
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
describe "edit" do
|
|
140
|
+
it "should trigger enforce_edit_permissions and load_fedora_document" do
|
|
141
|
+
controller.expects(:load_fedora_document)
|
|
142
|
+
controller.expects(:enforce_edit_permissions)
|
|
143
|
+
get :edit, :id=>'test:3'
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
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 CatalogController do
|
|
12
|
+
|
|
13
|
+
before do
|
|
14
|
+
controller.stubs(:load_fedora_document)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "show" do
|
|
18
|
+
it "should redirect to edit view if session is in edit context and user has edit permission" do
|
|
19
|
+
controller.stubs(:reader?).returns(true)
|
|
20
|
+
controller.expects(:editor?).returns(true)
|
|
21
|
+
|
|
22
|
+
controller.session[:viewing_context] = "edit"
|
|
23
|
+
get(:show, {:id=>"hydrangea:fixture_mods_article1"})
|
|
24
|
+
response.should redirect_to(:action => 'edit')
|
|
25
|
+
end
|
|
26
|
+
it "should allow you to reset the session context to browse using :viewing_context param" do
|
|
27
|
+
controller.stubs(:reader?).returns(true)
|
|
28
|
+
controller.session[:viewing_context] = "edit"
|
|
29
|
+
get(:show, :id=>"hydrangea:fixture_mods_article1", :viewing_context=>"browse")
|
|
30
|
+
session[:viewing_context].should == "browse"
|
|
31
|
+
response.should_not redirect_to(:action => 'edit')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should quietly switch session state to browse if user does not have edit permissions" do
|
|
35
|
+
controller.expects(:reader?).returns(true)
|
|
36
|
+
controller.expects(:editor?).returns(false)
|
|
37
|
+
controller.session[:viewing_context] = "edit"
|
|
38
|
+
get(:show, {:id=>"hydrangea:fixture_mods_article1"})
|
|
39
|
+
session[:viewing_context].should == "browse"
|
|
40
|
+
response.should_not redirect_to(:action => 'edit')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe "edit" do
|
|
45
|
+
it "should enforce edit permissions, redirecting to show action and resetting session context if user does not have edit permissions" do
|
|
46
|
+
mock_user = mock("User")
|
|
47
|
+
mock_user.stubs(:login).returns("patron1")
|
|
48
|
+
mock_user.stubs(:is_being_superuser?).returns(false)
|
|
49
|
+
controller.stubs(:current_user).returns(mock_user)
|
|
50
|
+
|
|
51
|
+
get :edit, :id=>"hydrangea:fixture_mods_article1"
|
|
52
|
+
response.should redirect_to(:action => 'show')
|
|
53
|
+
flash[:notice].should == "You do not have sufficient privileges to edit this document. You have been redirected to the read-only view."
|
|
54
|
+
end
|
|
55
|
+
it "should render normally if user has edit permissions" do
|
|
56
|
+
controller.expects(:editor?).returns(true)
|
|
57
|
+
get :edit, :id=>"hydrangea:fixture_mods_article1"
|
|
58
|
+
response.should_not redirect_to(:action => 'show')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
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 ContributorsController do
|
|
12
|
+
|
|
13
|
+
describe "create" do
|
|
14
|
+
it "should support adding new person / contributor / organization nodes" do
|
|
15
|
+
mock_document = mock("document")
|
|
16
|
+
["person","conference","organization"].each do |type|
|
|
17
|
+
mock_document.expects(:insert_contributor).with(type).returns(["foo node",989])
|
|
18
|
+
mock_document.expects(:save)
|
|
19
|
+
ModsAsset.expects(:find).with("_PID_").returns(mock_document)
|
|
20
|
+
post :create, :asset_id=>"_PID_", :controller => "contributors", :content_type => "mods_asset", :contributor_type=>type
|
|
21
|
+
response.should redirect_to "http://test.host/catalog/_PID_/edit##{type}_989"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
it "should return inline html if format is inline" do
|
|
25
|
+
mock_document = mock("document")
|
|
26
|
+
["person","conference","organization"].each do |type|
|
|
27
|
+
mock_document.expects(:insert_contributor).with(type).returns(["foo node","foo index"])
|
|
28
|
+
mock_document.expects(:save)
|
|
29
|
+
ModsAsset.expects(:find).with("_PID_").returns(mock_document)
|
|
30
|
+
post :create, :asset_id=>"_PID_", :controller => "contributors", :content_type => "mods_asset", :contributor_type=>type, :format=>"inline"
|
|
31
|
+
response.should render_template "contributors/_edit_#{type}"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe "destroy" do
|
|
37
|
+
it "should delete the contributor corresponding to contributor_type and index" do
|
|
38
|
+
mock_dataset = mock("Dataset")
|
|
39
|
+
mock_dataset.expects(:remove_contributor).with("conference", "3")
|
|
40
|
+
mock_dataset.expects(:save)
|
|
41
|
+
ModsAsset.expects(:find).with("_PID_").returns(mock_dataset)
|
|
42
|
+
|
|
43
|
+
delete :destroy, :asset_id=>"_PID_", :content_type => "mods_asset", :contributor_type=>"conference", :index=>"3"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe FileAssetsController do
|
|
4
|
+
include Devise::TestHelpers
|
|
5
|
+
|
|
6
|
+
before do
|
|
7
|
+
session[:user]='bob'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
## Plugin Tests
|
|
11
|
+
it "should use FileAssetsController" do
|
|
12
|
+
controller.should be_an_instance_of(FileAssetsController)
|
|
13
|
+
end
|
|
14
|
+
it "should be restful" do
|
|
15
|
+
{ :get => "/file_assets" }.should route_to(:controller=>'file_assets', :action=>'index')
|
|
16
|
+
{ :get => "/file_assets/3" }.should route_to(:controller=>'file_assets', :action=>'show', :id=>"3")
|
|
17
|
+
{ :delete=> "/file_assets/3" }.should route_to(:controller=>'file_assets', :action=>'destroy', :id=>"3")
|
|
18
|
+
{ :put=>"/file_assets/3" }.should route_to(:controller=>'file_assets', :action=>'update', :id=>"3")
|
|
19
|
+
{ :get => "/file_assets/3/edit" }.should route_to(:controller=>'file_assets', :action=>'edit', :id=>"3")
|
|
20
|
+
{ :get =>"/file_assets/new" }.should route_to(:controller=>'file_assets', :action=>'new')
|
|
21
|
+
{ :post => "/file_assets" }.should route_to(:controller=>'file_assets', :action=>'create')
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "index" do
|
|
26
|
+
|
|
27
|
+
it "should find all file assets in the repo if no container_id is provided" do
|
|
28
|
+
#FileAsset.expects(:find_by_solr).with(:all, {}).returns("solr result")
|
|
29
|
+
# Solr::Connection.any_instance.expects(:query).with('conforms_to_field:info\:fedora/afmodel\:FileAsset', {}).returns("solr result")
|
|
30
|
+
Solr::Connection.any_instance.expects(:query).with('active_fedora_model_s:FileAsset', {}).returns("solr result")
|
|
31
|
+
controller.stubs(:load_permissions_from_solr)
|
|
32
|
+
ActiveFedora::Base.expects(:new).never
|
|
33
|
+
xhr :get, :index
|
|
34
|
+
assigns[:solr_result].should == "solr result"
|
|
35
|
+
end
|
|
36
|
+
it "should find all file assets belonging to a given container object if container_id or container_id is provided" do
|
|
37
|
+
mock_container = mock("container")
|
|
38
|
+
mock_container.expects(:file_objects).with(:response_format => :solr).returns("solr result")
|
|
39
|
+
controller.expects(:get_search_results).with(:q=>'is_part_of_s:info\:fedora/_PID_').returns(["assets solr response","assets solr list"])
|
|
40
|
+
controller.expects(:get_solr_response_for_doc_id).with('_PID_').returns(["container solr response","container solr doc"])
|
|
41
|
+
controller.stubs(:load_permissions_from_solr)
|
|
42
|
+
|
|
43
|
+
ActiveFedora::Base.expects(:load_instance).with("_PID_").returns(mock_container)
|
|
44
|
+
xhr :get, :index, :asset_id=>"_PID_"
|
|
45
|
+
assigns[:response].should == "assets solr response"
|
|
46
|
+
assigns[:document_list].should == "assets solr list"
|
|
47
|
+
|
|
48
|
+
assigns[:container_response].should == "container solr response"
|
|
49
|
+
assigns[:document].should == "container solr doc"
|
|
50
|
+
assigns[:solr_result].should == "solr result"
|
|
51
|
+
assigns[:container].should == mock_container
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should find all file assets belonging to a given container object if container_id or container_id is provided" do
|
|
55
|
+
pending
|
|
56
|
+
# this was testing a hacked version
|
|
57
|
+
mock_solr_hash = {"has_collection_member_field"=>["info:fedora/foo:id"]}
|
|
58
|
+
mock_container = mock("container")
|
|
59
|
+
mock_container.expects(:collection_members).with(:response_format=>:solr).returns("solr result")
|
|
60
|
+
ActiveFedora::Base.expects(:load_instance).with("_PID_").returns(mock_container)
|
|
61
|
+
xhr :get, :index, :asset_id=>"_PID_"
|
|
62
|
+
assigns[:solr_result].should == "solr result"
|
|
63
|
+
assigns[:container].should == mock_container
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "index" do
|
|
68
|
+
before(:each) do
|
|
69
|
+
Fedora::Repository.stubs(:instance).returns(stub_everything)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should be refined further!"
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
describe "new" do
|
|
76
|
+
it "should return the file uploader view"
|
|
77
|
+
it "should set :container_id to value of :container_id if available" do
|
|
78
|
+
xhr :get, :new, :asset_id=>"_PID_"
|
|
79
|
+
@controller.params[:asset_id].should == "_PID_"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe "show" do
|
|
84
|
+
it "should redirect to index view if current_user does not have read or edit permissions" do
|
|
85
|
+
mock_user = mock("User")
|
|
86
|
+
mock_user.stubs(:login).returns("fake_user")
|
|
87
|
+
mock_user.stubs(:is_being_superuser?).returns(false)
|
|
88
|
+
controller.stubs(:current_user).returns(mock_user)
|
|
89
|
+
get(:show, :id=>"hydrangea:fixture_file_asset1")
|
|
90
|
+
response.should redirect_to(:action => 'index')
|
|
91
|
+
end
|
|
92
|
+
it "should redirect to index view if the file does not exist" do
|
|
93
|
+
get(:show, :id=>"example:invalid_object")
|
|
94
|
+
response.should redirect_to(:action => 'index')
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe "create" do
|
|
99
|
+
it "should create and save a file asset from the given params" do
|
|
100
|
+
mock_fa = mock("FileAsset")
|
|
101
|
+
mock_fa.stubs(:pid).returns("foo:pid")
|
|
102
|
+
controller.expects(:create_and_save_file_asset_from_params).returns(mock_fa)
|
|
103
|
+
xhr :post, :create, :Filedata=>mock("File"), :Filename=>"Foo File"
|
|
104
|
+
end
|
|
105
|
+
it "if container_id is provided, should associate the created file asset wtih the container" do
|
|
106
|
+
stub_fa = stub("FileAsset", :save)
|
|
107
|
+
stub_fa.stubs(:pid).returns("foo:pid")
|
|
108
|
+
controller.expects(:create_and_save_file_asset_from_params).returns(stub_fa)
|
|
109
|
+
controller.expects(:associate_file_asset_with_container)
|
|
110
|
+
xhr :post, :create, :Filedata=>stub("File"), :Filename=>"Foo File", :asset_id=>"_PID_"
|
|
111
|
+
end
|
|
112
|
+
it "should redirect back to container edit view if no Filedata is provided but container_id is provided" do
|
|
113
|
+
xhr :post, :create, :asset_id=>"_PID_"
|
|
114
|
+
response.should redirect_to(:controller=>"catalog", :id=>"_PID_", :action => 'edit')
|
|
115
|
+
# flash[:notice].should == "You must specify a file to upload."
|
|
116
|
+
end
|
|
117
|
+
it "should display a message that you need to select a file to upload if no Filedata is provided" do
|
|
118
|
+
xhr :post, :create
|
|
119
|
+
# flash[:notice].should == "You must specify a file to upload."
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe "destroy" do
|
|
125
|
+
it "should delete the asset identified by pid" do
|
|
126
|
+
mock_obj = mock("asset", :delete)
|
|
127
|
+
ActiveFedora::Base.expects(:load_instance).with("__PID__").returns(mock_obj)
|
|
128
|
+
delete(:destroy, :id => "__PID__")
|
|
129
|
+
end
|
|
130
|
+
it "should remove container relationship and perform proper garbage collection" do
|
|
131
|
+
pending "relies on ActiveFedora implementing Base.file_objects_remove"
|
|
132
|
+
mock_container = mock("asset")
|
|
133
|
+
mock_container.expects(:file_objects_remove).with("_file_asset_pid_")
|
|
134
|
+
FileAsset.expects(:garbage_collect).with("_file_asset_pid_")
|
|
135
|
+
ActiveFedora::Base.expects(:load_instance).with("_container_pid_").returns(mock_container)
|
|
136
|
+
delete(:destroy, :id => "_file_asset_pid_", :asset_id=>"_container_pid_")
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
describe "integration tests - " do
|
|
141
|
+
before(:all) do
|
|
142
|
+
Fedora::Repository.register(ActiveFedora.fedora_config[:url])
|
|
143
|
+
ActiveFedora::SolrService.register(ActiveFedora.solr_config[:url])
|
|
144
|
+
@test_container = ActiveFedora::Base.new
|
|
145
|
+
@test_container.add_relationship(:is_member_of, "foo:1")
|
|
146
|
+
@test_container.add_relationship(:has_collection_member, "foo:2")
|
|
147
|
+
@test_container.save
|
|
148
|
+
|
|
149
|
+
@test_fa = FileAsset.new
|
|
150
|
+
@test_fa.add_relationship(:is_part_of, @test_container)
|
|
151
|
+
@test_fa.save
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
after(:all) do
|
|
155
|
+
@test_container.delete
|
|
156
|
+
@test_fa.delete
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
describe "index" do
|
|
160
|
+
it "should retrieve the container object and its file assets" do
|
|
161
|
+
#xhr :get, :index, :container_id=>@test_container.pid
|
|
162
|
+
get :index, {:asset_id=>@test_container.pid}
|
|
163
|
+
@controller.params[:asset_id].should_not be_nil
|
|
164
|
+
assigns(:solr_result).should_not be_nil
|
|
165
|
+
#puts assigns(:solr_result).inspect
|
|
166
|
+
assigns(:container).file_objects(:response_format=>:id_array).should include(@test_fa.pid)
|
|
167
|
+
assigns(:container).file_objects(:response_format=>:id_array).should include("foo:2")
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
describe "create" do
|
|
172
|
+
before :each do
|
|
173
|
+
mock_user = mock("User")
|
|
174
|
+
mock_warden = mock("Warden")
|
|
175
|
+
mock_warden.stubs(:authenticate).returns(mock_user)
|
|
176
|
+
request.env['warden'] = mock_warden
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it "should set is_part_of relationship on the new File Asset pointing back at the container" do
|
|
180
|
+
|
|
181
|
+
test_file = fixture("empty_file.txt")
|
|
182
|
+
filename = "My File Name"
|
|
183
|
+
post :create, {:Filedata=>test_file, :Filename=>filename, :asset_id=>@test_container.pid}
|
|
184
|
+
assigns(:file_asset).relationships[:self][:is_part_of].should == ["info:fedora/#{@test_container.pid}"]
|
|
185
|
+
retrieved_fa = FileAsset.load_instance(@test_fa.pid).relationships[:self][:is_part_of].should == ["info:fedora/#{@test_container.pid}"]
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|