sufia 6.2.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +146 -0
- data/.travis.yml +4 -7
- data/Gemfile +2 -0
- data/History.md +29 -1
- data/README.md +25 -9
- data/SUFIA_VERSION +1 -1
- data/app/assets/stylesheets/sufia/_collections.scss +15 -0
- data/app/assets/stylesheets/sufia/_file-listing.scss +7 -0
- data/app/assets/stylesheets/sufia/_home-page.scss +10 -0
- data/app/builders/sufia/bootstrap_breadcrumbs_builder.rb +3 -5
- data/app/controllers/admin/stats_controller.rb +1 -76
- data/app/controllers/api/items_controller.rb +4 -6
- data/app/controllers/api/zotero_controller.rb +5 -5
- data/app/controllers/authorities_controller.rb +5 -1
- data/app/controllers/batch_edits_controller.rb +3 -3
- data/app/controllers/concerns/sufia/admin/depositor_stats.rb +41 -0
- data/app/controllers/concerns/sufia/admin/stats_behavior.rb +94 -0
- data/app/controllers/concerns/sufia/batch_controller_behavior.rb +16 -18
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +54 -56
- data/app/controllers/concerns/sufia/breadcrumbs.rb +3 -6
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +39 -39
- data/app/controllers/concerns/sufia/controller.rb +10 -10
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +17 -18
- data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +9 -12
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +6 -7
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +39 -40
- data/app/controllers/concerns/sufia/files_controller/upload_complete_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +109 -110
- data/app/controllers/concerns/sufia/homepage_controller.rb +8 -8
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +13 -10
- data/app/controllers/concerns/sufia/single_use_links_controller_behavior.rb +11 -14
- data/app/controllers/concerns/sufia/single_use_links_viewer_controller_behavior.rb +27 -21
- data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +17 -17
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +54 -54
- data/app/controllers/contact_form_controller.rb +1 -1
- data/app/controllers/content_blocks_controller.rb +11 -12
- data/app/controllers/directory_controller.rb +2 -3
- data/app/controllers/featured_work_lists_controller.rb +1 -1
- data/app/controllers/featured_works_controller.rb +2 -4
- data/app/controllers/homepage_controller.rb +1 -2
- data/app/controllers/mailbox_controller.rb +12 -32
- data/app/controllers/my/collections_controller.rb +3 -4
- data/app/controllers/my/files_controller.rb +4 -6
- data/app/controllers/my/highlights_controller.rb +4 -6
- data/app/controllers/my/shares_controller.rb +3 -5
- data/app/controllers/pages_controller.rb +1 -3
- data/app/controllers/single_use_links_controller.rb +0 -1
- data/app/controllers/single_use_links_viewer_controller.rb +0 -1
- data/app/controllers/static_controller.rb +1 -0
- data/app/forms/sufia/forms/collection_edit_form.rb +2 -2
- data/app/helpers/batch_edits_helper.rb +1 -3
- data/app/helpers/content_block_helper.rb +7 -8
- data/app/helpers/generic_file_helper.rb +23 -24
- data/app/helpers/sufia/blacklight_override.rb +6 -7
- data/app/helpers/sufia/dashboard_helper_behavior.rb +4 -7
- data/app/helpers/sufia/permissions_helper.rb +3 -4
- data/app/helpers/sufia/sufia_helper_behavior.rb +30 -29
- data/app/helpers/trophy_helper.rb +15 -15
- data/app/inputs/select_with_modal_help_input.rb +3 -3
- data/app/inputs/with_help_icon.rb +4 -4
- data/app/jobs/content_delete_event_job.rb +0 -1
- data/app/jobs/content_depositor_change_event_job.rb +1 -2
- data/app/jobs/event_job.rb +0 -1
- data/app/jobs/user_unfollow_event_job.rb +1 -0
- data/app/models/concerns/sufia/solr_document_behavior.rb +1 -2
- data/app/models/contact_form.rb +6 -6
- data/app/models/content_block.rb +1 -2
- data/app/models/featured_work_list.rb +3 -5
- data/app/models/user_mailbox.rb +44 -0
- data/app/presenters/sufia/collection_presenter.rb +6 -8
- data/app/presenters/sufia/generic_file_presenter.rb +2 -2
- data/app/presenters/sufia/presenter_renderer.rb +2 -2
- data/app/presenters/sufia/version_list_presenter.rb +1 -1
- data/app/presenters/sufia/version_presenter.rb +3 -6
- data/app/search_builders/deposit_search_builder.rb +19 -0
- data/app/search_builders/sufia/my_search_builder_behavior.rb +1 -2
- data/app/search_builders/sufia/search_builder.rb +1 -3
- data/app/uploaders/tinymce_asset_uploader.rb +0 -2
- data/app/views/_controls.html.erb +5 -5
- data/app/views/admin/stats/_deposits.html.erb +19 -0
- data/app/views/admin/stats/index.html.erb +2 -0
- data/app/views/batch_edits/edit.html.erb +2 -2
- data/app/views/collections/_edit_actions.html.erb +3 -3
- data/app/views/collections/_form_for_select_collection.html.erb +2 -2
- data/app/views/collections/_sort_and_per_page.html.erb +12 -9
- data/app/views/collections/_view_type_group.html.erb +1 -1
- data/app/views/collections/edit.html.erb +5 -5
- data/app/views/collections/show.html.erb +7 -6
- data/app/views/homepage/_announcement.html.erb +5 -0
- data/app/views/homepage/_home.html.erb +1 -0
- data/app/views/my/_sort_and_per_page.html.erb +14 -10
- data/app/views/my/index.html.erb +1 -1
- data/app/views/pages/show.html.erb +0 -2
- data/app/views/single_use_links/new_download.html.erb +1 -1
- data/app/views/single_use_links_viewer/show.html.erb +1 -1
- data/app/views/users/_notify_link.html.erb +1 -1
- data/app/views/users/_notify_number.html.erb +2 -2
- data/config/initializers/simple_form.rb +1 -1
- data/config/initializers/simple_form_bootstrap.rb +1 -1
- data/config/locales/sufia.en.yml +4 -0
- data/config/routes.rb +2 -3
- data/lib/generators/sufia/admin_stat_generator.rb +0 -3
- data/lib/generators/sufia/install_generator.rb +8 -9
- data/lib/generators/sufia/templates/catalog_controller.rb +2 -3
- data/lib/generators/sufia/templates/config/action_dispatch_http_upload_monkey_patch.rb +1 -0
- data/lib/generators/sufia/upgrade400_generator.rb +9 -9
- data/lib/generators/sufia/upgrade600_generator.rb +1 -4
- data/lib/sufia.rb +2 -2
- data/lib/sufia/arkivo/actor.rb +1 -1
- data/lib/sufia/arkivo/create_subscription_job.rb +30 -30
- data/lib/sufia/arkivo/metadata_munger.rb +7 -7
- data/lib/sufia/arkivo/schema_validator.rb +1 -1
- data/lib/sufia/single_use_error.rb +0 -1
- data/lib/sufia/version.rb +1 -1
- data/lib/sufia/zotero/config.rb +13 -13
- data/spec/actors/generic_file/actor_spec.rb +17 -18
- data/spec/controllers/admin_stats_controller_spec.rb +56 -5
- data/spec/controllers/api/zotero_controller_spec.rb +10 -9
- data/spec/controllers/authorities_controller_spec.rb +8 -8
- data/spec/controllers/batch_controller_spec.rb +19 -20
- data/spec/controllers/batch_edits_controller_spec.rb +8 -9
- data/spec/controllers/catalog_controller_spec.rb +7 -9
- data/spec/controllers/collections_controller_spec.rb +30 -32
- data/spec/controllers/content_blocks_controller_spec.rb +4 -4
- data/spec/controllers/dashboard_controller_spec.rb +12 -12
- data/spec/controllers/depositors_controller_spec.rb +8 -8
- data/spec/controllers/downloads_controller_spec.rb +10 -11
- data/spec/controllers/featured_work_lists_controller_spec.rb +4 -4
- data/spec/controllers/featured_works_controller_spec.rb +11 -12
- data/spec/controllers/generic_files_controller_spec.rb +154 -125
- data/spec/controllers/homepage_controller_spec.rb +22 -15
- data/spec/controllers/mailbox_controller_spec.rb +20 -36
- data/spec/controllers/my/collections_controller_spec.rb +4 -5
- data/spec/controllers/my/files_controller_spec.rb +10 -11
- data/spec/controllers/my/highlights_controller_spec.rb +4 -5
- data/spec/controllers/my/shares_controller_spec.rb +12 -14
- data/spec/controllers/my_controller_spec.rb +1 -3
- data/spec/controllers/pages_controller_spec.rb +4 -4
- data/spec/controllers/single_use_links_controller_spec.rb +1 -3
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +1 -2
- data/spec/controllers/static_controller_spec.rb +1 -1
- data/spec/controllers/tinymce_assets_controller_spec.rb +8 -9
- data/spec/controllers/transfers_controller_spec.rb +19 -19
- data/spec/controllers/users_controller_spec.rb +33 -35
- data/spec/factories/api_items.rb +2 -2
- data/spec/factories/content_blocks.rb +1 -1
- data/spec/factories/featured_works.rb +1 -1
- data/spec/factories/generic_files.rb +3 -3
- data/spec/factories/users.rb +7 -8
- data/spec/features/browse_dashboard_files_spec.rb +14 -18
- data/spec/features/browse_files_spec.rb +3 -4
- data/spec/features/catalog_search_spec.rb +3 -5
- data/spec/features/cloud_upload_spec.rb +2 -2
- data/spec/features/collection_spec.rb +21 -21
- data/spec/features/contact_form_spec.rb +10 -11
- data/spec/features/display_dashboard_spec.rb +5 -9
- data/spec/features/edit_file_spec.rb +8 -9
- data/spec/features/featured_item_spec.rb +1 -1
- data/spec/features/ingest_upload_files_spec.rb +5 -5
- data/spec/features/notifications_spec.rb +2 -6
- data/spec/features/ownership_transfer_spec.rb +2 -2
- data/spec/features/proxy_spec.rb +2 -2
- data/spec/features/search_spec.rb +3 -4
- data/spec/features/single_use_links_spec.rb +1 -1
- data/spec/features/users_spec.rb +4 -5
- data/spec/forms/collection_edit_form_spec.rb +2 -2
- data/spec/forms/generic_file_edit_form_spec.rb +6 -7
- data/spec/helpers/batch_edits_helper_spec.rb +9 -13
- data/spec/helpers/content_block_helper_spec.rb +3 -3
- data/spec/helpers/dashboard_helper_spec.rb +19 -24
- data/spec/helpers/generic_file_helper_spec.rb +5 -7
- data/spec/helpers/sufia_helper_spec.rb +43 -54
- data/spec/helpers/trophy_helper_spec.rb +5 -5
- data/spec/inputs/multi_value_with_help_input_spec.rb +1 -2
- data/spec/inputs/select_with_help_input_spec.rb +19 -15
- data/spec/javascripts/jasmine_spec.rb +4 -5
- data/spec/javascripts/support/jasmine_helper.rb +9 -9
- data/spec/jobs/active_fedora_id_based_job_spec.rb +7 -5
- data/spec/jobs/audit_job_spec.rb +7 -7
- data/spec/jobs/batch_update_job_spec.rb +5 -6
- data/spec/jobs/characterize_job_spec.rb +1 -1
- data/spec/jobs/content_depositor_change_event_job_spec.rb +1 -1
- data/spec/jobs/create_derivatives_job_spec.rb +5 -5
- data/spec/jobs/event_jobs_spec.rb +16 -16
- data/spec/jobs/import_url_job_spec.rb +36 -5
- data/spec/jobs/ingest_local_file_job_spec.rb +31 -20
- data/spec/jobs/sufia_resque_queue_spec.rb +1 -1
- data/spec/lib/sufia/analytics_spec.rb +0 -1
- data/spec/lib/sufia/arkivo/actor_spec.rb +6 -6
- data/spec/lib/sufia/arkivo/schema_validator_spec.rb +18 -18
- data/spec/lib/sufia/breadcrumbs_spec.rb +5 -6
- data/spec/lib/sufia/messages_spec.rb +11 -12
- data/spec/lib/sufia/readable_permissions_spec.rb +8 -10
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +6 -7
- data/spec/lib/sufia/user_stat_importer_spec.rb +30 -33
- data/spec/lib/sufia/writable_permissions_spec.rb +1 -3
- data/spec/lib/sufia/zotero/config_spec.rb +4 -6
- data/spec/models/ability_spec.rb +11 -9
- data/spec/models/batch_spec.rb +13 -13
- data/spec/models/characterization_spec.rb +2 -3
- data/spec/models/checksum_audit_log_spec.rb +18 -19
- data/spec/models/collection_spec.rb +11 -12
- data/spec/models/content_block_spec.rb +33 -22
- data/spec/models/download_spec.rb +3 -5
- data/spec/models/featured_work_list_spec.rb +3 -3
- data/spec/models/featured_work_spec.rb +12 -14
- data/spec/models/file_content_datastream_spec.rb +9 -7
- data/spec/models/file_download_stat_spec.rb +34 -40
- data/spec/models/file_usage_spec.rb +46 -52
- data/spec/models/file_view_stat_spec.rb +35 -41
- data/spec/models/fits_datastream_spec.rb +23 -25
- data/spec/models/generic_file/visibility_spec.rb +10 -5
- data/spec/models/generic_file_spec.rb +86 -88
- data/spec/models/geo_names_resource_spec.rb +3 -5
- data/spec/models/local_authority_spec.rb +30 -33
- data/spec/models/pageview_spec.rb +3 -3
- data/spec/models/proxy_deposit_request_spec.rb +3 -3
- data/spec/models/single_use_link_spec.rb +36 -36
- data/spec/models/solr_document_spec.rb +3 -6
- data/spec/models/trophy_spec.rb +8 -9
- data/spec/models/user_mailbox_spec.rb +62 -0
- data/spec/models/user_spec.rb +28 -29
- data/spec/presenters/presenter_renderer_spec.rb +1 -1
- data/spec/presenters/sufia/generic_file_presenter_spec.rb +5 -5
- data/spec/presenters/sufia/version_list_presenter_spec.rb +2 -2
- data/spec/presenters/sufia/version_presenter_spec.rb +1 -1
- data/spec/routing/featured_works_route_spec.rb +4 -4
- data/spec/routing/ownership_transfers_route_spec.rb +1 -1
- data/spec/routing/route_spec.rb +89 -89
- data/spec/services/generic_file_audit_service_spec.rb +8 -8
- data/spec/services/repository_audit_service_spec.rb +7 -3
- data/spec/spec_helper.rb +5 -4
- data/spec/support/features/session_helpers.rb +1 -1
- data/spec/support/input_support.rb +1 -2
- data/spec/support/rake.rb +1 -1
- data/spec/support/selectors.rb +1 -6
- data/spec/support/statistic_helper.rb +1 -1
- data/spec/support/uploaded_file_monkeypatch.rb +1 -1
- data/spec/tasks/rake_spec.rb +3 -5
- data/spec/views/admin/stats/index.html.erb_spec.rb +16 -16
- data/spec/views/batch/edit.html.erb_spec.rb +1 -3
- data/spec/views/batch_edits/check_all_spec.rb +5 -5
- data/spec/views/batch_edits/edit.html.erb_spec.rb +1 -3
- data/spec/views/catalog/index.html.erb_spec.rb +1 -3
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +4 -5
- data/spec/views/collections/_form.html.erb_spec.rb +5 -3
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +7 -8
- data/spec/views/collections/_show_document_list.erb_spec.rb +4 -6
- data/spec/views/dashboard/index_spec.rb +14 -21
- data/spec/views/generic_file/_browse_everything.html.erb_spec.rb +2 -2
- data/spec/views/generic_file/_permission_form.html.erb_spec.rb +8 -9
- data/spec/views/generic_file/edit.html.erb_spec.rb +7 -7
- data/spec/views/generic_file/show.html.erb_spec.rb +24 -25
- data/spec/views/generic_file/stats.html.erb_spec.rb +19 -19
- data/spec/views/homepage/_announcement.html.erb_spec.rb +51 -0
- data/spec/views/homepage/_featured_works.html.erb_spec.rb +5 -9
- data/spec/views/homepage/_home_header.html.erb_spec.rb +2 -2
- data/spec/views/my/facet.html.erb_spec.rb +4 -4
- data/spec/views/single_use_links/new_download.html.erb_spec.rb +28 -0
- data/spec/views/single_use_links_viewer/show.html.erb_spec.rb +29 -0
- data/spec/views/users/_follower_modal.html.erb_spec.rb +7 -8
- data/spec/views/users/_following_modal.html.erb_spec.rb +4 -5
- data/spec/views/users/_notify_number.html.erb_spec.rb +2 -5
- data/spec/views/users/_user_util_links.html.erb_spec.rb +5 -8
- data/spec/views/users/index.html.erb_spec.rb +4 -6
- data/spec/views/users/show.html.erb_spec.rb +4 -7
- data/tasks/sufia-dev.rake +19 -3
- metadata +20 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe DashboardController, :
|
|
3
|
+
describe DashboardController, type: :controller do
|
|
4
4
|
context "with an unauthenticated user" do
|
|
5
5
|
it "redirects to sign-in page" do
|
|
6
6
|
get :index
|
|
@@ -36,11 +36,11 @@ describe DashboardController, :type => :controller do
|
|
|
36
36
|
let(:another_user) { FactoryGirl.find_or_create(:archivist) }
|
|
37
37
|
context 'when incoming' do
|
|
38
38
|
let!(:incoming_file) do
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
GenericFile.new.tap do |f|
|
|
40
|
+
f.apply_depositor_metadata(another_user.user_key)
|
|
41
|
+
f.save!
|
|
42
|
+
f.request_transfer_to(user)
|
|
43
|
+
end
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it 'assigns an instance variable' do
|
|
@@ -53,11 +53,11 @@ describe DashboardController, :type => :controller do
|
|
|
53
53
|
|
|
54
54
|
context 'when outgoing' do
|
|
55
55
|
let!(:outgoing_file) do
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
GenericFile.new.tap do |f|
|
|
57
|
+
f.apply_depositor_metadata(user.user_key)
|
|
58
|
+
f.save!
|
|
59
|
+
f.request_transfer_to(another_user)
|
|
60
|
+
end
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it 'assigns an instance variable' do
|
|
@@ -74,7 +74,7 @@ describe DashboardController, :type => :controller do
|
|
|
74
74
|
|
|
75
75
|
before do
|
|
76
76
|
allow(activity).to receive(:map).and_return(activity)
|
|
77
|
-
allow_any_instance_of(User).to receive(:
|
|
77
|
+
allow_any_instance_of(User).to receive(:all_user_activity).and_return(activity)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it "gathers the user's recent activity within the default amount of time" do
|
|
@@ -10,13 +10,13 @@ describe DepositorsController do
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
describe "create" do
|
|
13
|
-
it "
|
|
14
|
-
expect { post :create, user_id: user.user_key, grantee_id: grantee.user_key, format: 'json' }.to change{ ProxyDepositRights.count }.by(1)
|
|
13
|
+
it "is successful" do
|
|
14
|
+
expect { post :create, user_id: user.user_key, grantee_id: grantee.user_key, format: 'json' }.to change { ProxyDepositRights.count }.by(1)
|
|
15
15
|
expect(response).to be_success
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
it "
|
|
19
|
-
expect { post :create, user_id: user.user_key, grantee_id: user.user_key, format: 'json' }.to change{ ProxyDepositRights.count }.by(0)
|
|
18
|
+
it "does not add current user" do
|
|
19
|
+
expect { post :create, user_id: user.user_key, grantee_id: user.user_key, format: 'json' }.to change { ProxyDepositRights.count }.by(0)
|
|
20
20
|
expect(response).to be_success
|
|
21
21
|
expect(response.body).to be_blank
|
|
22
22
|
end
|
|
@@ -26,8 +26,8 @@ describe DepositorsController do
|
|
|
26
26
|
before do
|
|
27
27
|
user.can_receive_deposits_from << grantee
|
|
28
28
|
end
|
|
29
|
-
it "
|
|
30
|
-
expect { delete :destroy, user_id: user.user_key, id: grantee.user_key, format: 'json' }.to change{ ProxyDepositRights.count }.by(-1)
|
|
29
|
+
it "is successful" do
|
|
30
|
+
expect { delete :destroy, user_id: user.user_key, id: grantee.user_key, format: 'json' }.to change { ProxyDepositRights.count }.by(-1)
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -37,14 +37,14 @@ describe DepositorsController do
|
|
|
37
37
|
sign_in FactoryGirl.create(:curator)
|
|
38
38
|
end
|
|
39
39
|
describe "create" do
|
|
40
|
-
it "
|
|
40
|
+
it "is not successful" do
|
|
41
41
|
post :create, user_id: user.user_key, grantee_id: grantee.user_key, format: 'json'
|
|
42
42
|
expect(response).to redirect_to root_path
|
|
43
43
|
expect(flash[:alert]).to eq "You are not authorized to access this page."
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
describe "destroy" do
|
|
47
|
-
it "
|
|
47
|
+
it "is not successful" do
|
|
48
48
|
delete :destroy, user_id: user.user_key, id: grantee.user_key, format: 'json'
|
|
49
49
|
expect(response).to redirect_to root_path
|
|
50
50
|
expect(flash[:alert]).to eq "You are not authorized to access this page."
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe DownloadsController, :
|
|
4
|
-
|
|
3
|
+
describe DownloadsController, type: :controller do
|
|
5
4
|
describe "with a file" do
|
|
6
5
|
let(:depositor) { FactoryGirl.find_or_create(:archivist) }
|
|
7
6
|
let(:file) do
|
|
@@ -26,9 +25,9 @@ describe DownloadsController, :type => :controller do
|
|
|
26
25
|
let(:expected_datastream) { object.content }
|
|
27
26
|
let(:expected_content) { expected_datastream.content }
|
|
28
27
|
|
|
29
|
-
it "
|
|
30
|
-
expect(
|
|
31
|
-
expect(controller).to receive(:send_file_headers!).with(
|
|
28
|
+
it "defaults to returning configured default download" do
|
|
29
|
+
expect(described_class.default_file_path).to eq "content"
|
|
30
|
+
expect(controller).to receive(:send_file_headers!).with(filename: 'world.png', disposition: 'inline', type: 'image/png')
|
|
32
31
|
get "show", id: file
|
|
33
32
|
expect(response).to be_success
|
|
34
33
|
expect(response.body).to eq expected_content
|
|
@@ -41,22 +40,22 @@ describe DownloadsController, :type => :controller do
|
|
|
41
40
|
file.save!
|
|
42
41
|
end
|
|
43
42
|
|
|
44
|
-
it "
|
|
43
|
+
it "returns requested datastreams" do
|
|
45
44
|
get "show", id: file, file: "characterization"
|
|
46
45
|
expect(response).to be_success
|
|
47
46
|
expect(response.body).to eq expected_content
|
|
48
47
|
end
|
|
49
48
|
end
|
|
50
49
|
|
|
51
|
-
it "
|
|
52
|
-
expect(controller).to receive(:send_file_headers!).with(
|
|
50
|
+
it "supports setting disposition to inline" do
|
|
51
|
+
expect(controller).to receive(:send_file_headers!).with(filename: 'world.png', disposition: 'inline', type: 'image/png')
|
|
53
52
|
get "show", id: file, disposition: "inline"
|
|
54
53
|
expect(response.body).to eq expected_content
|
|
55
54
|
expect(response).to be_success
|
|
56
55
|
end
|
|
57
56
|
|
|
58
|
-
it "
|
|
59
|
-
expect(controller).to receive(:send_file_headers!).with(
|
|
57
|
+
it "allows you to specify filename for download" do
|
|
58
|
+
expect(controller).to receive(:send_file_headers!).with(filename: 'my%20dog.png', disposition: 'inline', type: 'image/png')
|
|
60
59
|
get "show", id: file, "filename" => "my%20dog.png"
|
|
61
60
|
expect(response.body).to eq expected_content
|
|
62
61
|
expect(response).to be_success
|
|
@@ -70,7 +69,7 @@ describe DownloadsController, :type => :controller do
|
|
|
70
69
|
end
|
|
71
70
|
|
|
72
71
|
describe "show" do
|
|
73
|
-
it "
|
|
72
|
+
it "denies access" do
|
|
74
73
|
get "show", id: file
|
|
75
74
|
expect(response).to redirect_to root_path
|
|
76
75
|
expect(flash[:alert]).to eq 'You are not authorized to access this page.'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe FeaturedWorkListsController, :
|
|
3
|
+
describe FeaturedWorkListsController, type: :controller do
|
|
4
4
|
describe "#create" do
|
|
5
5
|
before do
|
|
6
6
|
expect(controller).to receive(:authorize!).with(:update, FeaturedWork)
|
|
@@ -9,10 +9,10 @@ describe FeaturedWorkListsController, :type => :controller do
|
|
|
9
9
|
let(:feature1) { FactoryGirl.create(:featured_work) }
|
|
10
10
|
let(:feature2) { FactoryGirl.create(:featured_work) }
|
|
11
11
|
|
|
12
|
-
it "
|
|
12
|
+
it "is successful" do
|
|
13
13
|
post :create, format: :json, featured_work_list: {
|
|
14
|
-
featured_works_attributes: [{id: feature1.id, order: "2"},
|
|
15
|
-
{id: feature2.id, order: "1"}]
|
|
14
|
+
featured_works_attributes: [{ id: feature1.id, order: "2" },
|
|
15
|
+
{ id: feature2.id, order: "1" }]
|
|
16
16
|
}
|
|
17
17
|
expect(feature1.reload.order).to eq 2
|
|
18
18
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe FeaturedWorksController, :
|
|
3
|
+
describe FeaturedWorksController, type: :controller do
|
|
4
4
|
describe "#create" do
|
|
5
5
|
before do
|
|
6
6
|
sign_in FactoryGirl.create(:user)
|
|
@@ -8,10 +8,10 @@ describe FeaturedWorksController, :type => :controller do
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
context "when there are no featured works" do
|
|
11
|
-
it "
|
|
12
|
-
expect
|
|
11
|
+
it "creates one" do
|
|
12
|
+
expect do
|
|
13
13
|
post :create, id: '1234abcd', format: :json
|
|
14
|
-
|
|
14
|
+
end.to change { FeaturedWork.count }.by(1)
|
|
15
15
|
expect(response).to be_successful
|
|
16
16
|
end
|
|
17
17
|
end
|
|
@@ -19,20 +19,19 @@ describe FeaturedWorksController, :type => :controller do
|
|
|
19
19
|
context "when there are 5 featured works" do
|
|
20
20
|
before do
|
|
21
21
|
5.times do |n|
|
|
22
|
-
FeaturedWork.create(generic_file_id:n.to_s)
|
|
22
|
+
FeaturedWork.create(generic_file_id: n.to_s)
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
-
it "
|
|
26
|
-
expect
|
|
25
|
+
it "does not create another" do
|
|
26
|
+
expect do
|
|
27
27
|
post :create, id: '1234abcd', format: :json
|
|
28
|
-
|
|
28
|
+
end.to_not change { FeaturedWork.count }
|
|
29
29
|
expect(response.status).to eq 422
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
describe "#destroy" do
|
|
35
|
-
|
|
36
35
|
let!(:featured_work) { FactoryGirl.create(:featured_work, generic_file_id: '1234abcd') }
|
|
37
36
|
|
|
38
37
|
before do
|
|
@@ -40,10 +39,10 @@ describe FeaturedWorksController, :type => :controller do
|
|
|
40
39
|
expect(controller).to receive(:authorize!).with(:destroy, FeaturedWork).and_return(true)
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
it "
|
|
44
|
-
expect
|
|
42
|
+
it "removes it" do
|
|
43
|
+
expect do
|
|
45
44
|
delete :destroy, id: '1234abcd', format: :json
|
|
46
|
-
|
|
45
|
+
end.to change { FeaturedWork.count }.by(-1)
|
|
47
46
|
expect(response.status).to eq 204
|
|
48
47
|
end
|
|
49
48
|
end
|
|
@@ -15,14 +15,14 @@ describe GenericFilesController do
|
|
|
15
15
|
let(:mock) { GenericFile.new(id: 'test123') }
|
|
16
16
|
let(:batch) { Batch.create }
|
|
17
17
|
let(:batch_id) { batch.id }
|
|
18
|
-
let(:file) { fixture_file_upload('/world.png','image/png') }
|
|
18
|
+
let(:file) { fixture_file_upload('/world.png', 'image/png') }
|
|
19
19
|
|
|
20
20
|
before do
|
|
21
21
|
allow(GenericFile).to receive(:new).and_return(mock)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
it "
|
|
25
|
-
file = fixture_file_upload('/world.png','image/png')
|
|
24
|
+
it "records on_behalf_of" do
|
|
25
|
+
file = fixture_file_upload('/world.png', 'image/png')
|
|
26
26
|
xhr :post, :create, files: [file], Filename: 'The world', batch_id: batch_id, on_behalf_of: 'carolyn', terms_of_service: '1'
|
|
27
27
|
expect(response).to be_success
|
|
28
28
|
saved_file = GenericFile.find('test123')
|
|
@@ -32,8 +32,8 @@ describe GenericFilesController do
|
|
|
32
32
|
context "when the file submitted isn't a file" do
|
|
33
33
|
let(:file) { 'hello' }
|
|
34
34
|
|
|
35
|
-
it "
|
|
36
|
-
xhr :post, :create, files: [file], Filename: "The World", batch_id: 'sample_batch_id', permission: {"group"=>{"public"=>"read"} }, terms_of_service: '1'
|
|
35
|
+
it "renders 422 error" do
|
|
36
|
+
xhr :post, :create, files: [file], Filename: "The World", batch_id: 'sample_batch_id', permission: { "group" => { "public" => "read" } }, terms_of_service: '1'
|
|
37
37
|
expect(response.status).to eq 422
|
|
38
38
|
expect(JSON.parse(response.body).first['error']).to match(/no file for upload/i)
|
|
39
39
|
end
|
|
@@ -43,18 +43,18 @@ describe GenericFilesController do
|
|
|
43
43
|
render_views
|
|
44
44
|
it "spawns a content deposit event job" do
|
|
45
45
|
expect_any_instance_of(Sufia::GenericFile::Actor).to receive(:create_content).with(file, 'world.png', 'content', 'image/png').and_return(true)
|
|
46
|
-
xhr :post, :create, files: [file], 'Filename' => 'The world', batch_id: batch_id, permission: {group: { public: 'read' } }, terms_of_service: '1'
|
|
46
|
+
xhr :post, :create, files: [file], 'Filename' => 'The world', batch_id: batch_id, permission: { group: { public: 'read' } }, terms_of_service: '1'
|
|
47
47
|
expect(response.body).to eq '[{"name":null,"size":null,"url":"/files/test123","thumbnail_url":"test123","delete_url":"deleteme","delete_type":"DELETE"}]'
|
|
48
48
|
expect(flash[:error]).to be_nil
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
it "
|
|
51
|
+
it "creates and save a file asset from the given params" do
|
|
52
52
|
date_today = DateTime.now
|
|
53
53
|
allow(DateTime).to receive(:now).and_return(date_today)
|
|
54
|
-
expect
|
|
54
|
+
expect do
|
|
55
55
|
xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id,
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
permission: { "group" => { "public" => "read" } }, terms_of_service: '1'
|
|
57
|
+
end.to change { GenericFile.count }.by(1)
|
|
58
58
|
expect(response).to be_success
|
|
59
59
|
|
|
60
60
|
saved_file = GenericFile.find('test123')
|
|
@@ -62,19 +62,19 @@ describe GenericFilesController do
|
|
|
62
62
|
# This is confirming that the correct file was attached
|
|
63
63
|
expect(saved_file.label).to eq 'world.png'
|
|
64
64
|
file.rewind
|
|
65
|
-
expect(saved_file.content.content).to eq
|
|
65
|
+
expect(saved_file.content.content).to eq(file.read)
|
|
66
66
|
# Confirming that date_uploaded and date_modified were set
|
|
67
67
|
expect(saved_file.date_uploaded).to eq date_today.new_offset(0)
|
|
68
68
|
expect(saved_file.date_modified).to eq date_today.new_offset(0)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
it "
|
|
72
|
-
xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id, permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
|
|
71
|
+
it "records what user created the first version of content" do
|
|
72
|
+
xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id, permission: { "group" => { "public" => "read" } }, terms_of_service: "1"
|
|
73
73
|
expect(VersionCommitter.pluck(:committer_login).last).to eq user.user_key
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
it "
|
|
77
|
-
xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id, permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
|
|
76
|
+
it "sets the depositor id" do
|
|
77
|
+
xhr :post, :create, files: [file], Filename: "The world", batch_id: batch_id, permission: { "group" => { "public" => "read" } }, terms_of_service: "1"
|
|
78
78
|
expect(response).to be_success
|
|
79
79
|
|
|
80
80
|
saved_file = GenericFile.find('test123')
|
|
@@ -87,18 +87,18 @@ describe GenericFilesController do
|
|
|
87
87
|
context "when the file has a virus" do
|
|
88
88
|
it "displays a flash error when file has a virus" do
|
|
89
89
|
expect(Sufia::GenericFile::Actor).to receive(:virus_check).with(file.path).and_raise(Sufia::VirusFoundError.new('A virus was found'))
|
|
90
|
-
xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample_batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: '1'
|
|
90
|
+
xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample_batch_id", permission: { "group" => { "public" => "read" } }, terms_of_service: '1'
|
|
91
91
|
expect(flash[:error]).not_to be_blank
|
|
92
92
|
expect(flash[:error]).to include('A virus was found')
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
context "when solr continuously has errors" do
|
|
97
|
-
it "
|
|
98
|
-
allow_any_instance_of(GenericFile).to receive(:save).and_raise(RSolr::Error::Http.new({},{}))
|
|
97
|
+
it "errors out of create and save after on continuos rsolr error" do
|
|
98
|
+
allow_any_instance_of(GenericFile).to receive(:save).and_raise(RSolr::Error::Http.new({}, {}))
|
|
99
99
|
|
|
100
|
-
file = fixture_file_upload('/world.png','image/png')
|
|
101
|
-
xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample_batch_id", permission: {"group"=>{"public"=>"read"} }, terms_of_service: "1"
|
|
100
|
+
file = fixture_file_upload('/world.png', 'image/png')
|
|
101
|
+
xhr :post, :create, files: [file], Filename: "The world", batch_id: "sample_batch_id", permission: { "group" => { "public" => "read" } }, terms_of_service: "1"
|
|
102
102
|
expect(response.body).to include("Error occurred while creating generic file.")
|
|
103
103
|
end
|
|
104
104
|
end
|
|
@@ -109,100 +109,130 @@ describe GenericFilesController do
|
|
|
109
109
|
let(:batch_id) { batch.id }
|
|
110
110
|
|
|
111
111
|
before do
|
|
112
|
-
@json_from_browse_everything = {"0"=>{"url"=>"https://dl.dropbox.com/fake/blah-blah.filepicker-demo.txt.txt", "expires"=>"2014-03-31T20:37:36.214Z", "file_name"=>"filepicker-demo.txt.txt"}, "1"=>{"url"=>"https://dl.dropbox.com/fake/blah-blah.Getting%20Started.pdf", "expires"=>"2014-03-31T20:37:36.731Z", "file_name"=>"Getting+Started.pdf"}}
|
|
112
|
+
@json_from_browse_everything = { "0" => { "url" => "https://dl.dropbox.com/fake/blah-blah.filepicker-demo.txt.txt", "expires" => "2014-03-31T20:37:36.214Z", "file_name" => "filepicker-demo.txt.txt" }, "1" => { "url" => "https://dl.dropbox.com/fake/blah-blah.Getting%20Started.pdf", "expires" => "2014-03-31T20:37:36.731Z", "file_name" => "Getting+Started.pdf" } }
|
|
113
113
|
end
|
|
114
|
-
it "
|
|
115
|
-
expect(ImportUrlJob).to receive(:new).twice {"ImportJob"}
|
|
114
|
+
it "ingests files from provide URLs" do
|
|
115
|
+
expect(ImportUrlJob).to receive(:new).twice { "ImportJob" }
|
|
116
116
|
expect(Sufia.queue).to receive(:push).with("ImportJob").twice
|
|
117
117
|
expect { post :create, selected_files: @json_from_browse_everything, batch_id: batch_id }.to change(GenericFile, :count).by(2)
|
|
118
118
|
created_files = GenericFile.all
|
|
119
119
|
["https://dl.dropbox.com/fake/blah-blah.Getting%20Started.pdf", "https://dl.dropbox.com/fake/blah-blah.filepicker-demo.txt.txt"].each do |url|
|
|
120
|
-
expect(created_files.map
|
|
120
|
+
expect(created_files.map(&:import_url)).to include(url)
|
|
121
121
|
end
|
|
122
|
-
["filepicker-demo.txt.txt","Getting+Started.pdf"].each do |filename|
|
|
123
|
-
expect(created_files.map
|
|
122
|
+
["filepicker-demo.txt.txt", "Getting+Started.pdf"].each do |filename|
|
|
123
|
+
expect(created_files.map(&:label)).to include(filename)
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
context "with local_file" do
|
|
129
|
-
let(:mock_url) {"http://example.com"}
|
|
129
|
+
let(:mock_url) { "http://example.com" }
|
|
130
130
|
let(:mock_upload_directory) { 'spec/mock_upload_directory' }
|
|
131
131
|
let(:batch) { Batch.create }
|
|
132
132
|
let(:batch_id) { batch.id }
|
|
133
133
|
|
|
134
|
-
before do
|
|
135
|
-
Sufia.config.enable_local_ingest = true
|
|
136
|
-
FileUtils.mkdir_p([File.join(mock_upload_directory, "import/files"), File.join(mock_upload_directory, "import/metadata")])
|
|
137
|
-
FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), mock_upload_directory)
|
|
138
|
-
FileUtils.copy(File.expand_path('../../fixtures/image.jpg', __FILE__), mock_upload_directory)
|
|
139
|
-
FileUtils.copy(File.expand_path('../../fixtures/dublin_core_rdf_descMetadata.nt', __FILE__), File.join(mock_upload_directory, "import/metadata"))
|
|
140
|
-
FileUtils.copy(File.expand_path('../../fixtures/icons.zip', __FILE__), File.join(mock_upload_directory, "import/files"))
|
|
141
|
-
FileUtils.copy(File.expand_path('../../fixtures/Example.ogg', __FILE__), File.join(mock_upload_directory, "import/files"))
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
after do
|
|
145
|
-
Sufia.config.enable_local_ingest = false
|
|
146
|
-
allow_any_instance_of(FileContentDatastream).to receive(:live?).and_return(true)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
134
|
context "when User model defines a directory path" do
|
|
150
135
|
before do
|
|
136
|
+
Sufia.config.enable_local_ingest = true
|
|
137
|
+
FileUtils.mkdir_p([File.join(mock_upload_directory, "import/files"), File.join(mock_upload_directory, "import/metadata")])
|
|
138
|
+
FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), mock_upload_directory)
|
|
139
|
+
FileUtils.copy(File.expand_path('../../fixtures/image.jpg', __FILE__), mock_upload_directory)
|
|
140
|
+
FileUtils.copy(File.expand_path('../../fixtures/dublin_core_rdf_descMetadata.nt', __FILE__), File.join(mock_upload_directory, "import/metadata"))
|
|
141
|
+
FileUtils.copy(File.expand_path('../../fixtures/icons.zip', __FILE__), File.join(mock_upload_directory, "import/files"))
|
|
142
|
+
FileUtils.copy(File.expand_path('../../fixtures/Example.ogg', __FILE__), File.join(mock_upload_directory, "import/files"))
|
|
143
|
+
|
|
151
144
|
allow_any_instance_of(User).to receive(:directory).and_return(mock_upload_directory)
|
|
152
145
|
end
|
|
153
146
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
147
|
+
after do
|
|
148
|
+
Sufia.config.enable_local_ingest = false
|
|
149
|
+
allow_any_instance_of(FileContentDatastream).to receive(:live?).and_return(true)
|
|
150
|
+
FileUtils.remove_dir(File.join(mock_upload_directory, "import/files"), true)
|
|
151
|
+
FileUtils.remove_dir(File.join(mock_upload_directory, "import/metadata"), true)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
let!(:actor) { Sufia::GenericFile::Actor.new(nil, nil) }
|
|
155
|
+
|
|
156
|
+
it "ingests files from the filesystem" do
|
|
157
|
+
# no need to save the files to fedora we justwant to know they were created
|
|
158
|
+
allow_any_instance_of(GenericFile).to receive(:save!).and_return(true)
|
|
159
|
+
|
|
160
|
+
# allow random GenericFiles to be created
|
|
161
|
+
allow(GenericFile).to receive(:new).with({}).and_call_original
|
|
162
|
+
|
|
163
|
+
# expect each file to be created
|
|
164
|
+
expect(GenericFile).to receive(:new).with(label: "world.png").and_call_original
|
|
165
|
+
expect(GenericFile).to receive(:new).with(label: "image.jpg").and_call_original
|
|
166
|
+
|
|
167
|
+
# expect metadata to be appplied to each file
|
|
168
|
+
expect(Sufia::GenericFile::Actor).to receive(:new).exactly(2).times.and_return(actor)
|
|
169
|
+
expect(actor).to receive(:create_metadata).exactly(2).times
|
|
170
|
+
|
|
171
|
+
# expect each file to be ingested
|
|
172
|
+
expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "world.png", user.user_key)
|
|
173
|
+
expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "image.jpg", user.user_key)
|
|
174
|
+
expect(Sufia.queue).to receive(:push).exactly(2).times
|
|
175
|
+
|
|
176
|
+
post :create, local_file: ["world.png", "image.jpg"], batch_id: batch_id
|
|
177
|
+
|
|
158
178
|
expect(response).to redirect_to Sufia::Engine.routes.url_helpers.batch_edit_path(batch_id)
|
|
159
|
-
# These files should have been moved out of the upload directory
|
|
160
|
-
expect(File).not_to exist("#{mock_upload_directory}/image.jpg")
|
|
161
|
-
expect(File).not_to exist("#{mock_upload_directory}/world.png")
|
|
162
|
-
# And into the storage directory
|
|
163
|
-
files = Batch.find(batch_id).generic_files
|
|
164
|
-
expect(files.first.label).to eq('world.png')
|
|
165
|
-
expect(files.to_a.map(&:label)).to eq ['world.png', 'image.jpg']
|
|
166
179
|
end
|
|
167
180
|
|
|
168
|
-
it "
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
it "ingests redirect to another location" do
|
|
182
|
+
# no need to save the files to fedora we justwant to know they were created
|
|
183
|
+
allow_any_instance_of(GenericFile).to receive(:save!).and_return(true)
|
|
184
|
+
|
|
185
|
+
# allow random GenericFiles to be created
|
|
186
|
+
allow(GenericFile).to receive(:new).with({}).and_call_original
|
|
187
|
+
|
|
188
|
+
# expect each file to be created
|
|
189
|
+
expect(GenericFile).to receive(:new).with(label: "world.png").and_call_original
|
|
190
|
+
|
|
191
|
+
# expect metadata to be appplied to each file
|
|
192
|
+
expect(Sufia::GenericFile::Actor).to receive(:new).exactly(1).times.and_return(actor)
|
|
193
|
+
expect(actor).to receive(:create_metadata).exactly(1).times
|
|
194
|
+
|
|
195
|
+
# expect each file to be ingested
|
|
196
|
+
expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "world.png", user.user_key)
|
|
197
|
+
expect(Sufia.queue).to receive(:push).exactly(1).times
|
|
198
|
+
expect(described_class).to receive(:upload_complete_path).and_return(mock_url)
|
|
199
|
+
|
|
200
|
+
post :create, local_file: ["world.png"], batch_id: batch_id
|
|
173
201
|
expect(response).to redirect_to mock_url
|
|
174
|
-
# These files should have been moved out of the upload directory
|
|
175
|
-
expect(File).not_to exist("#{mock_upload_directory}/world.png")
|
|
176
|
-
# And into the storage directory
|
|
177
|
-
files = Batch.find(batch_id).generic_files
|
|
178
|
-
expect(files.first.label).to eq 'world.png'
|
|
179
202
|
end
|
|
180
203
|
|
|
181
|
-
it "
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
expect
|
|
189
|
-
expect(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
expect(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
204
|
+
it "ingests directories from the filesystem" do
|
|
205
|
+
# no need to save the files to fedora we justwant to know they were created
|
|
206
|
+
allow_any_instance_of(GenericFile).to receive(:save!).and_return(true)
|
|
207
|
+
|
|
208
|
+
# allow random GenericFiles to be created
|
|
209
|
+
allow(GenericFile).to receive(:new).with({}).and_call_original
|
|
210
|
+
|
|
211
|
+
# expect each file to be created
|
|
212
|
+
expect(GenericFile).to receive(:new).with(label: "world.png").and_call_original
|
|
213
|
+
expect(GenericFile).to receive(:new).with(label: "icons.zip").and_call_original
|
|
214
|
+
expect(GenericFile).to receive(:new).with(label: "Example.ogg").and_call_original
|
|
215
|
+
expect(GenericFile).to receive(:new).with(label: "dublin_core_rdf_descMetadata.nt").and_call_original
|
|
216
|
+
|
|
217
|
+
# expect metadata to be appplied to each file
|
|
218
|
+
expect(Sufia::GenericFile::Actor).to receive(:new).exactly(4).times.and_return(actor)
|
|
219
|
+
expect(actor).to receive(:create_metadata).exactly(4).times
|
|
220
|
+
|
|
221
|
+
# expect each file to be ingested
|
|
222
|
+
expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "world.png", user.user_key)
|
|
223
|
+
expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "import/files/icons.zip", user.user_key)
|
|
224
|
+
expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "import/files/Example.ogg", user.user_key)
|
|
225
|
+
expect(IngestLocalFileJob).to receive(:new).with(nil, "spec/mock_upload_directory", "import/metadata/dublin_core_rdf_descMetadata.nt", user.user_key)
|
|
226
|
+
expect(Sufia.queue).to receive(:push).exactly(4).times
|
|
227
|
+
post :create, local_file: ["world.png", "import"], batch_id: batch_id
|
|
198
228
|
end
|
|
199
229
|
end
|
|
200
230
|
|
|
201
231
|
context "when User model does not define directory path" do
|
|
202
|
-
it "
|
|
203
|
-
expect
|
|
232
|
+
it "returns an error message and redirect to file upload page" do
|
|
233
|
+
expect do
|
|
204
234
|
post :create, local_file: ["world.png", "image.jpg"], batch_id: batch_id
|
|
205
|
-
|
|
235
|
+
end.to_not change(GenericFile, :count)
|
|
206
236
|
expect(response).to render_template :new
|
|
207
237
|
expect(flash[:alert]).to eq 'Your account is not configured for importing files from a user-directory on the server.'
|
|
208
238
|
end
|
|
@@ -218,7 +248,7 @@ describe GenericFilesController do
|
|
|
218
248
|
end
|
|
219
249
|
end
|
|
220
250
|
|
|
221
|
-
it "
|
|
251
|
+
it "returns json with the result" do
|
|
222
252
|
xhr :post, :audit, id: generic_file
|
|
223
253
|
expect(response).to be_success
|
|
224
254
|
json = JSON.parse(response.body)
|
|
@@ -238,11 +268,11 @@ describe GenericFilesController do
|
|
|
238
268
|
allow(ContentDeleteEventJob).to receive(:new).with(generic_file.id, user.user_key).and_return(delete_message)
|
|
239
269
|
end
|
|
240
270
|
let(:delete_message) { double('delete message') }
|
|
241
|
-
it "
|
|
271
|
+
it "deletes the file" do
|
|
242
272
|
expect(Sufia.queue).to receive(:push).with(delete_message)
|
|
243
|
-
expect
|
|
273
|
+
expect do
|
|
244
274
|
delete :destroy, id: generic_file
|
|
245
|
-
|
|
275
|
+
end.to change { GenericFile.exists?(generic_file.id) }.from(true).to(false)
|
|
246
276
|
end
|
|
247
277
|
|
|
248
278
|
context "when the file is featured" do
|
|
@@ -250,7 +280,7 @@ describe GenericFilesController do
|
|
|
250
280
|
FeaturedWork.create(generic_file_id: generic_file.id)
|
|
251
281
|
expect(Sufia.queue).to receive(:push).with(delete_message)
|
|
252
282
|
end
|
|
253
|
-
it "
|
|
283
|
+
it "makes the file not featured" do
|
|
254
284
|
expect(FeaturedWorkList.new.featured_works.map(&:generic_file_id)).to include(generic_file.id)
|
|
255
285
|
delete :destroy, id: generic_file.id
|
|
256
286
|
expect(FeaturedWorkList.new.featured_works.map(&:generic_file_id)).to_not include(generic_file.id)
|
|
@@ -270,11 +300,11 @@ describe GenericFilesController do
|
|
|
270
300
|
sign_in user
|
|
271
301
|
mock_query = double('query')
|
|
272
302
|
allow(mock_query).to receive(:for_path).and_return([
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
303
|
+
OpenStruct.new(date: '2014-01-01', pageviews: 4),
|
|
304
|
+
OpenStruct.new(date: '2014-01-02', pageviews: 8),
|
|
305
|
+
OpenStruct.new(date: '2014-01-03', pageviews: 6),
|
|
306
|
+
OpenStruct.new(date: '2014-01-04', pageviews: 10),
|
|
307
|
+
OpenStruct.new(date: '2014-01-05', pageviews: 2)])
|
|
278
308
|
allow(mock_query).to receive(:map).and_return(mock_query.for_path.map(&:marshal_dump))
|
|
279
309
|
profile = double('profile')
|
|
280
310
|
allow(profile).to receive(:sufia__pageview).and_return(mock_query)
|
|
@@ -331,7 +361,7 @@ describe GenericFilesController do
|
|
|
331
361
|
end
|
|
332
362
|
end
|
|
333
363
|
|
|
334
|
-
it "
|
|
364
|
+
it "sets the breadcrumbs and versions presenter" do
|
|
335
365
|
allow(controller.request).to receive(:referer).and_return('foo')
|
|
336
366
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
|
|
337
367
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.my.files'), Sufia::Engine.routes.url_helpers.dashboard_files_path)
|
|
@@ -359,10 +389,10 @@ describe GenericFilesController do
|
|
|
359
389
|
allow(ContentUpdateEventJob).to receive(:new).with(generic_file.id, 'jilluser@example.com').and_return(update_message)
|
|
360
390
|
end
|
|
361
391
|
|
|
362
|
-
it "
|
|
392
|
+
it "spawns a content update event job" do
|
|
363
393
|
expect(Sufia.queue).to receive(:push).with(update_message)
|
|
364
394
|
post :update, id: generic_file, generic_file: { title: ['new_title'], tag: [''],
|
|
365
|
-
permissions_attributes: [{ type: 'person', name: 'archivist1', access: 'edit'}] }
|
|
395
|
+
permissions_attributes: [{ type: 'person', name: 'archivist1', access: 'edit' }] }
|
|
366
396
|
end
|
|
367
397
|
|
|
368
398
|
it "spawns a content new version event job" do
|
|
@@ -374,7 +404,7 @@ describe GenericFilesController do
|
|
|
374
404
|
allow(CharacterizeJob).to receive(:new).with(generic_file.id).and_return(s2)
|
|
375
405
|
expect(Sufia.queue).to receive(:push).with(s2).once
|
|
376
406
|
file = fixture_file_upload('/world.png', 'image/png')
|
|
377
|
-
post :update, id: generic_file, filedata: file, generic_file: {tag: [''], permissions: { new_user_name: {archivist1: 'edit' } } }
|
|
407
|
+
post :update, id: generic_file, filedata: file, generic_file: { tag: [''], permissions: { new_user_name: { archivist1: 'edit' } } }
|
|
378
408
|
end
|
|
379
409
|
end
|
|
380
410
|
|
|
@@ -389,13 +419,12 @@ describe GenericFilesController do
|
|
|
389
419
|
expect(Sufia.queue).to receive(:push).with(s2).once
|
|
390
420
|
|
|
391
421
|
file = fixture_file_upload('/world.png', 'image/png')
|
|
392
|
-
post :update, id: generic_file, filedata: file, generic_file: {tag: [''],
|
|
393
|
-
|
|
422
|
+
post :update, id: generic_file, filedata: file, generic_file: { tag: [''],
|
|
423
|
+
permissions_attributes: [{ type: 'user', name: 'archivist1', access: 'edit' }] }
|
|
394
424
|
end
|
|
395
425
|
end
|
|
396
426
|
|
|
397
427
|
context "with two existing versions from different users" do
|
|
398
|
-
|
|
399
428
|
let(:file1) { "world.png" }
|
|
400
429
|
let(:file1_type) { "image/png" }
|
|
401
430
|
let(:file2) { "image.jpg" }
|
|
@@ -422,7 +451,7 @@ describe GenericFilesController do
|
|
|
422
451
|
let(:versions) { restored_content.versions }
|
|
423
452
|
let(:latest_version) { restored_content.latest_version }
|
|
424
453
|
|
|
425
|
-
it "
|
|
454
|
+
it "restores the first versions's content and metadata" do
|
|
426
455
|
expect(restored_content.mime_type).to eq file1_type
|
|
427
456
|
expect(restored_content.original_name).to eq file1
|
|
428
457
|
expect(versions.all.count).to eq 3
|
|
@@ -435,7 +464,7 @@ describe GenericFilesController do
|
|
|
435
464
|
before do
|
|
436
465
|
sign_in second_user
|
|
437
466
|
end
|
|
438
|
-
it "
|
|
467
|
+
it "does not create a new version" do
|
|
439
468
|
post :update, id: generic_file, revision: version1
|
|
440
469
|
expect(response).to be_redirect
|
|
441
470
|
end
|
|
@@ -443,27 +472,27 @@ describe GenericFilesController do
|
|
|
443
472
|
end
|
|
444
473
|
end
|
|
445
474
|
|
|
446
|
-
it "
|
|
475
|
+
it "adds new groups and users" do
|
|
447
476
|
post :update, id: generic_file,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
477
|
+
generic_file: { tag: [''],
|
|
478
|
+
permissions_attributes: [
|
|
479
|
+
{ type: 'person', name: 'user1', access: 'edit' },
|
|
480
|
+
{ type: 'group', name: 'group1', access: 'read' }
|
|
481
|
+
]
|
|
453
482
|
}
|
|
454
483
|
|
|
455
484
|
expect(assigns[:generic_file].read_groups).to eq ["group1"]
|
|
456
485
|
expect(assigns[:generic_file].edit_users).to include("user1", user.user_key)
|
|
457
486
|
end
|
|
458
487
|
|
|
459
|
-
it "
|
|
488
|
+
it "updates existing groups and users" do
|
|
460
489
|
generic_file.edit_groups = ['group3']
|
|
461
490
|
generic_file.save
|
|
462
491
|
post :update, id: generic_file,
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
492
|
+
generic_file: { tag: [''],
|
|
493
|
+
permissions_attributes: [
|
|
494
|
+
{ id: generic_file.permissions.last.id, type: 'group', name: 'group3', access: 'read' }
|
|
495
|
+
]
|
|
467
496
|
}
|
|
468
497
|
|
|
469
498
|
expect(assigns[:generic_file].read_groups).to eq(["group3"])
|
|
@@ -481,8 +510,8 @@ describe GenericFilesController do
|
|
|
481
510
|
expect(Sufia::GenericFile::Actor).to receive(:virus_check).and_return(0)
|
|
482
511
|
expect(Sufia.queue).to receive(:push).with(s2).once
|
|
483
512
|
post :update, id: generic_file.id, filedata: file, 'Filename' => 'The world',
|
|
484
|
-
|
|
485
|
-
|
|
513
|
+
generic_file: { tag: [''],
|
|
514
|
+
permissions_attributes: [{ type: 'user', name: 'archivist1', access: 'edit' }] }
|
|
486
515
|
end
|
|
487
516
|
|
|
488
517
|
context "when there's an error saving" do
|
|
@@ -493,7 +522,7 @@ describe GenericFilesController do
|
|
|
493
522
|
end
|
|
494
523
|
it "redirects to edit" do
|
|
495
524
|
expect_any_instance_of(GenericFile).to receive(:valid?).and_return(false)
|
|
496
|
-
post :update, id: generic_file, generic_file: {:
|
|
525
|
+
post :update, id: generic_file, generic_file: { tag: [''] }
|
|
497
526
|
expect(response).to be_successful
|
|
498
527
|
expect(response).to render_template('edit')
|
|
499
528
|
expect(assigns[:generic_file]).to eq generic_file
|
|
@@ -513,7 +542,7 @@ describe GenericFilesController do
|
|
|
513
542
|
end
|
|
514
543
|
|
|
515
544
|
describe "edit" do
|
|
516
|
-
it "
|
|
545
|
+
it "gives me a flash error" do
|
|
517
546
|
get :edit, id: generic_file
|
|
518
547
|
expect(response).to redirect_to @routes.url_helpers.generic_file_path('test5')
|
|
519
548
|
expect(flash[:alert]).not_to be_nil
|
|
@@ -523,7 +552,7 @@ describe GenericFilesController do
|
|
|
523
552
|
end
|
|
524
553
|
|
|
525
554
|
describe "#show" do
|
|
526
|
-
it "
|
|
555
|
+
it "shows me the file and set breadcrumbs" do
|
|
527
556
|
expect(GenericFile).not_to receive(:find)
|
|
528
557
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
|
|
529
558
|
get :show, id: generic_file
|
|
@@ -541,13 +570,13 @@ describe GenericFilesController do
|
|
|
541
570
|
end
|
|
542
571
|
|
|
543
572
|
describe "flash" do
|
|
544
|
-
it "
|
|
573
|
+
it "does not let the user submit if they logout" do
|
|
545
574
|
sign_out user
|
|
546
575
|
get :new
|
|
547
576
|
expect(response).to_not be_success
|
|
548
577
|
expect(flash[:alert]).to include("You need to sign in or sign up before continuing")
|
|
549
578
|
end
|
|
550
|
-
it "
|
|
579
|
+
it "filters flash if they signin" do
|
|
551
580
|
sign_in user
|
|
552
581
|
get :new
|
|
553
582
|
expect(flash[:alert]).to be_nil
|
|
@@ -558,7 +587,7 @@ describe GenericFilesController do
|
|
|
558
587
|
before do
|
|
559
588
|
User.audituser.send_message(user, "Test message", "Test subject")
|
|
560
589
|
end
|
|
561
|
-
it "
|
|
590
|
+
it "displays notifications" do
|
|
562
591
|
get :new
|
|
563
592
|
expect(assigns[:notify_number]).to eq 1
|
|
564
593
|
expect(user.mailbox.inbox[0].messages[0].subject).to eq "Test subject"
|
|
@@ -568,16 +597,16 @@ describe GenericFilesController do
|
|
|
568
597
|
describe "batch creation" do
|
|
569
598
|
context "when uploading a file" do
|
|
570
599
|
let(:batch_id) { ActiveFedora::Noid::Service.new.mint }
|
|
571
|
-
let(:file1) { fixture_file_upload('/world.png','image/png') }
|
|
572
|
-
let(:file2) { fixture_file_upload('/image.jpg','image/png') }
|
|
600
|
+
let(:file1) { fixture_file_upload('/world.png', 'image/png') }
|
|
601
|
+
let(:file2) { fixture_file_upload('/image.jpg', 'image/png') }
|
|
573
602
|
|
|
574
|
-
it "
|
|
603
|
+
it "does not create the batch on HTTP GET" do
|
|
575
604
|
expect(Batch).to_not receive(:create)
|
|
576
605
|
xhr :get, :new
|
|
577
606
|
expect(response).to be_success
|
|
578
607
|
end
|
|
579
608
|
|
|
580
|
-
it "
|
|
609
|
+
it "creates the batch on HTTP POST with multiple files" do
|
|
581
610
|
expect(GenericFile).to receive(:new).twice
|
|
582
611
|
expect(Batch).to receive(:find_or_create).twice
|
|
583
612
|
xhr :post, :create, files: [file1], Filename: 'The world 1', batch_id: batch_id, on_behalf_of: 'carolyn', terms_of_service: '1'
|