sufia 3.0.0 → 3.1.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/.gitignore +2 -0
- data/Gemfile +1 -1
- data/History.md +77 -0
- data/README.md +26 -11
- data/SUFIA_VERSION +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +4 -3
- data/app/helpers/sufia_helper.rb +7 -5
- data/app/jobs/ingest_local_file_job.rb +34 -0
- data/app/views/catalog/_facet_selected.html.erb +1 -1
- data/app/views/generic_files/_local_file_import.html.erb +3 -0
- data/app/views/generic_files/new.html.erb +10 -0
- data/app/views/generic_files/upload/_alerts.html.erb +2 -2
- data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +27 -0
- data/app/views/generic_files/upload/_script_templates.html.erb +1 -1
- data/lib/generators/sufia/sufia_generator.rb +1 -0
- data/lib/generators/sufia/templates/config/resque_config.rb +3 -20
- data/lib/sufia/files_controller/local_ingest_behavior.rb +54 -0
- data/lib/sufia/files_controller/upload_complete_behavior.rb +7 -0
- data/lib/sufia/files_controller_behavior.rb +31 -11
- data/lib/sufia/version.rb +1 -1
- data/spec/active_fedora/unsaved_digital_object_spec.rb +1 -1
- data/spec/controllers/authorities_controller_spec.rb +1 -1
- data/spec/controllers/batch_controller_spec.rb +4 -4
- data/spec/controllers/batch_edits_controller_spec.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +1 -1
- data/spec/controllers/dashboard_controller_spec.rb +2 -2
- data/spec/controllers/downloads_controller_spec.rb +2 -3
- data/spec/controllers/generic_files_controller_spec.rb +113 -31
- data/spec/controllers/mailbox_controller_spec.rb +1 -1
- data/spec/controllers/single_use_link_controller_spec.rb +4 -5
- data/spec/controllers/users_controller_spec.rb +3 -3
- data/spec/features/browse_dashboard_files.rb +1 -1
- data/spec/features/browse_files.rb +1 -1
- data/spec/features/contact_form.rb +1 -1
- data/spec/features/display_dashboard.rb +1 -1
- data/spec/features/ingest_upload_files.rb +1 -1
- data/spec/features/users_spec.rb +1 -1
- data/spec/helpers/generic_file_helper_spec.rb +1 -1
- data/spec/helpers/render_constraints_helper_behavior_spec.rb +42 -0
- data/spec/helpers/sufia_helper_spec.rb +40 -1
- data/spec/jobs/import_url_job_spec.rb +45 -0
- data/spec/jobs/ingest_local_file_job_spec.rb +35 -0
- data/spec/lib/sufia/id_service_spec.rb +1 -1
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +26 -0
- data/spec/models/audit_job_spec.rb +2 -2
- data/spec/models/batch_spec.rb +1 -1
- data/spec/models/batch_update_job_spec.rb +2 -4
- data/spec/models/characterize_job_spec.rb +17 -14
- data/spec/models/checksum_audit_log_spec.rb +2 -2
- data/spec/models/event_jobs_spec.rb +2 -2
- data/spec/models/file_content_datastream_spec.rb +5 -5
- data/spec/models/fits_datastream_spec.rb +2 -2
- data/spec/models/generic_file/actions_spec.rb +25 -0
- data/spec/models/generic_file/web_form_spec.rb +1 -1
- data/spec/models/generic_file_spec.rb +16 -33
- data/spec/models/local_authority_spec.rb +1 -1
- data/spec/models/properties_datastream_spec.rb +1 -1
- data/spec/models/single_use_link_spec.rb +1 -1
- data/spec/models/solr_document_spec.rb +1 -1
- data/spec/models/transcode_audio_job_spec.rb +22 -18
- data/spec/models/transcode_video_job_spec.rb +4 -3
- data/spec/models/trophy_spec.rb +1 -1
- data/spec/models/unzip_job_spec.rb +2 -2
- data/spec/models/user_spec.rb +1 -1
- data/spec/rake/sufia_fixtures_spec.rb +1 -1
- data/spec/routing/route_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/views/batch_edits/check_all_spec.rb +1 -1
- data/sufia-models/app/models/datastreams/file_content_datastream.rb +1 -15
- data/sufia-models/app/models/geo_names_resource.rb +0 -2
- data/sufia-models/lib/sufia/models.rb +1 -1
- data/sufia-models/lib/sufia/models/engine.rb +12 -1
- data/sufia-models/lib/sufia/models/file_content.rb +0 -3
- data/sufia-models/lib/sufia/models/generic_file.rb +6 -10
- data/sufia-models/lib/sufia/models/generic_file/actions.rb +1 -1
- data/sufia-models/lib/sufia/models/generic_file/characterization.rb +1 -1
- data/sufia-models/lib/sufia/models/generic_file/derivatives.rb +31 -0
- data/sufia-models/lib/sufia/models/generic_file/mime_types.rb +27 -0
- data/sufia-models/lib/sufia/models/generic_file/thumbnail.rb +6 -60
- data/sufia-models/lib/sufia/models/jobs/active_fedora_pid_based_job.rb +19 -0
- data/sufia-models/lib/sufia/models/jobs/audit_job.rb +12 -8
- data/sufia-models/lib/sufia/models/jobs/characterize_job.rb +3 -10
- data/sufia-models/lib/sufia/models/jobs/import_url_job.rb +2 -9
- data/sufia-models/lib/sufia/models/jobs/resolrize_job.rb +8 -1
- data/sufia-models/lib/sufia/models/jobs/transcode_audio_job.rb +4 -28
- data/sufia-models/lib/sufia/models/jobs/transcode_video_job.rb +4 -28
- data/sufia-models/lib/sufia/models/jobs/unzip_job.rb +5 -19
- data/sufia-models/lib/sufia/models/model_methods.rb +2 -16
- data/sufia-models/lib/sufia/models/user_local_directory_behavior.rb +29 -0
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +1 -1
- data/sufia.gemspec +2 -1
- data/tasks/sufia-dev.rake +1 -1
- metadata +26 -10
- data/app/assets/stylesheets/jquery-ui-1.8.1.custom.css +0 -486
- data/app/assets/stylesheets/jquery-ui-1.8.23.custom.css +0 -340
- data/sufia-models/lib/sufia/models/file_content/extract_metadata.rb +0 -60
- data/sufia-models/lib/sufia/models/jobs/ffmpeg_transcode_job.rb +0 -61
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe ImportUrlJob do
|
|
4
|
+
let(:user) { FactoryGirl.find_or_create(:user) }
|
|
5
|
+
|
|
6
|
+
let(:generic_file) do
|
|
7
|
+
GenericFile.new.tap do |f|
|
|
8
|
+
f.import_url = "http://example.org/world.png"
|
|
9
|
+
f.apply_depositor_metadata(user.user_key)
|
|
10
|
+
f.save
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
after do
|
|
15
|
+
generic_file.destroy
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
subject { ImportUrlJob.new(generic_file.id) }
|
|
19
|
+
|
|
20
|
+
it "should have no content at the outset" do
|
|
21
|
+
generic_file.content.size.should be_nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should create a content datastream" do
|
|
25
|
+
http_res = double('response')
|
|
26
|
+
http_res.stub(:read_body).and_yield(File.open(File.expand_path('../../fixtures/world.png', __FILE__)).read)
|
|
27
|
+
Net::HTTP.any_instance.stub(:request_get).and_yield(http_res)
|
|
28
|
+
Net::HTTP.any_instance.should_receive(:request_get).with(URI(generic_file.import_url).request_uri)
|
|
29
|
+
subject.run
|
|
30
|
+
generic_file.reload.content.size.should == 4218
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "virus checking" do
|
|
34
|
+
it "should run virus check" do
|
|
35
|
+
Sufia::GenericFile::Actions.should_receive(:virus_check).and_return(0)
|
|
36
|
+
Sufia::GenericFile::Actions.should_receive(:create_content).once
|
|
37
|
+
subject.run
|
|
38
|
+
end
|
|
39
|
+
it "should abort if virus check fails" do
|
|
40
|
+
Sufia::GenericFile::Actions.should_receive(:virus_check).and_return(1)
|
|
41
|
+
User.any_instance.should_receive(:send_message).with(user, 'The file (world.png) was unable to be imported because it contained a virus.', 'File Import Error')
|
|
42
|
+
subject.run
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe IngestLocalFileJob do
|
|
4
|
+
let(:user) { FactoryGirl.find_or_create(:user) }
|
|
5
|
+
|
|
6
|
+
let (:generic_file) do
|
|
7
|
+
GenericFile.new.tap { |f| f.apply_depositor_metadata(user); f.save }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
@mock_upload_directory = 'spec/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)
|
|
14
|
+
end
|
|
15
|
+
after do
|
|
16
|
+
generic_file.destroy
|
|
17
|
+
end
|
|
18
|
+
subject { IngestLocalFileJob.new(generic_file.id, @mock_upload_directory, "world.png", user.user_key) }
|
|
19
|
+
|
|
20
|
+
it "should have attached a file" do
|
|
21
|
+
subject.run
|
|
22
|
+
generic_file.reload.content.size.should == 4218
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "virus checking" do
|
|
26
|
+
it "should run virus check" do
|
|
27
|
+
Sufia::GenericFile::Actions.should_receive(:virus_check).and_return(0)
|
|
28
|
+
subject.run
|
|
29
|
+
end
|
|
30
|
+
it "should abort if virus check fails" do
|
|
31
|
+
Sufia::GenericFile::Actions.should_receive(:virus_check).and_return(1)
|
|
32
|
+
expect { subject.run }.to raise_error(StandardError, /Virus checking did not pass/)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
class UploadThing
|
|
3
|
+
extend Sufia::FilesController::UploadCompleteBehavior
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class UploadThingRedefine
|
|
7
|
+
extend Sufia::FilesController::UploadCompleteBehavior
|
|
8
|
+
def self.upload_complete_path(id)
|
|
9
|
+
return "example.com"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe Sufia::FilesController::UploadCompleteBehavior do
|
|
15
|
+
let (:test_id) {"123abc"}
|
|
16
|
+
context "Not overridden" do
|
|
17
|
+
it "respond with the batch edit path" do
|
|
18
|
+
UploadThing.upload_complete_path(test_id).should == Sufia::Engine.routes.url_helpers.batch_edit_path(test_id)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
context "overriden path" do
|
|
22
|
+
it "respond with the batch edit path" do
|
|
23
|
+
UploadThingRedefine.upload_complete_path(test_id).should == "example.com"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe AuditJob do
|
|
4
4
|
before do
|
|
@@ -7,7 +7,7 @@ describe AuditJob do
|
|
|
7
7
|
GenericFile.any_instance.should_receive(:characterize_if_changed).and_yield
|
|
8
8
|
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
9
9
|
@file = GenericFile.new
|
|
10
|
-
@file.apply_depositor_metadata(@user
|
|
10
|
+
@file.apply_depositor_metadata(@user)
|
|
11
11
|
@file.save
|
|
12
12
|
@ds = @file.datastreams.first
|
|
13
13
|
end
|
data/spec/models/batch_spec.rb
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
1
|
+
require 'spec_helper'
|
|
4
2
|
|
|
5
3
|
describe BatchUpdateJob do
|
|
6
4
|
before do
|
|
@@ -8,7 +6,7 @@ describe BatchUpdateJob do
|
|
|
8
6
|
@batch = Batch.new
|
|
9
7
|
@batch.save
|
|
10
8
|
@file = GenericFile.new(:batch=>@batch)
|
|
11
|
-
@file.apply_depositor_metadata(@user
|
|
9
|
+
@file.apply_depositor_metadata(@user)
|
|
12
10
|
@file.save
|
|
13
11
|
@file2 = GenericFile.new(:batch=>@batch)
|
|
14
12
|
@file2.apply_depositor_metadata('otherUser')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe CharacterizeJob do
|
|
4
4
|
before do
|
|
@@ -15,17 +15,18 @@ describe CharacterizeJob do
|
|
|
15
15
|
|
|
16
16
|
describe "with a AVI (video) file" do
|
|
17
17
|
before do
|
|
18
|
-
@generic_file.
|
|
18
|
+
@generic_file.add_file(File.open(fixture_path + '/countdown.avi'), 'content', 'countdown.avi')
|
|
19
19
|
@generic_file.stub(:characterize_if_changed).and_yield
|
|
20
20
|
@generic_file.save!
|
|
21
21
|
end
|
|
22
22
|
it "should create a transcode job" do
|
|
23
23
|
job = double("stub video job")
|
|
24
24
|
if $in_travis
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
# This is in place because we stub fits for travis, and the stub sets the mime to application/pdf, fixing that.
|
|
26
|
+
@generic_file.stub(:mime_type).and_return('video/avi')
|
|
27
|
+
ActiveFedora::Base.should_receive(:find).with(@generic_file.id, cast:true).and_return(@generic_file)
|
|
27
28
|
end
|
|
28
|
-
TranscodeVideoJob.should_receive(:new).with(@generic_file.id
|
|
29
|
+
TranscodeVideoJob.should_receive(:new).with(@generic_file.id).and_return(job)
|
|
29
30
|
Sufia.queue.should_receive(:push).with(job)
|
|
30
31
|
subject.run
|
|
31
32
|
end
|
|
@@ -37,17 +38,18 @@ describe CharacterizeJob do
|
|
|
37
38
|
|
|
38
39
|
describe "with a WAV (audio) file" do
|
|
39
40
|
before do
|
|
40
|
-
@generic_file.
|
|
41
|
+
@generic_file.add_file(File.open(fixture_path + '/piano_note.wav'), 'content', 'piano_note.wav')
|
|
41
42
|
@generic_file.stub(:characterize_if_changed).and_yield
|
|
42
43
|
@generic_file.save!
|
|
43
44
|
end
|
|
44
45
|
it "should create a transcode job" do
|
|
45
46
|
job = double("stub audio job")
|
|
46
47
|
if $in_travis
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
# This is in place because we stub fits for travis, and the stub sets the mime to application/pdf, fixing that.
|
|
49
|
+
@generic_file.stub(:mime_type).and_return('audio/wav')
|
|
50
|
+
ActiveFedora::Base.should_receive(:find).with(@generic_file.id, cast:true).and_return(@generic_file)
|
|
49
51
|
end
|
|
50
|
-
TranscodeAudioJob.should_receive(:new).with(@generic_file.id
|
|
52
|
+
TranscodeAudioJob.should_receive(:new).with(@generic_file.id).and_return(job)
|
|
51
53
|
Sufia.queue.should_receive(:push).with(job)
|
|
52
54
|
subject.run
|
|
53
55
|
end
|
|
@@ -55,7 +57,7 @@ describe CharacterizeJob do
|
|
|
55
57
|
|
|
56
58
|
describe "with an mp3 (audio) file" do
|
|
57
59
|
before do
|
|
58
|
-
@generic_file.
|
|
60
|
+
@generic_file.add_file(File.open(fixture_path + '/sufia/sufia_test5.mp3'), 'content', 'sufia_test5.mp3')
|
|
59
61
|
@generic_file.stub(:characterize_if_changed).and_yield
|
|
60
62
|
@generic_file.save!
|
|
61
63
|
end
|
|
@@ -63,10 +65,11 @@ describe CharacterizeJob do
|
|
|
63
65
|
# TODO just copy the 'content' datastream to the mp3 datastream if it's an mp3, and then transcode to ogg
|
|
64
66
|
job = double("stub audio job")
|
|
65
67
|
if $in_travis
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
# This is in place because we stub fits for travis, and the stub sets the mime to application/pdf, fixing that.
|
|
69
|
+
@generic_file.stub(:mime_type).and_return('audio/mpeg')
|
|
70
|
+
ActiveFedora::Base.should_receive(:find).with(@generic_file.id, cast:true).and_return(@generic_file)
|
|
68
71
|
end
|
|
69
|
-
TranscodeAudioJob.should_receive(:new).with(@generic_file.id
|
|
72
|
+
TranscodeAudioJob.should_receive(:new).with(@generic_file.id).and_return(job)
|
|
70
73
|
Sufia.queue.should_receive(:push).with(job)
|
|
71
74
|
subject.run
|
|
72
75
|
end
|
|
@@ -74,7 +77,7 @@ describe CharacterizeJob do
|
|
|
74
77
|
|
|
75
78
|
describe "with an jpeg2000 (image) file" do
|
|
76
79
|
before do
|
|
77
|
-
@generic_file.
|
|
80
|
+
@generic_file.add_file(File.open(fixture_path + '/image.jp2'), 'content', 'image.jp2')
|
|
78
81
|
@generic_file.stub(:characterize_if_changed).and_yield
|
|
79
82
|
@generic_file.save!
|
|
80
83
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe ChecksumAuditLog do
|
|
4
4
|
before(:all) do
|
|
5
5
|
@f = GenericFile.new
|
|
6
|
-
@f.
|
|
6
|
+
@f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
7
7
|
@f.apply_depositor_metadata('mjg36')
|
|
8
8
|
@f.stub(:characterize_if_changed).and_yield #don't run characterization
|
|
9
9
|
@f.save!
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe 'event jobs' do
|
|
4
4
|
before(:each) do
|
|
@@ -7,7 +7,7 @@ describe 'event jobs' do
|
|
|
7
7
|
@third_user = FactoryGirl.find_or_create(:curator)
|
|
8
8
|
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
9
9
|
@gf = GenericFile.new(pid: 'test:123')
|
|
10
|
-
@gf.apply_depositor_metadata(@user
|
|
10
|
+
@gf.apply_depositor_metadata(@user)
|
|
11
11
|
@gf.title = 'Hamlet'
|
|
12
12
|
@gf.save
|
|
13
13
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe FileContentDatastream do
|
|
4
4
|
before do
|
|
@@ -7,7 +7,7 @@ describe FileContentDatastream do
|
|
|
7
7
|
describe "version control" do
|
|
8
8
|
before do
|
|
9
9
|
f = GenericFile.new
|
|
10
|
-
f.
|
|
10
|
+
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
11
11
|
f.apply_depositor_metadata('mjg36')
|
|
12
12
|
f.stub(:characterize_if_changed).and_yield #don't run characterization
|
|
13
13
|
f.save
|
|
@@ -33,7 +33,7 @@ describe FileContentDatastream do
|
|
|
33
33
|
end
|
|
34
34
|
describe "add a version" do
|
|
35
35
|
before do
|
|
36
|
-
@file.
|
|
36
|
+
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
37
37
|
@file.stub(:characterize_if_changed).and_yield #don't run characterization
|
|
38
38
|
@file.save
|
|
39
39
|
end
|
|
@@ -93,13 +93,13 @@ describe FileContentDatastream do
|
|
|
93
93
|
@generic_file.delete
|
|
94
94
|
end
|
|
95
95
|
it "should only return true when the datastream has actually changed" do
|
|
96
|
-
@generic_file.
|
|
96
|
+
@generic_file.add_file(File.open(fixture_path + '/world.png', 'rb'), 'content', 'world.png')
|
|
97
97
|
@generic_file.content.changed?.should be_true
|
|
98
98
|
@generic_file.save!
|
|
99
99
|
@generic_file.content.changed?.should be_false
|
|
100
100
|
|
|
101
101
|
# Add a thumbnail ds
|
|
102
|
-
@generic_file.
|
|
102
|
+
@generic_file.add_file(File.open(fixture_path + '/world.png'), 'thumbnail', 'world.png')
|
|
103
103
|
@generic_file.thumbnail.changed?.should be_true
|
|
104
104
|
@generic_file.content.changed?.should be_false
|
|
105
105
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe FitsDatastream, :unless => $in_travis do
|
|
4
4
|
before(:all) do
|
|
5
5
|
@file = GenericFile.new
|
|
6
|
-
@file.
|
|
6
|
+
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
7
7
|
@file.characterize
|
|
8
8
|
end
|
|
9
9
|
it "should have a format label" do
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GenericFile do
|
|
4
|
+
|
|
5
|
+
describe "#virus_check" do
|
|
6
|
+
before do
|
|
7
|
+
unless defined? ClamAV
|
|
8
|
+
class ClamAV
|
|
9
|
+
def self.instance
|
|
10
|
+
new
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
@stubbed_clamav = true
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
after do
|
|
17
|
+
Object.send(:remove_const, :ClamAV) if @stubbed_clamav
|
|
18
|
+
end
|
|
19
|
+
it "should return the results of running ClamAV scanfile method" do
|
|
20
|
+
# subject.stub(:to_solr).and_return({})
|
|
21
|
+
ClamAV.any_instance.should_receive(:scanfile).and_return(1)
|
|
22
|
+
Sufia::GenericFile::Actions.virus_check(File.new(fixture_path + '/world.png')).should == 1
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe GenericFile do
|
|
4
4
|
before do
|
|
@@ -156,7 +156,7 @@ describe GenericFile do
|
|
|
156
156
|
@file.descMetadata.should be_kind_of GenericFileRdfDatastream
|
|
157
157
|
end
|
|
158
158
|
it "should have content datastream" do
|
|
159
|
-
@file.
|
|
159
|
+
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
160
160
|
@file.content.should be_kind_of FileContentDatastream
|
|
161
161
|
end
|
|
162
162
|
end
|
|
@@ -310,7 +310,7 @@ describe GenericFile do
|
|
|
310
310
|
describe "with a video", :if => Sufia.config.enable_ffmpeg do
|
|
311
311
|
before do
|
|
312
312
|
@f.stub(:mime_type=>'video/quicktime') #Would get set by the characterization job
|
|
313
|
-
@f.
|
|
313
|
+
@f.add_file(File.open("#{fixture_path}/countdown.avi", 'rb'), 'content', 'countdown.avi')
|
|
314
314
|
@f.save
|
|
315
315
|
end
|
|
316
316
|
it "should make a png thumbnail" do
|
|
@@ -319,36 +319,16 @@ describe GenericFile do
|
|
|
319
319
|
@f.thumbnail.mimeType.should == 'image/png'
|
|
320
320
|
end
|
|
321
321
|
end
|
|
322
|
-
|
|
323
|
-
describe "with an image that doesn't get resized" do
|
|
324
|
-
before do
|
|
325
|
-
@f.stub(:mime_type=>'image/png', :width=>['50'], :height=>['50']) #Would get set by the characterization job
|
|
326
|
-
@f.add_file_datastream(File.new("#{fixture_path}/world.png", 'rb'), :dsid=>'content')
|
|
327
|
-
@f.save
|
|
328
|
-
end
|
|
329
|
-
it "should keep the thumbnail at the original size (but transform to png)" do
|
|
330
|
-
@mock_image = double("image", :from_blob=>true)
|
|
331
|
-
@mock_image.should_not_receive(:scale)
|
|
332
|
-
@mock_image.should_receive(:to_blob).and_return('fake content')
|
|
333
|
-
Magick::ImageList.should_receive(:new).and_return(@mock_image)
|
|
334
|
-
@f.create_thumbnail
|
|
335
|
-
@f.thumbnail.content.should == 'fake content'
|
|
336
|
-
@f.thumbnail.mimeType.should == 'image/png'
|
|
337
|
-
end
|
|
338
|
-
end
|
|
339
322
|
end
|
|
340
323
|
describe "trophies" do
|
|
341
|
-
before
|
|
342
|
-
|
|
324
|
+
before do
|
|
325
|
+
u = FactoryGirl.create(:user)
|
|
343
326
|
@f = GenericFile.new.tap do |gf|
|
|
344
|
-
gf.apply_depositor_metadata(
|
|
327
|
+
gf.apply_depositor_metadata(u)
|
|
345
328
|
gf.stub(:characterize_if_changed).and_yield #don't run characterization
|
|
346
329
|
gf.save!
|
|
347
330
|
end
|
|
348
|
-
@t = Trophy.create(user_id:
|
|
349
|
-
end
|
|
350
|
-
after(:all) do
|
|
351
|
-
@u.destroy
|
|
331
|
+
@t = Trophy.create(user_id: u.id, generic_file_id: @f.pid)
|
|
352
332
|
end
|
|
353
333
|
it "should have a trophy" do
|
|
354
334
|
Trophy.where(generic_file_id: @f.pid).count.should == 1
|
|
@@ -363,13 +343,16 @@ describe GenericFile do
|
|
|
363
343
|
before(:each) do
|
|
364
344
|
u = FactoryGirl.create(:user)
|
|
365
345
|
f = GenericFile.new
|
|
366
|
-
f.
|
|
367
|
-
f.apply_depositor_metadata(u
|
|
346
|
+
f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
347
|
+
f.apply_depositor_metadata(u)
|
|
368
348
|
f.stub(:characterize_if_changed).and_yield #don't run characterization
|
|
369
349
|
f.save!
|
|
370
350
|
@f = f.reload
|
|
371
351
|
end
|
|
372
352
|
it "should schedule a audit job for each datastream" do
|
|
353
|
+
s0 = double('zero')
|
|
354
|
+
AuditJob.should_receive(:new).with(@f.pid, 'descMetadata', "descMetadata.0").and_return(s0)
|
|
355
|
+
Sufia.queue.should_receive(:push).with(s0)
|
|
373
356
|
s1 = double('one')
|
|
374
357
|
AuditJob.should_receive(:new).with(@f.pid, 'DC', "DC1.0").and_return(s1)
|
|
375
358
|
Sufia.queue.should_receive(:push).with(s1)
|
|
@@ -407,7 +390,7 @@ describe GenericFile do
|
|
|
407
390
|
describe "run_audit" do
|
|
408
391
|
before do
|
|
409
392
|
@f = GenericFile.new
|
|
410
|
-
@f.
|
|
393
|
+
@f.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
411
394
|
@f.apply_depositor_metadata('mjg36')
|
|
412
395
|
@f.stub(:characterize_if_changed).and_yield #don't run characterization
|
|
413
396
|
@f.save!
|
|
@@ -441,7 +424,7 @@ describe GenericFile do
|
|
|
441
424
|
@file.delete
|
|
442
425
|
end
|
|
443
426
|
it "should schedule a characterization job" do
|
|
444
|
-
@file.
|
|
427
|
+
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
445
428
|
Sufia.queue.should_receive(:push).once
|
|
446
429
|
@file.save
|
|
447
430
|
end
|
|
@@ -547,7 +530,7 @@ describe GenericFile do
|
|
|
547
530
|
end
|
|
548
531
|
describe "characterize" do
|
|
549
532
|
it "should return expected results when called", :unless => $in_travis do
|
|
550
|
-
@file.
|
|
533
|
+
@file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
|
|
551
534
|
@file.characterize
|
|
552
535
|
doc = Nokogiri::XML.parse(@file.characterization.content)
|
|
553
536
|
doc.root.xpath('//ns:imageWidth/text()', {'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output'}).inner_text.should == '50'
|
|
@@ -564,7 +547,7 @@ describe GenericFile do
|
|
|
564
547
|
describe "after job runs" do
|
|
565
548
|
before(:all) do
|
|
566
549
|
myfile = GenericFile.new
|
|
567
|
-
myfile.
|
|
550
|
+
myfile.add_file(File.open(fixture_path + '/sufia/sufia_test4.pdf'), 'content', 'sufia_test4.pdf')
|
|
568
551
|
myfile.label = 'label123'
|
|
569
552
|
myfile.apply_depositor_metadata('mjg36')
|
|
570
553
|
myfile.save
|