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
|
@@ -4,7 +4,7 @@ describe ImportUrlJob do
|
|
|
4
4
|
let(:user) { FactoryGirl.find_or_create(:jill) }
|
|
5
5
|
|
|
6
6
|
let(:file_path) { '/world.png' }
|
|
7
|
-
let(:file_hash)
|
|
7
|
+
let(:file_hash) { '/673467823498723948237462429793840923582' }
|
|
8
8
|
|
|
9
9
|
let(:generic_file) do
|
|
10
10
|
GenericFile.create do |f|
|
|
@@ -22,9 +22,9 @@ describe ImportUrlJob do
|
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
subject(:job) {
|
|
25
|
+
subject(:job) { described_class.new(generic_file.id) }
|
|
26
26
|
|
|
27
|
-
it "
|
|
27
|
+
it "has no content at the outset" do
|
|
28
28
|
expect(generic_file.content.size).to be_nil
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ describe ImportUrlJob do
|
|
|
41
41
|
expect(Sufia::GenericFile::Actor).to receive(:virus_check).and_return(false)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
it "
|
|
44
|
+
it "creates a content datastream" do
|
|
45
45
|
expect_any_instance_of(Net::HTTP).to receive(:request_get).with(file_hash).and_yield(mock_response)
|
|
46
46
|
job.run
|
|
47
47
|
expect(generic_file.reload.content.size).to eq 4218
|
|
@@ -55,10 +55,41 @@ describe ImportUrlJob do
|
|
|
55
55
|
|
|
56
56
|
allow(CharacterizeJob).to receive(:new).with(generic_file.id).never
|
|
57
57
|
end
|
|
58
|
-
it "
|
|
58
|
+
it "aborts if virus check fails" do
|
|
59
59
|
allow(Sufia::GenericFile::Actor).to receive(:virus_check).and_raise(Sufia::VirusFoundError.new('A virus was found'))
|
|
60
60
|
job.run
|
|
61
61
|
expect(user.mailbox.inbox.first.subject).to eq("File Import Error")
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
|
+
|
|
65
|
+
context "when a batch update job is running too" do
|
|
66
|
+
let(:title) { { generic_file.id => ['File One'] } }
|
|
67
|
+
let(:metadata) { {} }
|
|
68
|
+
let(:visibility) { nil }
|
|
69
|
+
|
|
70
|
+
let(:batch) { Batch.create }
|
|
71
|
+
let(:batch_job) { BatchUpdateJob.new(user.user_key, batch.id, title, metadata, visibility) }
|
|
72
|
+
|
|
73
|
+
before do
|
|
74
|
+
generic_file.batch = batch
|
|
75
|
+
generic_file.save
|
|
76
|
+
allow_any_instance_of(Ability).to receive(:can?).and_return(true)
|
|
77
|
+
expect_any_instance_of(Net::HTTP).to receive(:request_get).with(file_hash).and_yield(mock_response)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "does not kill all the metadata set by other jobs" do
|
|
81
|
+
# load the object before running the batch job
|
|
82
|
+
gf = job.object
|
|
83
|
+
|
|
84
|
+
# runthe batch job to set the title
|
|
85
|
+
batch_job.run
|
|
86
|
+
|
|
87
|
+
# run the import job
|
|
88
|
+
job.run
|
|
89
|
+
|
|
90
|
+
# import job should not override the title set by the batch job
|
|
91
|
+
file = GenericFile.find(gf.id)
|
|
92
|
+
expect(file.title).to eq(['File One'])
|
|
93
|
+
end
|
|
94
|
+
end
|
|
64
95
|
end
|
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe IngestLocalFileJob do
|
|
4
|
-
|
|
4
|
+
context "with valid data to run" do
|
|
5
|
+
let(:user) { FactoryGirl.find_or_create(:jill) }
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
let(:generic_file) { create :generic_file, depositor: user }
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
let(:job) { described_class.new(generic_file.id, mock_upload_directory, "world.png", user.user_key) }
|
|
10
|
+
let(:mock_upload_directory) { 'spec/mock_upload_directory' }
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
it "should have attached a file" do
|
|
17
|
-
job.run
|
|
18
|
-
expect(generic_file.reload.content.size).to eq(4218)
|
|
19
|
-
end
|
|
12
|
+
before do
|
|
13
|
+
Dir.mkdir mock_upload_directory unless File.exist? mock_upload_directory
|
|
14
|
+
FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), mock_upload_directory)
|
|
15
|
+
end
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
it "should run virus check" do
|
|
23
|
-
expect(Sufia::GenericFile::Actor).to receive(:virus_check).and_return(0)
|
|
17
|
+
it "has attached a file" do
|
|
24
18
|
job.run
|
|
19
|
+
expect(generic_file.reload.content.size).to eq(4218)
|
|
20
|
+
expect(File).not_to exist("#{mock_upload_directory}/world.png")
|
|
25
21
|
end
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
|
|
23
|
+
describe "virus checking" do
|
|
24
|
+
it "runs virus check" do
|
|
25
|
+
expect(Sufia::GenericFile::Actor).to receive(:virus_check).and_return(0)
|
|
26
|
+
job.run
|
|
27
|
+
end
|
|
28
|
+
it "aborts if virus check fails" do
|
|
29
|
+
allow(Sufia::GenericFile::Actor).to receive(:virus_check).and_raise(Sufia::VirusFoundError.new('A virus was found'))
|
|
30
|
+
job.run
|
|
31
|
+
expect(user.mailbox.inbox.first.subject).to eq("Local file ingest error")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "empty job" do
|
|
37
|
+
let(:job) { described_class.new(nil, nil, nil, nil) }
|
|
38
|
+
|
|
39
|
+
it "has the correct queue name" do
|
|
40
|
+
expect(job.queue_name).to eq(:ingest)
|
|
30
41
|
end
|
|
31
42
|
end
|
|
32
43
|
end
|
|
@@ -100,9 +100,9 @@ describe Sufia::Arkivo::Actor do
|
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
it 'changes the arkivo checksum' do
|
|
103
|
-
expect
|
|
103
|
+
expect do
|
|
104
104
|
subject.update_file_from_item(gf)
|
|
105
|
-
|
|
105
|
+
end.to change { gf.arkivo_checksum }.from(checksum).to(item['file']['md5'])
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
it 'calls update_content' do
|
|
@@ -111,9 +111,9 @@ describe Sufia::Arkivo::Actor do
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
it 'extracts a file from the item' do
|
|
114
|
-
expect
|
|
114
|
+
expect do
|
|
115
115
|
subject.update_file_from_item(gf)
|
|
116
|
-
|
|
116
|
+
end.to change { gf.content.content }.to("# HEADER\n\nThis is a paragraph!\n")
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
it 'returns a GF instance' do
|
|
@@ -131,9 +131,9 @@ describe Sufia::Arkivo::Actor do
|
|
|
131
131
|
it { is_expected.to respond_to(:destroy_file) }
|
|
132
132
|
|
|
133
133
|
it 'deletes the file' do
|
|
134
|
-
expect
|
|
134
|
+
expect do
|
|
135
135
|
subject.destroy_file(gf)
|
|
136
|
-
|
|
136
|
+
end.to change { gf.destroyed? }.from(nil).to(true)
|
|
137
137
|
end
|
|
138
138
|
end
|
|
139
139
|
end
|
|
@@ -4,62 +4,62 @@ describe Sufia::Arkivo::SchemaValidator do
|
|
|
4
4
|
let(:item) { JSON.parse(FactoryGirl.json(:post_item)) }
|
|
5
5
|
|
|
6
6
|
it 'ensures a token is included' do
|
|
7
|
-
expect
|
|
7
|
+
expect do
|
|
8
8
|
described_class.new(item.except('token')).call
|
|
9
|
-
|
|
9
|
+
end.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'token'/)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
it 'ensures a metadata section is included' do
|
|
13
|
-
expect
|
|
13
|
+
expect do
|
|
14
14
|
described_class.new(item.except('metadata')).call
|
|
15
|
-
|
|
15
|
+
end.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'metadata'/)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it 'ensures a file section is included' do
|
|
19
|
-
expect
|
|
19
|
+
expect do
|
|
20
20
|
described_class.new(item.except('file')).call
|
|
21
|
-
|
|
21
|
+
end.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'file'/)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it 'ensures the metadata has a title' do
|
|
25
25
|
item['metadata'].delete('title')
|
|
26
|
-
expect
|
|
26
|
+
expect do
|
|
27
27
|
described_class.new(item).call
|
|
28
|
-
|
|
28
|
+
end.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'title'/)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it 'ensures the metadata has rights' do
|
|
32
32
|
item['metadata'].delete('rights')
|
|
33
|
-
expect
|
|
33
|
+
expect do
|
|
34
34
|
described_class.new(item).call
|
|
35
|
-
|
|
35
|
+
end.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'rights'/)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it 'ensures the file has a b64-encoded content' do
|
|
39
39
|
item['file'].delete('base64')
|
|
40
|
-
expect
|
|
40
|
+
expect do
|
|
41
41
|
described_class.new(item).call
|
|
42
|
-
|
|
42
|
+
end.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'base64'/)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it 'ensures the file has a checksum' do
|
|
46
46
|
item['file'].delete('md5')
|
|
47
|
-
expect
|
|
47
|
+
expect do
|
|
48
48
|
described_class.new(item).call
|
|
49
|
-
|
|
49
|
+
end.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'md5'/)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it 'ensures the file has a filename' do
|
|
53
53
|
item['file'].delete('filename')
|
|
54
|
-
expect
|
|
54
|
+
expect do
|
|
55
55
|
described_class.new(item).call
|
|
56
|
-
|
|
56
|
+
end.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'filename'/)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it 'ensures the file has a content type' do
|
|
60
60
|
item['file'].delete('contentType')
|
|
61
|
-
expect
|
|
61
|
+
expect do
|
|
62
62
|
described_class.new(item).call
|
|
63
|
-
|
|
63
|
+
end.to raise_error(Sufia::Arkivo::InvalidItem, /required property of 'contentType'/)
|
|
64
64
|
end
|
|
65
65
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Sufia::Breadcrumbs do
|
|
4
|
-
|
|
3
|
+
describe Sufia::Breadcrumbs do
|
|
5
4
|
let(:crumbs) do
|
|
6
5
|
TestClass.new
|
|
7
6
|
end
|
|
@@ -18,7 +17,8 @@ describe Sufia::Breadcrumbs do
|
|
|
18
17
|
@trail = []
|
|
19
18
|
@request = true # avoids the allow_message_expectations_on_nil warning
|
|
20
19
|
end
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
def add_breadcrumb(text, link)
|
|
22
22
|
@trail << [text, link]
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -85,7 +85,7 @@ describe Sufia::Breadcrumbs do
|
|
|
85
85
|
allow(crumbs.request).to receive(:referer).and_return("http://...blargh/")
|
|
86
86
|
allow(crumbs).to receive(:user_signed_in?) { true }
|
|
87
87
|
allow(crumbs).to receive(:action_name).and_return("edit")
|
|
88
|
-
allow(crumbs).to receive(:params).and_return(
|
|
88
|
+
allow(crumbs).to receive(:params).and_return("id" => "abc123")
|
|
89
89
|
allow(crumbs).to receive(:controller_name).and_return("generic_files")
|
|
90
90
|
end
|
|
91
91
|
|
|
@@ -102,7 +102,7 @@ describe Sufia::Breadcrumbs do
|
|
|
102
102
|
allow(crumbs.request).to receive(:referer).and_return("http://...blargh/")
|
|
103
103
|
allow(crumbs).to receive(:user_signed_in?) { true }
|
|
104
104
|
allow(crumbs).to receive(:action_name).and_return("stats")
|
|
105
|
-
allow(crumbs).to receive(:params).and_return(
|
|
105
|
+
allow(crumbs).to receive(:params).and_return("id" => "abc123")
|
|
106
106
|
allow(crumbs).to receive(:controller_name).and_return("generic_files")
|
|
107
107
|
end
|
|
108
108
|
|
|
@@ -114,5 +114,4 @@ describe Sufia::Breadcrumbs do
|
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
|
-
|
|
118
117
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Sufia::Messages do
|
|
4
|
-
|
|
5
4
|
let(:message) do
|
|
6
5
|
TestClass.new
|
|
7
6
|
end
|
|
@@ -22,48 +21,48 @@ describe Sufia::Messages do
|
|
|
22
21
|
let(:file_list) { "<a href='/files/1'>File 1</a>, <a href='/files/2'>File 2</a>, <a href='/files/3'>File 3</a>" }
|
|
23
22
|
|
|
24
23
|
describe "message subjects" do
|
|
25
|
-
it "
|
|
24
|
+
it "provides a subject for a success message" do
|
|
26
25
|
expect(message.success_subject).to eq("Batch upload complete")
|
|
27
26
|
end
|
|
28
|
-
it "
|
|
27
|
+
it "provides a subject for a failure message" do
|
|
29
28
|
expect(message.failure_subject).to eq("Batch upload permission denied")
|
|
30
29
|
end
|
|
31
30
|
end
|
|
32
31
|
|
|
33
32
|
describe "#single_success" do
|
|
34
|
-
it "
|
|
33
|
+
it "renders a success message for a single file" do
|
|
35
34
|
node = Capybara::Node::Simple.new(message.single_success(batch_id, single))
|
|
36
|
-
expect(node).to have_selector("span[id=\"ss-1\"]", text:"File 1 has been saved.")
|
|
35
|
+
expect(node).to have_selector("span[id=\"ss-1\"]", text: "File 1 has been saved.")
|
|
37
36
|
expect(node).to have_selector("a[href=\"/files/1\"]")
|
|
38
37
|
end
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
describe "#multiple_success" do
|
|
42
|
-
it "
|
|
41
|
+
it "renders a success message for multiple files" do
|
|
43
42
|
node = Capybara::Node::Simple.new(message.multiple_success(batch_id, multiple))
|
|
44
|
-
expect(node).to have_selector("span[id=\"ss-1\"]", text:"These files have been saved.")
|
|
43
|
+
expect(node).to have_selector("span[id=\"ss-1\"]", text: "These files have been saved.")
|
|
45
44
|
expect(node).to have_selector("a[data-content=\"#{file_list}\"][rel=\"popover\"][data-title=\"Files uploaded successfully\"]")
|
|
46
45
|
end
|
|
47
46
|
end
|
|
48
47
|
|
|
49
48
|
describe "#single_failure" do
|
|
50
|
-
it "
|
|
49
|
+
it "renders a failure message for a single file" do
|
|
51
50
|
node = Capybara::Node::Simple.new(message.single_failure(batch_id, single))
|
|
52
|
-
expect(node).to have_selector("span[id=\"ss-1\"]", text:"File 1 could not be updated. You do not have sufficient privileges to edit it.")
|
|
51
|
+
expect(node).to have_selector("span[id=\"ss-1\"]", text: "File 1 could not be updated. You do not have sufficient privileges to edit it.")
|
|
53
52
|
expect(node).to have_selector("a[href=\"/files/1\"]")
|
|
54
53
|
end
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
describe "#multiple_failure" do
|
|
58
|
-
it "
|
|
57
|
+
it "renders a failure message for multiple files" do
|
|
59
58
|
node = Capybara::Node::Simple.new(message.multiple_failure(batch_id, multiple))
|
|
60
|
-
expect(node).to have_selector("span[id=\"ss-1\"]", text:"These files could not be updated. You do not have sufficient privileges to edit them.")
|
|
59
|
+
expect(node).to have_selector("span[id=\"ss-1\"]", text: "These files could not be updated. You do not have sufficient privileges to edit them.")
|
|
61
60
|
expect(node).to have_selector("a[data-content=\"#{file_list}\"][rel=\"popover\"][data-title=\"Files failed\"]")
|
|
62
61
|
end
|
|
63
62
|
end
|
|
64
63
|
|
|
65
64
|
describe "#file_list" do
|
|
66
|
-
it "
|
|
65
|
+
it "replaces double-quotes with single quotes" do
|
|
67
66
|
expect(message.file_list(multiple)).to eq(file_list)
|
|
68
67
|
end
|
|
69
68
|
end
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Sufia::Permissions::Readable do
|
|
4
|
-
|
|
5
4
|
class SubjectClass
|
|
6
5
|
include Sufia::Permissions::Readable
|
|
7
|
-
attr_accessor :read_groups
|
|
6
|
+
attr_accessor :read_groups
|
|
8
7
|
end
|
|
9
8
|
let(:subject) { SubjectClass.new }
|
|
10
9
|
|
|
11
10
|
describe "#public?" do
|
|
12
|
-
it "
|
|
13
|
-
subject.read_groups = ["public","othergroup"]
|
|
11
|
+
it "returns true for public items" do
|
|
12
|
+
subject.read_groups = ["public", "othergroup"]
|
|
14
13
|
expect(subject).to be_public
|
|
15
14
|
end
|
|
16
|
-
it "
|
|
17
|
-
subject.read_groups = ["notpublic","othergroup"]
|
|
15
|
+
it "returns fale for non-public items" do
|
|
16
|
+
subject.read_groups = ["notpublic", "othergroup"]
|
|
18
17
|
expect(subject).to_not be_public
|
|
19
18
|
end
|
|
20
19
|
end
|
|
21
20
|
|
|
22
21
|
describe "#registered?" do
|
|
23
|
-
it "
|
|
24
|
-
subject.read_groups = ["registered","othergroup"]
|
|
22
|
+
it "returns true for registered items" do
|
|
23
|
+
subject.read_groups = ["registered", "othergroup"]
|
|
25
24
|
expect(subject).to be_registered
|
|
26
25
|
end
|
|
27
|
-
it "
|
|
26
|
+
it "returns fale for non-registered items" do
|
|
28
27
|
subject.read_groups = ["othergroup"]
|
|
29
28
|
expect(subject).to_not be_registered
|
|
30
29
|
end
|
|
@@ -52,5 +51,4 @@ describe Sufia::Permissions::Readable do
|
|
|
52
51
|
end
|
|
53
52
|
end
|
|
54
53
|
end
|
|
55
|
-
|
|
56
54
|
end
|
|
@@ -5,18 +5,17 @@ end
|
|
|
5
5
|
|
|
6
6
|
class UploadThingRedefine
|
|
7
7
|
extend Sufia::FilesController::UploadCompleteBehavior
|
|
8
|
-
def self.upload_complete_path(
|
|
9
|
-
|
|
8
|
+
def self.upload_complete_path(_id)
|
|
9
|
+
"example.com"
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def self.destroy_complete_path(
|
|
13
|
-
|
|
12
|
+
def self.destroy_complete_path(_id)
|
|
13
|
+
"destroy.com"
|
|
14
14
|
end
|
|
15
|
-
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
describe Sufia::FilesController::UploadCompleteBehavior do
|
|
19
|
-
let(:test_id) {"123abc"}
|
|
18
|
+
let(:test_id) { "123abc" }
|
|
20
19
|
context "Not overridden" do
|
|
21
20
|
it "respond with the batch edit path" do
|
|
22
21
|
expect(UploadThing.upload_complete_path(test_id)).to eq(Sufia::Engine.routes.url_helpers.batch_edit_path(test_id))
|
|
@@ -33,4 +32,4 @@ describe Sufia::FilesController::UploadCompleteBehavior do
|
|
|
33
32
|
expect(UploadThingRedefine.destroy_complete_path(test_id)).to eq("destroy.com")
|
|
34
33
|
end
|
|
35
34
|
end
|
|
36
|
-
end
|
|
35
|
+
end
|