sufia 4.0.0.beta2 → 4.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +6 -4
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/folder.png +0 -0
- data/app/assets/javascripts/sufia.js +5 -0
- data/app/assets/javascripts/sufia/app.js +1 -0
- data/app/assets/javascripts/sufia/batch_select_all.js +1 -2
- data/app/assets/javascripts/sufia/dashboard_actions.js +13 -0
- data/app/assets/javascripts/sufia/editor.js +1 -1
- data/app/assets/javascripts/sufia/ga_events.js +10 -0
- data/app/assets/javascripts/sufia/search.js +67 -0
- data/app/assets/stylesheets/dashboard.css.scss +15 -1
- data/app/assets/stylesheets/sufia.css.scss +12 -0
- data/app/controllers/authorities_controller.rb +4 -4
- data/app/controllers/batch_controller.rb +4 -4
- data/app/controllers/collections_controller.rb +44 -0
- data/{lib → app/controllers/concerns}/sufia/batch_edits_controller_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/catalog.rb +9 -45
- data/{lib → app/controllers/concerns}/sufia/controller.rb +11 -21
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +34 -6
- data/{lib → app/controllers/concerns}/sufia/downloads_controller_behavior.rb +0 -0
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +35 -0
- data/{lib → app/controllers/concerns}/sufia/files_controller/local_ingest_behavior.rb +19 -7
- data/{lib → app/controllers/concerns}/sufia/files_controller/upload_complete_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +219 -0
- data/app/controllers/concerns/sufia/homepage_controller.rb +41 -0
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +3 -2
- data/app/controllers/dashboard/collections_controller.rb +19 -0
- data/app/controllers/dashboard/files_controller.rb +13 -0
- data/app/controllers/dashboard/highlights_controller.rb +20 -0
- data/app/controllers/dashboard/lists_controller.rb +13 -0
- data/app/controllers/dashboard/shares_controller.rb +19 -0
- data/app/controllers/directory_controller.rb +8 -8
- data/app/controllers/featured_work_lists_controller.rb +1 -1
- data/app/controllers/homepage_controller.rb +4 -0
- data/app/controllers/single_use_links_controller.rb +6 -6
- data/app/controllers/single_use_links_viewer_controller.rb +6 -6
- data/app/controllers/static_controller.rb +4 -3
- data/app/helpers/batch_edits_helper.rb +3 -6
- data/app/helpers/content_block_helper.rb +7 -2
- data/app/helpers/generic_file_helper.rb +33 -39
- data/app/helpers/records_helper.rb +4 -0
- data/app/helpers/sufia/blacklight_override.rb +11 -0
- data/app/helpers/sufia/records_helper_behavior.rb +38 -0
- data/app/helpers/sufia/sufia_helper_behavior.rb +109 -0
- data/{sufia-models/lib/sufia/models → app/models/concerns/sufia}/solr_document_behavior.rb +6 -1
- data/app/models/contact_form.rb +13 -13
- data/app/uploaders/tinymce_asset_uploader.rb +2 -2
- data/app/views/_controls.html.erb +1 -1
- data/app/views/_flash_msg.html.erb +2 -8
- data/app/views/_ga.html.erb +4 -0
- data/app/views/_user_util_links.html.erb +7 -7
- data/app/views/advanced/_advanced_search_facets.html.erb +1 -1
- data/app/views/advanced/_advanced_search_fields.html.erb +2 -2
- data/app/views/advanced/_advanced_search_form.html.erb +12 -12
- data/app/views/batch/_metadata.html.erb +12 -12
- data/app/views/batch/_more_metadata.html.erb +1 -2
- data/app/views/batch/edit.html.erb +5 -5
- data/app/views/batch_edits/_check_all.html.erb +1 -1
- data/app/views/batch_edits/_delete_selected.html.erb +2 -3
- data/app/views/batch_edits/edit.html.erb +20 -21
- data/app/views/catalog/_bookmark_control.html.erb +7 -8
- data/app/views/catalog/_constraints_element.html.erb +2 -2
- data/app/views/catalog/_delete_partials/_default.html.erb +9 -12
- data/app/views/catalog/_document.html.erb +5 -5
- data/app/views/catalog/_document_list.html.erb +2 -2
- data/app/views/catalog/_edit_partials/_default.html.erb +6 -9
- data/app/views/catalog/_edit_partials/_default_details.html.erb +2 -4
- data/app/views/catalog/_email_form.html.erb +1 -1
- data/app/views/catalog/_facet_limit.html.erb +6 -7
- data/app/views/catalog/_facet_selected.html.erb +3 -3
- data/app/views/catalog/_folder_control.html.erb +7 -8
- data/app/views/catalog/_index_default.html.erb +2 -2
- data/app/views/catalog/_index_header_default.html.erb +20 -0
- data/app/views/catalog/_index_partials/_default_group.html.erb +1 -1
- data/app/views/catalog/_index_partials/_list_files.html.erb +5 -2
- data/app/views/catalog/_refworks_form.html.erb +2 -2
- data/app/views/catalog/_results_pagination.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +24 -9
- data/app/views/catalog/_show_default.html.erb +2 -2
- data/app/views/catalog/_show_partials/_default.html.erb +4 -5
- data/app/views/catalog/_show_partials/_default_details.html.erb +5 -5
- data/app/views/catalog/_show_partials/_facets.html.erb +7 -7
- data/app/views/catalog/_show_tools.html.erb +6 -6
- data/app/views/catalog/_sms_form.html.erb +1 -1
- data/app/views/catalog/_sort_and_per_page.html.erb +8 -14
- data/app/views/catalog/citation.html.erb +1 -1
- data/app/views/catalog/email.erb +1 -1
- data/app/views/catalog/index.html.erb +16 -27
- data/app/views/catalog/recent.js.erb +1 -1
- data/app/views/catalog/show.html.erb +2 -2
- data/app/views/catalog/sms.erb +1 -1
- data/app/views/collections/_action_menu.html.erb +24 -0
- data/app/views/collections/_batch_edits_actions.html.erb +3 -0
- data/app/views/collections/_button_for_creating_empty_collection.html.erb +3 -0
- data/app/views/collections/_dashboard_document_list.html.erb +6 -0
- data/app/views/collections/_document_list.html.erb +10 -0
- data/app/views/collections/_edit_actions.html.erb +5 -0
- data/app/views/collections/_edit_descriptions.html.erb +20 -0
- data/app/views/collections/_form.html.erb +24 -0
- data/app/views/collections/_form_for_select_collection.html.erb +34 -0
- data/app/views/collections/_media_display.html.erb +1 -0
- data/app/views/collections/_paginate.html.erb +6 -0
- data/app/views/collections/_search_collection_dashboard_form.html.erb +10 -0
- data/app/views/collections/_show_actions.html.erb +7 -0
- data/app/views/collections/_show_descriptions.html.erb +8 -0
- data/app/views/collections/_show_fields.html.erb +0 -0
- data/app/views/collections/_single_item_action_fields.html.erb +6 -0
- data/app/views/collections/_sort_and_per_page.html.erb +29 -0
- data/app/views/collections/_view_type_group.html.erb +13 -0
- data/app/views/collections/edit.html.erb +30 -0
- data/app/views/collections/show.html.erb +32 -0
- data/app/views/contact_form/new.html.erb +13 -13
- data/app/views/dashboard/_action_menu.html.erb +29 -0
- data/app/views/dashboard/_collection_action_menu.html.erb +15 -0
- data/app/views/dashboard/_document_list.html.erb +1 -1
- data/app/views/dashboard/_facet_limit.html.erb +2 -2
- data/app/views/dashboard/_facet_pagination.html.erb +12 -12
- data/app/views/dashboard/_facet_selected.html.erb +2 -2
- data/app/views/dashboard/_facets.html.erb +2 -0
- data/app/views/dashboard/_index_partials/_default_group.html.erb +9 -2
- data/app/views/dashboard/_index_partials/_list_collections.html.erb +45 -0
- data/app/views/dashboard/_index_partials/_list_files.html.erb +5 -25
- data/app/views/dashboard/_results_pagination.html.erb +1 -1
- data/app/views/dashboard/_search_form.html.erb +2 -2
- data/app/views/dashboard/_show_partials/_default.html.erb +3 -3
- data/app/views/dashboard/_show_partials/_default_details.html.erb +5 -5
- data/app/views/dashboard/_show_partials/_facets.html.erb +6 -6
- data/app/views/dashboard/_sort_and_per_page.html.erb +24 -8
- data/app/views/dashboard/facet.html.erb +3 -3
- data/app/views/dashboard/index.html.erb +18 -41
- data/app/views/dashboard/lists/index.html.erb +59 -0
- data/app/views/generic_files/_breadcrumbs.html.erb +4 -4
- data/app/views/generic_files/_descriptions.html.erb +4 -4
- data/app/views/generic_files/_field_form.html.erb +5 -5
- data/app/views/generic_files/_flot_stats.js.erb +120 -0
- data/app/views/generic_files/_media_display.html.erb +14 -4
- data/app/views/generic_files/_permission.html.erb +3 -3
- data/app/views/generic_files/_permission_form.html.erb +20 -21
- data/app/views/generic_files/_show_actions.html.erb +13 -10
- data/app/views/generic_files/_show_details.html.erb +16 -9
- data/app/views/generic_files/_versioning.html.erb +3 -3
- data/app/views/generic_files/edit.html.erb +7 -7
- data/app/views/generic_files/edit_fields/_default.html.erb +3 -4
- data/app/views/generic_files/edit_fields/_description.html.erb +3 -4
- data/app/views/generic_files/edit_fields/_resource_type.html.erb +1 -3
- data/app/views/generic_files/edit_fields/_rights.html.erb +3 -5
- data/app/views/generic_files/edit_fields/_suffix.html.erb +1 -1
- data/app/views/generic_files/show.html.erb +3 -3
- data/app/views/generic_files/stats.html.erb +8 -124
- data/app/views/generic_files/upload/_alerts.html.erb +2 -4
- data/app/views/generic_files/upload/_form.html.erb +1 -1
- data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +1 -1
- data/app/views/generic_files/upload/_tos_checkbox.html.erb +1 -1
- data/app/views/homepage/_featured.html.erb +3 -1
- data/app/views/{catalog → homepage}/_featured_researcher.html.erb +0 -0
- data/app/views/{catalog → homepage}/_home.html.erb +1 -0
- data/app/views/{catalog → homepage}/_home_content.html.erb +4 -4
- data/app/views/homepage/_home_header.html.erb +12 -0
- data/app/views/homepage/_marketing.html.erb +4 -0
- data/app/views/{catalog → homepage}/_recent_document.html.erb +10 -5
- data/app/views/homepage/_recents.html.erb +15 -0
- data/app/views/homepage/_sortable_featured.html.erb +3 -1
- data/app/views/{catalog → homepage}/_tagcloud.html.erb +0 -0
- data/app/views/homepage/index.html.erb +1 -0
- data/app/views/kaminari/blacklight/_first_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_last_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_next_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_prev_page.html.erb +1 -1
- data/app/views/layouts/_head_tag_content.html.erb +1 -1
- data/app/views/layouts/error.html.erb +2 -2
- data/app/views/layouts/homepage.html.erb +4 -4
- data/app/views/layouts/sufia-dashboard.html.erb +7 -7
- data/app/views/layouts/sufia-one-column.html.erb +4 -4
- data/app/views/layouts/sufia-two-column.html.erb +7 -7
- data/app/views/mailbox/index.html.erb +2 -2
- data/app/views/pages/show.html.erb +1 -0
- data/app/views/records/_edit_field.html.erb +18 -0
- data/app/views/records/edit_fields/_description.html.erb +10 -0
- data/app/views/records/edit_fields/_resource_type.html.erb +7 -0
- data/app/views/records/edit_fields/_rights.html.erb +6 -0
- data/app/views/records/edit_fields/_suffix.html.erb +9 -0
- data/app/views/records/edit_fields/_type.html.erb +13 -0
- data/app/views/single_use_links/new_download.html.erb +1 -1
- data/app/views/users/_activity.html.erb +1 -1
- data/app/views/users/_contributions.html.erb +3 -1
- data/app/views/users/_left_sidebar.html.erb +1 -1
- data/app/views/users/_notify_link.html.erb +2 -2
- data/app/views/users/_profile.html.erb +2 -2
- data/app/views/users/_search_form.html.erb +3 -3
- data/app/views/users/edit.html.erb +15 -15
- data/app/views/users/index.html.erb +3 -3
- data/app/views/users/notifications_number.js.erb +1 -1
- data/config/locales/sufia.en.yml +13 -2
- data/config/routes.rb +56 -20
- data/db/seeds.rb +2 -2
- data/lib/generators/sufia/sufia_generator.rb +14 -4
- data/lib/generators/sufia/templates/catalog_controller.rb +98 -97
- data/lib/generators/sufia/templates/sufia_helper.rb +5 -0
- data/lib/sufia.rb +4 -0
- data/spec/{models/generic_file/actions_spec.rb → actors/generic_file/actor_spec.rb} +2 -2
- data/spec/controllers/authorities_controller_spec.rb +7 -7
- data/spec/controllers/batch_controller_spec.rb +22 -23
- data/spec/controllers/batch_edits_controller_spec.rb +4 -4
- data/spec/controllers/catalog_controller_spec.rb +27 -37
- data/spec/controllers/collections_controller_spec.rb +179 -0
- data/spec/controllers/dashboard/collections_controller_spec.rb +71 -0
- data/spec/controllers/dashboard/files_controller_spec.rb +71 -0
- data/spec/controllers/dashboard/highlights_controller_spec.rb +66 -0
- data/spec/controllers/dashboard/shares_controller_spec.rb +78 -0
- data/spec/controllers/dashboard_controller_spec.rb +0 -47
- data/spec/controllers/downloads_controller_spec.rb +10 -11
- data/spec/controllers/generic_files_controller_spec.rb +147 -118
- data/spec/controllers/homepage_controller_spec.rb +57 -0
- data/spec/controllers/mailbox_controller_spec.rb +3 -3
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +3 -3
- data/spec/factories/generic_files.rb +4 -0
- data/spec/factories/users.rb +0 -1
- data/spec/features/browse_dashboard_files_spec.rb +5 -1
- data/spec/features/collection_spec.rb +232 -0
- data/spec/features/display_dashboard_spec.rb +1 -0
- data/spec/features/notifications_spec.rb +1 -1
- data/spec/features/search_spec.rb +22 -0
- data/spec/features/single_use_links_spec.rb +2 -2
- data/spec/features/users_spec.rb +1 -1
- data/spec/fixtures/charter.docx +0 -0
- data/spec/helpers/records_helper_spec.rb +61 -0
- data/spec/helpers/sufia_helper_spec.rb +40 -2
- data/spec/{models → jobs}/active_fedora_pid_based_job_spec.rb +0 -0
- data/spec/{models → jobs}/audit_job_spec.rb +0 -2
- data/spec/{models → jobs}/batch_update_job_spec.rb +2 -2
- data/spec/jobs/characterize_job_spec.rb +25 -0
- data/spec/jobs/create_derivatives_job_spec.rb +186 -0
- data/spec/{models → jobs}/event_jobs_spec.rb +0 -1
- data/spec/jobs/import_url_job_spec.rb +36 -14
- data/spec/jobs/ingest_local_file_job_spec.rb +2 -2
- data/spec/lib/sufia/analytics_spec.rb +29 -0
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +1 -1
- data/spec/models/batch_spec.rb +3 -9
- data/spec/models/checksum_audit_log_spec.rb +5 -6
- data/spec/models/collection_spec.rb +24 -0
- data/spec/models/download_spec.rb +21 -0
- data/spec/models/featured_work_list_spec.rb +0 -1
- data/spec/models/file_content_datastream_spec.rb +8 -14
- data/spec/models/file_usage_spec.rb +91 -0
- data/spec/models/fits_datastream_spec.rb +1 -1
- data/spec/models/generic_file/web_form_spec.rb +2 -2
- data/spec/models/generic_file_rdf_datastream_spec.rb +12 -0
- data/spec/models/generic_file_spec.rb +150 -168
- data/spec/models/local_authority_spec.rb +9 -9
- data/spec/models/{pageview.rb → pageview_spec.rb} +0 -0
- data/spec/models/single_use_link_spec.rb +32 -35
- data/spec/routing/route_spec.rb +19 -3
- data/spec/spec_helper.rb +28 -6
- data/spec/support/features/session_helpers.rb +5 -6
- data/spec/support/lib/generators/test_app_generator.rb +6 -0
- data/spec/views/generic_file/edit.html.erb_spec.rb +4 -4
- data/spec/views/generic_file/show.html.erb_spec.rb +45 -17
- data/spec/views/generic_file/stats.html.erb_spec.rb +26 -7
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +98 -0
- data/sufia-models/app/models/batch.rb +3 -3
- data/sufia-models/app/models/checksum_audit_log.rb +3 -3
- data/sufia-models/app/models/collection.rb +41 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file.rb +33 -43
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/accessible_attributes.rb +3 -3
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/audit.rb +12 -18
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/characterization.rb +1 -8
- data/sufia-models/app/models/concerns/sufia/generic_file/derivatives.rb +26 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/export.rb +13 -13
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/featured.rb +0 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/metadata.rb +0 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/mime_types.rb +15 -1
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/permissions.rb +5 -1
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/reload_on_save.rb +0 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/trophies.rb +0 -0
- data/sufia-models/app/models/concerns/sufia/generic_file/versions.rb +16 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/virus_check.rb +2 -3
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/web_form.rb +9 -2
- data/sufia-models/app/models/concerns/sufia/properties_datastream_behavior.rb +3 -4
- data/sufia-models/app/models/concerns/sufia/user.rb +2 -2
- data/sufia-models/app/models/datastreams/fits_datastream.rb +137 -136
- data/sufia-models/app/models/datastreams/generic_file_rdf_datastream.rb +6 -0
- data/sufia-models/app/models/datastreams/paranoid_rights_datastream.rb +3 -3
- data/sufia-models/app/models/file_usage.rb +53 -0
- data/sufia-models/app/models/follow.rb +2 -4
- data/sufia-models/app/models/geo_names_resource.rb +5 -7
- data/sufia-models/app/models/local_authority.rb +14 -14
- data/sufia-models/app/models/single_use_link.rb +1 -1
- data/sufia-models/app/models/sufia/download.rb +9 -0
- data/sufia-models/app/models/trophy.rb +1 -1
- data/sufia-models/app/services/sufia/{usage_statistics.rb → analytics.rb} +1 -24
- data/sufia-models/app/services/sufia/id_service.rb +2 -2
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +5 -2
- data/sufia-models/lib/generators/sufia/models/templates/config/setup_mail.rb +1 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +5 -3
- data/sufia-models/lib/generators/sufia/models/templates/migrations/acts_as_follower_migration.rb +6 -6
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_checksum_audit_logs.rb +2 -3
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb +20 -20
- data/sufia-models/lib/sufia/ability.rb +1 -1
- data/sufia-models/lib/sufia/models/engine.rb +3 -9
- data/sufia-models/lib/sufia/models/file_content/versions.rb +3 -3
- data/sufia-models/lib/sufia/models/jobs/active_fedora_pid_based_job.rb +6 -2
- data/sufia-models/lib/sufia/models/jobs/batch_update_job.rb +6 -10
- data/sufia-models/lib/sufia/models/jobs/characterize_job.rb +1 -13
- data/sufia-models/lib/sufia/models/jobs/create_derivatives_job.rb +14 -0
- data/sufia-models/lib/sufia/models/jobs/import_url_job.rb +27 -23
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +1 -1
- data/sufia-models/sufia-models.gemspec +1 -1
- data/sufia.gemspec +7 -2
- data/tasks/jetty.rake +4 -4
- data/tasks/release.rake +8 -8
- data/tasks/sufia-db.rake +4 -4
- data/tasks/sufia-dev.rake +11 -5
- metadata +226 -95
- data/app/helpers/sufia_helper.rb +0 -93
- data/app/views/catalog/_bookmark_form.html.erb +0 -8
- data/app/views/catalog/_home_header.html.erb +0 -15
- data/app/views/catalog/_recents.html.erb +0 -17
- data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +0 -9
- data/app/views/layouts/_homepage_sidebar2.html.erb +0 -14
- data/lib/sufia/files_controller_behavior.rb +0 -253
- data/spec/helpers/generic_file_helper_spec.rb +0 -28
- data/spec/lib/sufia/usage_statistics_spec.rb +0 -75
- data/spec/models/characterize_job_spec.rb +0 -93
- data/spec/models/transcode_audio_job_spec.rb +0 -85
- data/spec/models/transcode_video_job_spec.rb +0 -31
- data/spec/views/dashboard/index_partials/_thumbnail_display.html.erb_spec.rb +0 -22
- data/sufia-models/lib/sufia/models/generic_file/actions.rb +0 -50
- data/sufia-models/lib/sufia/models/generic_file/derivatives.rb +0 -31
- data/sufia-models/lib/sufia/models/generic_file/thumbnail.rb +0 -37
- data/sufia-models/lib/sufia/models/generic_file/versions.rb +0 -16
- data/sufia-models/lib/sufia/models/jobs/transcode_audio_job.rb +0 -15
- data/sufia-models/lib/sufia/models/jobs/transcode_video_job.rb +0 -15
@@ -26,11 +26,11 @@ describe IngestLocalFileJob do
|
|
26
26
|
|
27
27
|
describe "virus checking" do
|
28
28
|
it "should run virus check" do
|
29
|
-
expect(Sufia::GenericFile::
|
29
|
+
expect(Sufia::GenericFile::Actor).to receive(:virus_check).twice.and_return(0)
|
30
30
|
job.run
|
31
31
|
end
|
32
32
|
it "should abort if virus check fails" do
|
33
|
-
Sufia::GenericFile::
|
33
|
+
allow(Sufia::GenericFile::Actor).to receive(:virus_check).and_raise(Sufia::VirusFoundError.new('A virus was found'))
|
34
34
|
job.run
|
35
35
|
expect(user.mailbox.inbox.first.subject).to eq("Local file ingest error")
|
36
36
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Analytics do
|
4
|
+
before do
|
5
|
+
token = OAuth2::AccessToken.new(nil, nil)
|
6
|
+
allow(subject).to receive(:token).and_return(token)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'responds to :config' do
|
10
|
+
expect(subject).to respond_to(:config)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'reads its config from a yaml file' do
|
14
|
+
expect(subject.config.keys.sort).to eql ['app_name', 'app_version', 'client_email', 'privkey_path', 'privkey_secret']
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'responds to :user' do
|
18
|
+
expect(subject).to respond_to(:user)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'instantiates a user' do
|
22
|
+
expect(subject.user).to be_a(Legato::User)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'responds to :profile' do
|
26
|
+
expect(subject).to respond_to(:profile)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -22,7 +22,7 @@ describe Sufia::FilesController::UploadCompleteBehavior do
|
|
22
22
|
UploadThing.upload_complete_path(test_id).should == Sufia::Engine.routes.url_helpers.batch_edit_path(test_id)
|
23
23
|
end
|
24
24
|
it "respond with the dashboard path" do
|
25
|
-
UploadThing.destroy_complete_path({}).should == Sufia::Engine.routes.url_helpers.
|
25
|
+
UploadThing.destroy_complete_path({}).should == Sufia::Engine.routes.url_helpers.dashboard_files_path
|
26
26
|
end
|
27
27
|
end
|
28
28
|
context "overriden path" do
|
data/spec/models/batch_spec.rb
CHANGED
@@ -3,14 +3,12 @@ require 'spec_helper'
|
|
3
3
|
describe Batch do
|
4
4
|
before(:all) do
|
5
5
|
@user = FactoryGirl.find_or_create(:jill)
|
6
|
-
GenericFile.any_instance.should_receive(:characterize_if_changed).and_yield
|
7
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
8
6
|
@file = GenericFile.new
|
9
7
|
@file.apply_depositor_metadata('mjg36')
|
10
8
|
@file.save
|
11
|
-
@batch = Batch.create(:
|
12
|
-
:
|
13
|
-
:
|
9
|
+
@batch = Batch.create(title: "test collection",
|
10
|
+
creator: @user.user_key,
|
11
|
+
part: @file.pid)
|
14
12
|
end
|
15
13
|
after(:all) do
|
16
14
|
@user.delete
|
@@ -36,11 +34,7 @@ describe Batch do
|
|
36
34
|
@batch.part.should == [@file.pid]
|
37
35
|
end
|
38
36
|
it "should be able to have more than one file" do
|
39
|
-
# not sure why this is needed here too, but when the test runs alone it is not needed but when run in the group it is needed
|
40
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
41
|
-
#logger.info "before create"
|
42
37
|
gf = GenericFile.new
|
43
|
-
#logger.info "after create"
|
44
38
|
gf.apply_depositor_metadata('mjg36')
|
45
39
|
gf.save
|
46
40
|
@batch.part << gf.pid
|
@@ -5,11 +5,10 @@ describe ChecksumAuditLog do
|
|
5
5
|
@f = GenericFile.new
|
6
6
|
@f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
7
7
|
@f.apply_depositor_metadata('mjg36')
|
8
|
-
@f.stub(:characterize_if_changed).and_yield #don't run characterization
|
9
8
|
@f.save!
|
10
9
|
@version = @f.datastreams['content'].versions.first
|
11
|
-
@old = ChecksumAuditLog.create(:
|
12
|
-
@new =
|
10
|
+
@old = ChecksumAuditLog.create(pid: @f.pid, dsid: @version.dsid, version: @version.versionID, pass: 1, created_at: 2.minutes.ago)
|
11
|
+
@new = ChecksumAuditLog.create(pid: @f.pid, dsid: @version.dsid, version: @version.versionID, pass: 0)
|
13
12
|
end
|
14
13
|
after(:all) do
|
15
14
|
@f.delete
|
@@ -22,11 +21,11 @@ describe ChecksumAuditLog do
|
|
22
21
|
@f.logs(@version.dsid).should == [@new, @old]
|
23
22
|
end
|
24
23
|
it "should prune history for a datastream" do
|
25
|
-
success1 = ChecksumAuditLog.create(:
|
24
|
+
success1 = ChecksumAuditLog.create(pid: @f.pid, dsid: @version.dsid, version: @version.versionID, pass: 1)
|
26
25
|
ChecksumAuditLog.prune_history(@version)
|
27
|
-
success2 = ChecksumAuditLog.create(:
|
26
|
+
success2 = ChecksumAuditLog.create(pid: @f.pid, dsid: @version.dsid, version: @version.versionID, pass: 1)
|
28
27
|
ChecksumAuditLog.prune_history(@version)
|
29
|
-
success3 = ChecksumAuditLog.create(:
|
28
|
+
success3 = ChecksumAuditLog.create(pid: @f.pid, dsid: @version.dsid, version: @version.versionID, pass: 1)
|
30
29
|
ChecksumAuditLog.prune_history(@version)
|
31
30
|
lambda { ChecksumAuditLog.find(success2.id)}.should raise_exception ActiveRecord::RecordNotFound
|
32
31
|
lambda { ChecksumAuditLog.find(success3.id)}.should raise_exception ActiveRecord::RecordNotFound
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Collection do
|
4
|
+
before(:all) do
|
5
|
+
@user = FactoryGirl.create(:user)
|
6
|
+
@collection = Collection.new(title: "test collection").tap do |c|
|
7
|
+
c.apply_depositor_metadata(@user.user_key)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
@collection.delete
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have open visibility" do
|
16
|
+
@collection.save
|
17
|
+
expect(@collection.read_groups).to eq ['public']
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should not allow a collection to be saved without a title" do
|
21
|
+
@collection.title = nil
|
22
|
+
expect{ @collection.save! }.to raise_error(ActiveFedora::RecordInvalid)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Download do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@download = Sufia::Download
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'has an events metric' do
|
10
|
+
expect(@download.metrics).to be == Legato::ListParameter.new(:metrics, [:totalEvents])
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'has dimensions' do
|
14
|
+
expect(@download.dimensions).to be == Legato::ListParameter.new(:dimensions, [:eventCategory, :eventAction, :eventLabel, :date])
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'responds to :for_file' do
|
18
|
+
expect(@download).to respond_to(:for_file)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -5,7 +5,6 @@ describe FeaturedWorkList do
|
|
5
5
|
let(:file2) { FactoryGirl.create(:generic_file) }
|
6
6
|
|
7
7
|
before do
|
8
|
-
GenericFile.any_instance.stub(:characterize_if_changed).and_yield
|
9
8
|
FeaturedWork.create(generic_file_id: file1.noid)
|
10
9
|
FeaturedWork.create(generic_file_id: file2.noid)
|
11
10
|
end
|
@@ -1,15 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FileContentDatastream do
|
4
|
-
before do
|
5
|
-
Sufia.queue.stub(:push).with(an_instance_of CharacterizeJob) #don't run characterization
|
6
|
-
end
|
7
4
|
describe "version control" do
|
8
5
|
before do
|
9
6
|
f = GenericFile.new
|
10
7
|
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
11
8
|
f.apply_depositor_metadata('mjg36')
|
12
|
-
f.stub(:characterize_if_changed).and_yield #don't run characterization
|
13
9
|
f.save
|
14
10
|
@file = f.reload
|
15
11
|
end
|
@@ -34,7 +30,6 @@ describe FileContentDatastream do
|
|
34
30
|
describe "add a version" do
|
35
31
|
before do
|
36
32
|
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
37
|
-
@file.stub(:characterize_if_changed).and_yield #don't run characterization
|
38
33
|
@file.save
|
39
34
|
end
|
40
35
|
it "should return two versions" do
|
@@ -51,22 +46,22 @@ describe FileContentDatastream do
|
|
51
46
|
describe "extract_metadata" do
|
52
47
|
before do
|
53
48
|
@subject = FileContentDatastream.new(nil, 'content')
|
54
|
-
@subject.stub(:
|
55
|
-
@subject.stub(:
|
49
|
+
@subject.stub(pid: 'my_pid')
|
50
|
+
@subject.stub(dsVersionID: 'content.7')
|
56
51
|
end
|
57
|
-
it "should return an xml document", :
|
52
|
+
it "should return an xml document", unless: $in_travis do
|
58
53
|
f = File.new(fixture_path + '/world.png', 'rb')
|
59
54
|
@subject.content = f.read
|
60
55
|
xml = @subject.extract_metadata
|
61
56
|
doc = Nokogiri::XML.parse(xml)
|
62
57
|
doc.root.xpath('//ns:imageWidth/text()', {'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output'}).inner_text.should == '50'
|
63
58
|
end
|
64
|
-
it "should return expected results when invoked via HTTP", :
|
65
|
-
f = ActionDispatch::Http::UploadedFile.new(:
|
66
|
-
:
|
59
|
+
it "should return expected results when invoked via HTTP", unless: $in_travis do
|
60
|
+
f = ActionDispatch::Http::UploadedFile.new(tempfile: File.new(fixture_path + '/world.png'),
|
61
|
+
filename: 'world.png')
|
67
62
|
content = double("file")
|
68
|
-
content.stub(:
|
69
|
-
content.stub(:
|
63
|
+
content.stub(read: f.read)
|
64
|
+
content.stub(rewind: f.rewind)
|
70
65
|
@subject.stub(:content).and_return(f)
|
71
66
|
xml = @subject.extract_metadata
|
72
67
|
doc = Nokogiri::XML.parse(xml)
|
@@ -77,7 +72,6 @@ describe FileContentDatastream do
|
|
77
72
|
before do
|
78
73
|
@generic_file = GenericFile.new
|
79
74
|
@generic_file.apply_depositor_metadata('mjg36')
|
80
|
-
@generic_file.stub(:characterize_if_changed).and_yield #don't run characterization
|
81
75
|
end
|
82
76
|
after do
|
83
77
|
@generic_file.delete
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FileUsage do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@file = GenericFile.new
|
7
|
+
@file.apply_depositor_metadata("awead")
|
8
|
+
@file.save
|
9
|
+
end
|
10
|
+
|
11
|
+
after :all do
|
12
|
+
@file.delete
|
13
|
+
end
|
14
|
+
|
15
|
+
# This is what the data looks like that's returned from Google Analytics (GA) via the Legato gem
|
16
|
+
# Due to the nature of querying GA, testing this data in an automated fashion is problematc.
|
17
|
+
# Sample data structures were created by sending real events to GA from a test instance of
|
18
|
+
# Scholarsphere. The data below are essentially a "cut and paste" from the output of query
|
19
|
+
# results from the Legato gem.
|
20
|
+
|
21
|
+
let(:sample_download_statistics) {
|
22
|
+
[
|
23
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: "20140101", totalEvents: "1"),
|
24
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: "20140102", totalEvents: "1"),
|
25
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: "20140103", totalEvents: "2"),
|
26
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: "20140104", totalEvents: "3"),
|
27
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:x920fw85p", date: "20140105", totalEvents: "5"),
|
28
|
+
]
|
29
|
+
}
|
30
|
+
|
31
|
+
let(:sample_pageview_statistics) {
|
32
|
+
[
|
33
|
+
OpenStruct.new(date: '20140101', pageviews: 4),
|
34
|
+
OpenStruct.new(date: '20140102', pageviews: 8),
|
35
|
+
OpenStruct.new(date: '20140103', pageviews: 6),
|
36
|
+
OpenStruct.new(date: '20140104', pageviews: 10),
|
37
|
+
OpenStruct.new(date: '20140105', pageviews: 2)
|
38
|
+
]
|
39
|
+
}
|
40
|
+
|
41
|
+
let(:usage) {
|
42
|
+
allow_any_instance_of(FileUsage).to receive(:download_statistics).and_return(sample_download_statistics)
|
43
|
+
allow_any_instance_of(FileUsage).to receive(:pageview_statistics).and_return(sample_pageview_statistics)
|
44
|
+
FileUsage.new(@file.id)
|
45
|
+
}
|
46
|
+
|
47
|
+
describe "#initialize" do
|
48
|
+
|
49
|
+
it "should set the id" do
|
50
|
+
expect(usage.id).to eq(@file.pid)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should set the path" do
|
54
|
+
expect(usage.path).to eq("/files/#{Sufia::Noid.noidify(@file.id)}")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should set the created date" do
|
58
|
+
expect(usage.created).to eq(DateTime.parse(@file.create_date))
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "statistics" do
|
64
|
+
|
65
|
+
before(:all) do
|
66
|
+
@system_timezone = ENV['TZ']
|
67
|
+
ENV['TZ'] = 'UTC'
|
68
|
+
end
|
69
|
+
|
70
|
+
after(:all) do
|
71
|
+
ENV['TZ'] = @system_timezone
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should count the total numver of downloads" do
|
75
|
+
expect(usage.total_downloads).to eq(12)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should count the total numver of pageviews" do
|
79
|
+
expect(usage.total_pageviews).to eq(30)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return an array of hashes for use with JQuery Flot" do
|
83
|
+
expect(usage.to_flot[0][:label]).to eq("Pageviews")
|
84
|
+
expect(usage.to_flot[1][:label]).to eq("Downloads")
|
85
|
+
expect(usage.to_flot[0][:data]).to include([1388534400000, 4], [1388620800000, 8], [1388707200000, 6], [1388793600000, 10], [1388880000000, 2])
|
86
|
+
expect(usage.to_flot[1][:data]).to include([1388534400000, 1], [1388620800000, 1], [1388707200000, 2], [1388793600000, 3], [1388880000000, 5])
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -22,9 +22,9 @@ describe GenericFile do
|
|
22
22
|
|
23
23
|
describe "accessible_attributes" do
|
24
24
|
it "should have a list" do
|
25
|
-
subject.accessible_attributes.should
|
25
|
+
subject.accessible_attributes.should include(:part_of, :resource_type, :title, :creator, :contributor, :description,
|
26
26
|
:tag, :rights, :publisher, :date_created, :date_uploaded, :date_modified, :subject, :language, :identifier,
|
27
|
-
:based_near, :related_url, :permissions
|
27
|
+
:based_near, :related_url, :permissions)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should sanitize them" do
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GenericFileRdfDatastream do
|
4
|
+
it "should have bibliographicCitation" do
|
5
|
+
subject.bibliographic_citation = "foo"
|
6
|
+
expect(subject.bibliographic_citation).to eq ["foo"]
|
7
|
+
end
|
8
|
+
it "should have source" do
|
9
|
+
subject.source = "foo"
|
10
|
+
expect(subject.source).to eq ["foo"]
|
11
|
+
end
|
12
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe GenericFile do
|
4
|
+
|
5
|
+
subject { GenericFile.new }
|
6
|
+
|
4
7
|
before do
|
5
8
|
subject.apply_depositor_metadata('jcoyne')
|
6
|
-
@file = subject #TODO remove this line someday (use subject instead)
|
7
|
-
|
8
9
|
end
|
9
10
|
|
10
11
|
describe '#to_s' do
|
@@ -27,7 +28,7 @@ describe GenericFile do
|
|
27
28
|
end
|
28
29
|
|
29
30
|
describe "mime type recognition" do
|
30
|
-
|
31
|
+
context "when image?" do
|
31
32
|
it "should be true for jpeg2000" do
|
32
33
|
subject.mime_type = 'image/jp2'
|
33
34
|
subject.should be_image
|
@@ -41,13 +42,13 @@ describe GenericFile do
|
|
41
42
|
subject.should be_image
|
42
43
|
end
|
43
44
|
end
|
44
|
-
|
45
|
+
context "when pdf?" do
|
45
46
|
it "should be true for pdf" do
|
46
47
|
subject.mime_type = 'application/pdf'
|
47
48
|
subject.should be_pdf
|
48
49
|
end
|
49
50
|
end
|
50
|
-
|
51
|
+
context "when audio?" do
|
51
52
|
it "should be true for wav" do
|
52
53
|
subject.mime_type = 'audio/x-wave'
|
53
54
|
subject.should be_audio
|
@@ -65,7 +66,7 @@ describe GenericFile do
|
|
65
66
|
subject.should be_audio
|
66
67
|
end
|
67
68
|
end
|
68
|
-
|
69
|
+
context "when video?" do
|
69
70
|
it "should be true for avi" do
|
70
71
|
subject.mime_type = 'video/avi'
|
71
72
|
subject.should be_video
|
@@ -122,48 +123,48 @@ describe GenericFile do
|
|
122
123
|
subject.read_groups=['group1', 'group2']
|
123
124
|
subject.edit_users=['user1']
|
124
125
|
subject.read_users=['user2', 'user3']
|
125
|
-
subject.permissions.should == [{:
|
126
|
-
{:
|
127
|
-
{:
|
128
|
-
{:
|
129
|
-
{:
|
126
|
+
subject.permissions.should == [{type: "group", access: "read", name: "group1"},
|
127
|
+
{type: "group", access: "read", name: "group2"},
|
128
|
+
{type: "user", access: "read", name: "user2"},
|
129
|
+
{type: "user", access: "read", name: "user3"},
|
130
|
+
{type: "user", access: "edit", name: "user1"}]
|
130
131
|
end
|
131
132
|
describe "updating permissions" do
|
132
133
|
it "should create new group permissions" do
|
133
|
-
subject.permissions = {:
|
134
|
-
subject.permissions.should == [{:
|
135
|
-
{:
|
134
|
+
subject.permissions = {new_group_name: {'group1'=>'read'}}
|
135
|
+
subject.permissions.should == [{type: "group", access: "read", name: "group1"},
|
136
|
+
{type: "user", access: "edit", name: "jcoyne"}]
|
136
137
|
end
|
137
138
|
it "should create new user permissions" do
|
138
|
-
subject.permissions = {:
|
139
|
-
subject.permissions.should == [{:
|
140
|
-
{:
|
139
|
+
subject.permissions = {new_user_name: {'user1'=>'read'}}
|
140
|
+
subject.permissions.should == [{type: "user", access: "read", name: "user1"},
|
141
|
+
{type: "user", access: "edit", name: "jcoyne"}]
|
141
142
|
end
|
142
143
|
it "should not replace existing groups" do
|
143
|
-
subject.permissions = {:
|
144
|
-
subject.permissions = {:
|
145
|
-
subject.permissions.should == [{:
|
146
|
-
{:
|
147
|
-
{:
|
144
|
+
subject.permissions = {new_group_name: {'group1' => 'read'}}
|
145
|
+
subject.permissions = {new_group_name: {'group2' => 'read'}}
|
146
|
+
subject.permissions.should == [{type: "group", access: "read", name: "group1"},
|
147
|
+
{type: "group", access: "read", name: "group2"},
|
148
|
+
{type: "user", access: "edit", name: "jcoyne"}]
|
148
149
|
end
|
149
150
|
it "should not replace existing users" do
|
150
|
-
subject.permissions = {:
|
151
|
-
subject.permissions = {:
|
152
|
-
subject.permissions.should == [{:
|
153
|
-
{:
|
154
|
-
{:
|
151
|
+
subject.permissions = {new_user_name:{'user1'=>'read'}}
|
152
|
+
subject.permissions = {new_user_name:{'user2'=>'read'}}
|
153
|
+
subject.permissions.should == [{type: "user", access: "read", name: "user1"},
|
154
|
+
{type: "user", access: "read", name: "user2"},
|
155
|
+
{type: "user", access: "edit", name: "jcoyne"}]
|
155
156
|
end
|
156
157
|
it "should update permissions on existing users" do
|
157
|
-
subject.permissions = {:
|
158
|
-
subject.permissions = {:
|
159
|
-
subject.permissions.should == [{:
|
160
|
-
{:
|
158
|
+
subject.permissions = {new_user_name:{'user1'=>'read'}}
|
159
|
+
subject.permissions = {user:{'user1'=>'edit'}}
|
160
|
+
subject.permissions.should == [{type: "user", access: "edit", name: "user1"},
|
161
|
+
{type: "user", access: "edit", name: "jcoyne"}]
|
161
162
|
end
|
162
163
|
it "should update permissions on existing groups" do
|
163
|
-
subject.permissions = {:
|
164
|
-
subject.permissions = {:
|
165
|
-
subject.permissions.should == [{:
|
166
|
-
{:
|
164
|
+
subject.permissions = {new_group_name:{'group1'=>'read'}}
|
165
|
+
subject.permissions = {group:{'group1'=>'edit'}}
|
166
|
+
subject.permissions.should == [{type: "group", access: "edit", name: "group1"},
|
167
|
+
{type: "user", access: "edit", name: "jcoyne"}]
|
167
168
|
end
|
168
169
|
end
|
169
170
|
it "should have a characterization datastream" do
|
@@ -179,41 +180,41 @@ describe GenericFile do
|
|
179
180
|
end
|
180
181
|
describe "delegations" do
|
181
182
|
it "should delegate methods to properties metadata" do
|
182
|
-
|
183
|
-
|
183
|
+
subject.should respond_to(:relative_path)
|
184
|
+
subject.should respond_to(:depositor)
|
184
185
|
end
|
185
186
|
it "should delegate methods to descriptive metadata" do
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
187
|
+
subject.should respond_to(:related_url)
|
188
|
+
subject.should respond_to(:based_near)
|
189
|
+
subject.should respond_to(:part_of)
|
190
|
+
subject.should respond_to(:contributor)
|
191
|
+
subject.should respond_to(:creator)
|
192
|
+
subject.should respond_to(:title)
|
193
|
+
subject.should respond_to(:description)
|
194
|
+
subject.should respond_to(:publisher)
|
195
|
+
subject.should respond_to(:date_created)
|
196
|
+
subject.should respond_to(:date_uploaded)
|
197
|
+
subject.should respond_to(:date_modified)
|
198
|
+
subject.should respond_to(:subject)
|
199
|
+
subject.should respond_to(:language)
|
200
|
+
subject.should respond_to(:rights)
|
201
|
+
subject.should respond_to(:resource_type)
|
202
|
+
subject.should respond_to(:identifier)
|
202
203
|
end
|
203
204
|
it "should delegate methods to characterization metadata" do
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
205
|
+
subject.should respond_to(:format_label)
|
206
|
+
subject.should respond_to(:mime_type)
|
207
|
+
subject.should respond_to(:file_size)
|
208
|
+
subject.should respond_to(:last_modified)
|
209
|
+
subject.should respond_to(:filename)
|
210
|
+
subject.should respond_to(:original_checksum)
|
211
|
+
subject.should respond_to(:well_formed)
|
212
|
+
subject.should respond_to(:file_title)
|
213
|
+
subject.should respond_to(:file_author)
|
214
|
+
subject.should respond_to(:page_count)
|
214
215
|
end
|
215
216
|
it "should redefine to_param to make redis keys more recognizable" do
|
216
|
-
|
217
|
+
subject.to_param.should == subject.noid
|
217
218
|
end
|
218
219
|
describe "that have been saved" do
|
219
220
|
# This file has no content, so it doesn't characterize
|
@@ -221,69 +222,69 @@ describe GenericFile do
|
|
221
222
|
# Sufia.queue.should_receive(:push).once
|
222
223
|
# end
|
223
224
|
after(:each) do
|
224
|
-
unless
|
225
|
+
unless subject.inner_object.class == ActiveFedora::UnsavedDigitalObject
|
225
226
|
begin
|
226
|
-
|
227
|
+
subject.delete
|
227
228
|
rescue ActiveFedora::ObjectNotFoundError
|
228
229
|
# do nothing
|
229
230
|
end
|
230
231
|
end
|
231
232
|
end
|
232
233
|
it "should have activity stream-related methods defined" do
|
233
|
-
|
234
|
-
f =
|
234
|
+
subject.save
|
235
|
+
f = subject.reload
|
235
236
|
f.should respond_to(:stream)
|
236
237
|
f.should respond_to(:events)
|
237
238
|
f.should respond_to(:create_event)
|
238
239
|
f.should respond_to(:log_event)
|
239
240
|
end
|
240
241
|
it "should be able to set values via delegated methods" do
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
f =
|
242
|
+
subject.related_url = "http://example.org/"
|
243
|
+
subject.creator = "John Doe"
|
244
|
+
subject.title = "New work"
|
245
|
+
subject.save
|
246
|
+
f = subject.reload
|
246
247
|
f.related_url.should == ["http://example.org/"]
|
247
248
|
f.creator.should == ["John Doe"]
|
248
249
|
f.title.should == ["New work"]
|
249
250
|
end
|
250
251
|
it "should be able to be added to w/o unexpected graph behavior" do
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
f =
|
252
|
+
subject.creator = "John Doe"
|
253
|
+
subject.title = "New work"
|
254
|
+
subject.save
|
255
|
+
f = subject.reload
|
255
256
|
f.creator.should == ["John Doe"]
|
256
257
|
f.title.should == ["New work"]
|
257
258
|
f.creator = "Jane Doe"
|
258
259
|
f.title << "Newer work"
|
259
260
|
f.save
|
260
|
-
f =
|
261
|
+
f = subject.reload
|
261
262
|
f.creator.should == ["Jane Doe"]
|
262
263
|
f.title.should == ["New work", "Newer work"]
|
263
264
|
end
|
264
265
|
end
|
265
266
|
end
|
266
|
-
it "
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
local =
|
267
|
+
it "supports to_solr" do
|
268
|
+
allow(subject).to receive(:pid).and_return('stubbed_pid')
|
269
|
+
subject.part_of = "Arabiana"
|
270
|
+
subject.contributor = "Mohammad"
|
271
|
+
subject.creator = "Allah"
|
272
|
+
subject.title = "The Work"
|
273
|
+
subject.description = "The work by Allah"
|
274
|
+
subject.publisher = "Vertigo Comics"
|
275
|
+
subject.date_created = "1200-01-01"
|
276
|
+
subject.date_uploaded = Date.parse("2011-01-01")
|
277
|
+
subject.date_modified = Date.parse("2012-01-01")
|
278
|
+
subject.subject = "Theology"
|
279
|
+
subject.language = "Arabic"
|
280
|
+
subject.rights = "Wide open, buddy."
|
281
|
+
subject.resource_type = "Book"
|
282
|
+
subject.identifier = "urn:isbn:1234567890"
|
283
|
+
subject.based_near = "Medina, Saudi Arabia"
|
284
|
+
subject.related_url = "http://example.org/TheWork/"
|
285
|
+
subject.mime_type = "image/jpeg"
|
286
|
+
subject.format_label = "JPEG Image"
|
287
|
+
local = subject.to_solr
|
287
288
|
local.should_not be_nil
|
288
289
|
local[Solrizer.solr_name("desc_metadata__part_of")].should be_nil
|
289
290
|
local[Solrizer.solr_name("desc_metadata__date_uploaded")].should be_nil
|
@@ -308,26 +309,25 @@ describe GenericFile do
|
|
308
309
|
local["noid_tsi"].should eq('stubbed_pid')
|
309
310
|
end
|
310
311
|
it "should support multi-valued fields in solr" do
|
311
|
-
|
312
|
-
lambda {
|
313
|
-
|
312
|
+
subject.tag = ["tag1", "tag2"]
|
313
|
+
lambda { subject.save }.should_not raise_error
|
314
|
+
subject.delete
|
314
315
|
end
|
315
316
|
it "should support setting and getting the relative_path value" do
|
316
|
-
|
317
|
-
|
317
|
+
subject.relative_path = "documents/research/NSF/2010"
|
318
|
+
subject.relative_path.should == "documents/research/NSF/2010"
|
318
319
|
end
|
319
320
|
describe "create_thumbnail" do
|
320
321
|
before do
|
321
322
|
@f = GenericFile.new
|
322
|
-
#@f.stub(:characterize_if_changed).and_yield #don't run characterization
|
323
323
|
@f.apply_depositor_metadata('mjg36')
|
324
324
|
end
|
325
325
|
after do
|
326
326
|
@f.delete
|
327
327
|
end
|
328
|
-
describe "with a video", :
|
328
|
+
describe "with a video", if: Sufia.config.enable_ffmpeg do
|
329
329
|
before do
|
330
|
-
@f.stub(:
|
330
|
+
@f.stub(mime_type: 'video/quicktime') #Would get set by the characterization job
|
331
331
|
@f.add_file(File.open("#{fixture_path}/countdown.avi", 'rb'), 'content', 'countdown.avi')
|
332
332
|
@f.save
|
333
333
|
end
|
@@ -343,7 +343,6 @@ describe GenericFile do
|
|
343
343
|
u = FactoryGirl.create(:jill)
|
344
344
|
@f = GenericFile.new.tap do |gf|
|
345
345
|
gf.apply_depositor_metadata(u)
|
346
|
-
gf.stub(:characterize_if_changed).and_yield #don't run characterization
|
347
346
|
gf.save!
|
348
347
|
end
|
349
348
|
@t = Trophy.create(user_id: u.id, generic_file_id: @f.pid)
|
@@ -364,7 +363,6 @@ describe GenericFile do
|
|
364
363
|
f = GenericFile.new
|
365
364
|
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
366
365
|
f.apply_depositor_metadata(u)
|
367
|
-
f.stub(:characterize_if_changed).and_yield #don't run characterization
|
368
366
|
f.save!
|
369
367
|
@f = f.reload
|
370
368
|
end
|
@@ -391,12 +389,12 @@ describe GenericFile do
|
|
391
389
|
end
|
392
390
|
it "should log a failing audit" do
|
393
391
|
@f.datastreams.each { |ds| ds.stub(:dsChecksumValid).and_return(false) }
|
394
|
-
GenericFile.stub(:run_audit).and_return(double(:respose, :
|
392
|
+
GenericFile.stub(:run_audit).and_return(double(:respose, pass:1, created_at: '2005-12-20', pid: 'foo:123', dsid: 'foo', version: '1'))
|
395
393
|
@f.audit!
|
396
394
|
ChecksumAuditLog.all.all? { |cal| cal.pass == 0 }.should be_true
|
397
395
|
end
|
398
396
|
it "should log a passing audit" do
|
399
|
-
GenericFile.stub(:run_audit).and_return(double(:respose, :
|
397
|
+
GenericFile.stub(:run_audit).and_return(double(:respose, pass:1, created_at: '2005-12-20', pid: 'foo:123', dsid: 'foo', version: '1'))
|
400
398
|
@f.audit!
|
401
399
|
ChecksumAuditLog.all.all? { |cal| cal.pass == 1 }.should be_true
|
402
400
|
end
|
@@ -411,11 +409,10 @@ describe GenericFile do
|
|
411
409
|
@f = GenericFile.new
|
412
410
|
@f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
413
411
|
@f.apply_depositor_metadata('mjg36')
|
414
|
-
@f.stub(:characterize_if_changed).and_yield #don't run characterization
|
415
412
|
@f.save!
|
416
413
|
@version = @f.datastreams['content'].versions.first
|
417
|
-
@old = ChecksumAuditLog.create(:
|
418
|
-
@new = ChecksumAuditLog.create(:
|
414
|
+
@old = ChecksumAuditLog.create(pid: @f.pid, dsid: @version.dsid, version: @version.versionID, pass: 1, created_at: 2.minutes.ago)
|
415
|
+
@new = ChecksumAuditLog.create(pid: @f.pid, dsid: @version.dsid, version: @version.versionID, pass: 0)
|
419
416
|
end
|
420
417
|
it "should not prune failed audits" do
|
421
418
|
@version.should_receive(:dsChecksumValid).and_return(true)
|
@@ -438,16 +435,6 @@ describe GenericFile do
|
|
438
435
|
|
439
436
|
end
|
440
437
|
|
441
|
-
describe "save" do
|
442
|
-
after(:each) do
|
443
|
-
@file.delete
|
444
|
-
end
|
445
|
-
it "should schedule a characterization job" do
|
446
|
-
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
447
|
-
Sufia.queue.should_receive(:push).once
|
448
|
-
@file.save
|
449
|
-
end
|
450
|
-
end
|
451
438
|
describe "related_files" do
|
452
439
|
let(:batch_id) { "foobar:100" }
|
453
440
|
before(:each) do
|
@@ -485,8 +472,7 @@ describe GenericFile do
|
|
485
472
|
end
|
486
473
|
describe "noid integration" do
|
487
474
|
before(:all) do
|
488
|
-
GenericFile.
|
489
|
-
@new_file = GenericFile.new(:pid => 'ns:123')
|
475
|
+
@new_file = GenericFile.new(pid: 'ns:123')
|
490
476
|
@new_file.apply_depositor_metadata('mjg36')
|
491
477
|
@new_file.save
|
492
478
|
end
|
@@ -506,31 +492,19 @@ describe GenericFile do
|
|
506
492
|
end
|
507
493
|
end
|
508
494
|
describe "characterize" do
|
509
|
-
it "should return expected results when called", :
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
# enqueued a job for characterizing
|
514
|
-
@file.stub(:save)
|
515
|
-
@file.characterize
|
516
|
-
doc = Nokogiri::XML.parse(@file.characterization.content)
|
495
|
+
it "should return expected results when called", unless: $in_travis do
|
496
|
+
subject.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
497
|
+
subject.characterize
|
498
|
+
doc = Nokogiri::XML.parse(subject.characterization.content)
|
517
499
|
doc.root.xpath('//ns:imageWidth/text()', {'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output'}).inner_text.should == '50'
|
518
500
|
end
|
519
|
-
|
520
|
-
Sufia.queue.should_receive(:push).once
|
521
|
-
@file.content.content = "hey"
|
522
|
-
@file.save
|
523
|
-
@file.related_url = 'http://example.com'
|
524
|
-
Sufia.queue.should_receive(:push).never
|
525
|
-
@file.save
|
526
|
-
@file.delete
|
527
|
-
end
|
528
|
-
describe "after job runs" do
|
501
|
+
context "after characterization" do
|
529
502
|
before(:all) do
|
530
503
|
myfile = GenericFile.new
|
531
|
-
myfile.add_file(File.open(fixture_path + '/sufia/sufia_test4.pdf'), 'content', 'sufia_test4.pdf')
|
504
|
+
myfile.add_file(File.open(fixture_path + '/sufia/sufia_test4.pdf', 'rb').read, 'content', 'sufia_test4.pdf')
|
532
505
|
myfile.label = 'label123'
|
533
506
|
myfile.apply_depositor_metadata('mjg36')
|
507
|
+
myfile.characterize
|
534
508
|
myfile.save
|
535
509
|
@myfile = myfile.reload
|
536
510
|
end
|
@@ -553,9 +527,7 @@ describe GenericFile do
|
|
553
527
|
@myfile.title.should include("Microsoft Word - sample.pdf.docx")
|
554
528
|
@myfile.filename[0].should == @myfile.label
|
555
529
|
end
|
556
|
-
|
557
|
-
@myfile.thumbnail.size.should_not be_nil
|
558
|
-
end
|
530
|
+
|
559
531
|
it "should append each term only once" do
|
560
532
|
@myfile.append_metadata
|
561
533
|
@myfile.format_label.should == ["Portable Document Format"]
|
@@ -565,8 +537,8 @@ describe GenericFile do
|
|
565
537
|
end
|
566
538
|
describe "label" do
|
567
539
|
it "should set the inner label" do
|
568
|
-
|
569
|
-
|
540
|
+
subject.label = "My New Label"
|
541
|
+
subject.inner_object.label.should == "My New Label"
|
570
542
|
end
|
571
543
|
end
|
572
544
|
context "with rightsMetadata" do
|
@@ -636,7 +608,7 @@ describe GenericFile do
|
|
636
608
|
RIGHTS
|
637
609
|
end
|
638
610
|
it "should work via permissions=()" do
|
639
|
-
@file.permissions = {:
|
611
|
+
@file.permissions = {user: {'mjg36' => 'read'}}
|
640
612
|
lambda { @file.save }.should_not raise_error
|
641
613
|
@file.new_record?.should be_true
|
642
614
|
@file.errors.should include(:edit_users)
|
@@ -645,7 +617,7 @@ describe GenericFile do
|
|
645
617
|
end
|
646
618
|
it "should work via update_attributes" do
|
647
619
|
# automatically triggers save
|
648
|
-
lambda { @file.update_attributes(:
|
620
|
+
lambda { @file.update_attributes(read_users_string: 'mjg36') }.should_not raise_error
|
649
621
|
@file.new_record?.should be_true
|
650
622
|
@file.errors.should include(:edit_users)
|
651
623
|
@file.errors[:edit_users].should include('Depositor must have edit access')
|
@@ -660,7 +632,7 @@ describe GenericFile do
|
|
660
632
|
@file.valid?.should be_false
|
661
633
|
end
|
662
634
|
it "should work via permissions()" do
|
663
|
-
@rightsmd.permissions({:
|
635
|
+
@rightsmd.permissions({person: "mjg36"}, "read")
|
664
636
|
lambda { @file.save }.should_not raise_error
|
665
637
|
@file.new_record?.should be_true
|
666
638
|
@file.errors.should include(:edit_users)
|
@@ -736,7 +708,7 @@ describe GenericFile do
|
|
736
708
|
RIGHTS
|
737
709
|
end
|
738
710
|
it "should work via permissions=()" do
|
739
|
-
@file.permissions = {:
|
711
|
+
@file.permissions = {group: {'public' => 'edit'}}
|
740
712
|
lambda { @file.save }.should_not raise_error
|
741
713
|
@file.new_record?.should be_true
|
742
714
|
@file.errors.should include(:edit_groups)
|
@@ -745,7 +717,7 @@ describe GenericFile do
|
|
745
717
|
end
|
746
718
|
it "should work via update_attributes" do
|
747
719
|
# automatically triggers save
|
748
|
-
lambda { @file.update_attributes(:
|
720
|
+
lambda { @file.update_attributes(edit_groups_string: 'public') }.should_not raise_error
|
749
721
|
@file.new_record?.should be_true
|
750
722
|
@file.errors.should include(:edit_groups)
|
751
723
|
@file.errors[:edit_groups].should include('Public cannot have edit access')
|
@@ -760,7 +732,7 @@ describe GenericFile do
|
|
760
732
|
@file.valid?.should be_false
|
761
733
|
end
|
762
734
|
it "should work via permissions()" do
|
763
|
-
@rightsmd.permissions({:
|
735
|
+
@rightsmd.permissions({group: "public"}, "edit")
|
764
736
|
lambda { @file.save }.should_not raise_error
|
765
737
|
@file.new_record?.should be_true
|
766
738
|
@file.errors.should include(:edit_groups)
|
@@ -836,7 +808,7 @@ describe GenericFile do
|
|
836
808
|
RIGHTS
|
837
809
|
end
|
838
810
|
it "should work via permissions=()" do
|
839
|
-
@file.permissions = {:
|
811
|
+
@file.permissions = {group: {'registered' => 'edit'}}
|
840
812
|
lambda { @file.save }.should_not raise_error
|
841
813
|
@file.new_record?.should be_true
|
842
814
|
@file.errors.should include(:edit_groups)
|
@@ -845,7 +817,7 @@ describe GenericFile do
|
|
845
817
|
end
|
846
818
|
it "should work via update_attributes" do
|
847
819
|
# automatically triggers save
|
848
|
-
lambda { @file.update_attributes(:
|
820
|
+
lambda { @file.update_attributes(edit_groups_string: 'registered') }.should_not raise_error
|
849
821
|
@file.new_record?.should be_true
|
850
822
|
@file.errors.should include(:edit_groups)
|
851
823
|
@file.errors[:edit_groups].should include('Registered cannot have edit access')
|
@@ -860,7 +832,7 @@ describe GenericFile do
|
|
860
832
|
@file.valid?.should be_false
|
861
833
|
end
|
862
834
|
it "should work via permissions()" do
|
863
|
-
@rightsmd.permissions({:
|
835
|
+
@rightsmd.permissions({group: "registered"}, "edit")
|
864
836
|
lambda { @file.save }.should_not raise_error
|
865
837
|
@file.new_record?.should be_true
|
866
838
|
@file.errors.should include(:edit_groups)
|
@@ -938,7 +910,7 @@ describe GenericFile do
|
|
938
910
|
RIGHTS
|
939
911
|
end
|
940
912
|
it "should work via permissions=()" do
|
941
|
-
@file.permissions = {:
|
913
|
+
@file.permissions = {group: {'registered' => 'read'}}
|
942
914
|
lambda { @file.save }.should_not raise_error
|
943
915
|
@file.new_record?.should be_false
|
944
916
|
@file.errors.should be_empty
|
@@ -946,7 +918,7 @@ describe GenericFile do
|
|
946
918
|
end
|
947
919
|
it "should work via update_attributes" do
|
948
920
|
# automatically triggers save
|
949
|
-
lambda { @file.update_attributes(:
|
921
|
+
lambda { @file.update_attributes(read_groups_string: 'registered') }.should_not raise_error
|
950
922
|
@file.new_record?.should be_false
|
951
923
|
@file.errors.should be_empty
|
952
924
|
@file.valid?.should be_true
|
@@ -959,7 +931,7 @@ describe GenericFile do
|
|
959
931
|
@file.valid?.should be_true
|
960
932
|
end
|
961
933
|
it "should work via permissions()" do
|
962
|
-
@rightsmd.permissions({:
|
934
|
+
@rightsmd.permissions({group: "registered"}, "read")
|
963
935
|
lambda { @file.save }.should_not raise_error
|
964
936
|
@file.new_record?.should be_false
|
965
937
|
@file.errors.should be_empty
|
@@ -996,25 +968,22 @@ describe GenericFile do
|
|
996
968
|
end
|
997
969
|
end
|
998
970
|
describe "file content validation" do
|
999
|
-
before do
|
1000
|
-
GenericFile.any_instance.stub(:create_derivatives)
|
1001
|
-
end
|
1002
971
|
context "when file contains a virus" do
|
1003
972
|
let(:f) { File.new(fixture_path + '/small_file.txt') }
|
1004
973
|
after(:each) do
|
1005
974
|
subject.destroy if subject.persisted?
|
1006
975
|
end
|
1007
976
|
it "populates the errors hash during validation" do
|
1008
|
-
allow(Sufia::GenericFile::
|
977
|
+
allow(Sufia::GenericFile::Actor).to receive(:virus_check).and_raise(Sufia::VirusFoundError, "A virus was found in #{f.path}: EL CRAPO VIRUS")
|
1009
978
|
subject.add_file(f, 'content', 'small_file.txt')
|
1010
979
|
subject.save
|
1011
980
|
subject.should_not be_persisted
|
1012
|
-
subject.errors.messages.
|
981
|
+
expect(subject.errors.messages).to eq(base: ["A virus was found in #{f.path}: EL CRAPO VIRUS"])
|
1013
982
|
end
|
1014
983
|
it "does not save a new version of a GenericFile" do
|
1015
984
|
subject.add_file(f, 'content', 'small_file.txt')
|
1016
985
|
subject.save
|
1017
|
-
allow(Sufia::GenericFile::
|
986
|
+
allow(Sufia::GenericFile::Actor).to receive(:virus_check).and_raise(Sufia::VirusFoundError)
|
1018
987
|
subject.add_file(File.new(fixture_path + '/sufia_generic_stub.txt') , 'content', 'sufia_generic_stub.txt')
|
1019
988
|
subject.save
|
1020
989
|
subject.reload.content.content.should == "small\n"
|
@@ -1045,4 +1014,17 @@ describe GenericFile do
|
|
1045
1014
|
expect(f2.to_solr[title_key]).to eq(f2.title)
|
1046
1015
|
end
|
1047
1016
|
end
|
1017
|
+
|
1018
|
+
describe "public?" do
|
1019
|
+
it "is true when read group is set to public" do
|
1020
|
+
subject.read_groups = ['public']
|
1021
|
+
expect(subject.public?).to be_true
|
1022
|
+
end
|
1023
|
+
|
1024
|
+
it "is false when read group is not set to public" do
|
1025
|
+
subject.read_groups = ['foo']
|
1026
|
+
expect(subject.public?).to be_false
|
1027
|
+
end
|
1028
|
+
|
1029
|
+
end
|
1048
1030
|
end
|