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
@@ -68,7 +68,7 @@ describe FileUsage, :type => :model do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should set the path" do
|
71
|
-
expect(usage.path).to eq("/files/#{URI.encode(
|
71
|
+
expect(usage.path).to eq("/files/#{URI.encode(file.id, '/')}")
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should set the created date" do
|
@@ -4,7 +4,7 @@ describe FitsDatastream, type: :model, unless: $in_travis do
|
|
4
4
|
describe "image" do
|
5
5
|
before(:all) do
|
6
6
|
@file = GenericFile.new(id: 'foo123')
|
7
|
-
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
7
|
+
@file.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
8
8
|
@file.characterize
|
9
9
|
end
|
10
10
|
it "should have a format label" do
|
@@ -43,13 +43,13 @@ describe FitsDatastream, type: :model, unless: $in_travis do
|
|
43
43
|
|
44
44
|
it "should index into solr" do
|
45
45
|
expect(solr_doc[Solrizer.solr_name("mime_type")].first).to eq "image/png"
|
46
|
-
end
|
46
|
+
end
|
47
47
|
end
|
48
48
|
|
49
49
|
describe "video" do
|
50
50
|
before(:all) do
|
51
51
|
@file = GenericFile.new(id: 'foo123')
|
52
|
-
@file.add_file(File.open(fixture_path + '/sample_mpeg4.mp4'), 'content', 'sample_mpeg4.mp4')
|
52
|
+
@file.add_file(File.open(fixture_path + '/sample_mpeg4.mp4'), path: 'content', original_name: 'sample_mpeg4.mp4')
|
53
53
|
@file.characterize
|
54
54
|
end
|
55
55
|
it "should have a format label" do
|
@@ -91,7 +91,7 @@ describe FitsDatastream, type: :model, unless: $in_travis do
|
|
91
91
|
describe "pdf" do
|
92
92
|
before do
|
93
93
|
@myfile = GenericFile.new(id: 'foo123')
|
94
|
-
@myfile.add_file(File.open(fixture_path + '/sufia/sufia_test4.pdf', 'rb').read, 'content', 'sufia_test4.pdf')
|
94
|
+
@myfile.add_file(File.open(fixture_path + '/sufia/sufia_test4.pdf', 'rb').read, path: 'content', original_name: 'sufia_test4.pdf', mime_type: 'application/pdf')
|
95
95
|
@myfile.apply_depositor_metadata('mjg36')
|
96
96
|
# characterize method saves
|
97
97
|
@myfile.characterize
|
@@ -52,10 +52,10 @@ describe GenericFile, :type => :model do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe "
|
56
|
-
it "should use the
|
55
|
+
describe "assign_id" do
|
56
|
+
it "should use the id service" do
|
57
57
|
expect(Sufia::IdService).to receive(:mint)
|
58
|
-
subject.
|
58
|
+
subject.assign_id
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -179,7 +179,7 @@ describe GenericFile, :type => :model do
|
|
179
179
|
end
|
180
180
|
|
181
181
|
it "should have content datastream" do
|
182
|
-
subject.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
182
|
+
subject.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
183
183
|
expect(subject.content).to be_kind_of FileContentDatastream
|
184
184
|
end
|
185
185
|
end
|
@@ -218,7 +218,7 @@ describe GenericFile, :type => :model do
|
|
218
218
|
expect(subject).to respond_to(:page_count)
|
219
219
|
end
|
220
220
|
it "should redefine to_param to make redis keys more recognizable" do
|
221
|
-
expect(subject.to_param).to eq subject.
|
221
|
+
expect(subject.to_param).to eq subject.id
|
222
222
|
end
|
223
223
|
|
224
224
|
describe "that have been saved" do
|
@@ -310,7 +310,6 @@ describe GenericFile, :type => :model do
|
|
310
310
|
expect(local[Solrizer.solr_name("identifier")]).to eq ["urn:isbn:1234567890"]
|
311
311
|
expect(local[Solrizer.solr_name("based_near")]).to eq ["Medina, Saudi Arabia"]
|
312
312
|
expect(local[Solrizer.solr_name("mime_type")]).to eq ["image/jpeg"]
|
313
|
-
expect(local["noid_tsi"]).to eq 'stubbed_pid'
|
314
313
|
expect(local['all_text_timv']).to eq('abcxyz')
|
315
314
|
end
|
316
315
|
end
|
@@ -331,7 +330,7 @@ describe GenericFile, :type => :model do
|
|
331
330
|
describe "with a video", if: Sufia.config.enable_ffmpeg do
|
332
331
|
before do
|
333
332
|
allow(@f).to receive(mime_type: 'video/quicktime') #Would get set by the characterization job
|
334
|
-
@f.add_file(File.open("#{fixture_path}/countdown.avi", 'rb'), 'content', 'countdown.avi')
|
333
|
+
@f.add_file(File.open("#{fixture_path}/countdown.avi", 'rb'), path: 'content', original_name: 'countdown.avi')
|
335
334
|
@f.save
|
336
335
|
end
|
337
336
|
it "should make a png thumbnail" do
|
@@ -348,14 +347,14 @@ describe GenericFile, :type => :model do
|
|
348
347
|
gf.apply_depositor_metadata(u)
|
349
348
|
gf.save!
|
350
349
|
end
|
351
|
-
@t = Trophy.create(user_id: u.id, generic_file_id: @f.
|
350
|
+
@t = Trophy.create(user_id: u.id, generic_file_id: @f.id)
|
352
351
|
end
|
353
352
|
it "should have a trophy" do
|
354
|
-
expect(Trophy.where(generic_file_id: @f.
|
353
|
+
expect(Trophy.where(generic_file_id: @f.id).count).to eq 1
|
355
354
|
end
|
356
355
|
it "should remove all trophies when file is deleted" do
|
357
356
|
@f.destroy
|
358
|
-
expect(Trophy.where(generic_file_id: @f.
|
357
|
+
expect(Trophy.where(generic_file_id: @f.id).count).to eq 0
|
359
358
|
end
|
360
359
|
end
|
361
360
|
|
@@ -403,10 +402,27 @@ describe GenericFile, :type => :model do
|
|
403
402
|
end
|
404
403
|
|
405
404
|
describe "noid integration" do
|
406
|
-
|
405
|
+
before do
|
406
|
+
allow(Sufia::IdService).to receive(:mint).once.and_return(noid)
|
407
|
+
end
|
408
|
+
|
409
|
+
let(:noid) { 'wd3763094' }
|
410
|
+
|
411
|
+
subject do
|
412
|
+
GenericFile.create do |f|
|
413
|
+
f.apply_depositor_metadata('mjg36')
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
it "runs the overridden #assign_id method" do
|
418
|
+
expect(Sufia::IdService).to receive(:mint).once
|
419
|
+
GenericFile.create do |f|
|
420
|
+
f.apply_depositor_metadata('mjg36')
|
421
|
+
end
|
422
|
+
end
|
407
423
|
|
408
424
|
it "should return the expected identifier" do
|
409
|
-
expect(subject.
|
425
|
+
expect(subject.id).to eq noid
|
410
426
|
end
|
411
427
|
|
412
428
|
it "should have a tree-like URL" do
|
@@ -507,7 +523,7 @@ describe GenericFile, :type => :model do
|
|
507
523
|
let(:f) { File.new(fixture_path + '/small_file.txt') }
|
508
524
|
|
509
525
|
before do
|
510
|
-
subject.add_file(f, 'content', 'small_file.txt')
|
526
|
+
subject.add_file(f, path: 'content', original_name: 'small_file.txt')
|
511
527
|
subject.apply_depositor_metadata('mjg36')
|
512
528
|
end
|
513
529
|
|
@@ -521,7 +537,7 @@ describe GenericFile, :type => :model do
|
|
521
537
|
it "does not save a new version of a GenericFile" do
|
522
538
|
subject.save!
|
523
539
|
allow(Sufia::GenericFile::Actor).to receive(:virus_check).and_raise(Sufia::VirusFoundError)
|
524
|
-
subject.add_file(File.new(fixture_path + '/sufia_generic_stub.txt') , 'content', 'sufia_generic_stub.txt')
|
540
|
+
subject.add_file(File.new(fixture_path + '/sufia_generic_stub.txt') , path: 'content', original_name: 'sufia_generic_stub.txt')
|
525
541
|
subject.save
|
526
542
|
expect(subject.reload.content.content).to eq "small\n"
|
527
543
|
end
|
@@ -540,7 +556,7 @@ describe GenericFile, :type => :model do
|
|
540
556
|
let(:title_key) { Solrizer.solr_name("title", :stored_searchable, type: :string) }
|
541
557
|
let(:title) { ["abc123"] }
|
542
558
|
let(:no_terms) { GenericFile.find(subject.id).to_solr }
|
543
|
-
let(:terms) {
|
559
|
+
let(:terms) {
|
544
560
|
file = GenericFile.find(subject.id)
|
545
561
|
file.title = title
|
546
562
|
file.save
|
@@ -34,7 +34,7 @@ describe SingleUseLink do
|
|
34
34
|
describe "find" do
|
35
35
|
describe "not expired" do
|
36
36
|
before do
|
37
|
-
@su = SingleUseLink.create(downloadKey: 'sha2hashb', itemId: file.id, path: Sufia::Engine.routes.url_helpers.download_path(file
|
37
|
+
@su = SingleUseLink.create(downloadKey: 'sha2hashb', itemId: file.id, path: Sufia::Engine.routes.url_helpers.download_path(file), expires: DateTime.now.advance(hours: 1))
|
38
38
|
end
|
39
39
|
it "should retrieve link" do
|
40
40
|
link = SingleUseLink.where(downloadKey: 'sha2hashb').first
|
@@ -51,7 +51,7 @@ describe SingleUseLink do
|
|
51
51
|
end
|
52
52
|
describe "expired" do
|
53
53
|
before do
|
54
|
-
@su = SingleUseLink.create!(downloadKey: 'sha2hashb', itemId:file.id, path:Sufia::Engine.routes.url_helpers.download_path(file
|
54
|
+
@su = SingleUseLink.create!(downloadKey: 'sha2hashb', itemId:file.id, path:Sufia::Engine.routes.url_helpers.download_path(file))
|
55
55
|
|
56
56
|
@su.update_attribute :expires, DateTime.now.advance(hours: -1)
|
57
57
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe SolrDocument, :
|
3
|
+
describe SolrDocument, type: :model do
|
4
4
|
|
5
5
|
describe "date_uploaded" do
|
6
6
|
before do
|
@@ -11,12 +11,15 @@ describe SolrDocument, :type => :model do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe
|
14
|
+
describe '#to_param' do
|
15
|
+
let(:id) { '1v53kn56d' }
|
16
|
+
|
15
17
|
before do
|
16
|
-
subject[
|
18
|
+
subject[:id] = id
|
17
19
|
end
|
18
|
-
|
19
|
-
|
20
|
+
|
21
|
+
it 'returns the object identifier' do
|
22
|
+
expect(subject.to_param).to eq id
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
data/spec/models/user_spec.rb
CHANGED
@@ -90,9 +90,9 @@ describe User, :type => :model do
|
|
90
90
|
let(:file1) { GenericFile.create { |f| f.apply_depositor_metadata(user) } }
|
91
91
|
let(:file2) { GenericFile.create { |f| f.apply_depositor_metadata(user) } }
|
92
92
|
let(:file3) { GenericFile.create { |f| f.apply_depositor_metadata(user) } }
|
93
|
-
let!(:trophy1) { user.trophies.create!(generic_file_id: file1.
|
94
|
-
let!(:trophy2) { user.trophies.create!(generic_file_id: file2.
|
95
|
-
let!(:trophy3) { user.trophies.create!(generic_file_id: file3.
|
93
|
+
let!(:trophy1) { user.trophies.create!(generic_file_id: file1.id) }
|
94
|
+
let!(:trophy2) { user.trophies.create!(generic_file_id: file2.id) }
|
95
|
+
let!(:trophy3) { user.trophies.create!(generic_file_id: file3.id) }
|
96
96
|
|
97
97
|
it "should return a list of generic files" do
|
98
98
|
expect(user.trophy_files).to eq [file1, file2, file3]
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sufia::CollectionPresenter do
|
4
|
+
describe ".terms" do
|
5
|
+
subject { described_class.terms }
|
6
|
+
it { is_expected.to eq [:title, :total_items, :size, :resource_type, :description, :creator,
|
7
|
+
:contributor, :tag, :rights, :publisher, :date_created, :subject,
|
8
|
+
:language, :identifier, :based_near, :related_url] }
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:collection) { Collection.new(description: 'a nice collection', title: 'A clever title') }
|
12
|
+
let(:presenter) { described_class.new(collection) }
|
13
|
+
|
14
|
+
describe "#terms_with_values" do
|
15
|
+
subject { presenter.terms_with_values }
|
16
|
+
|
17
|
+
it { is_expected.to eq [:title, :total_items, :size, :description] }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#title" do
|
21
|
+
subject { presenter.title }
|
22
|
+
it { is_expected.to eq 'A clever title' }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#size" do
|
26
|
+
subject { presenter.size }
|
27
|
+
it { is_expected.to eq '0 Bytes' }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#total_items" do
|
31
|
+
subject { presenter.total_items }
|
32
|
+
it { is_expected.to eq 0 }
|
33
|
+
end
|
34
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Sufia::GenericFilePresenter do
|
4
|
-
describe "
|
4
|
+
describe ".terms" do
|
5
5
|
it "should return a list" do
|
6
6
|
expect(described_class.terms).to eq([:resource_type, :title,
|
7
7
|
:creator, :contributor, :description, :tag, :rights, :publisher,
|
@@ -9,4 +9,44 @@ describe Sufia::GenericFilePresenter do
|
|
9
9
|
:related_url])
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
let(:presenter) { Sufia::GenericFilePresenter.new(file) }
|
14
|
+
|
15
|
+
describe '#tweeter' do
|
16
|
+
let(:file) { build(:generic_file).tap { |f| f.apply_depositor_metadata(user) } }
|
17
|
+
subject { presenter.tweeter }
|
18
|
+
|
19
|
+
context "with a user that can be found" do
|
20
|
+
let(:user) { create :user, twitter_handle: 'test' }
|
21
|
+
it { is_expected.to eq '@test' }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with a user that doesn't have a twitter handle" do
|
25
|
+
let(:user) { create :user, twitter_handle: '' }
|
26
|
+
it { is_expected.to eq '@HydraSphere' }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with a user that can't be found" do
|
30
|
+
let(:user) { 'sarah' }
|
31
|
+
it { is_expected.to eq '@HydraSphere' }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#itemtype' do
|
36
|
+
let(:file) { build(:generic_file, resource_type: type) }
|
37
|
+
|
38
|
+
subject { presenter.itemtype }
|
39
|
+
|
40
|
+
context 'when resource_type is Audio' do
|
41
|
+
let(:type) { ['Audio'] }
|
42
|
+
|
43
|
+
it { is_expected.to eq 'http://schema.org/AudioObject' }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when resource_type is Conference Proceeding' do
|
47
|
+
let(:type) { ['Conference Proceeding'] }
|
48
|
+
|
49
|
+
it { is_expected.to eq 'http://schema.org/ScholarlyArticle' }
|
50
|
+
end
|
51
|
+
end
|
12
52
|
end
|
@@ -9,14 +9,24 @@ describe Sufia::VersionListPresenter, :no_clean do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
let(:resource_version2) do
|
13
|
+
ActiveFedora::VersionsGraph::ResourceVersion.new.tap do |v|
|
14
|
+
v.uri = 'http://example.com/version2'
|
15
|
+
v.label = 'version2'
|
16
|
+
v.created = '2014-12-19T02:03:18.296Z'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
subject { Sufia::VersionListPresenter.new([resource_version, resource_version2]) }
|
13
21
|
|
14
22
|
describe "#each" do
|
15
23
|
it "should yield version_presenters" do
|
24
|
+
versions_descending = []
|
16
25
|
subject.each do |v|
|
17
26
|
expect(v).to be_kind_of Sufia::VersionPresenter
|
18
|
-
|
27
|
+
versions_descending.push(v.label)
|
19
28
|
end
|
29
|
+
expect(versions_descending).to eq ['version2', 'version1']
|
20
30
|
end
|
21
31
|
end
|
22
32
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Sufia::GenericFileAuditService do
|
4
4
|
let(:f) do
|
5
5
|
GenericFile.create do |f|
|
6
|
-
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
6
|
+
f.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
7
7
|
f.apply_depositor_metadata('mjg36')
|
8
8
|
end
|
9
9
|
end
|
@@ -14,7 +14,7 @@ describe Sufia::GenericFileAuditService do
|
|
14
14
|
before do
|
15
15
|
# force a second version
|
16
16
|
gf = GenericFile.find(f.id)
|
17
|
-
gf.add_file('hello two', 'content', 'hello2.txt')
|
17
|
+
gf.add_file('hello two', path: 'content', original_name: 'hello2.txt')
|
18
18
|
gf.save!
|
19
19
|
end
|
20
20
|
|
@@ -30,7 +30,7 @@ describe Sufia::GenericFileAuditService do
|
|
30
30
|
before do
|
31
31
|
# force a second version
|
32
32
|
gf = GenericFile.find(f.id)
|
33
|
-
gf.add_file('hello two', 'content', 'hello2.txt')
|
33
|
+
gf.add_file('hello two', path: 'content', original_name: 'hello2.txt')
|
34
34
|
gf.save!
|
35
35
|
end
|
36
36
|
|
data/spec/services/noid_spec.rb
CHANGED
@@ -1,16 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Sufia::Noid do
|
4
|
-
describe "#
|
5
|
-
subject { Sufia::Noid.
|
6
|
-
|
7
|
-
|
8
|
-
let(:id) { 'abc123' }
|
9
|
-
it { is_expected.to eq 'sufia:abc123' }
|
10
|
-
end
|
11
|
-
context "when the passed in pid has a namespace" do
|
12
|
-
let(:id) { 'ksl:abc123' }
|
13
|
-
it { is_expected.to eq 'ksl:abc123' }
|
14
|
-
end
|
4
|
+
describe "#treeify" do
|
5
|
+
subject { Sufia::Noid.treeify(id) }
|
6
|
+
let(:id) { 'abc123def45' }
|
7
|
+
it { is_expected.to eq 'ab/c1/23/de/abc123def45' }
|
15
8
|
end
|
16
9
|
end
|
@@ -4,7 +4,7 @@ describe Sufia::RepositoryAuditService do
|
|
4
4
|
let(:user) { FactoryGirl.create(:user) }
|
5
5
|
let!(:file) do
|
6
6
|
GenericFile.create! do |file|
|
7
|
-
file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
7
|
+
file.add_file(File.open(fixture_path + '/world.png'), path: 'content', original_name: 'world.png')
|
8
8
|
file.apply_depositor_metadata(user)
|
9
9
|
end
|
10
10
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# spec/support/fixture_helpers.rb
|
2
2
|
module FixtureHelpers
|
3
|
-
def create_file_fixtures(depositor=
|
3
|
+
def create_file_fixtures(depositor = 'archivist1@example.com')
|
4
4
|
handles = [:public_pdf, :public_mp3, :public_wav]
|
5
|
-
handles.map {|handle| FactoryGirl.create(handle, depositor: depositor) }
|
5
|
+
handles.map { |handle| FactoryGirl.create(handle, depositor: depositor) }
|
6
6
|
end
|
7
7
|
end
|
8
|
-
|
data/spec/support/selectors.rb
CHANGED
@@ -18,26 +18,26 @@ module Selectors
|
|
18
18
|
module Dashboard
|
19
19
|
|
20
20
|
def db_item_actions_toggle item
|
21
|
-
within "#document_#{item.
|
21
|
+
within "#document_#{item.id}" do
|
22
22
|
find '.dropdown-toggle'
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def db_item_title item
|
27
|
-
within "#document_#{item.
|
28
|
-
find "#src_copy_link#{item.
|
27
|
+
within "#document_#{item.id}" do
|
28
|
+
find "#src_copy_link#{item.id}"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def db_file_checkbox file
|
33
|
-
within "#document_#{file.
|
33
|
+
within "#document_#{file.id}" do
|
34
34
|
find '.batch_document_selector'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def db_collection_radio_button collection
|
39
39
|
within '#collection-list-container' do
|
40
|
-
find "input[id*='#{collection.
|
40
|
+
find "input[id*='#{collection.id}']"
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -52,8 +52,8 @@ module Selectors
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def db_visibility_link file
|
55
|
-
within "#document_#{file.
|
56
|
-
find "a#permission_#{file.
|
55
|
+
within "#document_#{file.id}" do
|
56
|
+
find "a#permission_#{file.id}"
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|