hydra-head 3.0.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- 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,28 @@
|
|
1
|
+
# Need way to find way to stub current_user and RoleMapper in order to run these tests
|
2
|
+
require File.expand_path( File.join( File.dirname(__FILE__),'..','spec_helper') )
|
3
|
+
|
4
|
+
|
5
|
+
describe Hydra::CommonModsIndexMethods do
|
6
|
+
describe "extract_person_full_names" do
|
7
|
+
it "should return an array of Solr::Field objects for :person_full_name_facet" do
|
8
|
+
full_names = ModsAsset.find("hydrangea:fixture_mods_article1").datastreams["descMetadata"].extract_person_full_names
|
9
|
+
full_names.should be_kind_of Hash
|
10
|
+
full_names["person_full_name_facet"].should be_kind_of Array
|
11
|
+
full_names["person_full_name_facet"].length.should == 2
|
12
|
+
full_names["person_full_name_facet"].first.should == "FAMILY NAME, GIVEN NAMES"
|
13
|
+
full_names["person_full_name_facet"].last.should == "Lacks, Henrietta"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
describe "extract_person_organizations" do
|
17
|
+
it "should return an array of Solr::Field objects for :mods_organization_facet" do
|
18
|
+
orgs = ModsAsset.find("hydrangea:fixture_mods_article1").datastreams["descMetadata"].extract_person_organizations
|
19
|
+
orgs.should be_kind_of Hash
|
20
|
+
orgs["mods_organization_facet"].should be_kind_of Array
|
21
|
+
orgs["mods_organization_facet"].length.should == 2
|
22
|
+
orgs["mods_organization_facet"].first.should == "FACULTY, UNIVERSITY"
|
23
|
+
orgs["mods_organization_facet"].last.should == "Baltimore"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require "active_fedora"
|
3
|
+
|
4
|
+
describe AudioAsset do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
Fedora::Repository.stubs(:instance).returns(stub_everything())
|
8
|
+
@asset = AudioAsset.new
|
9
|
+
@asset.stubs(:create_date).returns("2008-07-02T05:09:42.015Z")
|
10
|
+
@asset.stubs(:modified_date).returns("2008-09-29T21:21:52.892Z")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "Should be a kind of ActiveFedora::Base kind of FileAsset, and instance of AudioAsset" do
|
14
|
+
@asset.should be_kind_of(ActiveFedora::Base)
|
15
|
+
@asset.should be_kind_of(FileAsset)
|
16
|
+
@asset.should be_instance_of(AudioAsset)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have a conforms_to relationship pointing to FileAsset" do
|
20
|
+
@asset.relationships[:self][:has_model].should include("info:fedora/afmodel:FileAsset")
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require "active_fedora"
|
3
|
+
|
4
|
+
describe FileAsset do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
Fedora::Repository.stubs(:instance).returns(stub_everything())
|
8
|
+
@file_asset = FileAsset.new
|
9
|
+
@file_asset.stubs(:create_date).returns("2008-07-02T05:09:42.015Z")
|
10
|
+
@file_asset.stubs(:modified_date).returns("2008-09-29T21:21:52.892Z")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "Should be a kind of ActiveFedora::Base" do
|
14
|
+
@file_asset.should be_kind_of(ActiveFedora::Base)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should include Hydra Model Methods" do
|
18
|
+
@file_asset.class.included_modules.should include(Hydra::ModelMethods)
|
19
|
+
@file_asset.should respond_to(:apply_depositor_metadata)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#garbage_collect' do
|
23
|
+
it "should delete the object if it does not have any objects asserting has_collection_member" do
|
24
|
+
mock_non_orphan = mock("non-orphan file asset", :containers=>["foo"])
|
25
|
+
mock_non_orphan.expects(:delete).never
|
26
|
+
|
27
|
+
mock_orphan = mock("orphan file asset", :containers=>[])
|
28
|
+
mock_orphan.expects(:delete)
|
29
|
+
|
30
|
+
FileAsset.expects(:load_instance).with("_non_orphan_pid_").returns(mock_non_orphan)
|
31
|
+
FileAsset.expects(:load_instance).with("_orphan_pid_").returns(mock_orphan)
|
32
|
+
|
33
|
+
FileAsset.garbage_collect("_non_orphan_pid_")
|
34
|
+
FileAsset.garbage_collect("_orphan_pid_")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe ".add_file" do
|
39
|
+
it "should call super.add_file"
|
40
|
+
it "should set the FileAsset's title and label to the file datastream's filename if they are currently empty"
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require "active_fedora"
|
3
|
+
|
4
|
+
describe GenericContent do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
Fedora::Repository.stubs(:instance).returns(stub_everything())
|
8
|
+
@hydra_content = GenericContent.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it "Should be a kind of ActiveFedora::Base" do
|
12
|
+
@hydra_content.should be_kind_of(ActiveFedora::Base)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should include Hydra Model Methods" do
|
16
|
+
@hydra_content.class.included_modules.should include(Hydra::ModelMethods)
|
17
|
+
@hydra_content.should respond_to(:apply_depositor_metadata)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have accessors for its default datastreams of content and original" do
|
21
|
+
@hydra_content.should respond_to(:has_content?)
|
22
|
+
@hydra_content.should respond_to(:content)
|
23
|
+
@hydra_content.should respond_to(:content=)
|
24
|
+
@hydra_content.should respond_to(:has_original?)
|
25
|
+
@hydra_content.should respond_to(:original)
|
26
|
+
@hydra_content.should respond_to(:original=)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require "active_fedora"
|
3
|
+
|
4
|
+
describe GenericImage do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
Fedora::Repository.stubs(:instance).returns(stub_everything())
|
8
|
+
@hydra_image = GenericImage.new
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
it "Should be a kind of ActiveFedora::Base" do
|
13
|
+
@hydra_image.should be_kind_of(ActiveFedora::Base)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should include Hydra Model Methods" do
|
17
|
+
@hydra_image.class.included_modules.should include(Hydra::ModelMethods)
|
18
|
+
@hydra_image.should respond_to(:apply_depositor_metadata)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have accessors for its default datastreams of content and original" do
|
22
|
+
@hydra_image.should respond_to(:has_content?)
|
23
|
+
@hydra_image.should respond_to(:content)
|
24
|
+
@hydra_image.should respond_to(:content=)
|
25
|
+
@hydra_image.should respond_to(:has_original?)
|
26
|
+
@hydra_image.should respond_to(:original)
|
27
|
+
@hydra_image.should respond_to(:original=)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have accessors for its default datastreams of max, screen and thumbnail" do
|
31
|
+
@hydra_image.should respond_to(:has_max?)
|
32
|
+
@hydra_image.should respond_to(:max)
|
33
|
+
@hydra_image.should respond_to(:max=)
|
34
|
+
@hydra_image.should respond_to(:has_screen?)
|
35
|
+
@hydra_image.should respond_to(:screen)
|
36
|
+
@hydra_image.should respond_to(:screen=)
|
37
|
+
@hydra_image.should respond_to(:has_thumbnail?)
|
38
|
+
@hydra_image.should respond_to(:thumbnail)
|
39
|
+
@hydra_image.should respond_to(:thumbnail=)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should create a max datastream when setting max value to image file" do
|
43
|
+
f = File.new(File.join( File.dirname(__FILE__), "../../fixtures/image.jp2" ))
|
44
|
+
@hydra_image.max = f
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#content=' do
|
48
|
+
it "shoutld create a content datastream when given an image file" do
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#derive_all' do
|
53
|
+
it "should create a max, screen and thumbnail file" do
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require "active_fedora"
|
3
|
+
require "nokogiri"
|
4
|
+
|
5
|
+
describe Hydra::RightsMetadata do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
Fedora::Repository.stubs(:instance).returns(stub_everything())
|
9
|
+
@sample = Hydra::RightsMetadata.new
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "permissions" do
|
13
|
+
describe "setter" do
|
14
|
+
it "should create/update/delete permissions for the given user/group" do
|
15
|
+
@sample.class.terminology.xpath_for(:access, :person, "person_123").should == '//oxns:access/oxns:machine/oxns:person[contains(., "person_123")]'
|
16
|
+
|
17
|
+
person_123_perms_xpath = @sample.class.terminology.xpath_for(:access, :person, "person_123")
|
18
|
+
group_zzz_perms_xpath = @sample.class.terminology.xpath_for(:access, :group, "group_zzz")
|
19
|
+
|
20
|
+
@sample.find_by_terms(person_123_perms_xpath).should be_empty
|
21
|
+
@sample.permissions({"person"=>"person_123"}, "edit").should == "edit"
|
22
|
+
@sample.permissions({"group"=>"group_zzz"}, "edit").should == "edit"
|
23
|
+
|
24
|
+
@sample.find_by_terms(person_123_perms_xpath).first.ancestors("access").first.attributes["type"].text.should == "edit"
|
25
|
+
@sample.find_by_terms(group_zzz_perms_xpath).first.ancestors("access").first.attributes["type"].text.should == "edit"
|
26
|
+
|
27
|
+
@sample.permissions({"person"=>"person_123"}, "read")
|
28
|
+
@sample.permissions({"group"=>"group_zzz"}, "read")
|
29
|
+
@sample.find_by_terms(person_123_perms_xpath).length.should == 1
|
30
|
+
|
31
|
+
@sample.find_by_terms(person_123_perms_xpath).first.ancestors("access").first.attributes["type"].text.should == "read"
|
32
|
+
@sample.find_by_terms(group_zzz_perms_xpath).first.ancestors("access").first.attributes["type"].text.should == "read"
|
33
|
+
|
34
|
+
@sample.permissions({"person"=>"person_123"}, "none").should == "none"
|
35
|
+
@sample.permissions({"group"=>"group_zzz"}, "none").should == "none"
|
36
|
+
@sample.find_by_terms(person_123_perms_xpath).should be_empty
|
37
|
+
@sample.find_by_terms(person_123_perms_xpath).should be_empty
|
38
|
+
end
|
39
|
+
it "should remove existing permissions (leaving only one permission level per user/group)" do
|
40
|
+
person_123_perms_xpath = @sample.class.terminology.xpath_for(:access, :person, "person_123")
|
41
|
+
group_zzz_perms_xpath = @sample.class.terminology.xpath_for(:access, :group, "group_zzz")
|
42
|
+
|
43
|
+
@sample.find_by_terms(person_123_perms_xpath).length.should == 0
|
44
|
+
@sample.find_by_terms(group_zzz_perms_xpath).length.should == 0
|
45
|
+
@sample.permissions({"person"=>"person_123"}, "read")
|
46
|
+
@sample.permissions({"group"=>"group_zzz"}, "read")
|
47
|
+
@sample.find_by_terms(person_123_perms_xpath).length.should == 1
|
48
|
+
@sample.find_by_terms(group_zzz_perms_xpath).length.should == 1
|
49
|
+
|
50
|
+
@sample.permissions({"person"=>"person_123"}, "edit")
|
51
|
+
@sample.permissions({"group"=>"group_zzz"}, "edit")
|
52
|
+
@sample.find_by_terms(person_123_perms_xpath).length.should == 1
|
53
|
+
@sample.find_by_terms(group_zzz_perms_xpath).length.should == 1
|
54
|
+
end
|
55
|
+
it "should not impact other users permissions" do
|
56
|
+
@sample.permissions({"person"=>"person_123"}, "read")
|
57
|
+
@sample.permissions({"person"=>"person_789"}, "edit")
|
58
|
+
|
59
|
+
@sample.permissions({"person"=>"person_123"}).should == "read"
|
60
|
+
@sample.permissions({"person"=>"person_456"}, "read")
|
61
|
+
@sample.permissions({"person"=>"person_123"}).should == "read"
|
62
|
+
@sample.permissions({"person"=>"person_456"}).should == "read"
|
63
|
+
@sample.permissions({"person"=>"person_789"}).should == "edit"
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
describe "getter" do
|
69
|
+
it "should return permissions level for the given user/group" do
|
70
|
+
@sample.permissions({"person"=>"person_123"}, "edit")
|
71
|
+
@sample.permissions({"group"=>"group_zzz"}, "discover")
|
72
|
+
@sample.permissions({"person"=>"person_123"}).should == "edit"
|
73
|
+
@sample.permissions({"group"=>"group_zzz"}).should == "discover"
|
74
|
+
@sample.permissions({"group"=>"foo_people"}).should == "none"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
describe "groups" do
|
79
|
+
it "should return a hash of all groups with permissions set, along with their permission levels" do
|
80
|
+
@sample.permissions({"group"=>"group_zzz"}, "edit")
|
81
|
+
@sample.permissions({"group"=>"public"}, "discover")
|
82
|
+
|
83
|
+
#@sample.groups.should == {"group_zzz"=>"edit", "public"=>"discover"}
|
84
|
+
@sample.groups.should == {"public"=>"discover", "group_zzz"=>"edit"}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
describe "individuals" do
|
88
|
+
it "should return a hash of all individuals with permissions set, along with their permission levels" do
|
89
|
+
@sample.permissions({"person"=>"person_123"}, "read")
|
90
|
+
@sample.permissions({"person"=>"person_456"}, "edit")
|
91
|
+
@sample.individuals.should == {"person_123"=>"read", "person_456"=>"edit"}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "update_permissions" do
|
96
|
+
it "should accept a hash of groups and persons, updating their permissions accordingly" do
|
97
|
+
@sample.expects(:permissions).with({"group" => "group1"}, "discover")
|
98
|
+
@sample.expects(:permissions).with({"group" => "group2"}, "edit")
|
99
|
+
@sample.expects(:permissions).with({"person" => "person1"}, "read")
|
100
|
+
@sample.expects(:permissions).with({"person" => "person2"}, "discover")
|
101
|
+
|
102
|
+
@sample.update_permissions( {"group"=>{"group1"=>"discover","group2"=>"edit"}, "person"=>{"person1"=>"read","person2"=>"discover"}} )
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "update_indexed_attributes" do
|
107
|
+
it "should update the declared properties" do
|
108
|
+
@sample.find_by_terms(*[:edit_access, :person]).length.should == 0
|
109
|
+
@sample.update_values([:edit_access, :person]=>"user id").should == {"edit_access_person"=>{"0"=>"user id"}}
|
110
|
+
@sample.find_by_terms(*[:edit_access, :person]).length.should == 1
|
111
|
+
@sample.find_by_terms(*[:edit_access, :person]).first.text.should == "user id"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
describe "to_solr" do
|
115
|
+
it "should populate solr doc with the correct fields" do
|
116
|
+
params = {[:edit_access, :person]=>"Lil Kim", [:edit_access, :group]=>["group1","group2"], [:discover_access, :group]=>["public"],[:discover_access, :person]=>["Joe Schmoe"]}
|
117
|
+
@sample.update_values(params)
|
118
|
+
solr_doc = @sample.to_solr
|
119
|
+
|
120
|
+
solr_doc["edit_access_person_t"].should == ["Lil Kim"]
|
121
|
+
solr_doc["edit_access_group_t"].sort.should == ["group1", "group2"]
|
122
|
+
solr_doc["discover_access_person_t"].should == ["Joe Schmoe"]
|
123
|
+
solr_doc["discover_access_group_t"].should == ["public"]
|
124
|
+
end
|
125
|
+
it "should solrize fixture content correctly" do
|
126
|
+
fixture_xml = Nokogiri::XML::Document.parse( File.new(File.join( File.dirname(__FILE__), "../../fixtures/hydrangea_fixture_mods_article1.foxml.xml") ))
|
127
|
+
fixture_rights = fixture_xml.xpath("//foxml:datastream[@ID='rightsMetadata']/foxml:datastreamVersion[last()]/foxml:xmlContent", {'foxml'=>"info:fedora/fedora-system:def/foxml#"}).first.to_xml
|
128
|
+
lsample = Hydra::RightsMetadata.from_xml(fixture_rights)
|
129
|
+
solr_doc = lsample.to_solr
|
130
|
+
solr_doc["edit_access_person_t"].should == ["researcher1"]
|
131
|
+
solr_doc["edit_access_group_t"].should == ["archivist"]
|
132
|
+
solr_doc["read_access_group_t"].should == ["public"]
|
133
|
+
solr_doc["discover_access_group_t"].should == ["public"]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
describe "embargo_release_date=" do
|
137
|
+
it "should update the appropriate node with the value passed" do
|
138
|
+
@sample.embargo_release_date=("2010-12-01")
|
139
|
+
@sample.embargo_release_date.should == "2010-12-01"
|
140
|
+
end
|
141
|
+
it "should only accept valid date values" do
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
145
|
+
describe "embargo_release_date" do
|
146
|
+
it "should return the value as specified in the appropriate node" do
|
147
|
+
end
|
148
|
+
end
|
149
|
+
describe "under_embargo?" do
|
150
|
+
it "should return true if the current date is before the embargo release date" do
|
151
|
+
@sample.embargo_release_date=Date.today+1.month
|
152
|
+
@sample.under_embargo?.should be_true
|
153
|
+
end
|
154
|
+
it "should return false if the current date is after the embargo release date" do
|
155
|
+
@sample.embargo_release_date=Date.today-1.month
|
156
|
+
@sample.under_embargo?.should be_false
|
157
|
+
end
|
158
|
+
it "should return false if there is no embargo date" do
|
159
|
+
@sample.under_embargo?.should be_false
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require "active_fedora"
|
3
|
+
|
4
|
+
describe ImageAsset do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
Fedora::Repository.stubs(:instance).returns(stub_everything())
|
8
|
+
@asset = ImageAsset.new
|
9
|
+
@asset.stubs(:create_date).returns("2008-07-02T05:09:42.015Z")
|
10
|
+
@asset.stubs(:modified_date).returns("2008-09-29T21:21:52.892Z")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "Should be a kind of ActiveFedora::Base kind of FileAsset, and instance of ImageAsset" do
|
14
|
+
@asset.should be_kind_of(ActiveFedora::Base)
|
15
|
+
@asset.should be_kind_of(FileAsset)
|
16
|
+
@asset.should be_instance_of(ImageAsset)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have a conforms_to relationship pointing to FileAsset" do
|
20
|
+
@asset.relationships[:self][:has_model].should include("info:fedora/afmodel:FileAsset")
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe ModsAsset do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
Fedora::Repository.stubs(:instance).returns(stub_everything())
|
7
|
+
@asset = ModsAsset.new
|
8
|
+
# @asset.stubs(:create_date).returns("2008-07-02T05:09:42.015Z")
|
9
|
+
# @asset.stubs(:modified_date).returns("2008-09-29T21:21:52.892Z")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "Should be a kind of ActiveFedora::Base" do
|
13
|
+
@asset.should be_kind_of(ActiveFedora::Base)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should set up descMetadata and rightsMetadata datastreams" do
|
17
|
+
@asset.datastreams.should have_key("descMetadata")
|
18
|
+
@asset.datastreams["descMetadata"].should be_instance_of(Hydra::ModsArticle)
|
19
|
+
@asset.datastreams.should have_key("rightsMetadata")
|
20
|
+
@asset.datastreams["rightsMetadata"].should be_instance_of(Hydra::RightsMetadata)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have has_model relationships pointing to commonMetadata and modsObject cModels" do
|
24
|
+
pending "this is waiting for ActiveFedora::Base to support a self.relationships method"
|
25
|
+
@asset.relationships[:self][:has_model].should include("info:fedora/hydra-cModel:commonMetadata")
|
26
|
+
@asset.relationships[:self][:has_model].should include("info:fedora/hydra-cModel:modsObject")
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe RoleMapper do
|
4
|
+
|
5
|
+
it "should define the 4 roles" do
|
6
|
+
RoleMapper.role_names.sort.should == %w(admin_policy_object_editor archivist donor patron researcher)
|
7
|
+
end
|
8
|
+
it "should quer[iy]able for roles for a given user" do
|
9
|
+
RoleMapper.roles('leland_himself@example.com').sort.should == ['archivist', 'donor', 'patron']
|
10
|
+
RoleMapper.roles('archivist2@example.com').should == ['archivist']
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return an empty array if there are no roles" do
|
14
|
+
RoleMapper.roles('zeus@olympus.mt').empty?.should == true
|
15
|
+
end
|
16
|
+
it "should know who is what" do
|
17
|
+
RoleMapper.whois('archivist').sort.should == %w(archivist1@example.com archivist2@example.com leland_himself@example.com)
|
18
|
+
RoleMapper.whois('salesman').empty?.should == true
|
19
|
+
RoleMapper.whois('admin_policy_object_editor').sort.should == %w(archivist1@example.com)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require "active_fedora"
|
3
|
+
|
4
|
+
describe User do
|
5
|
+
|
6
|
+
describe "superuser" do
|
7
|
+
before(:each) do
|
8
|
+
@user = User.create(:email=> "testuser@example.com", :password=> "password", :password_confirmation => "password")
|
9
|
+
end
|
10
|
+
it "should know if a user can be a superuser" do
|
11
|
+
superuser = Superuser.create(:id => 20, :user_id => @user.id)
|
12
|
+
@user.extend(Hydra::SuperuserAttributes)
|
13
|
+
@user.can_be_superuser?.should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should know if a user shouldn't be a superuser" do
|
17
|
+
@user.extend(Hydra::SuperuserAttributes)
|
18
|
+
@user.can_be_superuser?.should be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should know if the user is being a superuser" do
|
22
|
+
superuser = Superuser.create(:id => 50, :user_id => @user.id)
|
23
|
+
@user.extend(Hydra::SuperuserAttributes)
|
24
|
+
session = { :superuser_mode => true }
|
25
|
+
@user.is_being_superuser?(session).should be_true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not let a non-superuser be a superuser" do
|
29
|
+
@user.extend(Hydra::SuperuserAttributes)
|
30
|
+
session = {}
|
31
|
+
@user.is_being_superuser?(session).should be_false
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should know if the user is not being a superuser even if the user can be a superuser" do
|
35
|
+
superuser = Superuser.create(:id => 60, :user_id => @user.id)
|
36
|
+
@user.extend(Hydra::SuperuserAttributes)
|
37
|
+
@user.can_be_superuser?.should be_true
|
38
|
+
session = {}
|
39
|
+
@user.is_being_superuser?(session).should be_false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module UserTestAttributes
|
45
|
+
['first_name','last_name','full_name','affiliation','photo'].each do |attr|
|
46
|
+
class_eval <<-EOM
|
47
|
+
def #{attr}
|
48
|
+
"test_#{attr}"
|
49
|
+
end
|
50
|
+
EOM
|
51
|
+
end
|
52
|
+
end
|