sufia 6.0.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -5
- data/CONTRIBUTING.md +4 -4
- data/Gemfile +2 -1
- data/History.md +69 -0
- data/README.md +84 -4
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/zotero.png +0 -0
- data/app/assets/javascripts/sufia/featured_works.js +20 -3
- data/app/assets/stylesheets/generic_files.css.erb +2 -2
- data/app/assets/stylesheets/sufia.css.scss +2 -2
- data/app/assets/stylesheets/sufia/_buttons.scss +2 -2
- data/app/assets/stylesheets/sufia/_collections.scss +4 -4
- data/app/assets/stylesheets/sufia/_dashboard.scss +1 -1
- data/app/assets/stylesheets/sufia/_file-listing.scss +3 -0
- data/app/assets/stylesheets/sufia/_modal.scss +4 -0
- data/app/assets/stylesheets/sufia/_settings.scss +4 -3
- data/app/assets/stylesheets/sufia/_styles.scss +4 -0
- data/app/controllers/admin/stats_controller.rb +68 -0
- data/app/controllers/api/items_controller.rb +78 -0
- data/app/controllers/api/zotero_controller.rb +70 -0
- data/app/controllers/authorities_controller.rb +6 -5
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +2 -1
- data/app/controllers/concerns/sufia/breadcrumbs.rb +1 -1
- data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +11 -0
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +23 -11
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +1 -7
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +1 -2
- data/app/controllers/my/collections_controller.rb +1 -0
- data/app/controllers/my/files_controller.rb +1 -1
- data/app/helpers/sufia/sufia_helper_behavior.rb +28 -16
- data/app/models/my_search_builder.rb +4 -0
- data/app/search_builders/sufia/my_search_builder_behavior.rb +20 -0
- data/app/search_builders/sufia/search_builder.rb +1 -1
- data/app/views/admin/stats/index.html.erb +68 -0
- data/app/views/collections/_action_menu.html.erb +22 -20
- data/app/views/collections/_collection.html.erb +1 -1
- data/app/views/collections/_form_for_select_collection.html.erb +5 -3
- data/app/views/generic_files/_show_actions.html.erb +4 -2
- data/app/views/generic_files/show.html.erb +1 -1
- data/app/views/layouts/sufia-dashboard.html.erb +5 -4
- data/app/views/layouts/sufia-one-column.html.erb +2 -0
- data/app/views/layouts/sufia-two-column.html.erb +6 -4
- data/app/views/my/_facet_layout.html.erb +2 -2
- data/app/views/my/_facets.html.erb +4 -6
- data/app/views/my/index.html.erb +4 -3
- data/app/views/users/_edit_primary.html.erb +18 -17
- data/app/views/users/_follower_modal.html.erb +5 -1
- data/app/views/users/_following_modal.html.erb +5 -1
- data/app/views/users/_user_info.html.erb +6 -1
- data/app/views/users/_zotero.html.erb +12 -0
- data/config/locales/sufia.en.yml +10 -1
- data/config/routes.rb +23 -1
- data/lib/generators/sufia/admin_stat_generator.rb +17 -0
- data/lib/generators/sufia/install_generator.rb +8 -3
- data/{sufia-models/lib/generators/sufia/models/templates/config/resque_admin.rb → lib/generators/sufia/templates/sufia/stats_admin.rb} +3 -3
- data/lib/generators/sufia/upgrade400_generator.rb +2 -2
- data/lib/sufia.rb +3 -0
- data/lib/sufia/arkivo.rb +11 -0
- data/lib/sufia/arkivo/actor.rb +95 -0
- data/lib/sufia/arkivo/config.rb +11 -0
- data/lib/sufia/arkivo/create_subscription_job.rb +67 -0
- data/lib/sufia/arkivo/metadata_munger.rb +51 -0
- data/lib/sufia/arkivo/schema_validator.rb +55 -0
- data/lib/sufia/form_builder.rb +1 -1
- data/lib/sufia/inflections.rb +3 -0
- data/lib/sufia/version.rb +1 -1
- data/lib/sufia/zotero.rb +6 -0
- data/lib/sufia/zotero/config.rb +15 -0
- data/solr_conf/conf/solrconfig.xml +11 -0
- data/spec/controllers/admin_stats_controller_spec.rb +73 -0
- data/spec/controllers/api/items_controller_spec.rb +476 -0
- data/spec/controllers/api/zotero_controller_spec.rb +178 -0
- data/spec/controllers/batch_edits_controller_spec.rb +7 -0
- data/spec/controllers/collections_controller_spec.rb +1 -1
- data/spec/controllers/dashboard_controller_spec.rb +1 -1
- data/spec/controllers/depositors_controller_spec.rb +9 -5
- data/spec/controllers/generic_files_controller_spec.rb +5 -4
- data/spec/controllers/mailbox_controller_spec.rb +2 -2
- data/spec/controllers/my/collections_controller_spec.rb +1 -2
- data/spec/controllers/my/files_controller_spec.rb +5 -5
- data/spec/controllers/my/shares_controller_spec.rb +15 -3
- data/spec/controllers/pages_controller_spec.rb +1 -1
- data/spec/controllers/users_controller_spec.rb +10 -9
- data/spec/factories/api_items.rb +91 -0
- data/spec/factories/generic_files.rb +4 -0
- data/spec/factories/users.rb +4 -4
- data/spec/features/featured_item_spec.rb +26 -0
- data/spec/features/ingest_upload_files_spec.rb +2 -3
- data/spec/features/proxy_spec.rb +0 -1
- data/spec/helpers/permissions_helper_spec.rb +2 -2
- data/spec/helpers/sufia_helper_spec.rb +11 -5
- data/spec/inputs/select_with_help_input_spec.rb +2 -2
- data/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/javascripts/helpers/jasmine-jquery.js +832 -0
- data/spec/javascripts/jasmine_spec.rb +31 -0
- data/spec/javascripts/notify_update_link_spec.js +8 -0
- data/spec/javascripts/single_use_link_spec.js.coffee +23 -0
- data/spec/javascripts/support/jasmine.yml +124 -0
- data/spec/javascripts/support/jasmine_helper.rb +15 -0
- data/spec/javascripts/terms_of_service_spec.js.coffee +32 -0
- data/spec/javascripts/toggle_icon_spec.js +11 -0
- data/spec/jobs/active_fedora_id_based_job_spec.rb +3 -3
- data/spec/jobs/import_url_job_spec.rb +0 -2
- data/spec/lib/sufia/arkivo/actor_spec.rb +139 -0
- data/spec/lib/sufia/arkivo/create_subscription_job_spec.rb +54 -0
- data/spec/lib/sufia/arkivo/metadata_munger_spec.rb +48 -0
- data/spec/lib/sufia/arkivo/schema_validator_spec.rb +65 -0
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +1 -1
- data/spec/lib/sufia/user_stat_importer_spec.rb +60 -0
- data/spec/lib/sufia/zotero/config_spec.rb +30 -0
- data/spec/models/collection_spec.rb +36 -7
- data/spec/models/file_download_stat_spec.rb +5 -5
- data/spec/models/file_usage_spec.rb +23 -0
- data/spec/models/file_view_stat_spec.rb +6 -6
- data/spec/models/fits_datastream_spec.rb +0 -5
- data/spec/models/generic_file_spec.rb +49 -14
- data/spec/models/local_authority_spec.rb +1 -1
- data/spec/models/proxy_deposit_request_spec.rb +1 -1
- data/spec/models/trophy_spec.rb +8 -8
- data/spec/models/user_spec.rb +33 -0
- data/spec/presenters/sufia/collection_presenter_spec.rb +1 -1
- data/spec/routing/api_route_spec.rb +91 -0
- data/spec/routing/route_spec.rb +1 -1
- data/spec/services/generic_file_audit_service_spec.rb +44 -8
- data/spec/spec_helper.rb +18 -3
- data/spec/support/features.rb +0 -2
- data/spec/support/locations.rb +0 -21
- data/spec/support/rake.rb +41 -0
- data/spec/support/selectors.rb +0 -50
- data/spec/tasks/rake_spec.rb +33 -12
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -0
- data/spec/views/admin/stats/index.html.erb_spec.rb +45 -0
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +0 -1
- data/spec/views/dashboard/index_spec.rb +1 -1
- data/spec/views/generic_file/edit.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/show.html.erb_spec.rb +1 -3
- data/spec/views/users/_follower_modal.html.erb_spec.rb +44 -7
- data/spec/views/users/_following_modal.html.erb_spec.rb +49 -7
- data/spec/views/users/edit.html.erb_spec.rb +72 -0
- data/spec/views/users/show.html.erb_spec.rb +1 -1
- data/sufia.gemspec +6 -2
- data/tasks/sufia-user.rake +14 -0
- metadata +130 -156
- data/spec/lib/sufia/id_service_spec.rb +0 -32
- data/spec/services/noid_spec.rb +0 -9
- data/spec/support/poltergeist.rb +0 -11
- data/spec/support/rake_output.rb +0 -20
- data/sufia-models/.gitignore +0 -17
- data/sufia-models/Gemfile +0 -4
- data/sufia-models/LICENSE.md +0 -177
- data/sufia-models/README.md +0 -39
- data/sufia-models/Rakefile +0 -1
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +0 -137
- data/sufia-models/app/jobs/active_fedora_id_based_job.rb +0 -22
- data/sufia-models/app/jobs/active_fedora_pid_based_job.rb +0 -7
- data/sufia-models/app/jobs/audit_job.rb +0 -62
- data/sufia-models/app/jobs/batch_update_job.rb +0 -72
- data/sufia-models/app/jobs/characterize_job.rb +0 -10
- data/sufia-models/app/jobs/create_derivatives_job.rb +0 -14
- data/sufia-models/app/jobs/import_url_job.rb +0 -52
- data/sufia-models/app/jobs/ingest_local_file_job.rb +0 -46
- data/sufia-models/app/jobs/resolrize_job.rb +0 -9
- data/sufia-models/app/models/batch.rb +0 -36
- data/sufia-models/app/models/checksum_audit_log.rb +0 -21
- data/sufia-models/app/models/concerns/sufia/ability.rb +0 -61
- data/sufia-models/app/models/concerns/sufia/collection_behavior.rb +0 -24
- data/sufia-models/app/models/concerns/sufia/file_stat_utils.rb +0 -35
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +0 -25
- data/sufia-models/app/models/concerns/sufia/generic_file/batches.rb +0 -28
- data/sufia-models/app/models/concerns/sufia/generic_file/characterization.rb +0 -89
- data/sufia-models/app/models/concerns/sufia/generic_file/content.rb +0 -13
- data/sufia-models/app/models/concerns/sufia/generic_file/derivatives.rb +0 -26
- data/sufia-models/app/models/concerns/sufia/generic_file/export.rb +0 -343
- data/sufia-models/app/models/concerns/sufia/generic_file/featured.rb +0 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +0 -43
- data/sufia-models/app/models/concerns/sufia/generic_file/indexing.rb +0 -14
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +0 -98
- data/sufia-models/app/models/concerns/sufia/generic_file/mime_types.rb +0 -69
- data/sufia-models/app/models/concerns/sufia/generic_file/permissions.rb +0 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb +0 -31
- data/sufia-models/app/models/concerns/sufia/generic_file/trophies.rb +0 -14
- data/sufia-models/app/models/concerns/sufia/generic_file/versions.rb +0 -16
- data/sufia-models/app/models/concerns/sufia/generic_file/virus_check.rb +0 -37
- data/sufia-models/app/models/concerns/sufia/model_methods.rb +0 -20
- data/sufia-models/app/models/concerns/sufia/user.rb +0 -137
- data/sufia-models/app/models/concerns/sufia/user_usage_stats.rb +0 -15
- data/sufia-models/app/models/datastreams/file_content_datastream.rb +0 -4
- data/sufia-models/app/models/datastreams/fits_datastream.rb +0 -152
- data/sufia-models/app/models/domain_term.rb +0 -5
- data/sufia-models/app/models/featured_work.rb +0 -22
- data/sufia-models/app/models/file_download_stat.rb +0 -18
- data/sufia-models/app/models/file_usage.rb +0 -34
- data/sufia-models/app/models/file_view_stat.rb +0 -18
- data/sufia-models/app/models/follow.rb +0 -12
- data/sufia-models/app/models/generic_file.rb +0 -3
- data/sufia-models/app/models/geo_names_resource.rb +0 -18
- data/sufia-models/app/models/group.rb +0 -8
- data/sufia-models/app/models/local_authority.rb +0 -86
- data/sufia-models/app/models/local_authority_entry.rb +0 -3
- data/sufia-models/app/models/proxy_deposit_request.rb +0 -85
- data/sufia-models/app/models/proxy_deposit_rights.rb +0 -4
- data/sufia-models/app/models/single_use_link.rb +0 -42
- data/sufia-models/app/models/subject_local_authority_entry.rb +0 -2
- data/sufia-models/app/models/sufia/avatar_uploader.rb +0 -20
- data/sufia-models/app/models/sufia/avatar_validator.rb +0 -8
- data/sufia-models/app/models/sufia/collection.rb +0 -5
- data/sufia-models/app/models/sufia/download.rb +0 -9
- data/sufia-models/app/models/sufia/orcid_validator.rb +0 -12
- data/sufia-models/app/models/sufia/pageview.rb +0 -9
- data/sufia-models/app/models/trophy.rb +0 -10
- data/sufia-models/app/models/user_stat.rb +0 -2
- data/sufia-models/app/models/version_committer.rb +0 -2
- data/sufia-models/app/services/sufia/analytics.rb +0 -50
- data/sufia-models/app/services/sufia/generic_file_audit_service.rb +0 -83
- data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +0 -12
- data/sufia-models/app/services/sufia/id_service.rb +0 -45
- data/sufia-models/app/services/sufia/noid.rb +0 -22
- data/sufia-models/app/services/sufia/repository_audit_service.rb +0 -9
- data/sufia-models/config/locales/sufia.en.yml +0 -6
- data/sufia-models/lib/generators/sufia/models/abstract_migration_generator.rb +0 -30
- data/sufia-models/lib/generators/sufia/models/cached_stats_generator.rb +0 -24
- data/sufia-models/lib/generators/sufia/models/fulltext_generator.rb +0 -27
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +0 -106
- data/sufia-models/lib/generators/sufia/models/orcid_field_generator.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/proxies_generator.rb +0 -24
- data/sufia-models/lib/generators/sufia/models/templates/app/models/collection.rb +0 -2
- data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +0 -9
- data/sufia-models/lib/generators/sufia/models/templates/config/clamav.rb +0 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/mailboxer.rb +0 -17
- data/sufia-models/lib/generators/sufia/models/templates/config/mime_types.rb +0 -6
- data/sufia-models/lib/generators/sufia/models/templates/config/redis.yml +0 -9
- data/sufia-models/lib/generators/sufia/models/templates/config/redis_config.rb +0 -32
- data/sufia-models/lib/generators/sufia/models/templates/config/resque-pool.yml +0 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/resque_config.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/config/setup_mail.rb +0 -3
- data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +0 -223
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +0 -144
- data/sufia-models/lib/generators/sufia/models/templates/migrations/acts_as_follower_migration.rb +0 -17
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_avatars_to_users.rb +0 -15
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_external_key_to_content_blocks.rb +0 -6
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_groups_to_users.rb +0 -11
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_ldap_attrs_to_user.rb +0 -27
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_linkedin_to_users.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_orcid_to_users.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_social_to_users.rb +0 -13
- data/sufia-models/lib/generators/sufia/models/templates/migrations/change_audit_log_pid_to_generic_file_id.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/change_proxy_deposit_request_pid_to_generic_file_id.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_checksum_audit_logs.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_content_blocks.rb +0 -10
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_featured_works.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_file_download_stats.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_file_view_stats.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb +0 -50
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_requests.rb +0 -16
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_rights.rb +0 -11
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_single_use_links.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_tinymce_assets.rb +0 -8
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_trophies.rb +0 -10
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_user_stats.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_version_committers.rb +0 -15
- data/sufia-models/lib/generators/sufia/models/update_content_blocks_generator.rb +0 -18
- data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +0 -54
- data/sufia-models/lib/generators/sufia/models/upgrade600_generator.rb +0 -21
- data/sufia-models/lib/generators/sufia/models/usagestats_generator.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/user_stats_generator.rb +0 -31
- data/sufia-models/lib/sufia/messages.rb +0 -66
- data/sufia-models/lib/sufia/models.rb +0 -34
- data/sufia-models/lib/sufia/models/active_fedora/redis.rb +0 -43
- data/sufia-models/lib/sufia/models/active_record/redis.rb +0 -56
- data/sufia-models/lib/sufia/models/engine.rb +0 -79
- data/sufia-models/lib/sufia/models/file_content.rb +0 -6
- data/sufia-models/lib/sufia/models/file_content/versions.rb +0 -21
- data/sufia-models/lib/sufia/models/resque.rb +0 -36
- data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +0 -108
- data/sufia-models/lib/sufia/models/user_local_directory_behavior.rb +0 -29
- data/sufia-models/lib/sufia/models/utils.rb +0 -22
- data/sufia-models/lib/sufia/models/version.rb +0 -5
- data/sufia-models/lib/sufia/models/virus_found_error.rb +0 -4
- data/sufia-models/lib/sufia/permissions.rb +0 -9
- data/sufia-models/lib/sufia/permissions/readable.rb +0 -20
- data/sufia-models/lib/sufia/permissions/writable.rb +0 -74
- data/sufia-models/lib/tasks/batch_cleanup.rake +0 -19
- data/sufia-models/lib/tasks/migrate.rake +0 -21
- data/sufia-models/lib/tasks/resque.rake +0 -13
- data/sufia-models/lib/tasks/stats_tasks.rake +0 -12
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +0 -80
- data/sufia-models/sufia-models.gemspec +0 -52
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Arkivo::MetadataMunger do
|
4
|
+
subject { described_class.new(metadata) }
|
5
|
+
|
6
|
+
let(:metadata) { JSON.parse(FactoryGirl.json(:post_item))['metadata'] }
|
7
|
+
|
8
|
+
it 'makes camelCase symbols into underscored strings' do
|
9
|
+
expect(metadata).to include('resourceType', 'dateCreated', 'basedNear')
|
10
|
+
munged = subject.call
|
11
|
+
expect(munged).not_to include('resourceType', 'dateCreated', 'basedNear')
|
12
|
+
expect(munged).to include('resource_type', 'date_created', 'based_near')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'replaces url with related_url' do
|
16
|
+
expect(metadata).to include('url')
|
17
|
+
munged = subject.call
|
18
|
+
expect(munged).not_to include('url')
|
19
|
+
expect(munged).to include('related_url')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'replaces tags with tag' do
|
23
|
+
expect(metadata).to include('tags')
|
24
|
+
munged = subject.call
|
25
|
+
expect(munged).not_to include('tags')
|
26
|
+
expect(munged).to include('tag')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'replaces firstName and lastName with name' do
|
30
|
+
expect(name_parts(metadata['creators']).count).to eq 4
|
31
|
+
subject.call
|
32
|
+
expect(name_parts(metadata['creators']).count).to eq 0
|
33
|
+
expect(metadata['creators'].map { |c| c['name'] }.compact.count).to eq 4
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'segregates creators and contributors' do
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'deletes the original creators array' do
|
40
|
+
expect(metadata['creators']).not_to be_nil
|
41
|
+
munged = subject.call
|
42
|
+
expect(munged['creators']).to be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def name_parts(creators)
|
46
|
+
creators.map { |c| c['firstName'] }.compact + creators.map { |c| c['lastName'] }.compact
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Arkivo::SchemaValidator do
|
4
|
+
let(:item) { JSON.parse(FactoryGirl.json(:post_item)) }
|
5
|
+
|
6
|
+
it 'ensures a token is included' do
|
7
|
+
expect {
|
8
|
+
described_class.new(item.except('token')).call
|
9
|
+
}.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'token'/)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'ensures a metadata section is included' do
|
13
|
+
expect {
|
14
|
+
described_class.new(item.except('metadata')).call
|
15
|
+
}.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'metadata'/)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'ensures a file section is included' do
|
19
|
+
expect {
|
20
|
+
described_class.new(item.except('file')).call
|
21
|
+
}.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'file'/)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'ensures the metadata has a title' do
|
25
|
+
item['metadata'].delete('title')
|
26
|
+
expect {
|
27
|
+
described_class.new(item).call
|
28
|
+
}.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'title'/)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'ensures the metadata has rights' do
|
32
|
+
item['metadata'].delete('rights')
|
33
|
+
expect {
|
34
|
+
described_class.new(item).call
|
35
|
+
}.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'rights'/)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'ensures the file has a b64-encoded content' do
|
39
|
+
item['file'].delete('base64')
|
40
|
+
expect {
|
41
|
+
described_class.new(item).call
|
42
|
+
}.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'base64'/)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'ensures the file has a checksum' do
|
46
|
+
item['file'].delete('md5')
|
47
|
+
expect {
|
48
|
+
described_class.new(item).call
|
49
|
+
}.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'md5'/)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'ensures the file has a filename' do
|
53
|
+
item['file'].delete('filename')
|
54
|
+
expect {
|
55
|
+
described_class.new(item).call
|
56
|
+
}.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'filename'/)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'ensures the file has a content type' do
|
60
|
+
item['file'].delete('contentType')
|
61
|
+
expect {
|
62
|
+
described_class.new(item).call
|
63
|
+
}.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'contentType'/)
|
64
|
+
end
|
65
|
+
end
|
@@ -16,7 +16,7 @@ class UploadThingRedefine
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe Sufia::FilesController::UploadCompleteBehavior do
|
19
|
-
let
|
19
|
+
let(:test_id) {"123abc"}
|
20
20
|
context "Not overridden" do
|
21
21
|
it "respond with the batch edit path" do
|
22
22
|
expect(UploadThing.upload_complete_path(test_id)).to eq(Sufia::Engine.routes.url_helpers.batch_edit_path(test_id))
|
@@ -133,6 +133,50 @@ describe Sufia::UserStatImporter do
|
|
133
133
|
|
134
134
|
expect(UserStat.count).to eq bilbos_stats.count + frodos_stats.count
|
135
135
|
end
|
136
|
+
|
137
|
+
context "when Google analytics throws an error" do
|
138
|
+
let(:importer) { Sufia::UserStatImporter.new({number_of_retries: 4}) }
|
139
|
+
|
140
|
+
context "both error out completely" do
|
141
|
+
before do
|
142
|
+
expect(FileDownloadStat).to receive(:ga_statistics).exactly(12).times.and_raise(StandardError.new("GA error"))
|
143
|
+
expect(FileViewStat).to receive(:ga_statistics).exactly(12).times.and_raise(StandardError.new("GA error"))
|
144
|
+
end
|
145
|
+
|
146
|
+
it "stops after 4 tries on each of the 3 files" do
|
147
|
+
importer.import
|
148
|
+
expect(UserStat.count).to eq 0
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context "Only View stats error out completely" do
|
153
|
+
before do
|
154
|
+
expect(FileViewStat).to receive(:ga_statistics).exactly(12).times.and_raise(StandardError.new("GA error"))
|
155
|
+
end
|
156
|
+
it "gathers the download stats even though the view stats are failing" do
|
157
|
+
importer.import
|
158
|
+
expect(UserStat.count).to eq 8 # 2 users for 4 days
|
159
|
+
UserStat.all.each do |stat|
|
160
|
+
expect(stat.file_views).to eq 0
|
161
|
+
expect(stat.file_downloads).not_to eq 0
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context "Only Download stats error out completely" do
|
167
|
+
before do
|
168
|
+
expect(FileDownloadStat).to receive(:ga_statistics).exactly(12).times.and_raise(StandardError.new("GA error"))
|
169
|
+
end
|
170
|
+
it "gathers the view stats even though the download stats are failing" do
|
171
|
+
importer.import
|
172
|
+
expect(UserStat.count).to eq 8 # 2 users for 4 days
|
173
|
+
UserStat.all.each do |stat|
|
174
|
+
expect(stat.file_views).not_to eq 0
|
175
|
+
expect(stat.file_downloads).to eq 0
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
136
180
|
end
|
137
181
|
|
138
182
|
describe 'with existing data in cache' do
|
@@ -172,6 +216,22 @@ describe Sufia::UserStatImporter do
|
|
172
216
|
sorted_ids = Sufia::UserStatImporter.new.sorted_users.map { |u| u.id }
|
173
217
|
expect(sorted_ids).to eq([gollum.id, frodo.id, bilbo.id])
|
174
218
|
end
|
219
|
+
|
220
|
+
context "a user is already up to date" do
|
221
|
+
let(:importer) {Sufia::UserStatImporter.new}
|
222
|
+
before do
|
223
|
+
allow(importer).to receive(:sorted_users).and_return([gollum, frodo, bilbo])
|
224
|
+
UserStat.create!(user_id: bilbo.id, date: dates[3], file_views: 999, file_downloads: 555)
|
225
|
+
end
|
226
|
+
|
227
|
+
it "skips if we already have uptodate information" do
|
228
|
+
expect(importer).to receive(:file_ids_for_user).with(gollum).and_call_original
|
229
|
+
expect(importer).to receive(:file_ids_for_user).with(frodo).and_call_original
|
230
|
+
#expect(importer).to receive(:file_ids_for_user).with(frodo.id).and_call_original
|
231
|
+
expect(importer).not_to receive(:file_ids_for_user).with(bilbo)
|
232
|
+
importer.import
|
233
|
+
end
|
234
|
+
end
|
175
235
|
end
|
176
236
|
end
|
177
237
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::Zotero do
|
4
|
+
it { is_expected.to respond_to(:config) }
|
5
|
+
|
6
|
+
describe 'configuration' do
|
7
|
+
subject { Sufia::Zotero.reload_config! }
|
8
|
+
|
9
|
+
let(:client_key) { 'abc123' }
|
10
|
+
let(:client_secret) { '789xyz' }
|
11
|
+
|
12
|
+
before do
|
13
|
+
stub_const('ENV', {
|
14
|
+
'ZOTERO_CLIENT_KEY' => client_key,
|
15
|
+
'ZOTERO_CLIENT_SECRET' => client_secret
|
16
|
+
})
|
17
|
+
end
|
18
|
+
|
19
|
+
# Reload the config so other tests don't see the stub_const values
|
20
|
+
after(:context) { Sufia::Zotero.reload_config! }
|
21
|
+
|
22
|
+
it 'has a client key' do
|
23
|
+
expect(subject['client_key']).to eq(client_key)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'has a client secret' do
|
27
|
+
expect(subject['client_secret']).to eq(client_secret)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Collection, :type => :model do
|
4
4
|
before do
|
5
5
|
@user = FactoryGirl.create(:user)
|
6
|
-
@collection = Collection.new(title: "test collection")
|
6
|
+
@collection = Collection.new(id: 'mock-collection-with-members', title: "test collection") do |c|
|
7
7
|
c.apply_depositor_metadata(@user.user_key)
|
8
8
|
end
|
9
9
|
end
|
@@ -21,15 +21,44 @@ describe Collection, :type => :model do
|
|
21
21
|
describe "::bytes" do
|
22
22
|
subject { @collection.bytes }
|
23
23
|
context "with no items" do
|
24
|
-
|
25
|
-
|
24
|
+
it "gets zero without querying solr" do
|
25
|
+
expect(ActiveFedora::SolrService).not_to receive(:query)
|
26
|
+
is_expected.to eq 0
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
|
-
context "with
|
29
|
-
let(:bitstream) { double("content", size: "
|
30
|
+
context "with three 33 byte files" do
|
31
|
+
let(:bitstream) { double("content", size: "33")}
|
30
32
|
let(:file) { mock_model GenericFile, content: bitstream }
|
31
|
-
|
32
|
-
|
33
|
+
let(:documents) do
|
34
|
+
[{ 'id' => 'file-1', 'file_size_is' => 33 },
|
35
|
+
{ 'id' => 'file-2', 'file_size_is' => 33 },
|
36
|
+
{ 'id' => 'file-3', 'file_size_is' => 33 }]
|
37
|
+
end
|
38
|
+
let(:query) { ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::GenericFile.to_class_uri) }
|
39
|
+
let(:args) do
|
40
|
+
{ fq: "{!join from=hasCollectionMember_ssim to=id}id:#{@collection.id}",
|
41
|
+
fl: "id, file_size_is",
|
42
|
+
rows: 3 }
|
43
|
+
end
|
44
|
+
|
45
|
+
before do
|
46
|
+
allow(@collection).to receive(:members).and_return([file, file, file])
|
47
|
+
allow(ActiveFedora::SolrService).to receive(:query).with(query, args).and_return(documents)
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when saved" do
|
51
|
+
before do
|
52
|
+
allow(@collection).to receive(:new_record?).and_return(false)
|
53
|
+
end
|
54
|
+
it { is_expected.to eq 99 }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when not saved" do
|
58
|
+
it "raises an error" do
|
59
|
+
expect { subject }.to raise_error "Collection must be saved to query for bytes"
|
60
|
+
end
|
61
|
+
end
|
33
62
|
end
|
34
63
|
|
35
64
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe FileDownloadStat, :type => :model do
|
4
|
-
let
|
5
|
-
let
|
6
|
-
let
|
4
|
+
let(:file_id) {"99"}
|
5
|
+
let(:date) {DateTime.new}
|
6
|
+
let(:file_stat) {FileDownloadStat.create(downloads:"2", date: date, file_id: file_id)}
|
7
7
|
|
8
8
|
it "has attributes" do
|
9
9
|
expect(file_stat).to respond_to(:downloads)
|
@@ -46,7 +46,7 @@ RSpec.describe FileDownloadStat, :type => :model do
|
|
46
46
|
}
|
47
47
|
|
48
48
|
describe "cache empty" do
|
49
|
-
let
|
49
|
+
let(:stats) {
|
50
50
|
expect(FileDownloadStat).to receive(:ga_statistics).and_return(sample_download_statistics)
|
51
51
|
FileDownloadStat.statistics(file_id,Date.today-4.day)
|
52
52
|
}
|
@@ -71,7 +71,7 @@ RSpec.describe FileDownloadStat, :type => :model do
|
|
71
71
|
|
72
72
|
let!(:file_download_stat) { FileDownloadStat.create(date: (Date.today-5.day).to_datetime, file_id: file_id, downloads:"25")}
|
73
73
|
|
74
|
-
let
|
74
|
+
let(:stats) {
|
75
75
|
expect(FileDownloadStat).to receive(:ga_statistics).and_return(sample_download_statistics)
|
76
76
|
FileDownloadStat.statistics(file_id,Date.today-5.day)
|
77
77
|
}
|
@@ -155,4 +155,27 @@ describe FileUsage, :type => :model do
|
|
155
155
|
|
156
156
|
end
|
157
157
|
end
|
158
|
+
|
159
|
+
describe "on a migrated file" do
|
160
|
+
let(:date_uploaded) { "2014-12-31" }
|
161
|
+
|
162
|
+
let(:file_migrated) do
|
163
|
+
GenericFile.new.tap do |file|
|
164
|
+
file.apply_depositor_metadata("awead")
|
165
|
+
file.date_uploaded = date_uploaded
|
166
|
+
file.save
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
let(:usage) {
|
171
|
+
expect(FileDownloadStat).to receive(:ga_statistics).and_return(sample_download_statistics)
|
172
|
+
expect(FileViewStat).to receive(:ga_statistics).and_return(sample_pageview_statistics)
|
173
|
+
FileUsage.new(file_migrated.id)
|
174
|
+
}
|
175
|
+
|
176
|
+
it "should use the date_uploaded for analytics" do
|
177
|
+
expect(usage.created).to eq(date_uploaded)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
158
181
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe FileViewStat, :type => :model do
|
4
|
-
let
|
5
|
-
let
|
6
|
-
let
|
7
|
-
let
|
4
|
+
let(:file_id) {"99"}
|
5
|
+
let(:user_id) {123}
|
6
|
+
let(:date) {DateTime.new}
|
7
|
+
let(:file_stat) {FileViewStat.create(views:"25", date: date, file_id: file_id, user_id: user_id)}
|
8
8
|
|
9
9
|
it "has attributes" do
|
10
10
|
expect(file_stat).to respond_to(:views)
|
@@ -46,7 +46,7 @@ RSpec.describe FileViewStat, :type => :model do
|
|
46
46
|
]
|
47
47
|
}
|
48
48
|
describe "cache empty" do
|
49
|
-
let
|
49
|
+
let(:stats) {
|
50
50
|
expect(FileViewStat).to receive(:ga_statistics).and_return(sample_pageview_statistics)
|
51
51
|
FileViewStat.statistics(file_id, Date.today-4.day, user_id)
|
52
52
|
}
|
@@ -72,7 +72,7 @@ RSpec.describe FileViewStat, :type => :model do
|
|
72
72
|
|
73
73
|
let!(:file_view_stat) { FileViewStat.create(date: (Date.today-5.day).to_datetime, file_id: file_id, views:"25")}
|
74
74
|
|
75
|
-
let
|
75
|
+
let(:stats) {
|
76
76
|
expect(FileViewStat).to receive(:ga_statistics).and_return(sample_pageview_statistics)
|
77
77
|
FileViewStat.statistics(file_id,Date.today-5.day)
|
78
78
|
}
|
@@ -35,15 +35,10 @@ describe FitsDatastream, type: :model, unless: $in_travis do
|
|
35
35
|
let(:datastream) { @file.characterization }
|
36
36
|
let(:xml) { datastream.ng_xml }
|
37
37
|
let(:namespace) { {'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output'} }
|
38
|
-
let(:solr_doc) { @file.to_solr }
|
39
38
|
|
40
39
|
it "should make the fits XML" do
|
41
40
|
expect(xml.xpath('//ns:imageWidth/text()', namespace).inner_text).to eq '50'
|
42
41
|
end
|
43
|
-
|
44
|
-
it "should index into solr" do
|
45
|
-
expect(solr_doc[Solrizer.solr_name("mime_type")].first).to eq "image/png"
|
46
|
-
end
|
47
42
|
end
|
48
43
|
|
49
44
|
describe "video" do
|
@@ -8,6 +8,11 @@ describe GenericFile, :type => :model do
|
|
8
8
|
@file.apply_depositor_metadata(user.user_key)
|
9
9
|
end
|
10
10
|
|
11
|
+
describe "rdf type" do
|
12
|
+
subject { described_class.new.type }
|
13
|
+
it { is_expected.to eq [::RDF::URI.new('http://pcdm.org/models#Object')] }
|
14
|
+
end
|
15
|
+
|
11
16
|
context "when it is initialized" do
|
12
17
|
it "has empty arrays for all the properties" do
|
13
18
|
subject.attributes.each do |k,v|
|
@@ -61,9 +66,21 @@ describe GenericFile, :type => :model do
|
|
61
66
|
end
|
62
67
|
|
63
68
|
describe "assign_id" do
|
64
|
-
|
65
|
-
|
66
|
-
|
69
|
+
context "with noids enabled (by default)" do
|
70
|
+
it "uses the noid service" do
|
71
|
+
expect_any_instance_of(ActiveFedora::Noid::Service).to receive(:mint).once
|
72
|
+
subject.assign_id
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "with noids disabled" do
|
77
|
+
before { Sufia.config.enable_noids = false }
|
78
|
+
after { Sufia.config.enable_noids = true }
|
79
|
+
|
80
|
+
it "does not use the noid service" do
|
81
|
+
expect_any_instance_of(ActiveFedora::Noid::Service).not_to receive(:mint)
|
82
|
+
subject.assign_id
|
83
|
+
end
|
67
84
|
end
|
68
85
|
end
|
69
86
|
|
@@ -411,35 +428,32 @@ describe GenericFile, :type => :model do
|
|
411
428
|
|
412
429
|
describe "noid integration" do
|
413
430
|
before do
|
414
|
-
|
431
|
+
allow_any_instance_of(ActiveFedora::Noid::Service).to receive(:mint).and_return(noid)
|
415
432
|
end
|
416
433
|
|
417
434
|
let(:noid) { 'wd3763094' }
|
418
435
|
|
419
436
|
subject do
|
420
|
-
GenericFile.create
|
421
|
-
f.apply_depositor_metadata('mjg36')
|
422
|
-
end
|
437
|
+
GenericFile.create { |f| f.apply_depositor_metadata('mjg36') }
|
423
438
|
end
|
424
439
|
|
425
440
|
it "runs the overridden #assign_id method" do
|
426
|
-
|
427
|
-
GenericFile.create
|
428
|
-
f.apply_depositor_metadata('mjg36')
|
429
|
-
end
|
441
|
+
expect_any_instance_of(ActiveFedora::Noid::Service).to receive(:mint).once
|
442
|
+
GenericFile.create { |f| f.apply_depositor_metadata('mjg36') }
|
430
443
|
end
|
431
444
|
|
432
|
-
it "
|
445
|
+
it "returns the expected identifier" do
|
433
446
|
expect(subject.id).to eq noid
|
434
447
|
end
|
435
448
|
|
436
|
-
it "
|
449
|
+
it "has a treeified URL" do
|
437
450
|
expect(subject.uri).to eq 'http://localhost:8983/fedora/rest/test/wd/37/63/09/wd3763094'
|
438
451
|
end
|
439
452
|
|
440
453
|
context "when a url is provided" do
|
441
454
|
let(:url) { 'http://localhost:8983/fedora/rest/test/wd/37/63/09/wd3763094' }
|
442
|
-
|
455
|
+
|
456
|
+
it "transforms the url into an id" do
|
443
457
|
expect(GenericFile.uri_to_id(url)).to eq 'wd3763094'
|
444
458
|
end
|
445
459
|
end
|
@@ -491,6 +505,27 @@ describe GenericFile, :type => :model do
|
|
491
505
|
describe "permissions validation" do
|
492
506
|
before { subject.apply_depositor_metadata('mjg36') }
|
493
507
|
|
508
|
+
describe "overriding" do
|
509
|
+
let(:asset) { SampleKlass.new }
|
510
|
+
before do
|
511
|
+
class SampleKlass < GenericFile
|
512
|
+
def paranoid_edit_permissions
|
513
|
+
[]
|
514
|
+
end
|
515
|
+
end
|
516
|
+
asset.apply_depositor_metadata('mjg36')
|
517
|
+
end
|
518
|
+
after do
|
519
|
+
Object.send(:remove_const, :SampleKlass)
|
520
|
+
end
|
521
|
+
context "when public has edit access" do
|
522
|
+
before { asset.edit_groups = ['public'] }
|
523
|
+
it "should be valid" do
|
524
|
+
expect(asset).to be_valid
|
525
|
+
end
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
494
529
|
context "when the depositor does not have edit access" do
|
495
530
|
before do
|
496
531
|
subject.permissions = [ Hydra::AccessControls::Permission.new(type: 'person', name: 'mjg36', access: 'read')]
|