hyrax 3.0.0.pre.beta2 → 3.0.0.pre.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +118 -181
- data/.gitignore +3 -0
- data/.regen +1 -0
- data/.rubocop_fixme.yml +1 -1
- data/README.md +11 -15
- data/app/actors/hyrax/actors/active_fedora_to_valkyrie.rb +59 -0
- data/app/actors/hyrax/actors/add_to_work_actor.rb +28 -5
- data/app/actors/hyrax/actors/apply_order_actor.rb +2 -2
- data/app/actors/hyrax/actors/attach_members_actor.rb +50 -28
- data/app/actors/hyrax/actors/base_actor.rb +17 -2
- data/app/actors/hyrax/actors/cleanup_file_sets_actor.rb +1 -1
- data/app/actors/hyrax/actors/collections_membership_actor.rb +2 -8
- data/app/actors/hyrax/actors/create_with_files_actor.rb +16 -6
- data/app/actors/hyrax/actors/create_with_files_ordered_members_actor.rb +2 -2
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +2 -1
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +8 -6
- data/app/actors/hyrax/actors/environment.rb +8 -16
- data/app/actors/hyrax/actors/file_actor.rb +75 -13
- data/app/actors/hyrax/actors/interpret_visibility_actor.rb +6 -8
- data/app/actors/hyrax/actors/valkyrie_to_active_fedora.rb +60 -0
- data/app/assets/javascripts/hyrax/collections.js +5 -4
- data/app/assets/javascripts/hyrax/nav_safety.js +4 -2
- data/app/assets/javascripts/hyrax/proxy_rights.js +8 -0
- data/app/assets/stylesheets/fileupload/jquery.fileupload-ui.scss +1 -15
- data/app/assets/stylesheets/hyrax/_collections.scss +1 -1
- data/app/assets/stylesheets/hyrax/_home-page.scss +6 -0
- data/app/assets/stylesheets/hyrax/_users.scss +11 -0
- data/app/assets/stylesheets/hyrax/_viewer.scss +14 -3
- data/app/controllers/concerns/hyrax/breadcrumbs.rb +2 -0
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +1 -1
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +2 -1
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +2 -1
- data/app/controllers/concerns/hyrax/local_file_downloads_controller_behavior.rb +2 -1
- data/app/controllers/hyrax/batch_edits_controller.rb +3 -3
- data/app/controllers/hyrax/dashboard/collections_controller.rb +16 -5
- data/app/controllers/hyrax/dashboard_controller.rb +9 -0
- data/app/controllers/hyrax/depositors_controller.rb +4 -6
- data/app/controllers/hyrax/downloads_controller.rb +1 -1
- data/app/controllers/hyrax/file_sets_controller.rb +3 -2
- data/app/controllers/hyrax/homepage_controller.rb +1 -1
- data/app/controllers/hyrax/my/works_controller.rb +2 -2
- data/app/controllers/hyrax/my_controller.rb +2 -2
- data/app/controllers/hyrax/permissions_controller.rb +1 -1
- data/app/controllers/hyrax/single_use_links_viewer_controller.rb +1 -1
- data/app/controllers/hyrax/workflow_actions_controller.rb +1 -1
- data/app/forms/hyrax/forms/admin_set_form.rb +8 -0
- data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/collection_form.rb +34 -3
- data/app/forms/hyrax/forms/file_set_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/work_form.rb +34 -7
- data/app/forms/hyrax/forms/workflow_responsibility_form.rb +0 -4
- data/app/helpers/hyrax/hyrax_helper_behavior.rb +3 -4
- data/app/helpers/hyrax/iiif_helper.rb +8 -0
- data/app/indexers/hyrax/admin_set_indexer.rb +1 -1
- data/app/indexers/hyrax/basic_metadata_indexer.rb +1 -1
- data/app/indexers/hyrax/collection_indexer.rb +2 -2
- data/app/indexers/hyrax/file_set_indexer.rb +7 -0
- data/app/indexers/hyrax/indexes_workflow.rb +3 -5
- data/app/indexers/hyrax/valkyrie_indexers/base_indexer.rb +19 -0
- data/app/indexers/hyrax/work_indexer.rb +1 -1
- data/app/jobs/attach_files_to_work_job.rb +9 -1
- data/app/jobs/characterize_job.rb +20 -5
- data/app/jobs/import_url_job.rb +9 -16
- data/app/jobs/ingest_local_file_job.rb +4 -0
- data/app/jobs/visibility_copy_job.rb +3 -17
- data/app/models/admin_set.rb +5 -0
- data/app/models/concerns/hyrax/ability.rb +3 -3
- data/app/models/concerns/hyrax/basic_metadata.rb +6 -2
- data/app/models/concerns/hyrax/collection_behavior.rb +22 -12
- data/app/models/concerns/hyrax/collection_nesting.rb +1 -1
- data/app/models/concerns/hyrax/file_set/characterization.rb +8 -1
- data/app/models/concerns/hyrax/file_set/querying.rb +1 -1
- data/app/models/concerns/hyrax/file_set_behavior.rb +1 -1
- data/app/models/concerns/hyrax/human_readable_type.rb +2 -2
- data/app/models/concerns/hyrax/solr_document/characterization.rb +27 -23
- data/app/models/concerns/hyrax/solr_document/metadata.rb +37 -39
- data/app/models/concerns/hyrax/solr_document_behavior.rb +4 -8
- data/app/models/concerns/hyrax/virus_check.rb +20 -0
- data/app/models/concerns/hyrax/work_behavior.rb +3 -1
- data/app/models/file_download_stat.rb +2 -1
- data/app/models/hyrax/active_job_proxy.rb +43 -0
- data/app/models/hyrax/embargo.rb +21 -0
- data/app/models/hyrax/file_metadata.rb +109 -0
- data/app/models/hyrax/lease.rb +21 -0
- data/app/models/hyrax/permission_template.rb +8 -8
- data/app/models/hyrax/resource.rb +31 -0
- data/app/models/hyrax/statistic.rb +5 -1
- data/app/models/hyrax/uploaded_file.rb +0 -2
- data/app/models/hyrax/virus_scanner.rb +56 -0
- data/app/models/job_io_wrapper.rb +24 -9
- data/app/models/proxy_deposit_request.rb +1 -1
- data/app/models/solr_hit.rb +23 -0
- data/app/presenters/hyrax/admin_set_presenter.rb +1 -1
- data/app/presenters/hyrax/characterization_behavior.rb +2 -2
- data/app/presenters/hyrax/displays_image.rb +25 -7
- data/app/presenters/hyrax/file_set_presenter.rb +3 -3
- data/app/presenters/hyrax/member_presenter_factory.rb +9 -9
- data/app/presenters/hyrax/presenter_factory.rb +1 -4
- data/app/presenters/hyrax/trophy_presenter.rb +1 -1
- data/app/presenters/hyrax/work_show_presenter.rb +3 -3
- data/app/renderers/hyrax/renderers/faceted_attribute_renderer.rb +1 -1
- data/app/search_builders/hyrax/catalog_search_builder.rb +1 -1
- data/app/search_builders/hyrax/collection_search_builder.rb +1 -1
- data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/deposit_search_builder.rb +1 -1
- data/app/search_builders/hyrax/my/find_works_search_builder.rb +5 -9
- data/app/search_builders/hyrax/my/highlights_search_builder.rb +1 -3
- data/app/search_builders/hyrax/nested_collections_parent_search_builder.rb +1 -1
- data/app/search_builders/hyrax/parent_collection_search_builder.rb +1 -1
- data/app/services/hyrax/adapters/nesting_index_adapter.rb +6 -6
- data/app/services/hyrax/admin_set_service.rb +3 -11
- data/app/services/hyrax/analytics.rb +6 -6
- data/app/services/hyrax/collection_types/permissions_service.rb +5 -5
- data/app/services/hyrax/collections/permissions_service.rb +2 -2
- data/app/services/hyrax/custom_queries/navigators/child_collections_navigator.rb +39 -0
- data/app/services/hyrax/custom_queries/navigators/child_filesets_navigator.rb +39 -0
- data/app/services/hyrax/custom_queries/navigators/child_works_navigator.rb +39 -0
- data/app/services/hyrax/custom_queries/wings.rb +34 -0
- data/app/services/hyrax/database_migrator.rb +1 -0
- data/app/services/hyrax/derivative_path.rb +1 -1
- data/app/services/hyrax/embargo_manager.rb +100 -0
- data/app/services/hyrax/file_set_csv_service.rb +2 -0
- data/app/services/hyrax/file_set_visibility_propagator.rb +41 -0
- data/app/services/hyrax/graph_exporter.rb +1 -1
- data/app/services/hyrax/lease_manager.rb +71 -0
- data/app/services/hyrax/persist_directly_contained_output_file_service.rb +1 -1
- data/app/services/hyrax/query_service.rb +0 -0
- data/app/services/hyrax/resource_visibility_propagator.rb +50 -0
- data/app/services/hyrax/solr_query_builder_service.rb +71 -0
- data/app/services/hyrax/solr_service.rb +144 -0
- data/app/services/hyrax/statistics/file_sets/by_format.rb +1 -1
- data/app/services/hyrax/statistics/term_query.rb +7 -12
- data/app/services/hyrax/statistics/works/by_resource_type.rb +1 -1
- data/app/services/hyrax/thumbnail_path_service.rb +4 -3
- data/app/services/hyrax/versioning_service.rb +74 -19
- data/app/services/hyrax/virus_checker_service.rb +52 -0
- data/app/services/hyrax/visibility_intention_applicator.rb +43 -0
- data/app/services/hyrax/visibility_map.rb +65 -0
- data/app/services/hyrax/visibility_propagator.rb +19 -0
- data/app/services/hyrax/visibility_reader.rb +43 -0
- data/app/services/hyrax/visibility_writer.rb +43 -0
- data/app/services/hyrax/work_query_service.rb +3 -3
- data/app/services/hyrax/workflow/deposited_notification.rb +1 -1
- data/app/services/hyrax/works/migration_service.rb +33 -0
- data/app/views/hyrax/admin/admin_sets/_form.html.erb +6 -5
- data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +2 -1
- data/app/views/hyrax/admin/admin_sets/_form_workflow.erb +1 -1
- data/app/views/hyrax/base/_attribute_rows.html.erb +2 -0
- data/app/views/hyrax/base/_attributes.html.erb +3 -3
- data/app/views/hyrax/base/_citations.html.erb +4 -4
- data/app/views/hyrax/base/_file_manager_actions.html.erb +2 -2
- data/app/views/hyrax/base/_file_manager_member_resource_options.html.erb +2 -2
- data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
- data/app/views/hyrax/base/_form_files.html.erb +11 -9
- data/app/views/hyrax/base/_form_member_of_collections.html.erb +1 -1
- data/app/views/hyrax/base/_form_permission.html.erb +1 -2
- data/app/views/hyrax/base/_form_progress.html.erb +2 -2
- data/app/views/hyrax/base/_form_share.html.erb +8 -11
- data/app/views/hyrax/base/_show_actions.html.erb +3 -3
- data/app/views/hyrax/base/_social_media.html.erb +0 -13
- data/app/views/hyrax/base/_work_button_row.html.erb +7 -7
- data/app/views/hyrax/base/_workflow_actions.html.erb +4 -4
- data/app/views/hyrax/base/file_manager.html.erb +2 -2
- data/app/views/hyrax/base/iiif_viewers/_universal_viewer.html.erb +5 -2
- data/app/views/hyrax/base/inspect_work.html.erb +13 -13
- data/app/views/hyrax/base/unauthorized.html.erb +4 -4
- data/app/views/hyrax/batch_edits/_check_all.html.erb +1 -1
- data/app/views/hyrax/batch_edits/_delete_selected.html.erb +1 -1
- data/app/views/hyrax/batch_edits/edit.html.erb +11 -11
- data/app/views/hyrax/citations/work.html.erb +1 -1
- data/app/views/hyrax/collections/_show_document_list.html.erb +1 -1
- data/app/views/hyrax/collections/_sort_and_per_page.html.erb +4 -4
- data/app/views/hyrax/dashboard/collections/_form.html.erb +6 -5
- data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +10 -10
- data/app/views/hyrax/dashboard/collections/_form_share.html.erb +5 -5
- data/app/views/hyrax/dashboard/collections/_show_descriptions.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_show_document_list.html.erb +6 -6
- data/app/views/hyrax/dashboard/collections/_show_document_list_menu.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_show_document_list_row.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb +2 -3
- data/app/views/hyrax/dashboard/collections/_work_action_menu.html.erb +8 -8
- data/app/views/hyrax/dashboard/collections/edit.html.erb +2 -2
- data/app/views/hyrax/dashboard/profiles/_edit_primary.html.erb +8 -8
- data/app/views/hyrax/dashboard/sidebar/_activity.html.erb +2 -0
- data/app/views/hyrax/dashboard/sidebar/_configuration.html.erb +4 -1
- data/app/views/hyrax/dashboard/sidebar/_menu_partials.html.erb +3 -0
- data/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb +2 -0
- data/app/views/hyrax/dashboard/sidebar/_tasks.html.erb +2 -0
- data/app/views/hyrax/dashboard/works/_default_group.html.erb +4 -4
- data/app/views/hyrax/dashboard/works/_list_works.html.erb +1 -1
- data/app/views/hyrax/depositors/_modal_proxy_deny.html.erb +14 -0
- data/app/views/hyrax/depositors/index.html.erb +3 -0
- data/app/views/hyrax/embargoes/_list_expired_active_embargoes.html.erb +1 -1
- data/app/views/hyrax/file_sets/_actions.html.erb +1 -1
- data/app/views/hyrax/file_sets/_asset_deleted_flash.html.erb +1 -1
- data/app/views/hyrax/file_sets/_asset_saved_flash.html.erb +5 -6
- data/app/views/hyrax/file_sets/_asset_updated_flash.html.erb +2 -1
- data/app/views/hyrax/file_sets/_descriptions.html.erb +2 -2
- data/app/views/hyrax/file_sets/_extra_fields_modal.html.erb +3 -3
- data/app/views/hyrax/file_sets/_form.html.erb +1 -1
- data/app/views/hyrax/file_sets/_permission.html.erb +2 -1
- data/app/views/hyrax/file_sets/_permission_form.html.erb +9 -9
- data/app/views/hyrax/file_sets/_show_actions.html.erb +4 -4
- data/app/views/hyrax/file_sets/_show_details.html.erb +7 -7
- data/app/views/hyrax/file_sets/_versioning.html.erb +3 -3
- data/app/views/hyrax/file_sets/edit.html.erb +4 -3
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +2 -2
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +2 -2
- data/app/views/hyrax/file_sets/proxy.html.erb +2 -2
- data/app/views/hyrax/my/_sort_and_per_page.html.erb +1 -1
- data/app/views/hyrax/my/collections/_modal_delete_selected_collections.html.erb +4 -1
- data/app/views/hyrax/my/collections/index.html.erb +1 -1
- data/app/views/hyrax/my/index.html.erb +1 -1
- data/app/views/hyrax/my/works/_default_group.html.erb +4 -4
- data/app/views/hyrax/my/works/_list_works.html.erb +3 -3
- data/app/views/hyrax/my/works/index.html.erb +1 -1
- data/app/views/hyrax/notifications/index.html.erb +1 -1
- data/app/views/hyrax/operations/index.html.erb +4 -4
- data/app/views/hyrax/pages/_form.html.erb +61 -60
- data/app/views/hyrax/permissions/confirm_access.html.erb +1 -1
- data/app/views/hyrax/single_use_links_viewer/single_use_error.html.erb +3 -7
- data/app/views/hyrax/static/mendeley.html.erb +2 -4
- data/app/views/hyrax/static/zotero.html.erb +2 -4
- data/app/views/hyrax/transfers/_received.html.erb +10 -10
- data/app/views/hyrax/transfers/_sent.html.erb +6 -6
- data/app/views/hyrax/uploads/_js_templates.html.erb +7 -7
- data/app/views/hyrax/uploads/_js_templates_branding.html.erb +8 -8
- data/app/views/hyrax/users/_activity_log.html.erb +25 -22
- data/app/views/hyrax/users/_left_sidebar.html.erb +1 -1
- data/app/views/hyrax/users/_proxies.html.erb +1 -1
- data/app/views/hyrax/users/_search_form.html.erb +3 -3
- data/app/views/hyrax/users/_vitals.html.erb +1 -1
- data/app/views/hyrax/users/index.html.erb +6 -6
- data/app/views/records/edit_fields/_abstract.html.erb +5 -0
- data/app/views/records/edit_fields/_access_right.html.erb +5 -0
- data/app/views/records/edit_fields/_alt_title.html.erb +3 -0
- data/app/views/records/edit_fields/_title.html.erb +1 -0
- data/app/views/records/show_fields/_based_near.html.erb +1 -1
- data/app/views/records/show_fields/_creator.html.erb +1 -1
- data/app/views/records/show_fields/_keyword.html.erb +1 -1
- data/app/views/records/show_fields/_language.html.erb +1 -1
- data/app/views/records/show_fields/_publisher.html.erb +1 -1
- data/app/views/records/show_fields/_resource_type.html.erb +1 -1
- data/app/views/records/show_fields/_subject.html.erb +1 -1
- data/config/initializers/indexing_adapter_initializer.rb +16 -0
- data/config/initializers/samvera-nesting_indexer_initializer.rb +3 -3
- data/config/locales/hyrax.de.yml +303 -24
- data/config/locales/hyrax.en.yml +279 -0
- data/config/locales/hyrax.es.yml +284 -5
- data/config/locales/hyrax.fr.yml +280 -1
- data/config/locales/hyrax.it.yml +279 -0
- data/config/locales/hyrax.pt-BR.yml +279 -0
- data/config/locales/hyrax.zh.yml +279 -0
- data/hyrax.gemspec +10 -11
- data/lib/generators/hyrax/config_generator.rb +6 -0
- data/lib/generators/hyrax/install_generator.rb +5 -0
- data/lib/generators/hyrax/riiif_generator.rb +2 -2
- data/lib/generators/hyrax/templates/catalog_controller.rb +71 -71
- data/lib/generators/hyrax/templates/config/analytics.yml +5 -5
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +11 -1
- data/lib/generators/hyrax/templates/config/initializers/riiif.rb +3 -3
- data/lib/generators/hyrax/templates/config/solr_wrapper_valkyrie_test.yml +7 -0
- data/lib/generators/hyrax/templates/config/valkyrie_index.yml +12 -0
- data/lib/generators/hyrax/templates/package.json +17 -0
- data/lib/generators/hyrax/templates/uv-config.json +3 -0
- data/lib/generators/hyrax/templates/uv.html +87 -0
- data/lib/generators/hyrax/work/templates/feature_spec.rb.erb +0 -1
- data/lib/hyrax.rb +17 -1
- data/lib/hyrax/configuration.rb +34 -20
- data/lib/hyrax/engine.rb +12 -10
- data/lib/hyrax/errors.rb +4 -0
- data/lib/hyrax/transactions/container.rb +13 -0
- data/lib/hyrax/transactions/create_work.rb +11 -0
- data/lib/hyrax/transactions/steps/apply_collection_permission_template.rb +32 -0
- data/lib/hyrax/transactions/steps/apply_permission_template.rb +2 -1
- data/lib/hyrax/transactions/steps/apply_visibility.rb +39 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/tasks/migrate.rake +6 -0
- data/lib/tasks/universal_viewer.rake +15 -0
- data/lib/valkyrie/indexing/solr/indexing_adapter.rb +102 -0
- data/lib/valkyrie/indexing_adapter.rb +29 -0
- data/lib/wings.rb +13 -4
- data/lib/wings/active_fedora_converter.rb +129 -15
- data/lib/wings/converter_value_mapper.rb +111 -0
- data/lib/wings/hydra/pcdm/models/concerns/collection_valkyrie_behavior.rb +27 -0
- data/lib/wings/hydra/pcdm/models/concerns/object_valkyrie_behavior.rb +27 -0
- data/lib/wings/hydra/pcdm/models/concerns/pcdm_valkyrie_behavior.rb +172 -0
- data/lib/wings/hydra/works/models/concerns/collection_valkyrie_behavior.rb +30 -0
- data/lib/wings/hydra/works/models/concerns/file_set_valkyrie_behavior.rb +30 -0
- data/lib/wings/hydra/works/models/concerns/work_valkyrie_behavior.rb +59 -0
- data/lib/wings/hydra/works/services/add_file_metadata_to_file_set.rb +113 -0
- data/lib/wings/model_transformer.rb +172 -47
- data/lib/wings/models/concerns/collection_behavior.rb +38 -0
- data/lib/wings/models/multi_checksum.rb +18 -0
- data/lib/wings/services/file_metadata_builder.rb +81 -0
- data/lib/wings/services/id_converter_service.rb +14 -0
- data/lib/wings/{value_mapper.rb → transformer_value_mapper.rb} +24 -5
- data/lib/wings/valkyrie/persister.rb +47 -24
- data/lib/wings/valkyrie/query_service.rb +141 -6
- data/lib/wings/valkyrie/storage/active_fedora.rb +27 -0
- data/spec/abilities/proxies_and_transfer_abilities_spec.rb +50 -10
- data/spec/actors/hyrax/actors/active_fedora_to_valkyrie_spec.rb +70 -0
- data/spec/actors/hyrax/actors/attach_members_actor_spec.rb +55 -10
- data/spec/actors/hyrax/actors/create_with_remote_files_actor_spec.rb +14 -0
- data/spec/actors/hyrax/actors/create_with_remote_files_ordered_members_actor_spec.rb +22 -30
- data/spec/actors/hyrax/actors/file_actor_spec.rb +200 -84
- data/spec/actors/hyrax/actors/file_set_actor_spec.rb +1 -1
- data/spec/actors/hyrax/actors/generic_work_actor_spec.rb +2 -6
- data/spec/actors/hyrax/actors/interpret_visibility_actor_spec.rb +1 -1
- data/spec/actors/hyrax/actors/ordered_members_actor_spec.rb +1 -1
- data/spec/actors/hyrax/actors/valkyrie_to_active_fedora_spec.rb +70 -0
- data/spec/controllers/catalog_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/api/items_controller_spec.rb +9 -15
- data/spec/controllers/hyrax/collections_controller_spec.rb +6 -2
- data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +53 -4
- data/spec/controllers/hyrax/depositors_controller_spec.rb +3 -3
- data/spec/controllers/hyrax/downloads_controller_spec.rb +11 -2
- data/spec/controllers/hyrax/file_sets_controller_spec.rb +40 -2
- data/spec/controllers/hyrax/generic_works_controller_spec.rb +13 -3
- data/spec/controllers/hyrax/homepage_controller_spec.rb +3 -3
- data/spec/controllers/hyrax/single_use_links_viewer_controller_spec.rb +1 -2
- data/spec/factories/admin_sets_lw.rb +1 -1
- data/spec/factories/collections.rb +1 -1
- data/spec/factories/hyrax_embargo.rb +16 -0
- data/spec/factories/hyrax_lease.rb +16 -0
- data/spec/factories/hyrax_resource.rb +16 -0
- data/spec/factory_tests/adminsets_factory_spec.rb +4 -4
- data/spec/factory_tests/collections_factory_spec.rb +3 -3
- data/spec/features/actor_stack_spec.rb +64 -0
- data/spec/features/batch_create_spec.rb +1 -2
- data/spec/features/collection_multi_membership_spec.rb +1 -0
- data/spec/features/collection_spec.rb +2 -2
- data/spec/features/collection_type_spec.rb +1 -0
- data/spec/features/create_work_spec.rb +15 -6
- data/spec/features/dashboard/collection_spec.rb +103 -14
- data/spec/features/edit_content_block_admin_spec.rb +3 -3
- data/spec/features/edit_pages_admin.spec.rb +62 -0
- data/spec/features/proxy_spec.rb +21 -0
- data/spec/features/static_pages_spec.rb +1 -1
- data/spec/features/work_show_spec.rb +7 -3
- data/spec/fixtures/sample-file.pdf +0 -0
- data/spec/fixtures/updated-file.txt +1 -0
- data/spec/forms/hyrax/forms/batch_upload_form_spec.rb +5 -2
- data/spec/forms/hyrax/forms/collection_form_spec.rb +5 -2
- data/spec/forms/hyrax/forms/work_form_spec.rb +18 -5
- data/spec/forms/hyrax/generic_work_form_spec.rb +4 -4
- data/spec/helpers/hyrax/collections_helper_spec.rb +8 -8
- data/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb +7 -8
- data/spec/helpers/hyrax/iiif_helper_spec.rb +16 -0
- data/spec/helpers/hyrax_helper_spec.rb +4 -4
- data/spec/hyrax/transactions/create_work_spec.rb +68 -0
- data/spec/hyrax/transactions/steps/apply_collection_permission_template_spec.rb +59 -0
- data/spec/hyrax/transactions/steps/apply_visibility_spec.rb +82 -0
- data/spec/indexers/hyrax/admin_set_indexer_spec.rb +15 -0
- data/spec/indexers/hyrax/file_set_indexer_spec.rb +26 -1
- data/spec/indexers/hyrax/valkyrie_indexers/base_indexer_spec.rb +16 -0
- data/spec/jobs/import_url_job_spec.rb +49 -2
- data/spec/jobs/ingest_local_file_job_spec.rb +25 -1
- data/spec/jobs/visibility_copy_job_spec.rb +46 -0
- data/spec/lib/hyrax/configuration_spec.rb +17 -11
- data/spec/lib/hyrax/redis_event_store_spec.rb +1 -1
- data/spec/matcher_tests/match_valkyrie_ids_with_af_ids_spec.rb +40 -0
- data/spec/models/file_set_spec.rb +4 -3
- data/spec/models/hyrax/embargo_spec.rb +27 -0
- data/spec/models/hyrax/file_metadata_spec.rb +110 -0
- data/spec/models/hyrax/lease_spec.rb +25 -0
- data/spec/models/hyrax/permission_template_spec.rb +2 -2
- data/spec/models/hyrax/resource_spec.rb +60 -0
- data/spec/models/hyrax/virus_scanner_spec.rb +50 -0
- data/spec/models/job_io_wrapper_spec.rb +63 -0
- data/spec/models/solr_hit_spec.rb +9 -0
- data/spec/models/user_spec.rb +1 -1
- data/spec/presenters/hyrax/file_set_presenter_spec.rb +11 -7
- data/spec/presenters/hyrax/presenter_factory_spec.rb +2 -2
- data/spec/presenters/hyrax/work_show_presenter_spec.rb +1 -1
- data/spec/requests/riiif_spec.rb +2 -2
- data/spec/search_builders/hyrax/my/find_works_search_builder_spec.rb +3 -3
- data/spec/services/hyrax/adapters/nesting_index_adapter_spec.rb +5 -6
- data/spec/services/hyrax/admin_set_service_spec.rb +2 -2
- data/spec/services/hyrax/custom_queries/navigators/child_collections_navigator_spec.rb +41 -0
- data/spec/services/hyrax/custom_queries/navigators/child_filesets_navigator_spec.rb +41 -0
- data/spec/services/hyrax/custom_queries/navigators/child_works_navigator_spec.rb +79 -0
- data/spec/services/hyrax/custom_queries/wings.rb +52 -0
- data/spec/services/hyrax/embargo_manager_spec.rb +123 -0
- data/spec/services/hyrax/embargo_service_spec.rb +2 -2
- data/spec/services/hyrax/file_set_visibility_propagator_spec.rb +59 -0
- data/spec/services/hyrax/resource_visibility_propagator_spec.rb +71 -0
- data/spec/services/hyrax/solr_query_builder_service_spec.rb +17 -0
- data/spec/services/hyrax/solr_service_spec.rb +218 -0
- data/spec/services/hyrax/thumbnail_path_service_spec.rb +6 -0
- data/spec/services/hyrax/versioning_service_spec.rb +35 -15
- data/spec/services/hyrax/visibility_intention_applicator_spec.rb +69 -0
- data/spec/services/hyrax/visibility_reader_spec.rb +38 -0
- data/spec/services/hyrax/visibility_writer_spec.rb +47 -0
- data/spec/services/hyrax/workflow/status_list_service_spec.rb +1 -13
- data/spec/services/hyrax/works/migration_service_spec.rb +29 -0
- data/spec/spec_helper.rb +24 -23
- data/spec/support/clean_solr.rb +7 -0
- data/spec/support/create_for_repository.rb +25 -0
- data/spec/support/factory_helpers.rb +3 -1
- data/spec/support/fakes/fake_actor.rb +21 -0
- data/spec/support/matchers/embargo.rb +9 -0
- data/spec/support/matchers/lease.rb +9 -0
- data/spec/support/matchers/match_valkyrie_ids_with_af_ids.rb +11 -0
- data/spec/support/matchers/permission.rb +22 -0
- data/spec/support/valkyrie_indexing.rb +1 -0
- data/spec/test_app_templates/Gemfile.extra +0 -2
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +5 -6
- data/spec/valkyrie/indexing/solr/indexing_adapter_spec.rb +41 -0
- data/spec/valkyrie/indexing_adapter_spec.rb +25 -0
- data/spec/views/hyrax/base/_attributes.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/base/_social_media.html.erb_spec.rb +0 -1
- data/spec/views/hyrax/base/show.html.erb_spec.rb +2 -2
- data/spec/views/hyrax/collections/_sort_and_per_page.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/dashboard/_sidebar.html.erb_spec.rb +39 -0
- data/spec/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/file_sets/_versioning.html.erb_spec.rb +1 -0
- data/spec/views/hyrax/my/collections/_list_collections.html.erb_spec.rb +2 -2
- data/spec/views/records/edit_fields/_alt_title.html.erb_spec.rb +26 -0
- data/spec/views/records/edit_fields/_title.html.erb_spec.rb +24 -0
- data/spec/wings/active_fedora_converter_spec.rb +136 -1
- data/spec/wings/converter_value_mapper_spec.rb +23 -0
- data/spec/wings/hydra/pcdm/models/concerns/collection_valkyrie_behavior_spec.rb +41 -0
- data/spec/wings/hydra/pcdm/models/concerns/object_valkyrie_behavior_spec.rb +19 -0
- data/spec/wings/hydra/pcdm/models/concerns/pcdm_valkyrie_behavior_spec.rb +442 -0
- data/spec/wings/hydra/works/models/concerns/collection_valkyrie_behavior_spec.rb +22 -0
- data/spec/wings/hydra/works/models/concerns/file_set_valkyrie_behavior_spec.rb +90 -0
- data/spec/wings/hydra/works/models/concerns/work_valkyrie_behavior_spec.rb +218 -0
- data/spec/wings/model_transformer_spec.rb +167 -112
- data/spec/wings/models/concerns/collection_behavior_spec.rb +120 -0
- data/spec/wings/services/file_metadata_builder_spec.rb +39 -0
- data/spec/wings/services/id_converter_service_spec.rb +24 -0
- data/spec/wings/{value_mapper_spec.rb → transformer_value_mapper_spec.rb} +2 -2
- data/spec/wings/valkyrie/persister_spec.rb +544 -53
- data/spec/wings/valkyrie/query_service_spec.rb +381 -4
- data/spec/wings_helper.rb +4 -0
- data/template.rb +1 -1
- metadata +205 -49
- data/.travis.yml +0 -36
- data/lib/wings/resource_factory.rb +0 -8
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'wings_helper'
|
3
|
+
require 'wings/model_transformer'
|
4
|
+
|
5
|
+
RSpec.describe Wings::CollectionBehavior do
|
6
|
+
subject(:factory) { Wings::ModelTransformer.new(pcdm_object: pcdm_object) }
|
7
|
+
|
8
|
+
let(:resource) { subject.build }
|
9
|
+
|
10
|
+
let(:collection1) { build(:public_collection_lw, id: 'col1', title: ['Collection 1']) }
|
11
|
+
let(:collection2) { create(:public_collection_lw, id: 'col2', title: ['Collection 2']) }
|
12
|
+
let(:collection3) { create(:public_collection_lw, id: 'col3', title: ['Collection 3']) }
|
13
|
+
let(:work1) { create(:work, id: 'wk1', title: ['Work 1']) }
|
14
|
+
let(:work2) { create(:work, id: 'wk2', title: ['Work 2']) }
|
15
|
+
let(:work3) { build(:work, id: 'wk3', title: ['Work 3']) }
|
16
|
+
let(:fileset1) { build(:file_set, id: 'fs1', title: ['Fileset 1']) }
|
17
|
+
let(:fileset2) { build(:file_set, id: 'fs2', title: ['Fileset 2']) }
|
18
|
+
|
19
|
+
describe '#add_collections_and_works' do
|
20
|
+
let(:pcdm_object) { collection1 }
|
21
|
+
let(:parent_collection_resource) { resource }
|
22
|
+
|
23
|
+
context 'when new_member_ids are valkyrie ids' do
|
24
|
+
let(:collection_resource2) { Wings::ModelTransformer.new(pcdm_object: collection2).build }
|
25
|
+
let(:collection_resource3) { Wings::ModelTransformer.new(pcdm_object: collection3).build }
|
26
|
+
let(:work_resource1) { Wings::ModelTransformer.new(pcdm_object: work1).build }
|
27
|
+
let(:work_resource2) { Wings::ModelTransformer.new(pcdm_object: work2).build }
|
28
|
+
|
29
|
+
it 'adds the collections and works to the parent collection' do
|
30
|
+
valkyrie_ids = [collection_resource2.id, collection_resource3.id, work_resource1.id, work_resource2.id]
|
31
|
+
parent_collection_resource.add_collections_and_works(valkyrie_ids, valkyrie: true)
|
32
|
+
|
33
|
+
resources = parent_collection_resource.child_collections_and_works(valkyrie: true)
|
34
|
+
expect(resources.map(&:id)).to match_valkyrie_ids_with_active_fedora_ids([collection2.id, collection3.id, work1.id, work2.id])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when new_member_ids are active fedora ids' do
|
39
|
+
it 'adds the collections and works to the parent collection' do
|
40
|
+
af_ids = [collection2.id, collection3.id, work1.id, work2.id]
|
41
|
+
parent_collection_resource.add_collections_and_works(af_ids, valkyrie: false)
|
42
|
+
|
43
|
+
resources = parent_collection_resource.child_collections_and_works(valkyrie: true)
|
44
|
+
expect(resources.map(&:id)).to match_valkyrie_ids_with_active_fedora_ids([collection2.id, collection3.id, work1.id, work2.id])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#child_collections_and_works' do
|
50
|
+
let(:pcdm_object) { collection1 }
|
51
|
+
let(:parent_collection_resource) { resource }
|
52
|
+
|
53
|
+
before do
|
54
|
+
collection2.member_of_collections = [collection1]
|
55
|
+
collection3.member_of_collections = [collection1]
|
56
|
+
work1.member_of_collections = [collection1]
|
57
|
+
work2.member_of_collections = [collection1]
|
58
|
+
collection2.save!
|
59
|
+
collection3.save!
|
60
|
+
work1.save!
|
61
|
+
work2.save!
|
62
|
+
collection1.save!
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when valkyrie resources requested' do
|
66
|
+
it 'returns parent collections as valkyrie resources through pcdm_valkyrie_behavior' do
|
67
|
+
resources = parent_collection_resource.child_collections_and_works(valkyrie: true)
|
68
|
+
expect(resources.map(&:id)).to match_valkyrie_ids_with_active_fedora_ids([collection2.id, collection3.id, work1.id, work2.id])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
context 'when active fedora objects requested' do
|
72
|
+
it 'returns parent collections as fedora objects through pcdm_valkyrie_behavior' do
|
73
|
+
af_objects = parent_collection_resource.child_collections_and_works(valkyrie: false)
|
74
|
+
expect(af_objects.map(&:id)).to match_array [collection2.id, collection3.id, work1.id, work2.id]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
context 'when return type is not specified' do
|
78
|
+
it 'returns parent collections as fedora objects through pcdm_valkyrie_behavior' do
|
79
|
+
af_objects = parent_collection_resource.child_collections_and_works
|
80
|
+
expect(af_objects.map(&:id)).to match_array [collection2.id, collection3.id, work1.id, work2.id]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#child_collections_and_works_ids' do
|
86
|
+
let(:pcdm_object) { collection1 }
|
87
|
+
let(:parent_collection_resource) { resource }
|
88
|
+
|
89
|
+
before do
|
90
|
+
collection2.member_of_collections = [collection1]
|
91
|
+
collection3.member_of_collections = [collection1]
|
92
|
+
work1.member_of_collections = [collection1]
|
93
|
+
work2.member_of_collections = [collection1]
|
94
|
+
collection2.save!
|
95
|
+
collection3.save!
|
96
|
+
work1.save!
|
97
|
+
work2.save!
|
98
|
+
collection1.save!
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when valkyrie resources requested' do
|
102
|
+
it 'returns ids of works only as valkyrie resources through pcdm_valkyrie_behavior' do
|
103
|
+
resource_ids = parent_collection_resource.child_collections_and_works_ids(valkyrie: true)
|
104
|
+
expect(resource_ids).to match_valkyrie_ids_with_active_fedora_ids([work1.id, work2.id, collection2.id, collection3.id])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
context 'when active fedora objects requested' do
|
108
|
+
it 'returns ids of works only as fedora objects through pcdm_valkyrie_behavior' do
|
109
|
+
af_object_ids = parent_collection_resource.child_collections_and_works_ids(valkyrie: false)
|
110
|
+
expect(af_object_ids.to_a).to match_array [work1.id, work2.id, collection2.id, collection3.id]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
context 'when return type is not specified' do
|
114
|
+
it 'returns ids of works only as fedora objects through pcdm_valkyrie_behavior' do
|
115
|
+
af_object_ids = parent_collection_resource.child_collections_and_works_ids
|
116
|
+
expect(af_object_ids.to_a).to match_array [work1.id, work2.id, collection2.id, collection3.id]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'wings_helper'
|
3
|
+
require 'wings/services/file_metadata_builder'
|
4
|
+
|
5
|
+
RSpec.describe Wings::FileMetadataBuilder do
|
6
|
+
subject do
|
7
|
+
described_class.new(storage_adapter: Hyrax.storage_adapter,
|
8
|
+
persister: Hyrax.persister)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:af_file_set) { create(:file_set, id: 'fileset_id') }
|
12
|
+
let!(:file_set) { af_file_set.valkyrie_resource }
|
13
|
+
|
14
|
+
let(:io_wrapper) { instance_double(JobIoWrapper, file: file, original_name: original_name, mime_type: mime_type, size: file.size) }
|
15
|
+
let(:file) { File.open(File.join(fixture_path, original_name)) }
|
16
|
+
let(:original_name) { 'sample-file.pdf' }
|
17
|
+
let(:mime_type) { 'application/pdf' }
|
18
|
+
let(:use) { Valkyrie::Vocab::PCDMUse.OriginalFile }
|
19
|
+
|
20
|
+
let(:original_file_metadata) do
|
21
|
+
Hyrax::FileMetadata.new(label: original_name,
|
22
|
+
original_filename: original_name,
|
23
|
+
mime_type: mime_type,
|
24
|
+
use: [use])
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#create(io_wrapper:, file_metadata:, file_set:)' do
|
28
|
+
it 'creates file metadata' do
|
29
|
+
built_file_metadata = subject.create(io_wrapper: io_wrapper, file_metadata: original_file_metadata, file_set: file_set)
|
30
|
+
expect(built_file_metadata).to be_kind_of Hyrax::FileMetadata
|
31
|
+
expect(built_file_metadata.original_file?).to be true
|
32
|
+
expect(built_file_metadata.file_set_id.id).to eq file_set.id.id
|
33
|
+
expect(built_file_metadata.label).to contain_exactly(original_name)
|
34
|
+
expect(built_file_metadata.original_filename).to contain_exactly(original_name)
|
35
|
+
expect(built_file_metadata.mime_type).to contain_exactly(mime_type)
|
36
|
+
expect(built_file_metadata.use).to contain_exactly(use)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'wings_helper'
|
3
|
+
require 'wings/model_transformer'
|
4
|
+
|
5
|
+
RSpec.describe Wings::IdConverterService do
|
6
|
+
let(:collection1) { create(:public_collection_lw, id: 'col1', title: ['Collection 1']) }
|
7
|
+
let(:work1) { create(:work, id: 'wk1', title: ['Work 1']) }
|
8
|
+
let(:collection_resource1) { Wings::ModelTransformer.new(pcdm_object: collection1).build }
|
9
|
+
let(:work_resource1) { Wings::ModelTransformer.new(pcdm_object: work1).build }
|
10
|
+
let(:active_fedora_ids) { [collection1.id, work1.id] }
|
11
|
+
let(:resource_ids) { [collection_resource1.id, work_resource1.id] }
|
12
|
+
|
13
|
+
describe '#convert_to_active_fedora_ids' do
|
14
|
+
it 'returns active fedora ids' do
|
15
|
+
expect(described_class.convert_to_active_fedora_ids(resource_ids)).to match_array active_fedora_ids
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#convert_to_valkyrie_resource_ids' do
|
20
|
+
it 'returns valkyrie resource ids' do
|
21
|
+
expect(described_class.convert_to_valkyrie_resource_ids(active_fedora_ids)).to match_array resource_ids
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'spec_helper'
|
3
|
-
require 'wings/
|
3
|
+
require 'wings/transformer_value_mapper'
|
4
4
|
|
5
|
-
RSpec.describe Wings::
|
5
|
+
RSpec.describe Wings::TransformerValueMapper do
|
6
6
|
subject(:mapper) { described_class.for(value) }
|
7
7
|
let(:value) { 'a value' }
|
8
8
|
let(:uri) { RDF::URI('http://example.com/moomin') }
|
@@ -1,71 +1,562 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require '
|
2
|
+
require 'wings_helper'
|
3
3
|
require 'valkyrie/specs/shared_specs'
|
4
4
|
require 'wings'
|
5
5
|
|
6
6
|
RSpec.describe Wings::Valkyrie::Persister do
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
context "When passing a Valkyrie::Resource converted from an ActiveFedora::Base" do
|
8
|
+
before do
|
9
|
+
class Book < ActiveFedora::Base
|
10
|
+
include Hydra::AccessControls::Permissions
|
11
|
+
include Hyrax::CoreMetadata
|
12
|
+
include Hydra::WithDepositor
|
13
|
+
property :title, predicate: ::RDF::Vocab::DC.title, multiple: true
|
14
|
+
end
|
10
15
|
end
|
11
|
-
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
after do
|
18
|
+
Object.send(:remove_const, :Book)
|
19
|
+
end
|
16
20
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
subject(:persister) { described_class.new(adapter: adapter) }
|
22
|
+
let(:adapter) { Wings::Valkyrie::MetadataAdapter.new }
|
23
|
+
let(:query_service) { adapter.query_service }
|
24
|
+
let(:af_resource_class) { Book }
|
25
|
+
let(:resource_class) { Wings::ModelTransformer.to_valkyrie_resource_class(klass: af_resource_class) }
|
26
|
+
let(:resource) { resource_class.new(title: ['Foo']) }
|
23
27
|
|
24
|
-
|
28
|
+
# it_behaves_like "a Valkyrie::Persister", :no_deep_nesting, :no_mixed_nesting
|
25
29
|
|
26
|
-
|
27
|
-
|
28
|
-
|
30
|
+
describe 'persists permissions' do
|
31
|
+
let(:depositor) { create(:user) }
|
32
|
+
let(:v_work) { resource_class.new(title: ['test_work'], depositor: depositor.user_key, read_groups: ['registered']) }
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
it 'has permissions once saved' do
|
35
|
+
saved = persister.save(resource: v_work)
|
36
|
+
expect(saved.read_groups).to eq(['registered'])
|
37
|
+
expect(saved.depositor).to eq(depositor.user_key)
|
38
|
+
expect(saved.edit_users).to include(depositor.user_key)
|
39
|
+
end
|
40
|
+
end
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
expect(book.created_at).not_to be_blank
|
42
|
-
expect(book.updated_at).not_to be_blank
|
43
|
-
expect(book.created_at).not_to be_kind_of Array
|
44
|
-
expect(book.updated_at).not_to be_kind_of Array
|
45
|
-
expect(book.updated_at > book.created_at).to eq true
|
46
|
-
end
|
42
|
+
it { is_expected.to respond_to(:save).with_keywords(:resource) }
|
43
|
+
it { is_expected.to respond_to(:save_all).with_keywords(:resources) }
|
44
|
+
it { is_expected.to respond_to(:delete).with_keywords(:resource) }
|
45
|
+
it { is_expected.to respond_to(:wipe!) }
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
47
|
+
it "can save a resource" do
|
48
|
+
expect(resource).not_to be_persisted
|
49
|
+
saved = persister.save(resource: resource)
|
50
|
+
expect(saved).to be_persisted
|
51
|
+
expect(saved.id).not_to be_blank
|
52
|
+
end
|
53
|
+
|
54
|
+
it "stores created_at/updated_at" do
|
55
|
+
book = persister.save(resource: resource)
|
56
|
+
book.title = ["test"]
|
57
|
+
book = persister.save(resource: book)
|
58
|
+
expect(book.created_at).not_to be_blank
|
59
|
+
expect(book.updated_at).not_to be_blank
|
60
|
+
expect(book.created_at).not_to be_kind_of Array
|
61
|
+
expect(book.updated_at).not_to be_kind_of Array
|
62
|
+
expect(book.updated_at > book.created_at).to eq true
|
63
|
+
end
|
64
|
+
|
65
|
+
it "can override default id generation with a provided id" do
|
66
|
+
id = SecureRandom.uuid
|
67
|
+
valkyrie_id = Valkyrie::ID.new(id)
|
68
|
+
book = persister.save(resource: resource_class.new(id: id, title: ['Foo']))
|
69
|
+
reloaded = query_service.find_by(id: book.id)
|
70
|
+
expect(reloaded.id).to eq valkyrie_id
|
71
|
+
expect(reloaded.alternate_ids.first).to eq valkyrie_id
|
72
|
+
expect(reloaded).to be_persisted
|
73
|
+
expect(reloaded.created_at).not_to be_blank
|
74
|
+
expect(reloaded.updated_at).not_to be_blank
|
75
|
+
expect(reloaded.created_at).not_to be_kind_of Array
|
76
|
+
expect(reloaded.updated_at).not_to be_kind_of Array
|
77
|
+
end
|
78
|
+
|
79
|
+
it "doesn't override a resource that already has an ID" do
|
80
|
+
book = persister.save(resource: resource_class.new(title: ['Foo']))
|
81
|
+
id = book.id
|
82
|
+
output = persister.save(resource: book)
|
83
|
+
expect(output.id).to eq id
|
84
|
+
end
|
85
|
+
|
86
|
+
it "can find that resource again" do
|
87
|
+
id = persister.save(resource: resource).id
|
88
|
+
expect(query_service.find_by(id: id).internal_resource).to eq resource.internal_resource
|
89
|
+
end
|
90
|
+
|
91
|
+
it "can save multiple resources at once" do
|
92
|
+
resource2 = resource_class.new
|
93
|
+
results = persister.save_all(resources: [resource, resource2])
|
94
|
+
|
95
|
+
expect(results.map(&:id).uniq.length).to eq 2
|
96
|
+
expect(persister.save_all(resources: [])).to eq []
|
97
|
+
end
|
59
98
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
99
|
+
it "can delete objects" do
|
100
|
+
persisted = persister.save(resource: resource)
|
101
|
+
persister.delete(resource: persisted)
|
102
|
+
expect { query_service.find_by(id: persisted.id) }.to raise_error Hyrax::ObjectNotFoundError
|
103
|
+
end
|
104
|
+
|
105
|
+
it "can delete all objects" do
|
106
|
+
resource2 = resource_class.new
|
107
|
+
persister.save_all(resources: [resource, resource2])
|
108
|
+
persister.wipe!
|
109
|
+
expect(query_service.find_all.to_a.length).to eq 0
|
110
|
+
end
|
65
111
|
end
|
66
112
|
|
67
|
-
|
68
|
-
|
69
|
-
|
113
|
+
context "When passing a Valkyrie::Resource that was never an ActiveFedora::Base" do
|
114
|
+
subject(:persister) { described_class.new(adapter: adapter) }
|
115
|
+
let(:adapter) { Wings::Valkyrie::MetadataAdapter.new }
|
116
|
+
let(:query_service) { adapter.query_service }
|
117
|
+
before do
|
118
|
+
class CustomResource < Valkyrie::Resource
|
119
|
+
include Valkyrie::Resource::AccessControls
|
120
|
+
attribute :title
|
121
|
+
attribute :author
|
122
|
+
attribute :member_ids
|
123
|
+
attribute :nested_resource
|
124
|
+
attribute :depositor, Valkyrie::Types::String.optional
|
125
|
+
attribute :ordered_authors, Valkyrie::Types::Array.of(Valkyrie::Types::Anything).meta(ordered: true)
|
126
|
+
attribute :ordered_nested, Valkyrie::Types::Array.of(CustomResource).meta(ordered: true)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
after do
|
130
|
+
Object.send(:remove_const, :CustomResource)
|
131
|
+
end
|
132
|
+
|
133
|
+
subject { persister }
|
134
|
+
let(:resource_class) { CustomResource }
|
135
|
+
let(:resource) { resource_class.new }
|
136
|
+
|
137
|
+
it { is_expected.to respond_to(:save).with_keywords(:resource) }
|
138
|
+
it { is_expected.to respond_to(:save_all).with_keywords(:resources) }
|
139
|
+
it { is_expected.to respond_to(:delete).with_keywords(:resource) }
|
140
|
+
|
141
|
+
it "can save a resource" do
|
142
|
+
expect(resource).not_to be_persisted
|
143
|
+
saved = persister.save(resource: resource)
|
144
|
+
expect(saved).to be_persisted
|
145
|
+
expect(saved.id).not_to be_blank
|
146
|
+
expect(saved.alternate_ids.first).to eq saved.id
|
147
|
+
end
|
148
|
+
|
149
|
+
it "can save multiple resources at once" do
|
150
|
+
resource2 = resource_class.new
|
151
|
+
results = persister.save_all(resources: [resource, resource2])
|
152
|
+
|
153
|
+
expect(results.map(&:id).uniq.length).to eq 2
|
154
|
+
expect(persister.save_all(resources: [])).to eq []
|
155
|
+
end
|
156
|
+
|
157
|
+
it "can save nested resources" do
|
158
|
+
book2 = resource_class.new(title: "Nested")
|
159
|
+
book3 = persister.save(resource: resource_class.new(nested_resource: book2))
|
160
|
+
|
161
|
+
reloaded = query_service.find_by(id: book3.id)
|
162
|
+
expect(reloaded.nested_resource.first.title).to eq ["Nested"]
|
163
|
+
end
|
164
|
+
|
165
|
+
it "can persist single values" do
|
166
|
+
resource.depositor = "user@institution.edu"
|
167
|
+
|
168
|
+
output = persister.save(resource: resource)
|
169
|
+
|
170
|
+
expect(output.depositor).to eq "user@institution.edu"
|
171
|
+
end
|
172
|
+
|
173
|
+
it "returns nil for an unset single value" do
|
174
|
+
output = persister.save(resource: resource_class.new)
|
175
|
+
|
176
|
+
expect(output.depositor).to be_nil
|
177
|
+
end
|
178
|
+
|
179
|
+
it "stores created_at/updated_at" do
|
180
|
+
book = persister.save(resource: resource_class.new)
|
181
|
+
book.title = "test"
|
182
|
+
book = persister.save(resource: book)
|
183
|
+
expect(book.created_at).not_to be_blank
|
184
|
+
expect(book.updated_at).not_to be_blank
|
185
|
+
expect(book.created_at).not_to be_kind_of Array
|
186
|
+
expect(book.updated_at).not_to be_kind_of Array
|
187
|
+
expect(book.updated_at > book.created_at).to eq true
|
188
|
+
end
|
189
|
+
|
190
|
+
it "can handle Boolean RDF properties" do
|
191
|
+
boolean_rdf = RDF::Literal.new(false)
|
192
|
+
book = persister.save(resource: resource_class.new(title: [boolean_rdf]))
|
193
|
+
reloaded = query_service.find_by(id: book.id)
|
194
|
+
expect(reloaded.title).to contain_exactly boolean_rdf
|
195
|
+
end
|
196
|
+
|
197
|
+
it "can handle custom-typed RDF properties" do
|
198
|
+
custom_rdf = RDF::Literal.new("Test", datatype: RDF::URI.parse("http://my_made_up_type"))
|
199
|
+
book = persister.save(resource: resource_class.new(title: [custom_rdf]))
|
200
|
+
reloaded = query_service.find_by(id: book.id)
|
201
|
+
expect(reloaded.title).to contain_exactly custom_rdf
|
202
|
+
end
|
203
|
+
|
204
|
+
xit "can handle Date RDF properties" do
|
205
|
+
date_rdf = RDF::Literal.new(Date.current)
|
206
|
+
book = persister.save(resource: resource_class.new(title: [date_rdf]))
|
207
|
+
reloaded = query_service.find_by(id: book.id)
|
208
|
+
expect(reloaded.title).to contain_exactly date_rdf
|
209
|
+
end
|
210
|
+
|
211
|
+
xit "can handle DateTime RDF properties" do
|
212
|
+
datetime_rdf = RDF::Literal.new(DateTime.current)
|
213
|
+
book = persister.save(resource: resource_class.new(title: [datetime_rdf]))
|
214
|
+
reloaded = query_service.find_by(id: book.id)
|
215
|
+
expect(reloaded.title).to contain_exactly datetime_rdf
|
216
|
+
end
|
217
|
+
|
218
|
+
xit "can handle Decimal RDF properties" do
|
219
|
+
decimal_rdf = RDF::Literal.new(BigDecimal(5.5, 10))
|
220
|
+
book = persister.save(resource: resource_class.new(title: [decimal_rdf]))
|
221
|
+
reloaded = query_service.find_by(id: book.id)
|
222
|
+
expect(reloaded.title).to contain_exactly decimal_rdf
|
223
|
+
end
|
224
|
+
|
225
|
+
xit "can handle Double RDF properties" do
|
226
|
+
double_rdf = RDF::Literal.new(5.5)
|
227
|
+
book = persister.save(resource: resource_class.new(title: [double_rdf]))
|
228
|
+
reloaded = query_service.find_by(id: book.id)
|
229
|
+
expect(reloaded.title).to contain_exactly double_rdf
|
230
|
+
end
|
231
|
+
|
232
|
+
xit "can handle Integer RDF properties" do
|
233
|
+
int_rdf = RDF::Literal.new(17)
|
234
|
+
book = persister.save(resource: resource_class.new(title: [int_rdf]))
|
235
|
+
reloaded = query_service.find_by(id: book.id)
|
236
|
+
expect(reloaded.title).to contain_exactly int_rdf
|
237
|
+
end
|
238
|
+
|
239
|
+
it "can handle language-typed RDF properties" do
|
240
|
+
language_rdf = RDF::Literal.new("Test", language: :fr)
|
241
|
+
book = persister.save(resource: resource_class.new(title: ["Test1", language_rdf]))
|
242
|
+
reloaded = query_service.find_by(id: book.id)
|
243
|
+
expect(reloaded.title).to contain_exactly "Test1", language_rdf
|
244
|
+
end
|
245
|
+
|
246
|
+
xit "can handle Time RDF properties" do
|
247
|
+
time_rdf = RDF::Literal.new(Time.current)
|
248
|
+
book = persister.save(resource: resource_class.new(title: [time_rdf]))
|
249
|
+
reloaded = query_service.find_by(id: book.id)
|
250
|
+
expect(reloaded.title).to contain_exactly time_rdf
|
251
|
+
end
|
252
|
+
|
253
|
+
# https://github.com/samvera-labs/valkyrie/wiki/Supported-Data-Types
|
254
|
+
it "can store booleans" do
|
255
|
+
boolean = [false, true]
|
256
|
+
book = persister.save(resource: resource_class.new(title: boolean))
|
257
|
+
reloaded = query_service.find_by(id: book.id)
|
258
|
+
expect(reloaded.title).to contain_exactly(*boolean)
|
259
|
+
end
|
260
|
+
|
261
|
+
xit "can store DateTimes" do
|
262
|
+
time1 = DateTime.current
|
263
|
+
time2 = Time.current.in_time_zone
|
264
|
+
book = persister.save(resource: resource_class.new(title: [time1], author: [time2]))
|
265
|
+
|
266
|
+
reloaded = query_service.find_by(id: book.id)
|
267
|
+
|
268
|
+
expect(reloaded.title.first.to_i).to eq(time1.to_i)
|
269
|
+
expect(reloaded.title.first.zone).to eq('UTC')
|
270
|
+
expect(reloaded.author.first.to_i).to eq(time2.to_i)
|
271
|
+
expect(reloaded.author.first.zone).to eq('UTC')
|
272
|
+
end
|
273
|
+
|
274
|
+
xit "can store Floats" do
|
275
|
+
decimal = 5.5
|
276
|
+
book = persister.save(resource: resource_class.new(title: [decimal]))
|
277
|
+
reloaded = query_service.find_by(id: book.id)
|
278
|
+
expect(reloaded.title).to contain_exactly decimal
|
279
|
+
end
|
280
|
+
|
281
|
+
it "can store integers" do
|
282
|
+
book = persister.save(resource: resource_class.new(title: [1]))
|
283
|
+
reloaded = query_service.find_by(id: book.id)
|
284
|
+
expect(reloaded.title).to contain_exactly 1
|
285
|
+
end
|
286
|
+
|
287
|
+
it "can store ::RDF::URIs" do
|
288
|
+
book = persister.save(resource: resource_class.new(title: [::RDF::URI("http://example.com")]))
|
289
|
+
reloaded = query_service.find_by(id: book.id)
|
290
|
+
expect(reloaded.title).to contain_exactly RDF::URI("http://example.com")
|
291
|
+
end
|
292
|
+
|
293
|
+
xit "can store Valkyrie::IDs" do
|
294
|
+
shared_title = persister.save(resource: resource_class.new)
|
295
|
+
book = persister.save(resource: resource_class.new(title: [shared_title.id, Valkyrie::ID.new("adapter://1"), "test"]))
|
296
|
+
reloaded = query_service.find_by(id: book.id)
|
297
|
+
expect(reloaded.title).to contain_exactly(shared_title.id, Valkyrie::ID.new("adapter://1"), "test")
|
298
|
+
expect([shared_title.id, Valkyrie::ID.new("adapter://1"), "test"]).to contain_exactly(*reloaded.title)
|
299
|
+
end
|
300
|
+
|
301
|
+
it "can override default id generation with a provided id" do
|
302
|
+
id = SecureRandom.uuid
|
303
|
+
book = persister.save(resource: resource_class.new(id: id))
|
304
|
+
reloaded = query_service.find_by(id: book.id)
|
305
|
+
expect(reloaded.id).to eq Valkyrie::ID.new(id)
|
306
|
+
expect(reloaded).to be_persisted
|
307
|
+
expect(reloaded.created_at).not_to be_blank
|
308
|
+
expect(reloaded.updated_at).not_to be_blank
|
309
|
+
expect(reloaded.created_at).not_to be_kind_of Array
|
310
|
+
expect(reloaded.updated_at).not_to be_kind_of Array
|
311
|
+
end
|
312
|
+
|
313
|
+
context "parent tests" do
|
314
|
+
let(:book) { persister.save(resource: resource_class.new(title: ['Book'])) }
|
315
|
+
let(:book2) { persister.save(resource: resource_class.new(title: ['Book 2'])) }
|
316
|
+
|
317
|
+
it "can order members" do
|
318
|
+
book3 = persister.save(resource: resource_class.new(title: ['Book 3']))
|
319
|
+
parent = persister.save(resource: resource_class.new(title: ['Parent'], member_ids: [book2.id, book.id]))
|
320
|
+
parent.member_ids = parent.member_ids + [book3.id]
|
321
|
+
parent = persister.save(resource: parent)
|
322
|
+
reloaded = query_service.find_by(id: parent.id)
|
323
|
+
expect(reloaded.member_ids).to eq [book2.id, book.id, book3.id]
|
324
|
+
end
|
325
|
+
|
326
|
+
it "can remove members" do
|
327
|
+
parent = persister.save(resource: resource_class.new(title: ['Parent'], member_ids: [book2.id, book.id]))
|
328
|
+
parent.member_ids = parent.member_ids - [book2.id]
|
329
|
+
parent = persister.save(resource: parent)
|
330
|
+
expect(parent.member_ids).to eq [book.id]
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
it "doesn't override a resource that already has an ID" do
|
335
|
+
book = persister.save(resource: resource_class.new)
|
336
|
+
id = book.id
|
337
|
+
output = persister.save(resource: book)
|
338
|
+
expect(output.id).to eq id
|
339
|
+
end
|
340
|
+
|
341
|
+
# not sure how to fix this one. When a resource wasn't ever in AF, it is persisted as
|
342
|
+
# internal_resource="Wings::ActiveFedoraConverter::DefaultWork"
|
343
|
+
# so the CustomResource defined above will not be persisted as such.
|
344
|
+
xit "can find that resource again" do
|
345
|
+
id = persister.save(resource: resource).id
|
346
|
+
item = query_service.find_by(id: id)
|
347
|
+
expect(item).to be_kind_of resource_class
|
348
|
+
end
|
349
|
+
|
350
|
+
it "can delete objects" do
|
351
|
+
persisted = persister.save(resource: resource)
|
352
|
+
persister.delete(resource: persisted)
|
353
|
+
expect { query_service.find_by(id: persisted.id) }.to raise_error Hyrax::ObjectNotFoundError
|
354
|
+
end
|
355
|
+
|
356
|
+
it "can delete all objects" do
|
357
|
+
resource2 = resource_class.new
|
358
|
+
persister.save_all(resources: [resource, resource2])
|
359
|
+
persister.wipe!
|
360
|
+
expect(query_service.find_all.to_a.length).to eq 0
|
361
|
+
end
|
362
|
+
|
363
|
+
context "optimistic locking" do
|
364
|
+
before do
|
365
|
+
class MyLockingResource < Valkyrie::Resource
|
366
|
+
enable_optimistic_locking
|
367
|
+
attribute :title
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
after do
|
372
|
+
ActiveSupport::Dependencies.remove_constant("MyLockingResource")
|
373
|
+
end
|
374
|
+
|
375
|
+
describe "#save" do
|
376
|
+
context "when creating a resource" do
|
377
|
+
xit "returns the value of the system-generated optimistic locking attribute on the resource" do
|
378
|
+
resource = MyLockingResource.new(title: ["My Locked Resource"])
|
379
|
+
saved_resource = persister.save(resource: resource)
|
380
|
+
expect(saved_resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK]).not_to be_empty
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
context "when updating a resource with a correct lock token" do
|
385
|
+
xit "successfully saves the resource and returns the updated value of the optimistic locking attribute" do
|
386
|
+
resource = MyLockingResource.new(title: ["My Locked Resource"])
|
387
|
+
initial_resource = persister.save(resource: resource)
|
388
|
+
updated_resource = persister.save(resource: initial_resource)
|
389
|
+
expect(initial_resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK])
|
390
|
+
.not_to eq updated_resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK]
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
context "when updating a resource with an incorrect lock token" do
|
395
|
+
xit "raises a Valkyrie::Persistence::StaleObjectError" do
|
396
|
+
resource = MyLockingResource.new(title: ["My Locked Resource"])
|
397
|
+
resource = persister.save(resource: resource)
|
398
|
+
# update the resource in the datastore to make its token stale
|
399
|
+
persister.save(resource: resource)
|
400
|
+
|
401
|
+
expect { persister.save(resource: resource) }.to raise_error(Valkyrie::Persistence::StaleObjectError, "The object #{resource.id} has been updated by another process.")
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
context "when lock token is nil" do
|
406
|
+
xit "successfully saves the resource and returns the updated value of the optimistic locking attribute" do
|
407
|
+
resource = MyLockingResource.new(title: ["My Locked Resource"])
|
408
|
+
initial_resource = persister.save(resource: resource)
|
409
|
+
initial_token = initial_resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK].first
|
410
|
+
initial_resource.send("#{Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK}=", [])
|
411
|
+
updated_resource = persister.save(resource: initial_resource)
|
412
|
+
expect(initial_token.serialize)
|
413
|
+
.not_to eq(updated_resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK].first.serialize)
|
414
|
+
expect(updated_resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK]).not_to be_empty
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
context "when there is a token, but it's for a different adapter (migration use case)" do
|
419
|
+
xit "successfully saves the resource and returns a token for the adapter that was saved to" do
|
420
|
+
resource = MyLockingResource.new(title: ["My Locked Resource"])
|
421
|
+
initial_resource = persister.save(resource: resource)
|
422
|
+
new_token = Valkyrie::Persistence::OptimisticLockToken.new(
|
423
|
+
adapter_id: Valkyrie::ID.new("fake_adapter"),
|
424
|
+
token: "token"
|
425
|
+
)
|
426
|
+
initial_resource.send("#{Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK}=", [new_token])
|
427
|
+
updated_resource = persister.save(resource: initial_resource)
|
428
|
+
expect(new_token.serialize)
|
429
|
+
.not_to eq(updated_resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK].first.serialize)
|
430
|
+
expect(updated_resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK]).not_to be_empty
|
431
|
+
end
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
describe "#save_all" do
|
436
|
+
context "when creating multiple resources" do
|
437
|
+
xit "returns an array of resources with their system-generated optimistic locking attributes" do
|
438
|
+
resource1 = MyLockingResource.new(title: ["My Locked Resource 1"])
|
439
|
+
resource2 = MyLockingResource.new(title: ["My Locked Resource 2"])
|
440
|
+
resource3 = MyLockingResource.new(title: ["My Locked Resource 3"])
|
441
|
+
saved_resources = persister.save_all(resources: [resource1, resource2, resource3])
|
442
|
+
saved_resources.each do |saved_resource|
|
443
|
+
expect(saved_resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK]).not_to be_empty
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
context "when updating multiple resources that all have a correct lock token" do
|
449
|
+
xit "saves the resources and returns them with updated values of the optimistic locking attribute" do
|
450
|
+
resource1 = MyLockingResource.new(title: ["My Locked Resource 1"])
|
451
|
+
resource2 = MyLockingResource.new(title: ["My Locked Resource 2"])
|
452
|
+
resource3 = MyLockingResource.new(title: ["My Locked Resource 3"])
|
453
|
+
saved_resources = persister.save_all(resources: [resource1, resource2, resource3])
|
454
|
+
initial_lock_tokens = saved_resources.map do |r|
|
455
|
+
r[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK]
|
456
|
+
end
|
457
|
+
updated_resources = persister.save_all(resources: saved_resources)
|
458
|
+
updated_lock_tokens = updated_resources.map do |r|
|
459
|
+
r[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK]
|
460
|
+
end
|
461
|
+
expect(initial_lock_tokens & updated_lock_tokens).to be_empty
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
context "when one of the resources has an incorrect lock token" do
|
466
|
+
xit "raises a Valkyrie::Persistence::StaleObjectError" do
|
467
|
+
resource1 = MyLockingResource.new(title: ["My Locked Resource 1"])
|
468
|
+
resource2 = MyLockingResource.new(title: ["My Locked Resource 2"])
|
469
|
+
resource3 = MyLockingResource.new(title: ["My Locked Resource 3"])
|
470
|
+
resource1, resource2, resource3 = persister.save_all(resources: [resource1, resource2, resource3])
|
471
|
+
# update a resource in the datastore to make its token stale
|
472
|
+
persister.save(resource: resource2)
|
473
|
+
|
474
|
+
expect { persister.save_all(resources: [resource1, resource2, resource3]) }
|
475
|
+
.to raise_error(Valkyrie::Persistence::StaleObjectError, "One or more resources have been updated by another process.")
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
context 'ordered properties' do
|
482
|
+
xit "orders string values and returns them in the appropriate order" do
|
483
|
+
validate_order ["a", "b", "a"]
|
484
|
+
end
|
485
|
+
|
486
|
+
xit "orders boolean values and returns them in the appropriate order" do
|
487
|
+
validate_order [true, false, true]
|
488
|
+
end
|
489
|
+
|
490
|
+
xit "orders integer values and returns them in the appropriate order" do
|
491
|
+
validate_order [1, 2, 1]
|
492
|
+
end
|
493
|
+
|
494
|
+
xit "orders date values and returns them in the appropriate order" do
|
495
|
+
now = Time.now.round(0).utc
|
496
|
+
validate_order [now, now - 3.hours, now - 1.hour]
|
497
|
+
end
|
498
|
+
|
499
|
+
xit "orders URIs and returns them in the appropriate order" do
|
500
|
+
uri1 = RDF::URI("http://example.com/foo")
|
501
|
+
uri2 = RDF::URI("http://example.com/bar")
|
502
|
+
uri3 = RDF::URI("http://example.com/baz")
|
503
|
+
validate_order [uri1, uri2, uri3]
|
504
|
+
end
|
505
|
+
|
506
|
+
xit "orders IDs and returns them in the appropriate order" do
|
507
|
+
page1 = persister.save(resource: resource_class.new(authors: ["Page 1"]))
|
508
|
+
page2 = persister.save(resource: resource_class.new(authors: ["Page 2"]))
|
509
|
+
page3 = persister.save(resource: resource_class.new(authors: ["Page 3"]))
|
510
|
+
validate_order [page1.id, page2.id, page3.id]
|
511
|
+
end
|
512
|
+
|
513
|
+
xit "orders floating point values and returns them in the appropriate order" do
|
514
|
+
validate_order [1.123, 2.222, 1.123]
|
515
|
+
end
|
516
|
+
|
517
|
+
xit "orders different types of objects together" do
|
518
|
+
validate_order [
|
519
|
+
RDF::URI("http://example.com/foo", language: :ita),
|
520
|
+
RDF::URI("http://example.com/foo", datatype: RDF::URI("http://datatype")),
|
521
|
+
1,
|
522
|
+
1.01,
|
523
|
+
"Test"
|
524
|
+
]
|
525
|
+
end
|
526
|
+
|
527
|
+
xit "orders nested objects with strings" do
|
528
|
+
nested1 = resource_class.new(id: Valkyrie::ID.new("resource1"))
|
529
|
+
|
530
|
+
resource.ordered_authors = [nested1, "test"]
|
531
|
+
|
532
|
+
output = persister.save(resource: resource)
|
533
|
+
expect(output.ordered_authors[0].id).to eq nested1.id
|
534
|
+
expect(output.ordered_authors[1]).to eq "test"
|
535
|
+
end
|
536
|
+
|
537
|
+
xit "orders nested objects" do
|
538
|
+
nested1 = resource_class.new(id: Valkyrie::ID.new("resource1"), authors: ["Resource 1"])
|
539
|
+
nested2 = resource_class.new(id: Valkyrie::ID.new("resource2"), authors: ["Resource 2"])
|
540
|
+
nested3 = resource_class.new(id: Valkyrie::ID.new("resource3"), authors: ["Resource 3"])
|
541
|
+
values = [nested1, nested2, nested3]
|
542
|
+
|
543
|
+
resource.ordered_nested = values
|
544
|
+
|
545
|
+
output = persister.save(resource: resource)
|
546
|
+
expect(output.ordered_nested.map(&:id)).to eq values.map(&:id)
|
547
|
+
|
548
|
+
reloaded = query_service.find_by(id: output.id)
|
549
|
+
expect(reloaded.ordered_nested.map(&:id)).to eq values.map(&:id)
|
550
|
+
end
|
551
|
+
|
552
|
+
def validate_order(values)
|
553
|
+
resource.ordered_authors = values
|
554
|
+
output = persister.save(resource: resource)
|
555
|
+
expect(output.ordered_authors).to eq(values)
|
556
|
+
|
557
|
+
reloaded = query_service.find_by(id: output.id)
|
558
|
+
expect(reloaded.ordered_authors).to eq(values)
|
559
|
+
end
|
560
|
+
end
|
70
561
|
end
|
71
562
|
end
|