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
@@ -90,7 +90,7 @@ describe LocalAuthority, :type => :model do
|
|
90
90
|
it "should return entries by term" do
|
91
91
|
term = DomainTerm.where(model: "my_tests", term: "genre").first
|
92
92
|
authorities = term.local_authorities.collect(&:id).uniq
|
93
|
-
|
93
|
+
LocalAuthorityEntry.where("local_authority_id in (?)", authorities).where("label like ?", "A%").select("label, uri").limit(25)
|
94
94
|
expect(LocalAuthority.entries_by_term("my_tests", "genre", "A").count).to eq(6)
|
95
95
|
end
|
96
96
|
end
|
data/spec/models/trophy_spec.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Trophy, :type => :model do
|
4
|
-
|
4
|
+
before(:all) do
|
5
5
|
@trophy = Trophy.create(user_id:99,generic_file_id:"99")
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should have a user" do
|
9
|
-
|
10
|
-
|
9
|
+
expect(@trophy).to respond_to(:user_id)
|
10
|
+
expect(@trophy.user_id).to eq(99)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should have a file" do
|
14
|
-
|
15
|
-
|
14
|
+
expect(@trophy).to respond_to(:generic_file_id)
|
15
|
+
expect(@trophy.generic_file_id).to eq("99")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should not allow six trophies" do
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
(1..6).each { |n| Trophy.create(user_id:120,generic_file_id:n.to_s) }
|
20
|
+
expect(Trophy.where(user_id:120).count).to eq(5)
|
21
|
+
Trophy.where(user_id:120).map(&:delete)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
data/spec/models/user_spec.rb
CHANGED
@@ -22,6 +22,39 @@ describe User, :type => :model do
|
|
22
22
|
expect(user).to respond_to(:linkedin_handle)
|
23
23
|
expect(user).to respond_to(:orcid)
|
24
24
|
end
|
25
|
+
|
26
|
+
describe 'Arkivo and Zotero integration' do
|
27
|
+
it 'sets an Arkivo token after_initialize if API is enabled' do
|
28
|
+
expect(User.new).to respond_to(:arkivo_token)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'Arkivo token generation' do
|
32
|
+
before do
|
33
|
+
allow(SecureRandom).to receive(:base64).with(24).and_return(token1, token1, token2)
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:token1) { 'token1' }
|
37
|
+
let(:token2) { 'token2' }
|
38
|
+
|
39
|
+
it 'generates a new token if a user is found with the existing token' do
|
40
|
+
user1 = User.create(email: 'foo@example.org', password: 'foobarbaz')
|
41
|
+
expect(user1.arkivo_token).to eq token1
|
42
|
+
user2 = User.create(email: 'bar@example.org', password: 'bazquuxquuux')
|
43
|
+
expect(user2.arkivo_token).to eq token2
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'Zotero tokens' do
|
48
|
+
let(:token) { 'something' }
|
49
|
+
|
50
|
+
it 'has a custom getter/setter for Zotero request tokens' do
|
51
|
+
user.zotero_token = token
|
52
|
+
expect(user.read_attribute(:zotero_token)).to eq Marshal::dump(token)
|
53
|
+
expect(user.zotero_token).to eq token
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
25
58
|
describe 'ORCID validation and normalization' do
|
26
59
|
it 'saves when a valid bare ORCID is supplied' do
|
27
60
|
user.orcid = '0000-0000-1111-2222'
|
@@ -8,7 +8,7 @@ describe Sufia::CollectionPresenter do
|
|
8
8
|
:language, :identifier, :based_near, :related_url] }
|
9
9
|
end
|
10
10
|
|
11
|
-
let(:collection) { Collection.new(description: 'a nice collection', title: 'A clever title') }
|
11
|
+
let(:collection) { Collection.new(id: 'my-nice-collection', description: 'a nice collection', title: 'A clever title') }
|
12
12
|
let(:presenter) { described_class.new(collection) }
|
13
13
|
|
14
14
|
describe "#terms_with_values" do
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'routing and paths', type: :routing do
|
4
|
+
routes { Sufia::Engine.routes }
|
5
|
+
|
6
|
+
let(:item_id) { '123' }
|
7
|
+
|
8
|
+
describe 'Arkivo' do
|
9
|
+
context 'with a constraint defined' do
|
10
|
+
before do
|
11
|
+
allow(Sufia::ArkivoConstraint).to receive(:matches?) { false }
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'does not recognize routes' do
|
15
|
+
expect(post: '/api/items').not_to be_routable
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'without a constraint defined' do
|
20
|
+
before do
|
21
|
+
allow(Sufia::ArkivoConstraint).to receive(:matches?) { true }
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'routes POSTs to the items resource' do
|
25
|
+
expect(post: '/api/items').to route_to(controller: 'api/items', action: 'create', format: :json)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'does not route GETs to the items resource' do
|
29
|
+
expect(get: '/api/items').not_to route_to(controller: 'api/items', action: 'index', format: :json)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'does not route DELETEs to the items resource' do
|
33
|
+
expect(delete: '/api/items').not_to route_to(controller: 'api/items', action: 'destroy', format: :json)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'does not route PUTs to the items resource' do
|
37
|
+
expect(put: '/api/items').not_to route_to(controller: 'api/items', action: 'update', format: :json)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'does not route PATCHes to the items resource' do
|
41
|
+
expect(patch: '/api/items').not_to route_to(controller: 'api/items', action: 'update', format: :json)
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with a member resource' do
|
45
|
+
subject { "/api/items/#{item_id}" }
|
46
|
+
|
47
|
+
it 'routes GETs to an item resource' do
|
48
|
+
expect(get: subject).to route_to(controller: 'api/items', action: 'show', id: item_id, format: :json)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'routes PUTs to an item resource' do
|
52
|
+
expect(put: subject).to route_to(controller: 'api/items', action: 'update', id: item_id, format: :json)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'routes DELETEs to an item resource' do
|
56
|
+
expect(delete: subject).to route_to(controller: 'api/items', action: 'destroy', id: item_id, format: :json)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'Zotero' do
|
63
|
+
it 'routes GETs to the zotero resource' do
|
64
|
+
expect(get: '/api/zotero').to route_to(controller: 'api/zotero', action: 'initiate')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'Zotero callbacks' do
|
69
|
+
it 'routes GETs to the callback resource' do
|
70
|
+
expect(get: '/api/zotero/callback').to route_to(controller: 'api/zotero', action: 'callback')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'path helpers' do
|
75
|
+
it 'has a path for creating new items' do
|
76
|
+
expect(api_items_path).to eq '/api/items'
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'has a path for operating on existing items' do
|
80
|
+
expect(api_item_path(item_id)).to eq "/api/items/#{item_id}"
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'has a path for initiating Zotero authentication' do
|
84
|
+
expect(api_zotero_initiate_path).to eq '/api/zotero'
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'has a path for Zotero authN callbacks' do
|
88
|
+
expect(api_zotero_callback_path).to eq '/api/zotero/callback'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/spec/routing/route_spec.rb
CHANGED
@@ -72,7 +72,7 @@ describe 'Routes', :type => :routing do
|
|
72
72
|
expect({ get: '/dashboard' }).to route_to(controller: 'dashboard', action: 'index')
|
73
73
|
end
|
74
74
|
|
75
|
-
|
75
|
+
it "should route to dashboard activity" do
|
76
76
|
expect({ get: '/dashboard/activity' }).to route_to(controller: 'dashboard', action: 'activity')
|
77
77
|
end
|
78
78
|
|
@@ -44,19 +44,55 @@ describe Sufia::GenericFileAuditService do
|
|
44
44
|
|
45
45
|
describe "#audit_stat" do
|
46
46
|
subject { service.send(:audit_stat) }
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
|
48
|
+
describe "file loaded from fedora" do
|
49
|
+
context "when no audits have been run" do
|
50
|
+
it "should report that audits have not been run" do
|
51
|
+
expect(subject).to eq "Audits have not yet been run on this file."
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when no audit is passing" do
|
56
|
+
before do
|
57
|
+
ChecksumAuditLog.create!(pass: 1, generic_file_id: f.id, version: f.content.versions.first.label, dsid: 'content')
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should report that audit result" do
|
61
|
+
expect(subject).to eq 1
|
62
|
+
end
|
50
63
|
end
|
51
64
|
end
|
52
65
|
|
53
|
-
|
54
|
-
|
55
|
-
|
66
|
+
describe "file loaded from solr" do
|
67
|
+
let(:solr_file) { GenericFile.load_instance_from_solr(f.id) }
|
68
|
+
let(:service) { Sufia::GenericFileAuditService.new(solr_file) }
|
69
|
+
|
70
|
+
it "should not audit by version" do
|
71
|
+
expect(service).not_to receive(:audit_stat_by_version)
|
72
|
+
expect(subject).to eq "Audits have not yet been run on this file."
|
56
73
|
end
|
57
74
|
|
58
|
-
|
59
|
-
|
75
|
+
context "when no audit is passing" do
|
76
|
+
before do
|
77
|
+
ChecksumAuditLog.create!(pass: 1, generic_file_id: f.id, version: f.content.versions.first.label, dsid: 'content')
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should report that audit result" do
|
81
|
+
expect(service).not_to receive(:audit_stat_by_version)
|
82
|
+
expect(subject).to eq 1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "when one audit is passing" do
|
87
|
+
before do
|
88
|
+
ChecksumAuditLog.create!(pass: 0, generic_file_id: f.id, version: f.content.versions.first.label, dsid: 'content')
|
89
|
+
ChecksumAuditLog.create!(pass: 1, generic_file_id: f.id, version: f.content.versions.first.label, dsid: 'content')
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should report that audit result" do
|
93
|
+
expect(service).not_to receive(:audit_stat_by_version)
|
94
|
+
expect(subject).to eq 0
|
95
|
+
end
|
60
96
|
end
|
61
97
|
end
|
62
98
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
1
4
|
ENV["RAILS_ENV"] ||= 'test'
|
2
5
|
require "bundler/setup"
|
3
6
|
|
4
|
-
|
5
7
|
require 'factory_girl'
|
6
8
|
require 'engine_cart'
|
7
9
|
EngineCart.load_application!
|
8
10
|
|
9
11
|
require 'devise'
|
10
|
-
|
11
12
|
require 'mida'
|
12
13
|
require 'rspec/rails'
|
13
14
|
require 'rspec/its'
|
@@ -20,6 +21,7 @@ require 'equivalent-xml'
|
|
20
21
|
require 'equivalent-xml/rspec_matchers'
|
21
22
|
require 'database_cleaner'
|
22
23
|
require 'support/features'
|
24
|
+
require 'support/rake'
|
23
25
|
require 'support/input_support'
|
24
26
|
require 'byebug' unless ENV['TRAVIS']
|
25
27
|
|
@@ -73,6 +75,19 @@ end
|
|
73
75
|
|
74
76
|
Resque.inline = Rails.env.test?
|
75
77
|
|
78
|
+
class JsonStrategy
|
79
|
+
def initialize
|
80
|
+
@strategy = FactoryGirl.strategy_by_name(:create).new
|
81
|
+
end
|
82
|
+
|
83
|
+
delegate :association, to: :@strategy
|
84
|
+
|
85
|
+
def result(evaluation)
|
86
|
+
@strategy.result(evaluation).to_json
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
FactoryGirl.register_strategy(:json, JsonStrategy)
|
76
91
|
FactoryGirl.definition_file_paths = [File.expand_path("../factories", __FILE__)]
|
77
92
|
FactoryGirl.find_definitions
|
78
93
|
|
@@ -134,7 +149,7 @@ RSpec.configure do |config|
|
|
134
149
|
end
|
135
150
|
|
136
151
|
module FactoryGirl
|
137
|
-
def self.find_or_create(handle, by
|
152
|
+
def self.find_or_create(handle, by = :email)
|
138
153
|
tmpl = FactoryGirl.build(handle)
|
139
154
|
tmpl.class.send("find_by_#{by}".to_sym, tmpl.send(by)) || FactoryGirl.create(handle)
|
140
155
|
end
|
data/spec/support/features.rb
CHANGED
@@ -4,10 +4,8 @@ require File.expand_path('../fixture_helpers', __FILE__)
|
|
4
4
|
require File.expand_path('../selectors', __FILE__)
|
5
5
|
require File.expand_path('../proxies', __FILE__)
|
6
6
|
require File.expand_path('../locations', __FILE__)
|
7
|
-
require File.expand_path('../poltergeist', __FILE__)
|
8
7
|
require File.expand_path('../cleaner', __FILE__)
|
9
8
|
require File.expand_path('../statistic_helper', __FILE__)
|
10
|
-
require File.expand_path('../rake_output', __FILE__)
|
11
9
|
|
12
10
|
RSpec.configure do |config|
|
13
11
|
config.include Features::SessionHelpers, type: :feature
|
data/spec/support/locations.rb
CHANGED
@@ -1,30 +1,9 @@
|
|
1
1
|
module Locations
|
2
|
-
def go_to_dashboard
|
3
|
-
visit '/dashboard'
|
4
|
-
# causes selenium to wait until text appears on the page
|
5
|
-
expect(page).to have_content('My Dashboard')
|
6
|
-
end
|
7
|
-
|
8
2
|
def go_to_dashboard_files
|
9
3
|
visit '/dashboard/files'
|
10
4
|
expect(page).to have_selector('li.active', text: "My Files")
|
11
5
|
end
|
12
6
|
|
13
|
-
def go_to_dashboard_collections
|
14
|
-
visit '/dashboard/collections'
|
15
|
-
expect(page).to have_content('My Collections')
|
16
|
-
end
|
17
|
-
|
18
|
-
def go_to_dashboard_shares
|
19
|
-
visit '/dashboard/shares'
|
20
|
-
expect(page).to have_content('Files Shared with Me')
|
21
|
-
end
|
22
|
-
|
23
|
-
def go_to_dashboard_highlights
|
24
|
-
visit '/dashboard/highlights'
|
25
|
-
expect(page).to have_content('My Highlights')
|
26
|
-
end
|
27
|
-
|
28
7
|
def go_to_user_profile
|
29
8
|
first(".dropdown-toggle").click
|
30
9
|
click_link "my profile"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
module RakeHelper
|
4
|
+
def load_rake_environment(files)
|
5
|
+
@rake = Rake::Application.new
|
6
|
+
Rake.application = @rake
|
7
|
+
Rake::Task.define_task(:environment)
|
8
|
+
files.each {|file| load file}
|
9
|
+
end
|
10
|
+
|
11
|
+
def run_task(task, arg = nil)
|
12
|
+
capture_stdout_stderr do
|
13
|
+
@rake[task].invoke(arg)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# saves original $stdout in variable
|
18
|
+
# set $stdout as local instance of StringIO
|
19
|
+
# yields to code execution
|
20
|
+
# returns the local instance of StringIO
|
21
|
+
# resets $stdout to original value
|
22
|
+
def capture_stdout_stderr
|
23
|
+
out = StringIO.new
|
24
|
+
err = StringIO.new
|
25
|
+
$stdout = out
|
26
|
+
$stderr = err
|
27
|
+
begin
|
28
|
+
yield
|
29
|
+
rescue SystemExit => e
|
30
|
+
puts "error = #{e.inspect}"
|
31
|
+
end
|
32
|
+
return "Output: #{out.string}\n Errors:#{err.string}"
|
33
|
+
ensure
|
34
|
+
$stdout = STDOUT
|
35
|
+
$stdout = STDERR
|
36
|
+
end
|
37
|
+
|
38
|
+
RSpec.configure do |config|
|
39
|
+
config.include RakeHelper
|
40
|
+
end
|
41
|
+
end
|
data/spec/support/selectors.rb
CHANGED
@@ -22,56 +22,6 @@ module Selectors
|
|
22
22
|
find '.dropdown-toggle'
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
|
-
def db_item_title item
|
27
|
-
within "#document_#{item.id}" do
|
28
|
-
find "#src_copy_link#{item.id}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def db_file_checkbox file
|
33
|
-
within "#document_#{file.id}" do
|
34
|
-
find '.batch_document_selector'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def db_collection_radio_button collection
|
39
|
-
within '#collection-list-container' do
|
40
|
-
find "input[id*='#{collection.id}']"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def db_create_empty_collection_button
|
45
|
-
first '#hydra-collection-add'
|
46
|
-
end
|
47
|
-
|
48
|
-
def db_create_populated_collection_button
|
49
|
-
within '#collection-list-container' do
|
50
|
-
first '#hydra-collection-add'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def db_visibility_link file
|
55
|
-
within "#document_#{file.id}" do
|
56
|
-
find "a#permission_#{file.id}"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def db_facet_category_toggle id
|
61
|
-
find("a[data-target='#{id}']")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
module EditCollections
|
66
|
-
|
67
|
-
def ec_update_submit
|
68
|
-
within '.col-xs-12.col-sm-10' do
|
69
|
-
within '.primary-actions' do
|
70
|
-
find_button 'Update Collection'
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
25
|
end
|
76
26
|
|
77
27
|
module NewTransfers
|