sufia 6.0.0.rc2 → 6.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -5
- data/History.md +14 -0
- data/LICENSE +15 -0
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/sufia/batch_edit.js +1 -1
- data/app/assets/javascripts/sufia/permissions.js +8 -12
- data/app/assets/stylesheets/sufia.css.scss +1 -1
- data/app/assets/stylesheets/sufia/_multi_value_fields.css.scss +67 -0
- data/app/assets/stylesheets/sufia/_settings.scss +1 -0
- data/app/assets/stylesheets/sufia/_styles.scss +4 -0
- data/app/assets/stylesheets/sufia/_tinymce.scss +14 -0
- data/app/controllers/batch_controller.rb +11 -2
- data/app/controllers/concerns/sufia/breadcrumbs.rb +2 -3
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +0 -1
- data/app/controllers/concerns/sufia/contact_form_controller_behavior.rb +1 -2
- data/app/controllers/concerns/sufia/controller.rb +1 -7
- data/app/controllers/concerns/sufia/downloads_controller_behavior.rb +3 -8
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +2 -3
- data/app/controllers/concerns/sufia/files_controller/upload_complete_behavior.rb +1 -2
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +27 -14
- data/app/controllers/concerns/sufia/homepage_controller.rb +3 -2
- data/app/controllers/content_blocks_controller.rb +17 -1
- data/app/controllers/downloads_controller.rb +0 -1
- data/app/controllers/my/shares_controller.rb +1 -0
- data/app/controllers/single_use_links_controller.rb +0 -1
- data/app/controllers/single_use_links_viewer_controller.rb +3 -8
- data/app/forms/sufia/forms/generic_file_edit_form.rb +1 -8
- data/app/helpers/content_block_helper.rb +30 -10
- data/app/helpers/generic_file_helper.rb +4 -4
- data/app/helpers/sufia/dashboard_helper_behavior.rb +2 -2
- data/app/helpers/sufia/sufia_helper_behavior.rb +4 -4
- data/app/helpers/trophy_helper.rb +3 -3
- data/app/jobs/content_delete_event_job.rb +1 -2
- data/app/jobs/content_deposit_event_job.rb +1 -1
- data/app/jobs/content_depositor_change_event_job.rb +1 -1
- data/app/jobs/content_new_version_event_job.rb +1 -1
- data/app/jobs/content_restored_version_event_job.rb +1 -1
- data/app/jobs/content_update_event_job.rb +1 -1
- data/app/models/concerns/sufia/solr_document_behavior.rb +5 -9
- data/app/models/content_block.rb +20 -0
- data/app/models/featured_work_list.rb +4 -0
- data/app/presenters/sufia/collection_presenter.rb +14 -2
- data/app/presenters/sufia/generic_file_presenter.rb +16 -0
- data/app/presenters/sufia/version_list_presenter.rb +1 -1
- data/app/views/batch/_metadata.html.erb +4 -4
- data/app/views/batch_edits/edit.html.erb +1 -1
- data/app/views/collections/_action_menu.html.erb +4 -5
- data/app/views/collections/_show_descriptions.html.erb +1 -5
- data/app/views/collections/_show_document_list.html.erb +0 -2
- data/app/views/collections/_show_document_list_menu.html.erb +5 -6
- data/app/views/collections/_show_document_list_row.html.erb +9 -9
- data/app/views/collections/_sort_and_per_page.html.erb +1 -1
- data/app/views/collections/_view_type_group.html.erb +1 -1
- data/app/views/collections/show.html.erb +3 -3
- data/app/views/generic_files/_asset_permissions_denial_flash.html.erb +1 -1
- data/app/views/generic_files/_asset_saved_flash.html.erb +1 -1
- data/app/views/generic_files/_asset_updated_flash.html.erb +1 -1
- data/app/views/generic_files/_browse_everything.html.erb +4 -4
- data/app/views/generic_files/_media_display.html.erb +9 -9
- data/app/views/generic_files/_permission_form.html.erb +1 -1
- data/app/views/generic_files/_show_actions.html.erb +1 -1
- data/app/views/generic_files/_show_collections.html.erb +2 -2
- data/app/views/generic_files/_show_details.html.erb +1 -1
- data/app/views/generic_files/_versioning.html.erb +9 -5
- data/app/views/generic_files/jq_upload.json.jbuilder +1 -1
- data/app/views/generic_files/new.html.erb +2 -3
- data/app/views/generic_files/show.html.erb +13 -16
- data/app/views/generic_files/upload/_alerts.html.erb +2 -2
- data/app/views/generic_files/upload/_form_fields.html.erb +1 -1
- data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +1 -1
- data/app/views/generic_files/upload/_script_templates.html.erb +2 -2
- data/app/views/homepage/_featured.html.erb +2 -4
- data/app/views/homepage/_featured_researcher.html.erb +1 -1
- data/app/views/homepage/_featured_works.html.erb +5 -3
- data/app/views/homepage/_home_content.html.erb +1 -1
- data/app/views/homepage/_recent_document.html.erb +2 -2
- data/app/views/homepage/_sortable_featured.html.erb +1 -2
- data/app/views/my/_action_menu.html.erb +8 -8
- data/app/views/my/_collection_action_menu.html.erb +4 -4
- data/app/views/my/_index_partials/_list_collections.html.erb +9 -12
- data/app/views/my/_index_partials/_list_files.html.erb +9 -9
- data/app/views/my/index.html.erb +0 -1
- data/app/views/records/_rights_modal.html.erb +1 -0
- data/app/views/users/_contributions.html.erb +2 -3
- data/app/views/users/_edit_primary.html.erb +68 -0
- data/app/views/users/_edit_secondary.html.erb +1 -0
- data/app/views/users/_trophy_edit.html.erb +1 -3
- data/app/views/users/edit.html.erb +4 -78
- data/config/initializers/simple_form.rb +167 -0
- data/config/initializers/simple_form_bootstrap.rb +137 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/locales/sufia.en.yml +7 -4
- data/config/routes.rb +1 -1
- data/lib/generators/sufia/templates/catalog_controller.rb +1 -1
- data/lib/sufia/single_use_error.rb +1 -1
- data/lib/sufia/version.rb +1 -1
- data/spec/actors/generic_file/actor_spec.rb +5 -5
- data/spec/controllers/batch_controller_spec.rb +15 -0
- data/spec/controllers/collections_controller_spec.rb +1 -1
- data/spec/controllers/content_blocks_controller_spec.rb +23 -3
- data/spec/controllers/downloads_controller_spec.rb +5 -5
- data/spec/controllers/generic_files_controller_spec.rb +12 -12
- data/spec/controllers/homepage_controller_spec.rb +19 -6
- data/spec/controllers/my/files_controller_spec.rb +8 -10
- data/spec/controllers/my/shares_controller_spec.rb +34 -23
- data/spec/controllers/single_use_links_controller_spec.rb +2 -3
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +19 -20
- data/spec/controllers/users_controller_spec.rb +8 -8
- data/spec/factories/generic_files.rb +4 -4
- data/spec/factories/users.rb +2 -3
- data/spec/features/browse_dashboard_files_spec.rb +8 -8
- data/spec/features/collection_spec.rb +15 -8
- data/spec/features/edit_file_spec.rb +26 -0
- data/spec/features/single_use_links_spec.rb +3 -3
- data/spec/forms/generic_file_edit_form_spec.rb +8 -1
- data/spec/helpers/content_block_helper_spec.rb +10 -0
- data/spec/helpers/dashboard_helper_spec.rb +42 -0
- data/spec/helpers/sufia_helper_spec.rb +34 -7
- data/spec/helpers/trophy_helper_spec.rb +6 -6
- data/spec/inputs/select_with_help_input_spec.rb +16 -0
- data/spec/jobs/audit_job_spec.rb +1 -1
- data/spec/jobs/characterize_job_spec.rb +2 -7
- data/spec/jobs/create_derivatives_job_spec.rb +27 -38
- data/spec/jobs/import_url_job_spec.rb +2 -2
- data/spec/jobs/ingest_local_file_job_spec.rb +6 -8
- data/spec/lib/sufia/id_service_spec.rb +0 -7
- data/spec/lib/sufia/messages_spec.rb +16 -13
- data/spec/models/ability_spec.rb +3 -0
- data/spec/models/checksum_audit_log_spec.rb +1 -1
- data/spec/models/content_block_spec.rb +41 -0
- data/spec/models/featured_work_list_spec.rb +23 -9
- data/spec/models/file_content_datastream_spec.rb +4 -4
- data/spec/models/file_usage_spec.rb +1 -1
- data/spec/models/fits_datastream_spec.rb +4 -4
- data/spec/models/generic_file_spec.rb +31 -15
- data/spec/models/single_use_link_spec.rb +2 -2
- data/spec/models/solr_document_spec.rb +8 -5
- data/spec/models/user_spec.rb +3 -3
- data/spec/presenters/sufia/collection_presenter_spec.rb +34 -0
- data/spec/presenters/sufia/generic_file_presenter_spec.rb +41 -1
- data/spec/presenters/sufia/version_list_presenter_spec.rb +12 -2
- data/spec/services/generic_file_audit_service_spec.rb +3 -3
- data/spec/services/noid_spec.rb +4 -11
- data/spec/services/repository_audit_service_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/fixture_helpers.rb +2 -3
- data/spec/support/selectors.rb +7 -7
- data/spec/test_app_templates/Gemfile.extra +1 -0
- data/spec/views/batch/edit.html.erb_spec.rb +14 -17
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/_permission_form.html.erb_spec.rb +29 -7
- data/spec/views/generic_file/edit.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/show.html.erb_spec.rb +69 -151
- data/spec/views/generic_file/stats.html.erb_spec.rb +1 -1
- data/spec/views/homepage/_featured_works.html.erb_spec.rb +29 -0
- data/spec/views/users/show.html.erb_spec.rb +1 -1
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +12 -8
- data/sufia-models/app/jobs/batch_update_job.rb +2 -2
- data/sufia-models/app/jobs/import_url_job.rb +5 -3
- data/sufia-models/app/jobs/ingest_local_file_job.rb +46 -0
- data/sufia-models/app/jobs/resolrize_job.rb +1 -8
- data/sufia-models/app/models/batch.rb +0 -7
- data/sufia-models/app/models/concerns/sufia/ability.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/{collection.rb → collection_behavior.rb} +1 -13
- data/sufia-models/app/models/concerns/sufia/generic_file/batches.rb +3 -4
- data/sufia-models/app/models/concerns/sufia/generic_file/export.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/generic_file/featured.rb +1 -4
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +7 -7
- data/sufia-models/app/models/concerns/sufia/generic_file/trophies.rb +1 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/virus_check.rb +16 -11
- data/sufia-models/app/models/concerns/sufia/model_methods.rb +1 -14
- data/sufia-models/app/models/concerns/sufia/user.rb +5 -0
- data/sufia-models/app/models/file_usage.rb +1 -1
- data/sufia-models/app/models/file_view_stat.rb +1 -1
- data/sufia-models/app/models/sufia/collection.rb +5 -0
- data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +1 -1
- data/sufia-models/app/services/sufia/id_service.rb +1 -2
- data/sufia-models/app/services/sufia/noid.rb +4 -24
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +6 -1
- data/sufia-models/lib/generators/sufia/models/templates/app/models/collection.rb +2 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/resque_config.rb +1 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +46 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +9 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_external_key_to_content_blocks.rb +6 -0
- data/sufia-models/lib/generators/sufia/models/update_content_blocks_generator.rb +18 -0
- data/sufia-models/lib/sufia/messages.rb +11 -12
- data/sufia-models/lib/sufia/models/engine.rb +2 -1
- data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +9 -5
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +5 -5
- data/sufia.gemspec +15 -15
- data/tasks/sufia-dev.rake +0 -16
- metadata +86 -64
- data/LICENSE.md +0 -14
- data/app/jobs/ingest_local_file_job.rb +0 -39
- data/sufia-models/app/models/collection.rb +0 -3
- data/sufia-models/app/services/sufia/indexing_service.rb +0 -15
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'SelectWithHelpInput', type: :input do
|
4
|
+
subject { input_for form, :resource_type, options }
|
5
|
+
let(:file) { GenericFile.new }
|
6
|
+
let(:form) { Sufia::Forms::BatchEditForm.new(file) }
|
7
|
+
let(:base_options) { { as: :select_with_help, collection: Sufia.config.resource_types,
|
8
|
+
input_html: { class: 'form-control', multiple: true } } }
|
9
|
+
let(:options) { base_options }
|
10
|
+
|
11
|
+
it "should not be required by default" do
|
12
|
+
expect(subject).to have_selector 'select'
|
13
|
+
expect(subject).not_to match /required/
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
data/spec/jobs/audit_job_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe AuditJob do
|
|
5
5
|
|
6
6
|
let(:file) do
|
7
7
|
GenericFile.create do |file|
|
8
|
-
file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
8
|
+
file.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
9
9
|
file.apply_depositor_metadata(user)
|
10
10
|
end
|
11
11
|
end
|
@@ -5,17 +5,12 @@ describe CharacterizeJob do
|
|
5
5
|
allow_any_instance_of(GenericFile).to receive(:reload_on_save?).and_return(false)
|
6
6
|
# Don't actually create the derivatives -- that is tested elsewhere
|
7
7
|
allow_any_instance_of(GenericFile).to receive(:create_derivatives)
|
8
|
-
@generic_file = GenericFile.
|
8
|
+
@generic_file = GenericFile.create do |gf|
|
9
9
|
gf.apply_depositor_metadata('jcoyne@example.com')
|
10
|
-
gf.add_file(File.open(fixture_path + '/charter.docx'), 'content', 'charter.docx')
|
11
|
-
gf.save
|
10
|
+
gf.add_file(File.open(fixture_path + '/charter.docx'), path: 'content', original_name: 'charter.docx')
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
after do
|
16
|
-
@generic_file.destroy
|
17
|
-
end
|
18
|
-
|
19
14
|
subject { CharacterizeJob.new(@generic_file.id)}
|
20
15
|
|
21
16
|
it 'spawns a CreateDerivatives job' do
|
@@ -4,10 +4,7 @@ describe CreateDerivativesJob do
|
|
4
4
|
before do
|
5
5
|
@ffmpeg_enabled = Sufia.config.enable_ffmpeg
|
6
6
|
Sufia.config.enable_ffmpeg = true
|
7
|
-
@generic_file = GenericFile.
|
8
|
-
gf.apply_depositor_metadata('jcoyne@example.com')
|
9
|
-
gf.save
|
10
|
-
end
|
7
|
+
@generic_file = GenericFile.create { |gf| gf.apply_depositor_metadata('jcoyne@example.com') }
|
11
8
|
end
|
12
9
|
|
13
10
|
after do
|
@@ -17,12 +14,14 @@ describe CreateDerivativesJob do
|
|
17
14
|
subject { CreateDerivativesJob.new(@generic_file.id) }
|
18
15
|
|
19
16
|
describe 'thumbnail generation' do
|
17
|
+
before do
|
18
|
+
@generic_file.add_file(File.open(fixture_path + '/' + file_name), path: 'content', original_name: file_name, mime_type: mime_type)
|
19
|
+
allow_any_instance_of(GenericFile).to receive(:mime_type).and_return(mime_type)
|
20
|
+
@generic_file.save!
|
21
|
+
end
|
20
22
|
context 'with a video (.avi) file', unless: $in_travis do
|
21
|
-
|
22
|
-
|
23
|
-
allow_any_instance_of(GenericFile).to receive(:mime_type).and_return('video/avi')
|
24
|
-
@generic_file.save!
|
25
|
-
end
|
23
|
+
let(:mime_type) { 'video/avi' }
|
24
|
+
let(:file_name) { 'countdown.avi' }
|
26
25
|
|
27
26
|
it 'lacks a thumbnail' do
|
28
27
|
expect(@generic_file.thumbnail).not_to have_content
|
@@ -37,11 +36,8 @@ describe CreateDerivativesJob do
|
|
37
36
|
end
|
38
37
|
|
39
38
|
context 'with an audio (.wav) file', unless: $in_travis do
|
40
|
-
|
41
|
-
|
42
|
-
allow_any_instance_of(GenericFile).to receive(:mime_type).and_return('audio/wav')
|
43
|
-
@generic_file.save!
|
44
|
-
end
|
39
|
+
let(:mime_type) { 'audio/wav' }
|
40
|
+
let(:file_name) { 'piano_note.wav' }
|
45
41
|
|
46
42
|
it 'lacks a thumbnail' do
|
47
43
|
expect(@generic_file.thumbnail).not_to have_content
|
@@ -55,11 +51,8 @@ describe CreateDerivativesJob do
|
|
55
51
|
end
|
56
52
|
|
57
53
|
context 'with an image (.jp2) file' do
|
58
|
-
|
59
|
-
|
60
|
-
allow_any_instance_of(GenericFile).to receive(:mime_type).and_return('image/jp2')
|
61
|
-
@generic_file.save!
|
62
|
-
end
|
54
|
+
let(:mime_type) { 'image/jp2' }
|
55
|
+
let(:file_name) { 'image.jp2' }
|
63
56
|
|
64
57
|
it 'lacks a thumbnail' do
|
65
58
|
expect(@generic_file.thumbnail).not_to have_content
|
@@ -74,11 +67,8 @@ describe CreateDerivativesJob do
|
|
74
67
|
end
|
75
68
|
|
76
69
|
context 'with an office document (.docx) file', unless: $in_travis do
|
77
|
-
|
78
|
-
|
79
|
-
allow_any_instance_of(GenericFile).to receive(:mime_type).and_return('application/vnd.openxmlformats-officedocument.wordprocessingml.document')
|
80
|
-
@generic_file.save!
|
81
|
-
end
|
70
|
+
let(:mime_type) { 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }
|
71
|
+
let(:file_name) { 'charter.docx' }
|
82
72
|
|
83
73
|
it 'lacks a thumbnail' do
|
84
74
|
expect(@generic_file.thumbnail).not_to have_content
|
@@ -94,12 +84,14 @@ describe CreateDerivativesJob do
|
|
94
84
|
end
|
95
85
|
|
96
86
|
describe 'audiovisual transcoding' do
|
87
|
+
before do
|
88
|
+
@generic_file.add_file(File.open(fixture_path + '/' + file_name), path: 'content', original_name: file_name, mime_type: mime_type)
|
89
|
+
allow_any_instance_of(GenericFile).to receive(:mime_type).and_return(mime_type)
|
90
|
+
@generic_file.save!
|
91
|
+
end
|
97
92
|
context 'with a video (.avi) file', unless: $in_travis do
|
98
|
-
|
99
|
-
|
100
|
-
allow_any_instance_of(GenericFile).to receive(:mime_type).and_return('video/avi')
|
101
|
-
@generic_file.save!
|
102
|
-
end
|
93
|
+
let(:mime_type) { 'video/avi' }
|
94
|
+
let(:file_name) { 'countdown.avi' }
|
103
95
|
|
104
96
|
it 'transcodes to webm and mp4' do
|
105
97
|
subject.run
|
@@ -117,11 +109,8 @@ describe CreateDerivativesJob do
|
|
117
109
|
end
|
118
110
|
|
119
111
|
context 'with an audio (.wav) file', unless: $in_travis do
|
120
|
-
|
121
|
-
|
122
|
-
allow_any_instance_of(GenericFile).to receive(:mime_type).and_return('audio/wav')
|
123
|
-
@generic_file.save!
|
124
|
-
end
|
112
|
+
let(:mime_type) { 'audio/wav' }
|
113
|
+
let(:file_name) { 'piano_note.wav' }
|
125
114
|
|
126
115
|
it 'transcodes to mp3 and ogg' do
|
127
116
|
subject.run
|
@@ -145,8 +134,8 @@ describe CreateDerivativesJob do
|
|
145
134
|
# @generic_file.save!
|
146
135
|
# end
|
147
136
|
|
148
|
-
|
149
|
-
|
137
|
+
#Need a way to do this in hydra-derivatives
|
138
|
+
it 'should copy the content to the mp3 datastream and transcode to ogg', skip: true do
|
150
139
|
subject.run
|
151
140
|
reloaded = @generic_file.reload
|
152
141
|
derivative = reloaded.attached_files['mp3']
|
@@ -166,8 +155,8 @@ describe CreateDerivativesJob do
|
|
166
155
|
# @generic_file.save!
|
167
156
|
# end
|
168
157
|
|
169
|
-
|
170
|
-
|
158
|
+
#Need a way to do this in hydra-derivatives
|
159
|
+
it 'should copy the content to the ogg datastream and transcode to mp3', skip: true do
|
171
160
|
subject.run
|
172
161
|
reloaded = @generic_file.reload
|
173
162
|
derivative = reloaded.attached_files['mp3']
|
@@ -7,17 +7,17 @@ describe ImportUrlJob do
|
|
7
7
|
let(:file_hash) {'/673467823498723948237462429793840923582'}
|
8
8
|
|
9
9
|
let(:generic_file) do
|
10
|
-
GenericFile.
|
10
|
+
GenericFile.create do |f|
|
11
11
|
f.import_url = "http://example.org#{file_hash}"
|
12
12
|
f.label = file_path
|
13
13
|
f.apply_depositor_metadata(user.user_key)
|
14
|
-
f.save
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
18
17
|
let(:mock_response) do
|
19
18
|
double('response').tap do |http_res|
|
20
19
|
allow(http_res).to receive(:start).and_yield
|
20
|
+
allow(http_res).to receive(:content_type).and_return('image/png')
|
21
21
|
allow(http_res).to receive(:read_body).and_yield(File.open(File.expand_path('../../fixtures/world.png', __FILE__)).read)
|
22
22
|
end
|
23
23
|
end
|
@@ -3,16 +3,14 @@ require 'spec_helper'
|
|
3
3
|
describe IngestLocalFileJob do
|
4
4
|
let(:user) { FactoryGirl.find_or_create(:jill) }
|
5
5
|
|
6
|
-
let
|
7
|
-
GenericFile.new.tap { |f| f.apply_depositor_metadata(user); f.save }
|
8
|
-
end
|
6
|
+
let(:generic_file) { create :generic_file, depositor: user }
|
9
7
|
|
10
|
-
|
8
|
+
let(:job) { IngestLocalFileJob.new(generic_file.id, mock_upload_directory, "world.png", user.user_key) }
|
9
|
+
let(:mock_upload_directory) { 'spec/mock_upload_directory' }
|
11
10
|
|
12
11
|
before do
|
13
|
-
|
14
|
-
|
15
|
-
FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), @mock_upload_directory)
|
12
|
+
Dir.mkdir mock_upload_directory unless File.exists? mock_upload_directory
|
13
|
+
FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), mock_upload_directory)
|
16
14
|
end
|
17
15
|
|
18
16
|
it "should have attached a file" do
|
@@ -22,7 +20,7 @@ describe IngestLocalFileJob do
|
|
22
20
|
|
23
21
|
describe "virus checking" do
|
24
22
|
it "should run virus check" do
|
25
|
-
expect(Sufia::GenericFile::Actor).to receive(:virus_check).
|
23
|
+
expect(Sufia::GenericFile::Actor).to receive(:virus_check).and_return(0)
|
26
24
|
job.run
|
27
25
|
end
|
28
26
|
it "should abort if virus check fails" do
|
@@ -14,11 +14,6 @@ describe Sufia::IdService do
|
|
14
14
|
expect(Sufia::IdService.valid?(subject)).to be true
|
15
15
|
end
|
16
16
|
|
17
|
-
it "should be reversable" do
|
18
|
-
new_id = Sufia::IdService.mint
|
19
|
-
expect(Sufia::Noid.noidify(new_id)).to eq new_id
|
20
|
-
end
|
21
|
-
|
22
17
|
context "when the pid already exists in Fedora" do
|
23
18
|
let(:mock_pid) { 'ef12ef12f' }
|
24
19
|
let(:unique_pid) { 'bb22bb22b' }
|
@@ -34,6 +29,4 @@ describe Sufia::IdService do
|
|
34
29
|
end
|
35
30
|
end
|
36
31
|
end
|
37
|
-
|
38
|
-
|
39
32
|
end
|
@@ -16,10 +16,10 @@ describe Sufia::Messages do
|
|
16
16
|
Object.send(:remove_const, :TestClass)
|
17
17
|
end
|
18
18
|
|
19
|
-
let(:batch_id)
|
20
|
-
let(:single)
|
21
|
-
let(:multiple)
|
22
|
-
let(:file_list) { "<a href='/files/1'>File 1</a>, <a href='/files/2'>File 2</a>, <a href='/files/3'>File 3</a>"
|
19
|
+
let(:batch_id) { "1" }
|
20
|
+
let(:single) { double(to_param: "1", to_s: "File 1") }
|
21
|
+
let(:multiple) { [double(to_param: "1", to_s: "File 1"), double(to_param: "2", to_s: "File 2"), double(to_param: "3", to_s: "File 3")] }
|
22
|
+
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
23
|
|
24
24
|
describe "message subjects" do
|
25
25
|
it "should provide a subject for a success message" do
|
@@ -31,30 +31,34 @@ describe Sufia::Messages do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe "#single_success" do
|
34
|
-
let(:expected) { '<span id="ss-1"><a href="/files/1">File 1</a> has been saved.</span>' }
|
35
34
|
it "should render a success message for a single file" do
|
36
|
-
|
35
|
+
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.")
|
37
|
+
expect(node).to have_selector("a[href=\"/files/1\"]")
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
describe "#multiple_success" do
|
41
|
-
let(:expected) { '<span id="ss-1"><a data-content="'+file_list+'" data-title="Files uploaded successfully" href="#" rel="popover">These files</a> have been saved.</span>' }
|
42
42
|
it "should render a success message for multiple files" do
|
43
|
-
|
43
|
+
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.")
|
45
|
+
expect(node).to have_selector("a[data-content=\"#{file_list}\"][rel=\"popover\"][data-title=\"Files uploaded successfully\"]")
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
49
|
describe "#single_failure" do
|
48
|
-
let(:expected) { '<span id="ss-1"><a href="/files/1">File 1</a> could not be updated. You do not have sufficient privileges to edit it.</span>' }
|
49
50
|
it "should render a failure message for a single file" do
|
50
|
-
|
51
|
+
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.")
|
53
|
+
expect(node).to have_selector("a[href=\"/files/1\"]")
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
54
57
|
describe "#multiple_failure" do
|
55
|
-
let(:expected) { '<span id="ss-1"><a data-content="'+file_list+'" data-title="Files failed" href="#" rel="popover">These files</a> could not be updated. You do not have sufficient privileges to edit them.</span>' }
|
56
58
|
it "should render a failure message for multiple files" do
|
57
|
-
|
59
|
+
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.")
|
61
|
+
expect(node).to have_selector("a[data-content=\"#{file_list}\"][rel=\"popover\"][data-title=\"Files failed\"]")
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
@@ -63,5 +67,4 @@ describe Sufia::Messages do
|
|
63
67
|
expect(message.file_list(multiple)).to eq(file_list)
|
64
68
|
end
|
65
69
|
end
|
66
|
-
|
67
70
|
end
|
data/spec/models/ability_spec.rb
CHANGED
@@ -7,6 +7,7 @@ describe Sufia::Ability, :type => :model do
|
|
7
7
|
subject { Ability.new(user) }
|
8
8
|
it { is_expected.not_to be_able_to(:create, GenericFile) }
|
9
9
|
it { is_expected.not_to be_able_to(:create, TinymceAsset) }
|
10
|
+
it { is_expected.not_to be_able_to(:create, ContentBlock) }
|
10
11
|
it { is_expected.not_to be_able_to(:update, ContentBlock) }
|
11
12
|
end
|
12
13
|
|
@@ -15,6 +16,7 @@ describe Sufia::Ability, :type => :model do
|
|
15
16
|
subject { Ability.new(user) }
|
16
17
|
it { is_expected.to be_able_to(:create, GenericFile) }
|
17
18
|
it { is_expected.not_to be_able_to(:create, TinymceAsset) }
|
19
|
+
it { is_expected.not_to be_able_to(:create, ContentBlock) }
|
18
20
|
it { is_expected.not_to be_able_to(:update, ContentBlock) }
|
19
21
|
end
|
20
22
|
|
@@ -24,6 +26,7 @@ describe Sufia::Ability, :type => :model do
|
|
24
26
|
subject { Ability.new(user) }
|
25
27
|
it { is_expected.to be_able_to(:create, GenericFile) }
|
26
28
|
it { is_expected.to be_able_to(:create, TinymceAsset) }
|
29
|
+
it { is_expected.to be_able_to(:create, ContentBlock) }
|
27
30
|
it { is_expected.to be_able_to(:update, ContentBlock) }
|
28
31
|
end
|
29
32
|
|
@@ -7,7 +7,7 @@ describe ChecksumAuditLog do
|
|
7
7
|
|
8
8
|
let(:f) do
|
9
9
|
GenericFile.create do |gf|
|
10
|
-
gf.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
10
|
+
gf.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
11
11
|
gf.apply_depositor_metadata('mjg36')
|
12
12
|
end
|
13
13
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ContentBlock, :type => :model do
|
4
|
+
|
5
|
+
let(:bilbo) { ContentBlock.create!(
|
6
|
+
name: ContentBlock::RESEARCHER,
|
7
|
+
value: '<h1>Bilbo Baggins</h1>',
|
8
|
+
created_at: Time.now)
|
9
|
+
}
|
10
|
+
|
11
|
+
let(:frodo) { ContentBlock.create!(
|
12
|
+
name: ContentBlock::RESEARCHER,
|
13
|
+
value: '<h1>Frodo Baggins</h1>',
|
14
|
+
created_at: 2.hours.ago)
|
15
|
+
}
|
16
|
+
|
17
|
+
let(:marketing) { ContentBlock.create!(
|
18
|
+
name: ContentBlock::MARKETING,
|
19
|
+
value: '<h1>Marketing Text</h1>')
|
20
|
+
}
|
21
|
+
|
22
|
+
describe '.recent_researchers' do
|
23
|
+
before { frodo; bilbo; marketing }
|
24
|
+
subject { ContentBlock.recent_researchers }
|
25
|
+
|
26
|
+
it 'returns featured_researcher entries in chronological order' do
|
27
|
+
expect(ContentBlock.count).to eq 3
|
28
|
+
expect(subject).to eq [bilbo, frodo]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '.featured_researcher' do
|
33
|
+
before { frodo; bilbo; marketing }
|
34
|
+
subject { ContentBlock.featured_researcher }
|
35
|
+
|
36
|
+
it 'finds the most recent entry for featured_researcher' do
|
37
|
+
expect(subject).to eq bilbo
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -1,32 +1,46 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FeaturedWorkList, :type => :model do
|
4
|
-
let(:file1) {
|
5
|
-
let(:file2) {
|
6
|
-
|
7
|
-
before do
|
8
|
-
FeaturedWork.create(generic_file_id: file1.noid)
|
9
|
-
FeaturedWork.create(generic_file_id: file2.noid)
|
10
|
-
end
|
4
|
+
let(:file1) { create(:generic_file) }
|
5
|
+
let(:file2) { create(:generic_file) }
|
11
6
|
|
12
7
|
describe 'featured_works' do
|
8
|
+
before do
|
9
|
+
create(:featured_work, generic_file_id: file1.id)
|
10
|
+
create(:featured_work, generic_file_id: file2.id)
|
11
|
+
end
|
12
|
+
|
13
13
|
it 'should be a list of the featured work objects, each with the generic_file\'s solr_doc' do
|
14
14
|
expect(subject.featured_works.size).to eq 2
|
15
15
|
solr_doc = subject.featured_works.first.generic_file_solr_document
|
16
16
|
expect(solr_doc).to be_kind_of SolrDocument
|
17
|
-
expect(solr_doc.
|
17
|
+
expect(solr_doc.id).to eq file1.id
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe 'file deleted' do
|
22
22
|
before do
|
23
|
+
create(:featured_work, generic_file_id: file1.id)
|
24
|
+
create(:featured_work, generic_file_id: file2.id)
|
23
25
|
file1.destroy
|
24
26
|
end
|
27
|
+
|
25
28
|
it 'should be a list of the remaining featured work objects, each with the generic_file\'s solr_doc' do
|
26
29
|
expect(subject.featured_works.size).to eq 1
|
27
30
|
solr_doc = subject.featured_works.first.generic_file_solr_document
|
28
31
|
expect(solr_doc).to be_kind_of SolrDocument
|
29
|
-
expect(solr_doc.
|
32
|
+
expect(solr_doc.id).to eq file2.id
|
30
33
|
end
|
31
34
|
end
|
35
|
+
|
36
|
+
describe '#empty?' do
|
37
|
+
context "when there are featured works" do
|
38
|
+
before do
|
39
|
+
create(:featured_work, generic_file_id: file1.id)
|
40
|
+
end
|
41
|
+
it { is_expected.not_to be_empty }
|
42
|
+
end
|
43
|
+
|
44
|
+
it { is_expected.to be_empty }
|
45
|
+
end
|
32
46
|
end
|
@@ -4,7 +4,7 @@ describe FileContentDatastream, :type => :model do
|
|
4
4
|
describe "#latest_version" do
|
5
5
|
let(:file) do
|
6
6
|
GenericFile.create do |f|
|
7
|
-
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
7
|
+
f.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
8
8
|
f.apply_depositor_metadata('mjg36')
|
9
9
|
end
|
10
10
|
end
|
@@ -16,7 +16,7 @@ describe FileContentDatastream, :type => :model do
|
|
16
16
|
|
17
17
|
context "with two versions" do
|
18
18
|
before do
|
19
|
-
file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
19
|
+
file.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
20
20
|
file.save
|
21
21
|
end
|
22
22
|
subject { file.content.latest_version.label }
|
@@ -44,13 +44,13 @@ describe FileContentDatastream, :type => :model do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should only return true when the datastream has actually changed" do
|
47
|
-
@generic_file.add_file(File.open(fixture_path + '/world.png', 'rb'), 'content', 'world.png')
|
47
|
+
@generic_file.add_file(File.open(fixture_path + '/world.png', 'rb'), path: 'content', original_name: 'world.png')
|
48
48
|
expect(@generic_file.content).to be_changed
|
49
49
|
@generic_file.save!
|
50
50
|
expect(@generic_file.content).to_not be_changed
|
51
51
|
|
52
52
|
# Add a thumbnail ds
|
53
|
-
@generic_file.add_file(File.open(fixture_path + '/world.png'), 'thumbnail', 'world.png')
|
53
|
+
@generic_file.add_file(File.open(fixture_path + '/world.png'), path: 'thumbnail', original_name: 'world.png')
|
54
54
|
expect(@generic_file.thumbnail).to be_changed
|
55
55
|
expect(@generic_file.content).to_not be_changed
|
56
56
|
|