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
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dashboard::CollectionsController do
|
4
|
+
describe "logged in user" do
|
5
|
+
before (:each) do
|
6
|
+
@user = FactoryGirl.find_or_create(:archivist)
|
7
|
+
sign_in @user
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#index" do
|
11
|
+
before do
|
12
|
+
GenericFile.destroy_all
|
13
|
+
Collection.destroy_all
|
14
|
+
@my_file = FactoryGirl.create(:generic_file, depositor: @user)
|
15
|
+
@my_collection = Collection.new(title: "test collection").tap do |c|
|
16
|
+
c.apply_depositor_metadata(@user.user_key)
|
17
|
+
c.save!
|
18
|
+
end
|
19
|
+
@unrelated_collection = Collection.new(title: "test collection").tap do |c|
|
20
|
+
c.apply_depositor_metadata(FactoryGirl.create(:user).user_key)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should respond with success" do
|
25
|
+
get :index
|
26
|
+
expect(response).to be_successful
|
27
|
+
expect(response).to render_template('dashboard/lists/index')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "sets the controller name" do
|
31
|
+
expect(controller.controller_name).to eq :dashboard
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should paginate" do
|
35
|
+
other_user = FactoryGirl.create(:user)
|
36
|
+
Collection.new(title: "test collection").tap do |c|
|
37
|
+
c.apply_depositor_metadata(@user.user_key)
|
38
|
+
c.save!
|
39
|
+
end
|
40
|
+
Collection.new(title: "test collection").tap do |c|
|
41
|
+
c.apply_depositor_metadata(@user.user_key)
|
42
|
+
c.save!
|
43
|
+
end
|
44
|
+
get :index, per_page: 2
|
45
|
+
expect(assigns[:document_list].length).to eq 2
|
46
|
+
get :index, per_page: 2, page: 2
|
47
|
+
expect(assigns[:document_list].length).to be >= 1
|
48
|
+
end
|
49
|
+
|
50
|
+
it "shows the correct collections" do
|
51
|
+
get :index
|
52
|
+
# shows my collections
|
53
|
+
expect(assigns[:document_list].map(&:id)).to include(@my_collection.id)
|
54
|
+
# doesn't show files
|
55
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@my_file.id)
|
56
|
+
# doesn't show other users' collections" do
|
57
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@unrelated_collection.id)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "not logged in as a user" do
|
63
|
+
describe "#index" do
|
64
|
+
it "should return an error" do
|
65
|
+
get :index
|
66
|
+
expect(response).to be_redirect
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dashboard::FilesController do
|
4
|
+
describe "logged in user" do
|
5
|
+
before (:each) do
|
6
|
+
@user = FactoryGirl.find_or_create(:archivist)
|
7
|
+
sign_in @user
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#index" do
|
11
|
+
before do
|
12
|
+
GenericFile.destroy_all
|
13
|
+
Collection.destroy_all
|
14
|
+
@my_file = FactoryGirl.create(:generic_file, depositor: @user)
|
15
|
+
@my_collection = Collection.new(title: "test collection").tap do |c|
|
16
|
+
c.apply_depositor_metadata(@user.user_key)
|
17
|
+
end
|
18
|
+
@my_collection.save!
|
19
|
+
@shared_file = FactoryGirl.build(:generic_file).tap do |r|
|
20
|
+
r.apply_depositor_metadata FactoryGirl.create(:user)
|
21
|
+
r.edit_users += [@user.user_key]
|
22
|
+
r.save!
|
23
|
+
end
|
24
|
+
@unrelated_file = FactoryGirl.create(:generic_file, depositor: FactoryGirl.create(:user))
|
25
|
+
@wrong_type = Batch.create
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should respond with success" do
|
29
|
+
get :index
|
30
|
+
expect(response).to be_successful
|
31
|
+
expect(response).to render_template('dashboard/lists/index')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "sets the controller name" do
|
35
|
+
expect(controller.controller_name).to eq :dashboard
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should paginate" do
|
39
|
+
FactoryGirl.create(:generic_file)
|
40
|
+
FactoryGirl.create(:generic_file)
|
41
|
+
get :index, per_page: 2
|
42
|
+
expect(assigns[:document_list].length).to eq 2
|
43
|
+
get :index, per_page: 2, page: 2
|
44
|
+
expect(assigns[:document_list].length).to be >= 1
|
45
|
+
end
|
46
|
+
|
47
|
+
it "shows the correct files" do
|
48
|
+
get :index
|
49
|
+
# shows documents I deposited
|
50
|
+
expect(assigns[:document_list].map(&:id)).to include(@my_file.id)
|
51
|
+
# doesn't show collections
|
52
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@my_collection.id)
|
53
|
+
# doesn't show shared files
|
54
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@shared_file.id)
|
55
|
+
# doesn't show other users' files
|
56
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@unrelated_file.id)
|
57
|
+
# doesn't show non-generic files
|
58
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@wrong_type.id)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "not logged in as a user" do
|
64
|
+
describe "#index" do
|
65
|
+
it "should return an error" do
|
66
|
+
get :index
|
67
|
+
expect(response).to be_redirect
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dashboard::HighlightsController do
|
4
|
+
describe "logged in user" do
|
5
|
+
before (:each) do
|
6
|
+
@user = FactoryGirl.find_or_create(:archivist)
|
7
|
+
sign_in @user
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#index" do
|
11
|
+
before do
|
12
|
+
GenericFile.destroy_all
|
13
|
+
Collection.destroy_all
|
14
|
+
@highlighted_file = FactoryGirl.create(:generic_file, depositor: @user)
|
15
|
+
@user.trophies.create(generic_file_id: @highlighted_file.id)
|
16
|
+
@normal_file = FactoryGirl.create(:generic_file, depositor: @user)
|
17
|
+
other_user = FactoryGirl.create(:user)
|
18
|
+
@unrelated_highlighted_file = FactoryGirl.create(:generic_file).tap do |r|
|
19
|
+
r.apply_depositor_metadata other_user
|
20
|
+
r.edit_users += [@user.user_key]
|
21
|
+
r.save!
|
22
|
+
end
|
23
|
+
other_user.trophies.create(generic_file_id: @unrelated_highlighted_file.id)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should respond with success" do
|
27
|
+
get :index
|
28
|
+
expect(response).to be_successful
|
29
|
+
expect(response).to render_template('dashboard/lists/index')
|
30
|
+
end
|
31
|
+
|
32
|
+
it "sets the controller name" do
|
33
|
+
expect(controller.controller_name).to eq :dashboard
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should paginate" do
|
37
|
+
@user.trophies.create(generic_file_id: FactoryGirl.create(:generic_file, depositor: @user).id)
|
38
|
+
@user.trophies.create(generic_file_id: FactoryGirl.create(:generic_file, depositor: @user).id)
|
39
|
+
get :index, per_page: 2
|
40
|
+
expect(assigns[:document_list].length).to eq 2
|
41
|
+
get :index, per_page: 2, page: 2
|
42
|
+
expect(assigns[:document_list].length).to be >= 1
|
43
|
+
end
|
44
|
+
|
45
|
+
it "shows the correct files" do
|
46
|
+
get :index
|
47
|
+
# shows documents I've highlighted
|
48
|
+
expect(assigns[:document_list].map(&:id)).to include(@highlighted_file.id)
|
49
|
+
# doesn't show non-highlighted files
|
50
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@normal_file.id)
|
51
|
+
# doesn't show other users' highlighted files
|
52
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@unrelated_highlighted_file.id)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "not logged in as a user" do
|
58
|
+
describe "#index" do
|
59
|
+
it "should return an error" do
|
60
|
+
get :index
|
61
|
+
expect(response).to be_redirect
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dashboard::SharesController do
|
4
|
+
describe "logged in user" do
|
5
|
+
before (:each) do
|
6
|
+
@user = FactoryGirl.find_or_create(:archivist)
|
7
|
+
sign_in @user
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#index" do
|
11
|
+
before do
|
12
|
+
GenericFile.destroy_all
|
13
|
+
Collection.destroy_all
|
14
|
+
@other_user = FactoryGirl.create(:user)
|
15
|
+
@my_file = FactoryGirl.create(:generic_file, depositor: @user)
|
16
|
+
@unshared_file = FactoryGirl.create(:generic_file, depositor: @other_user)
|
17
|
+
@shared_with_me = FactoryGirl.create(:generic_file).tap do |r|
|
18
|
+
r.apply_depositor_metadata @other_user
|
19
|
+
r.edit_users += [@user.user_key]
|
20
|
+
r.save!
|
21
|
+
end
|
22
|
+
@shared_with_someone_else = FactoryGirl.create(:generic_file).tap do |r|
|
23
|
+
r.apply_depositor_metadata @user
|
24
|
+
r.edit_users += [@other_user.user_key]
|
25
|
+
r.save!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should respond with success" do
|
30
|
+
get :index
|
31
|
+
expect(response).to be_successful
|
32
|
+
expect(response).to render_template('dashboard/lists/index')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "sets the controller name" do
|
36
|
+
expect(controller.controller_name).to eq :dashboard
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should paginate" do
|
40
|
+
FactoryGirl.create(:generic_file).tap do |r|
|
41
|
+
r.apply_depositor_metadata @other_user
|
42
|
+
r.edit_users += [@user.user_key]
|
43
|
+
r.save!
|
44
|
+
end
|
45
|
+
FactoryGirl.create(:generic_file).tap do |r|
|
46
|
+
r.apply_depositor_metadata @other_user
|
47
|
+
r.edit_users += [@user.user_key]
|
48
|
+
r.save!
|
49
|
+
end
|
50
|
+
get :index, per_page: 2
|
51
|
+
expect(assigns[:document_list].length).to eq 2
|
52
|
+
get :index, per_page: 2, page: 2
|
53
|
+
expect(assigns[:document_list].length).to be >= 1
|
54
|
+
end
|
55
|
+
|
56
|
+
it "shows the correct documents" do
|
57
|
+
get :index
|
58
|
+
# shows documents shared with me
|
59
|
+
expect(assigns[:document_list].map(&:id)).to include(@shared_with_me.id)
|
60
|
+
# doesn't show normal files
|
61
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@my_file.id)
|
62
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@unshared_file.id)
|
63
|
+
# doesn't show files shared with other users
|
64
|
+
expect(assigns[:document_list].map(&:id)).to_not include(@shared_with_someone_else.id)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "not logged in as a user" do
|
70
|
+
describe "#index" do
|
71
|
+
it "should return an error" do
|
72
|
+
get :index
|
73
|
+
expect(response).to be_redirect
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
@@ -2,7 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe DashboardController do
|
4
4
|
before do
|
5
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
6
5
|
User.any_instance.stub(:groups).and_return([])
|
7
6
|
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
8
7
|
end
|
@@ -39,50 +38,4 @@ describe DashboardController do
|
|
39
38
|
get :index
|
40
39
|
end
|
41
40
|
end
|
42
|
-
describe "logged in user" do
|
43
|
-
before (:each) do
|
44
|
-
@user = FactoryGirl.find_or_create(:archivist)
|
45
|
-
sign_in @user
|
46
|
-
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
47
|
-
User.any_instance.stub(:groups).and_return([])
|
48
|
-
end
|
49
|
-
describe "#index" do
|
50
|
-
before (:each) do
|
51
|
-
xhr :get, :index
|
52
|
-
# Make sure there are at least 3 files owned by @user. Otherwise, the tests aren't meaningful.
|
53
|
-
if assigns(:document_list).count < 3
|
54
|
-
files_count = assigns(:document_list).count
|
55
|
-
until files_count == 3
|
56
|
-
gf = GenericFile.new()
|
57
|
-
gf.apply_depositor_metadata(@user)
|
58
|
-
gf.save
|
59
|
-
files_count += 1
|
60
|
-
end
|
61
|
-
xhr :get, :index
|
62
|
-
end
|
63
|
-
end
|
64
|
-
it "should be a success" do
|
65
|
-
response.should be_success
|
66
|
-
response.should render_template('dashboard/index')
|
67
|
-
end
|
68
|
-
it "should return an array of documents I can edit" do
|
69
|
-
editable_docs_response = ActiveFedora::SolrService.instance.conn.get "select", :params=>{:fq=>["edit_access_group_ssim:public OR edit_access_person_ssim:#{@user.user_key}"]}
|
70
|
-
assigns(:result_set_size).should eql(editable_docs_response["response"]["numFound"])
|
71
|
-
assigns(:document_list).each {|doc| doc.should be_kind_of SolrDocument}
|
72
|
-
end
|
73
|
-
it "should paginate" do
|
74
|
-
xhr :get, :index, per_page: 2
|
75
|
-
response.should be_success
|
76
|
-
response.should render_template('dashboard/index')
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
describe "not logged in as a user" do
|
81
|
-
describe "#index" do
|
82
|
-
it "should return an error" do
|
83
|
-
xhr :post, :index
|
84
|
-
response.should_not be_success
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
41
|
end
|
@@ -4,10 +4,9 @@ describe DownloadsController do
|
|
4
4
|
|
5
5
|
describe "with a file" do
|
6
6
|
before do
|
7
|
-
@f = GenericFile.new(:
|
7
|
+
@f = GenericFile.new(pid: 'sufia:test1')
|
8
8
|
@f.apply_depositor_metadata('archivist1@example.com')
|
9
9
|
@f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
10
|
-
@f.should_receive(:characterize_if_changed).and_yield
|
11
10
|
@f.save!
|
12
11
|
end
|
13
12
|
|
@@ -26,24 +25,24 @@ describe DownloadsController do
|
|
26
25
|
DownloadsController.default_content_dsid.should == "content"
|
27
26
|
controller.stub(:render) # send_data calls render internally
|
28
27
|
expected_content = ActiveFedora::Base.find("sufia:test1", cast: true).content.content
|
29
|
-
controller.should_receive(:send_file_headers!).with({:
|
30
|
-
get "show", :
|
28
|
+
controller.should_receive(:send_file_headers!).with({filename: 'world.png', disposition: 'inline', type: 'image/png' })
|
29
|
+
get "show", id: "test1"
|
31
30
|
response.body.should == expected_content
|
32
31
|
response.should be_success
|
33
32
|
end
|
34
33
|
it "should return requested datastreams" do
|
35
34
|
controller.stub(:render) # send_data calls render internally
|
36
35
|
expected_content = ActiveFedora::Base.find("sufia:test1", cast: true).descMetadata.content
|
37
|
-
controller.should_receive(:send_file_headers!).with({:
|
38
|
-
get "show", :
|
36
|
+
controller.should_receive(:send_file_headers!).with({filename: 'descMetadata', disposition: 'inline', type: 'text/plain' })
|
37
|
+
get "show", id: "test1", datastream_id: "descMetadata"
|
39
38
|
response.body.should == expected_content
|
40
39
|
response.should be_success
|
41
40
|
end
|
42
41
|
it "should support setting disposition to inline" do
|
43
42
|
controller.stub(:render) # send_data calls render internally
|
44
43
|
expected_content = ActiveFedora::Base.find("sufia:test1", cast: true).content.content
|
45
|
-
controller.should_receive(:send_file_headers!).with({:
|
46
|
-
get "show", :
|
44
|
+
controller.should_receive(:send_file_headers!).with({filename: 'world.png', disposition: 'inline', type: 'image/png' })
|
45
|
+
get "show", id: "test1", disposition: "inline"
|
47
46
|
response.body.should == expected_content
|
48
47
|
response.should be_success
|
49
48
|
end
|
@@ -51,8 +50,8 @@ describe DownloadsController do
|
|
51
50
|
it "should allow you to specify filename for download" do
|
52
51
|
controller.stub(:render) # send_data calls render internally
|
53
52
|
expected_content = ActiveFedora::Base.find("sufia:test1", cast: true).content.content
|
54
|
-
controller.should_receive(:send_file_headers!).with({:
|
55
|
-
get "show", :
|
53
|
+
controller.should_receive(:send_file_headers!).with({filename: 'my%20dog.png', disposition: 'inline', type: 'image/png' })
|
54
|
+
get "show", id: "test1", "filename" => "my%20dog.png"
|
56
55
|
response.body.should == expected_content
|
57
56
|
end
|
58
57
|
end
|
@@ -67,7 +66,7 @@ describe DownloadsController do
|
|
67
66
|
|
68
67
|
describe "show" do
|
69
68
|
it "should deny access" do
|
70
|
-
get "show", :
|
69
|
+
get "show", id: "test1"
|
71
70
|
response.should redirect_to root_path
|
72
71
|
flash[:alert].should == 'You are not authorized to access this page.'
|
73
72
|
end
|
@@ -12,7 +12,7 @@ describe GenericFilesController do
|
|
12
12
|
describe "#create" do
|
13
13
|
before do
|
14
14
|
@file_count = GenericFile.count
|
15
|
-
@mock = GenericFile.new({:
|
15
|
+
@mock = GenericFile.new({pid: 'test:123'})
|
16
16
|
GenericFile.stub(:new).and_return(@mock)
|
17
17
|
end
|
18
18
|
|
@@ -24,28 +24,28 @@ describe GenericFilesController do
|
|
24
24
|
|
25
25
|
it "should render error the file wasn't actually a file" do
|
26
26
|
file = 'hello'
|
27
|
-
xhr :post, :create, :
|
27
|
+
xhr :post, :create, files: [file], Filename: "The World", batch_id: 'sample:batch_id', permission: {"group"=>{"public"=>"read"} }, terms_of_service: '1'
|
28
28
|
response.status.should == 422
|
29
29
|
JSON.parse(response.body).first['error'].should match(/no file for upload/i)
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "spawns a content deposit event job" do
|
33
33
|
file = fixture_file_upload('/world.png','image/png')
|
34
34
|
s1 = double('one')
|
35
|
-
ContentDepositEventJob.
|
36
|
-
Sufia.queue.
|
35
|
+
allow(ContentDepositEventJob).to receive(:new).with('test:123', 'jilluser@example.com').and_return(s1)
|
36
|
+
expect(Sufia.queue).to receive(:push).with(s1).once
|
37
37
|
|
38
38
|
s2 = double('one')
|
39
|
-
CharacterizeJob.
|
40
|
-
Sufia.queue.
|
41
|
-
xhr :post, :create, :
|
42
|
-
flash[:error].
|
39
|
+
allow(CharacterizeJob).to receive(:new).with('test:123').and_return(s2)
|
40
|
+
expect(Sufia.queue).to receive(:push).with(s2).once
|
41
|
+
xhr :post, :create, files: [file], 'Filename' => 'The world', batch_id: 'sample:batch_id', permission: {group: { public: 'read' } }, terms_of_service: '1'
|
42
|
+
expect(flash[:error]).to be_nil
|
43
43
|
end
|
44
44
|
|
45
45
|
it "displays a flash error when file has a virus" do
|
46
46
|
file = fixture_file_upload('/world.png', 'image/png')
|
47
|
-
Sufia::GenericFile::
|
48
|
-
xhr :post, :create, :
|
47
|
+
Sufia::GenericFile::Actor.should_receive(:virus_check).with(file.path).and_raise(Sufia::VirusFoundError.new('A virus was found'))
|
48
|
+
xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample:batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: '1'
|
49
49
|
flash[:error].should_not be_blank
|
50
50
|
flash[:error].should include('A virus was found')
|
51
51
|
end
|
@@ -54,7 +54,7 @@ describe GenericFilesController do
|
|
54
54
|
date_today = Date.today
|
55
55
|
Date.stub(:today).and_return(date_today)
|
56
56
|
file = fixture_file_upload('/world.png','image/png')
|
57
|
-
xhr :post, :create, :
|
57
|
+
xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample:batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: '1'
|
58
58
|
response.should be_success
|
59
59
|
GenericFile.count.should == @file_count + 1
|
60
60
|
|
@@ -73,7 +73,7 @@ describe GenericFilesController do
|
|
73
73
|
it "should record what user created the first version of content" do
|
74
74
|
#GenericFile.any_instance.stub(:to_solr).and_return({})
|
75
75
|
file = fixture_file_upload('/world.png','image/png')
|
76
|
-
xhr :post, :create, :
|
76
|
+
xhr :post, :create, files: [file], Filename: "The world", terms_of_service: "1"
|
77
77
|
|
78
78
|
saved_file = GenericFile.find('test:123')
|
79
79
|
version = saved_file.content.latest_version
|
@@ -85,14 +85,14 @@ describe GenericFilesController do
|
|
85
85
|
Sufia.config.stub(:id_namespace).and_return('sample')
|
86
86
|
file = fixture_file_upload('/world.png','image/png')
|
87
87
|
controller.stub(:add_posted_blob_to_asset)
|
88
|
-
xhr :post, :create, :
|
88
|
+
xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample:batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
|
89
89
|
lambda {Batch.find("sample:batch_id")}.should raise_error(ActiveFedora::ObjectNotFoundError) # The controller shouldn't actually save the Batch, but it should write the batch id to the files.
|
90
90
|
b = Batch.create(pid: "sample:batch_id")
|
91
91
|
b.generic_files.first.pid.should == "test:123"
|
92
92
|
end
|
93
93
|
it "should set the depositor id" do
|
94
94
|
file = fixture_file_upload('/world.png','image/png')
|
95
|
-
xhr :post, :create, :
|
95
|
+
xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample:batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
|
96
96
|
response.should be_success
|
97
97
|
|
98
98
|
saved_file = GenericFile.find('test:123')
|
@@ -115,11 +115,11 @@ describe GenericFilesController do
|
|
115
115
|
GenericFile.any_instance.stub(:save).and_raise(RSolr::Error::Http.new({},{}))
|
116
116
|
|
117
117
|
file = fixture_file_upload('/world.png','image/png')
|
118
|
-
xhr :post, :create, :
|
118
|
+
xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample:batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
|
119
119
|
response.body.should include("Error occurred while creating generic file.")
|
120
120
|
end
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
describe "#create with browse-everything" do
|
124
124
|
before do
|
125
125
|
GenericFile.delete_all
|
@@ -128,14 +128,14 @@ describe GenericFilesController do
|
|
128
128
|
it "should ingest files from provide URLs" do
|
129
129
|
ImportUrlJob.should_receive(:new).twice {"ImportJob"}
|
130
130
|
Sufia.queue.should_receive(:push).with("ImportJob").twice
|
131
|
-
lambda { post :create, selected_files: @json_from_browse_everything, :
|
131
|
+
lambda { post :create, selected_files: @json_from_browse_everything, batch_id: "sample:batch_id"}.should change(GenericFile, :count).by(2)
|
132
132
|
created_files = GenericFile.all
|
133
133
|
["https://dl.dropbox.com/fake/Getting%20Started.pdf", "https://dl.dropbox.com/fake/filepicker-demo.txt.txt"].each do |url|
|
134
|
-
created_files.map {|f| f.import_url}.should include(url)
|
134
|
+
created_files.map {|f| f.import_url}.should include(url)
|
135
135
|
end
|
136
|
-
end
|
136
|
+
end
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
describe "#create with local_file" do
|
140
140
|
let (:mock_url) {"http://example.com"}
|
141
141
|
before do
|
@@ -220,7 +220,7 @@ describe GenericFilesController do
|
|
220
220
|
@generic_file.delete
|
221
221
|
end
|
222
222
|
it "should return json with the result" do
|
223
|
-
xhr :post, :audit, :
|
223
|
+
xhr :post, :audit, id: @generic_file.pid
|
224
224
|
response.should be_success
|
225
225
|
lambda { JSON.parse(response.body) }.should_not raise_error
|
226
226
|
audit_results = JSON.parse(response.body).collect { |result| result["pass"] }
|
@@ -241,14 +241,14 @@ describe GenericFilesController do
|
|
241
241
|
end
|
242
242
|
it "should delete the file" do
|
243
243
|
GenericFile.find(@generic_file.pid).should_not be_nil
|
244
|
-
delete :destroy, :
|
244
|
+
delete :destroy, id: @generic_file.pid
|
245
245
|
lambda { GenericFile.find(@generic_file.pid) }.should raise_error(ActiveFedora::ObjectNotFoundError)
|
246
246
|
end
|
247
247
|
it "should spawn a content delete event job" do
|
248
248
|
s1 = double('one')
|
249
249
|
ContentDeleteEventJob.should_receive(:new).with(@generic_file.noid, @user.user_key).and_return(s1)
|
250
250
|
Sufia.queue.should_receive(:push).with(s1).once
|
251
|
-
delete :destroy, :
|
251
|
+
delete :destroy, id: @generic_file.pid
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
@@ -277,8 +277,15 @@ describe GenericFilesController do
|
|
277
277
|
allow(mock_query).to receive(:map).and_return(mock_query.for_path.map(&:marshal_dump))
|
278
278
|
profile = double('profile')
|
279
279
|
allow(profile).to receive(:pageview).and_return(mock_query)
|
280
|
-
allow(Sufia::
|
281
|
-
|
280
|
+
allow(Sufia::Analytics).to receive(:profile).and_return(profile)
|
281
|
+
|
282
|
+
download_query = double('query')
|
283
|
+
allow(download_query).to receive(:for_file).and_return([
|
284
|
+
OpenStruct.new(eventCategory: "Files", eventAction: "Downloaded", eventLabel: "sufia:123456789", totalEvents: "3")
|
285
|
+
])
|
286
|
+
allow(download_query).to receive(:map).and_return(download_query.for_file.map(&:marshal_dump))
|
287
|
+
allow(profile).to receive(:download).and_return(download_query)
|
288
|
+
end
|
282
289
|
|
283
290
|
it 'renders the stats view' do
|
284
291
|
get :stats, id: @generic_file.noid
|
@@ -301,38 +308,41 @@ describe GenericFilesController do
|
|
301
308
|
end
|
302
309
|
|
303
310
|
describe "update" do
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
311
|
+
let(:generic_file) do
|
312
|
+
GenericFile.new.tap do |gf|
|
313
|
+
gf.apply_depositor_metadata(@user)
|
314
|
+
gf.save!
|
315
|
+
end
|
308
316
|
end
|
317
|
+
|
309
318
|
after do
|
310
|
-
|
319
|
+
generic_file.destroy
|
311
320
|
end
|
312
321
|
|
313
322
|
it "should spawn a content update event job" do
|
314
323
|
s1 = double('one')
|
315
|
-
ContentUpdateEventJob.should_receive(:new).with(
|
324
|
+
ContentUpdateEventJob.should_receive(:new).with(generic_file.pid, 'jilluser@example.com').and_return(s1)
|
316
325
|
Sufia.queue.should_receive(:push).with(s1).once
|
317
326
|
@user = FactoryGirl.find_or_create(:jill)
|
318
327
|
sign_in @user
|
319
|
-
post :update, :
|
328
|
+
post :update, id: generic_file, generic_file: {title: 'new_title', tag: [''], permissions: { new_user_name: {'archivist1'=>'edit'}}}
|
320
329
|
@user.delete
|
321
330
|
end
|
322
331
|
|
323
|
-
it "
|
332
|
+
it "spawns a content new version event job" do
|
324
333
|
s1 = double('one')
|
325
|
-
ContentNewVersionEventJob.
|
326
|
-
Sufia.queue.
|
334
|
+
allow(ContentNewVersionEventJob).to receive(:new).with(generic_file.pid, 'jilluser@example.com').and_return(s1)
|
335
|
+
expect(Sufia.queue).to receive(:push).with(s1).once
|
336
|
+
|
327
337
|
s2 = double('one')
|
328
|
-
CharacterizeJob.
|
329
|
-
Sufia.queue.
|
338
|
+
allow(CharacterizeJob).to receive(:new).with(generic_file.pid).and_return(s2)
|
339
|
+
expect(Sufia.queue).to receive(:push).with(s2).once
|
330
340
|
@user = FactoryGirl.find_or_create(:jill)
|
331
341
|
sign_in @user
|
332
342
|
|
333
|
-
file = fixture_file_upload('/world.png','image/png')
|
334
|
-
post :update, :
|
335
|
-
@user.
|
343
|
+
file = fixture_file_upload('/world.png', 'image/png')
|
344
|
+
post :update, id: generic_file, filedata: file, generic_file: {tag: [''], permissions: { new_user_name: {archivist1: 'edit' } } }
|
345
|
+
@user.destroy
|
336
346
|
end
|
337
347
|
|
338
348
|
it "should change mime type when restoring a revision with a different mime type" do
|
@@ -340,23 +350,23 @@ describe GenericFilesController do
|
|
340
350
|
sign_in @user
|
341
351
|
|
342
352
|
file = fixture_file_upload('/world.png','image/png')
|
343
|
-
post :update, :
|
353
|
+
post :update, id: generic_file, filedata: file, generic_file: { tag: [''], permissions: { new_user_name: { 'archivist1@example.com'=>'edit' } } }
|
344
354
|
|
345
|
-
posted_file = GenericFile.find(
|
355
|
+
posted_file = GenericFile.find(generic_file.pid)
|
346
356
|
version1 = posted_file.content.latest_version
|
347
357
|
posted_file.content.version_committer(version1).should == @user.user_key
|
348
358
|
|
349
359
|
file = fixture_file_upload('/image.jpg','image/jpg')
|
350
|
-
post :update, :
|
360
|
+
post :update, id: generic_file, filedata: file, generic_file: { tag: [''], permissions: { new_user_name: { 'archivist1@example.com'=>'edit' } } }
|
351
361
|
|
352
|
-
posted_file = GenericFile.find(
|
362
|
+
posted_file = GenericFile.find(generic_file.pid)
|
353
363
|
version2 = posted_file.content.latest_version
|
354
364
|
posted_file.content.version_committer(version2).should == @user.user_key
|
355
365
|
|
356
366
|
posted_file.content.mimeType.should == "image/jpeg"
|
357
|
-
post :update, :
|
367
|
+
post :update, id: generic_file, revision: 'content.0'
|
358
368
|
|
359
|
-
restored_file = GenericFile.find(
|
369
|
+
restored_file = GenericFile.find(generic_file.pid)
|
360
370
|
version3 = restored_file.content.latest_version
|
361
371
|
version3.versionID.should_not == version2.versionID
|
362
372
|
version3.versionID.should_not == version1.versionID
|
@@ -365,117 +375,136 @@ describe GenericFilesController do
|
|
365
375
|
@user.delete
|
366
376
|
end
|
367
377
|
|
368
|
-
|
369
|
-
|
370
|
-
|
378
|
+
context "when two users edit a file" do
|
379
|
+
let(:archivist) { FactoryGirl.find_or_create(:archivist) }
|
380
|
+
let(:user) { FactoryGirl.find_or_create(:jill) }
|
381
|
+
let(:generic_file) do
|
382
|
+
GenericFile.new.tap do |gf|
|
383
|
+
gf.apply_depositor_metadata(user)
|
384
|
+
gf.edit_users = [user.user_key, archivist.user_key]
|
385
|
+
gf.save!
|
386
|
+
end
|
387
|
+
end
|
388
|
+
before do
|
389
|
+
allow_any_instance_of(Sufia::GenericFile::Actor).to receive(:push_characterize_job)
|
390
|
+
sign_in user
|
391
|
+
end
|
371
392
|
|
372
|
-
|
373
|
-
|
393
|
+
it "records which user added a new version" do
|
394
|
+
file = fixture_file_upload('/world.png','image/png')
|
395
|
+
post :update, id: generic_file, filedata: file
|
374
396
|
|
375
|
-
|
376
|
-
|
377
|
-
|
397
|
+
posted_file = GenericFile.find(generic_file.pid)
|
398
|
+
version1 = posted_file.content.latest_version
|
399
|
+
expect(posted_file.content.version_committer(version1)).to eq(user.user_key)
|
378
400
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
401
|
+
# other user uploads new version
|
402
|
+
# TODO this should be a separate test
|
403
|
+
allow(controller).to receive(:current_user).and_return(archivist)
|
404
|
+
# reset controller:
|
405
|
+
controller.instance_variable_set(:@actor, nil)
|
383
406
|
|
384
|
-
|
407
|
+
expect(ContentUpdateEventJob).to receive(:new).with(generic_file.pid, 'jilluser@example.com').never
|
385
408
|
|
386
|
-
|
387
|
-
|
388
|
-
|
409
|
+
s1 = double('one')
|
410
|
+
allow(ContentNewVersionEventJob).to receive(:new).with(generic_file.pid, archivist.user_key).and_return(s1)
|
411
|
+
expect(Sufia.queue).to receive(:push).with(s1).once
|
389
412
|
|
390
|
-
|
391
|
-
|
392
|
-
Sufia.queue.should_receive(:push).with(s2).once
|
393
|
-
file = fixture_file_upload('/image.jpg','image/jpg')
|
394
|
-
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world"
|
413
|
+
file = fixture_file_upload('/image.jpg', 'image/jpg')
|
414
|
+
post :update, id: generic_file, filedata: file
|
395
415
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
416
|
+
edited_file = generic_file.reload
|
417
|
+
version2 = edited_file.content.latest_version
|
418
|
+
expect(version2.versionID).not_to eq(version1.versionID)
|
419
|
+
expect(edited_file.content.version_committer(version2)).to eq(archivist.user_key)
|
400
420
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
421
|
+
# original user restores his or her version
|
422
|
+
allow(controller).to receive(:current_user).and_return(user)
|
423
|
+
sign_in user
|
424
|
+
expect(ContentUpdateEventJob).to receive(:new).with(generic_file.pid, 'jilluser@example.com').never
|
425
|
+
s1 = double('one')
|
426
|
+
allow(ContentRestoredVersionEventJob).to receive(:new).with(generic_file.pid, user.user_key, 'content.0').and_return(s1)
|
427
|
+
expect(Sufia.queue).to receive(:push).with(s1).once
|
408
428
|
|
409
|
-
|
410
|
-
|
411
|
-
Sufia.queue.should_receive(:push).with(s2).once
|
412
|
-
post :update, :id=>@generic_file.pid, :revision=>'content.0'
|
429
|
+
# reset controller:
|
430
|
+
controller.instance_variable_set(:@actor, nil)
|
413
431
|
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
432
|
+
post :update, id: generic_file, revision: 'content.0'
|
433
|
+
|
434
|
+
restored_file = generic_file.reload
|
435
|
+
version3 = restored_file.content.latest_version
|
436
|
+
expect(version3.versionID).not_to eq(version2.versionID)
|
437
|
+
expect(version3.versionID).not_to eq(version1.versionID)
|
438
|
+
expect(restored_file.content.version_committer(version3)).to eq(user.user_key)
|
439
|
+
end
|
420
440
|
end
|
421
441
|
|
422
|
-
it "should add
|
423
|
-
post :update, :
|
442
|
+
it "should add new groups and users" do
|
443
|
+
post :update, id: generic_file, generic_file: { tag: [''], permissions:
|
444
|
+
{ new_group_name: { 'group1' => 'read' }, new_user_name: { 'user1' => 'edit' }}}
|
424
445
|
|
425
446
|
assigns[:generic_file].read_groups.should == ["group1"]
|
426
447
|
assigns[:generic_file].edit_users.should include("user1", @user.user_key)
|
427
448
|
end
|
428
449
|
it "should update existing groups and users" do
|
429
|
-
|
430
|
-
|
431
|
-
post :update, :
|
450
|
+
generic_file.read_groups = ['group3']
|
451
|
+
generic_file.save
|
452
|
+
post :update, id: generic_file, generic_file: { tag: [''], permissions:
|
453
|
+
{ new_group_name: '', new_group_permission: '', new_user_name: '', new_user_permission: '', group: { 'group3' => 'read' }}}
|
432
454
|
|
433
455
|
assigns[:generic_file].read_groups.should == ["group3"]
|
434
456
|
end
|
435
|
-
|
436
|
-
|
437
|
-
Sufia::GenericFile::Actions.should_receive(:virus_check).and_return(0)
|
457
|
+
|
458
|
+
it "spawns a virus check" do
|
438
459
|
s1 = double('one')
|
439
|
-
ContentNewVersionEventJob.
|
440
|
-
Sufia.queue.
|
460
|
+
allow(ContentNewVersionEventJob).to receive(:new).with(generic_file.pid, 'jilluser@example.com').and_return(s1)
|
461
|
+
expect(Sufia.queue).to receive(:push).with(s1).once
|
441
462
|
|
442
463
|
s2 = double('one')
|
443
|
-
CharacterizeJob.
|
444
|
-
|
445
|
-
GenericFile.stub(:save).and_return({})
|
464
|
+
allow(CharacterizeJob).to receive(:new).with(generic_file.pid).and_return(s2)
|
465
|
+
allow(CreateDerivativesJob).to receive(:new).with(generic_file.pid).and_return(s2)
|
446
466
|
@user = FactoryGirl.find_or_create(:jill)
|
447
467
|
sign_in @user
|
448
|
-
file = fixture_file_upload('/world.png','image/png')
|
449
|
-
|
468
|
+
file = fixture_file_upload('/world.png', 'image/png')
|
469
|
+
expect(Sufia::GenericFile::Actor).to receive(:virus_check).and_return(0)
|
470
|
+
expect(Sufia.queue).to receive(:push).with(s2).once
|
471
|
+
post :update, id: generic_file.pid, filedata: file, 'Filename' => 'The world', generic_file: { tag: [''], permissions: { new_user_name: { archivist1: 'edit' } } }
|
450
472
|
end
|
451
473
|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
474
|
+
context "when there's an error saving" do
|
475
|
+
let!(:generic_file) do
|
476
|
+
GenericFile.new.tap do |gf|
|
477
|
+
gf.apply_depositor_metadata(@user)
|
478
|
+
gf.save!
|
479
|
+
end
|
480
|
+
end
|
481
|
+
it "redirects to edit" do
|
482
|
+
GenericFile.any_instance.should_receive(:valid?).and_return(false)
|
483
|
+
post :update, id: generic_file, generic_file: {:tag=>['']}
|
484
|
+
response.should be_successful
|
485
|
+
response.should render_template('edit')
|
486
|
+
expect(assigns[:generic_file]).to eq generic_file
|
487
|
+
end
|
458
488
|
end
|
459
|
-
|
460
489
|
end
|
461
490
|
|
462
491
|
describe "someone elses files" do
|
463
492
|
before do
|
464
|
-
f = GenericFile.new(:
|
493
|
+
f = GenericFile.new(pid: 'sufia:test5')
|
465
494
|
f.apply_depositor_metadata('archivist1@example.com')
|
466
495
|
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
467
496
|
# grant public read access explicitly
|
468
497
|
f.read_groups = ['public']
|
469
|
-
f.should_receive(:characterize_if_changed).and_yield
|
470
498
|
f.save
|
471
499
|
@file = f
|
500
|
+
allow_any_instance_of(Sufia::GenericFile::Actor).to receive(:push_characterize_job)
|
472
501
|
end
|
473
502
|
after do
|
474
503
|
GenericFile.find('sufia:test5').destroy
|
475
504
|
end
|
476
505
|
describe "edit" do
|
477
506
|
it "should give me a flash error" do
|
478
|
-
get :edit, id:"test5"
|
507
|
+
get :edit, id: "test5"
|
479
508
|
response.should redirect_to @routes.url_helpers.generic_file_path('test5')
|
480
509
|
flash[:alert].should_not be_nil
|
481
510
|
flash[:alert].should_not be_empty
|
@@ -484,8 +513,8 @@ describe GenericFilesController do
|
|
484
513
|
end
|
485
514
|
describe "view" do
|
486
515
|
it "should show me the file" do
|
487
|
-
get :show, id:"test5"
|
488
|
-
response.should_not redirect_to(:
|
516
|
+
get :show, id: "test5"
|
517
|
+
response.should_not redirect_to(action: 'show')
|
489
518
|
flash[:alert].should be_nil
|
490
519
|
end
|
491
520
|
end
|
@@ -499,7 +528,7 @@ describe GenericFilesController do
|
|
499
528
|
end
|
500
529
|
it "should filter flash if they signin" do
|
501
530
|
sign_in @user
|
502
|
-
get :show, id:"test5"
|
531
|
+
get :show, id: "test5"
|
503
532
|
flash[:alert].should be_nil
|
504
533
|
end
|
505
534
|
describe "failing audit" do
|
@@ -511,7 +540,7 @@ describe GenericFilesController do
|
|
511
540
|
sign_in @archivist
|
512
541
|
@ds = @file.datastreams.first
|
513
542
|
AuditJob.new(@file.pid, @ds[0], @ds[1].versionID).run
|
514
|
-
get :show, id:"test5"
|
543
|
+
get :show, id: "test5"
|
515
544
|
assigns[:notify_number].should == 1
|
516
545
|
@archivist.mailbox.inbox[0].messages[0].subject.should == "Failing Audit Run"
|
517
546
|
end
|