sufia 0.0.1.pre2 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -5
- data/README.md +44 -12
- data/app/assets/javascripts/{scholarsphere.js → sufia.js} +0 -0
- data/app/assets/stylesheets/{scholarsphere.css → sufia.css} +0 -0
- data/app/controllers/batch_controller.rb +2 -3
- data/app/controllers/batch_edits_controller.rb +4 -4
- data/app/controllers/dashboard_controller.rb +5 -3
- data/app/controllers/generic_files_controller.rb +77 -41
- data/app/controllers/users_controller.rb +9 -21
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
- data/app/helpers/sufia_helper.rb +23 -2
- data/app/models/datastreams/file_content_datastream.rb +17 -9
- data/app/models/generic_file.rb +1 -809
- data/app/views/_add_assets_links.html.erb +1 -1
- data/app/views/_user_util_links.html.erb +2 -2
- data/app/views/batch/_metadata.html.erb +16 -16
- data/app/views/batch/edit.html.erb +16 -10
- data/app/views/batch_edits/_metadata.html.erb +16 -16
- data/app/views/catalog/_index_partials/_list_files.html.erb +2 -2
- data/app/views/catalog/index.html.erb +5 -0
- data/app/views/dashboard/_facet_limit.html.erb +1 -1
- data/app/views/dashboard/_facet_pagination.html.erb +4 -4
- data/app/views/dashboard/_facet_selected.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_list_files.html.erb +8 -8
- data/app/views/dashboard/_search_form.html.erb +1 -1
- data/app/views/dashboard/_sort_and_per_page.html.erb +1 -1
- data/app/views/dashboard/index.html.erb +0 -1
- data/app/views/generic_files/_breadcrumbs.html.erb +1 -1
- data/app/views/generic_files/_descriptions.html.erb +3 -3
- data/app/views/generic_files/_field_form +3 -3
- data/app/views/generic_files/_media_display.html.erb +5 -4
- data/app/views/generic_files/_permission.html.erb +5 -5
- data/app/views/generic_files/_versioning.html.erb +1 -1
- data/app/views/generic_files/edit.html.erb +2 -2
- data/app/views/generic_files/show.html.erb +3 -3
- data/app/views/static/versions.html.erb +1 -1
- data/app/views/users/edit.html.erb +5 -3
- data/app/views/users/index.html.erb +3 -3
- data/app/views/users/show.html.erb +6 -6
- data/config/jetty.yml +6 -0
- data/config/routes.rb +8 -4
- data/features/browse_dashboard_files.feature +11 -1
- data/features/browse_files.feature +6 -5
- data/features/contact_form.feature +4 -0
- data/features/display_dashboard.feature +6 -3
- data/features/ingest_upload_files.feature +2 -2
- data/features/step_definitions/fixture_steps.rb +6 -5
- data/features/step_definitions/scholarsphere.rb +24 -1
- data/features/step_definitions/user_steps.rb +2 -2
- data/features/step_definitions/web_steps.rb +1 -1
- data/features/support/env.rb +26 -0
- data/features/users.feature +18 -0
- data/lib/active_support/core_ext/marshal.rb +22 -0
- data/lib/generators/sufia/sufia_generator.rb +18 -2
- data/lib/generators/sufia/templates/catalog_controller.rb +3 -4
- data/{spec/support → lib/generators/sufia/templates}/config/redis.yml +0 -0
- data/lib/generators/sufia/templates/config/sufia.rb +68 -0
- data/lib/generators/sufia/templates/migrations/add_ldap_attrs_to_user.rb +41 -0
- data/lib/kaminari/helpers/tag.rb +11 -0
- data/lib/sufia.rb +30 -7
- data/lib/sufia/controller.rb +1 -5
- data/lib/sufia/generic_file.rb +200 -0
- data/lib/sufia/generic_file/audit.rb +119 -0
- data/lib/sufia/generic_file/characterization.rb +82 -0
- data/lib/sufia/generic_file/export.rb +339 -0
- data/lib/sufia/generic_file/permissions.rb +64 -0
- data/lib/sufia/generic_file/thumbnail.rb +68 -0
- data/{app/models → lib/sufia/jobs}/audit_job.rb +13 -3
- data/lib/sufia/jobs/batch_update_job.rb +86 -0
- data/lib/sufia/jobs/characterize_job.rb +35 -0
- data/{app/models → lib/sufia/jobs}/content_delete_event_job.rb +3 -1
- data/{app/models → lib/sufia/jobs}/content_deposit_event_job.rb +1 -1
- data/{app/models → lib/sufia/jobs}/content_new_version_event_job.rb +1 -1
- data/{app/models → lib/sufia/jobs}/content_restored_version_event_job.rb +8 -0
- data/{app/models → lib/sufia/jobs}/content_update_event_job.rb +1 -1
- data/{app/models → lib/sufia/jobs}/event_job.rb +7 -3
- data/{app/models → lib/sufia/jobs}/resolrize_job.rb +4 -2
- data/lib/sufia/jobs/transcode_video_job.rb +79 -0
- data/{app/models → lib/sufia/jobs}/unzip_job.rb +11 -3
- data/{app/models → lib/sufia/jobs}/user_edit_profile_event_job.rb +6 -0
- data/{app/models → lib/sufia/jobs}/user_follow_event_job.rb +9 -4
- data/{app/models → lib/sufia/jobs}/user_unfollow_event_job.rb +6 -0
- data/lib/sufia/queue/resque.rb +30 -0
- data/lib/sufia/role_mapper.rb +0 -1
- data/{app/models/characterize_job.rb → lib/sufia/solr_document_behavior.rb} +6 -7
- data/lib/sufia/user.rb +3 -3
- data/lib/sufia/version.rb +1 -1
- data/lib/tasks/fixtures.rake +38 -38
- data/lib/tasks/resque.rake +1 -0
- data/solr_conf/conf/solrconfig.xml +32 -1615
- data/solr_conf/solr.xml +1 -1
- data/spec/active_fedora/unsaved_digital_object_spec.rb +4 -4
- data/spec/config/host_to_vhost_spec.rb +4 -4
- data/spec/controllers/authorities_controller_spec.rb +1 -1
- data/spec/controllers/batch_controller_spec.rb +12 -10
- data/spec/controllers/catalog_controller_spec.rb +13 -13
- data/spec/controllers/dashboard_controller_spec.rb +15 -15
- data/spec/controllers/downloads_controller_spec.rb +14 -14
- data/spec/controllers/generic_files_controller_spec.rb +88 -46
- data/spec/controllers/mailbox_controller_spec.rb +2 -2
- data/spec/controllers/sessions_controller_spec.rb +1 -1
- data/spec/controllers/single_use_link_controller_spec.rb +18 -18
- data/spec/controllers/users_controller_spec.rb +47 -31
- data/spec/fixtures/countdown.avi +0 -0
- data/spec/fixtures/sufia/.gitignore +1 -0
- data/spec/fixtures/{scholarsphere → sufia}/bg_header.jpg +0 -0
- data/spec/fixtures/sufia/sufia_test1.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere → sufia}/sufia_test1.foxml.erb +2 -2
- data/spec/fixtures/{scholarsphere/scholarsphere_test1.txt → sufia/sufia_test1.txt} +0 -0
- data/spec/fixtures/sufia/sufia_test2.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere/scholarsphere_test2.docx → sufia/sufia_test2.docx} +0 -0
- data/spec/fixtures/{scholarsphere/scholarsphere_test2.foxml.erb → sufia/sufia_test2.foxml.erb} +6 -6
- data/spec/fixtures/sufia/sufia_test3.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere/scholarsphere_test3.foxml.erb → sufia/sufia_test3.foxml.erb} +6 -6
- data/spec/fixtures/{scholarsphere/scholarsphere_test3.xls → sufia/sufia_test3.xls} +0 -0
- data/spec/fixtures/sufia/sufia_test4.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere/scholarsphere_test4.foxml.erb → sufia/sufia_test4.foxml.erb} +6 -6
- data/spec/fixtures/{scholarsphere/scholarsphere_test4.pdf → sufia/sufia_test4.pdf} +0 -0
- data/spec/fixtures/sufia/sufia_test5.descMeta.txt +19 -0
- data/spec/fixtures/{scholarsphere → sufia}/sufia_test5.foxml.erb +3 -3
- data/spec/fixtures/{scholarsphere/scholarsphere_test5.mp3 → sufia/sufia_test5.mp3} +0 -0
- data/spec/fixtures/sufia/sufia_test5.txt +1 -0
- data/spec/fixtures/sufia/sufia_test6.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere/scholarsphere_test6.foxml.erb → sufia/sufia_test6.foxml.erb} +6 -6
- data/spec/fixtures/{scholarsphere/scholarsphere_test6.jp2 → sufia/sufia_test6.jp2} +0 -0
- data/spec/fixtures/sufia/sufia_test6.txt +1 -0
- data/spec/fixtures/sufia_generic_stub.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere_generic_stub.foxml.erb → sufia_generic_stub.foxml.erb} +3 -3
- data/spec/fixtures/sufia_generic_stub.txt +1 -0
- data/spec/lib/sufia/role_mapper_spec.rb +1 -1
- data/spec/models/audit_job_spec.rb +8 -11
- data/spec/models/batch_spec.rb +5 -5
- data/spec/models/batch_update_job_spec.rb +18 -15
- data/spec/models/checksum_audit_log_spec.rb +6 -19
- data/spec/models/event_jobs_spec.rb +23 -23
- data/spec/models/file_content_datastream_spec.rb +14 -14
- data/spec/models/fits_datastream_spec.rb +1 -1
- data/spec/models/generic_file_spec.rb +88 -41
- data/spec/models/single_use_link_spec.rb +3 -3
- data/spec/models/transcode_video_job_spec.rb +30 -0
- data/spec/models/unzip_job_spec.rb +6 -4
- data/spec/rake/{scholarsphere_fixtures_spec.rb → sufia_fixtures_spec.rb} +16 -16
- data/spec/routing/route_spec.rb +4 -8
- data/spec/spec_helper.rb +0 -7
- data/spec/support/Gemfile +4 -2
- data/spec/support/fedora_conf/fedora.fcfg +953 -0
- data/spec/support/lib/generators/test_app_generator.rb +1 -11
- data/sufia.gemspec +5 -3
- data/tasks/{scholarsphere-db.rake → sufia-db.rake} +1 -1
- data/tasks/{scholarsphere-dev.rake → sufia-dev.rake} +7 -3
- data/tasks/{scholarsphere-fixtures.rake → sufia-fixtures.rake} +43 -43
- data/tasks/{scholarsphere.rake → sufia.rake} +2 -2
- metadata +126 -95
- data/app/models/batch_update_job.rb +0 -82
- data/app/models/solr_document.rb +0 -50
- data/lib/sufia/permissions.rb +0 -43
- data/spec/fixtures/scholarsphere/scholarsphere_test1.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/scholarsphere_test2.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/scholarsphere_test3.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/scholarsphere_test4.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/scholarsphere_test5.descMeta.txt +0 -19
- data/spec/fixtures/scholarsphere/scholarsphere_test5.txt +0 -1
- data/spec/fixtures/scholarsphere/scholarsphere_test6.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/scholarsphere_test6.txt +0 -1
- data/spec/fixtures/scholarsphere/sufia_scholarsphere1.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/sufia_scholarsphere1.foxml.erb +0 -79
- data/spec/fixtures/scholarsphere/sufia_scholarsphere1.txt +0 -1
- data/spec/fixtures/scholarsphere_generic_stub.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere_generic_stub.txt +0 -1
@@ -16,17 +16,17 @@ require 'spec_helper'
|
|
16
16
|
|
17
17
|
describe FileContentDatastream do
|
18
18
|
before do
|
19
|
-
GenericFile.any_instance.
|
19
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
20
20
|
@subject = FileContentDatastream.new(nil, 'content')
|
21
|
-
@subject.
|
22
|
-
@subject.
|
21
|
+
@subject.stub(:pid=>'my_pid')
|
22
|
+
@subject.stub(:dsVersionID=>'content.7')
|
23
23
|
end
|
24
24
|
describe "version control" do
|
25
25
|
before(:all) do
|
26
|
-
GenericFile.any_instance.
|
26
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
27
27
|
f = GenericFile.new
|
28
28
|
f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
29
|
-
f.
|
29
|
+
f.should_receive(:characterize_if_changed).and_yield
|
30
30
|
f.apply_depositor_metadata('mjg36')
|
31
31
|
f.save
|
32
32
|
@file = GenericFile.find(f.pid)
|
@@ -52,7 +52,7 @@ describe FileContentDatastream do
|
|
52
52
|
describe "add a version" do
|
53
53
|
before(:all) do
|
54
54
|
@file.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
55
|
-
@file.
|
55
|
+
@file.should_receive(:characterize_if_changed).and_yield
|
56
56
|
@file.save
|
57
57
|
end
|
58
58
|
it "should return two versions" do
|
@@ -73,25 +73,25 @@ describe FileContentDatastream do
|
|
73
73
|
end
|
74
74
|
it "should return an xml document" do
|
75
75
|
repo = mock("repo")
|
76
|
-
repo.
|
76
|
+
repo.stub(:config=>{})
|
77
77
|
f = File.new(fixture_path + '/world.png')
|
78
78
|
content = mock("file")
|
79
|
-
content.
|
80
|
-
content.
|
81
|
-
@subject.
|
79
|
+
content.stub(:read=>f.read)
|
80
|
+
content.stub(:rewind=>f.rewind)
|
81
|
+
@subject.should_receive(:content).exactly(5).times.and_return(f)
|
82
82
|
xml = @subject.extract_metadata
|
83
83
|
doc = Nokogiri::XML.parse(xml)
|
84
84
|
doc.root.xpath('//ns:imageWidth/text()', {'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output'}).inner_text.should == '50'
|
85
85
|
end
|
86
86
|
it "should return expected results when invoked via HTTP" do
|
87
87
|
repo = mock("repo")
|
88
|
-
repo.
|
88
|
+
repo.stub(:config=>{})
|
89
89
|
f = ActionDispatch::Http::UploadedFile.new(:tempfile => File.new(fixture_path + '/world.png'),
|
90
90
|
:filename => 'world.png')
|
91
91
|
content = mock("file")
|
92
|
-
content.
|
93
|
-
content.
|
94
|
-
@subject.
|
92
|
+
content.stub(:read=>f.read)
|
93
|
+
content.stub(:rewind=>f.rewind)
|
94
|
+
@subject.should_receive(:content).exactly(5).times.and_return(f)
|
95
95
|
xml = @subject.extract_metadata
|
96
96
|
doc = Nokogiri::XML.parse(xml)
|
97
97
|
doc.root.xpath('//ns:identity/@mimetype', {'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output'}).first.value.should == 'image/png'
|
@@ -16,7 +16,7 @@ require 'spec_helper'
|
|
16
16
|
|
17
17
|
describe FitsDatastream do
|
18
18
|
before(:all) do
|
19
|
-
GenericFile.any_instance.
|
19
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
20
20
|
@file = GenericFile.new
|
21
21
|
@file.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
22
22
|
@file.apply_depositor_metadata('mjg36')
|
@@ -16,7 +16,7 @@ require 'spec_helper'
|
|
16
16
|
|
17
17
|
describe GenericFile do
|
18
18
|
before(:each) do
|
19
|
-
GenericFile.any_instance.
|
19
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
20
20
|
@file = GenericFile.new
|
21
21
|
@file.apply_depositor_metadata('jcoyne')
|
22
22
|
end
|
@@ -131,7 +131,7 @@ describe GenericFile do
|
|
131
131
|
end
|
132
132
|
describe "that have been saved" do
|
133
133
|
before(:each) do
|
134
|
-
|
134
|
+
Sufia.queue.should_receive(:push).once
|
135
135
|
end
|
136
136
|
after(:each) do
|
137
137
|
unless @file.inner_object.class == ActiveFedora::UnsavedDigitalObject
|
@@ -227,18 +227,18 @@ describe GenericFile do
|
|
227
227
|
describe "with an image that doesn't get resized" do
|
228
228
|
before do
|
229
229
|
@f = GenericFile.new
|
230
|
-
@f.
|
230
|
+
@f.stub(:mime_type=>'image/png', :width=>['50'], :height=>['50']) #Would get set by the characterization job
|
231
231
|
@f.add_file_datastream(File.new("#{fixture_path}/world.png"), :dsid=>'content')
|
232
232
|
@f.apply_depositor_metadata('mjg36')
|
233
233
|
@f.save
|
234
234
|
@mock_image = mock("image", :from_blob=>true)
|
235
|
-
Magick::ImageList.
|
235
|
+
Magick::ImageList.should_receive(:new).and_return(@mock_image)
|
236
236
|
end
|
237
237
|
after do
|
238
238
|
@f.delete
|
239
239
|
end
|
240
240
|
it "should scale the thumbnail to original size" do
|
241
|
-
@mock_image.
|
241
|
+
@mock_image.should_receive(:scale).with(50, 50).and_return(stub(:to_blob=>'fake content'))
|
242
242
|
@f.create_thumbnail
|
243
243
|
@f.content.changed?.should be_false
|
244
244
|
@f.thumbnail.content.should == 'fake content'
|
@@ -246,48 +246,95 @@ describe GenericFile do
|
|
246
246
|
end
|
247
247
|
end
|
248
248
|
describe "audit" do
|
249
|
-
before(:
|
250
|
-
|
251
|
-
GenericFile.
|
252
|
-
f
|
249
|
+
before(:each) do
|
250
|
+
u = FactoryGirl.create(:user)
|
251
|
+
f = GenericFile.new(:terms_of_service=>'1')
|
252
|
+
f.stub(:characterize).and_return(true)
|
253
253
|
f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
254
|
-
f.apply_depositor_metadata(
|
255
|
-
f.save
|
254
|
+
f.apply_depositor_metadata(u.user_key)
|
255
|
+
f.save!
|
256
256
|
@f = GenericFile.find(f.pid)
|
257
|
-
@
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
257
|
+
@f.stub(:characterize).and_return(true)
|
258
|
+
end
|
259
|
+
it "should schedule a audit job for each datastream" do
|
260
|
+
s1 = stub('one')
|
261
|
+
AuditJob.should_receive(:new).with(@f.pid, 'DC', "DC1.0").and_return(s1)
|
262
|
+
Sufia.queue.should_receive(:push).with(s1)
|
263
|
+
s2 = stub('two')
|
264
|
+
AuditJob.should_receive(:new).with(@f.pid, 'RELS-EXT', "RELS-EXT.0").and_return(s2)
|
265
|
+
Sufia.queue.should_receive(:push).with(s2)
|
266
|
+
s3 = stub('three')
|
267
|
+
AuditJob.should_receive(:new).with(@f.pid, 'rightsMetadata', "rightsMetadata.0").and_return(s3)
|
268
|
+
Sufia.queue.should_receive(:push).with(s3)
|
269
|
+
s4 = stub('four')
|
270
|
+
AuditJob.should_receive(:new).with(@f.pid, 'properties', "properties.0").and_return(s4)
|
271
|
+
Sufia.queue.should_receive(:push).with(s4)
|
272
|
+
s5 = stub('five')
|
273
|
+
AuditJob.should_receive(:new).with(@f.pid, 'content', "content.0").and_return(s5)
|
274
|
+
Sufia.queue.should_receive(:push).with(s5)
|
275
|
+
s6 = stub('six')
|
276
|
+
AuditJob.should_receive(:new).with(@f.pid, 'characterization', "characterization.0").and_return(s6)
|
277
|
+
Sufia.queue.should_receive(:push).with(s6)
|
278
|
+
s7 = stub('seven')
|
279
|
+
AuditJob.should_receive(:new).with(@f.pid, 'thumbnail', "thumbnail.0").and_return(s7)
|
280
|
+
Sufia.queue.should_receive(:push).with(s7)
|
268
281
|
@f.audit!
|
269
282
|
end
|
270
283
|
it "should log a failing audit" do
|
271
|
-
@datastreams.each { |ds| ds.
|
284
|
+
@f.datastreams.each { |ds| ds.stub(:dsChecksumValid).and_return(false) }
|
285
|
+
GenericFile.stub(:run_audit).and_return(stub(:respose, :pass=>1, :created_at=>'2005-12-20', :pid=>'foo:123', :dsid=>'foo', :version=>'1'))
|
272
286
|
@f.audit!
|
273
287
|
ChecksumAuditLog.all.all? { |cal| cal.pass == 0 }.should be_true
|
274
288
|
end
|
275
289
|
it "should log a passing audit" do
|
276
|
-
|
290
|
+
GenericFile.stub(:run_audit).and_return(stub(:respose, :pass=>1, :created_at=>'2005-12-20', :pid=>'foo:123', :dsid=>'foo', :version=>'1'))
|
277
291
|
@f.audit!
|
278
292
|
ChecksumAuditLog.all.all? { |cal| cal.pass == 1 }.should be_true
|
279
293
|
end
|
294
|
+
|
280
295
|
it "should return true on audit_status" do
|
281
296
|
@f.audit_stat.should be_true
|
282
297
|
end
|
283
298
|
end
|
299
|
+
|
300
|
+
describe "run_audit" do
|
301
|
+
before do
|
302
|
+
@f = GenericFile.new(:terms_of_service => '1')
|
303
|
+
@f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
304
|
+
@f.apply_depositor_metadata('mjg36')
|
305
|
+
@f.save!
|
306
|
+
@version = @f.datastreams['content'].versions.first
|
307
|
+
@old = ChecksumAuditLog.create(:pid=>@f.pid, :dsid=>@version.dsid, :version=>@version.versionID, :pass=>1, :created_at=>2.minutes.ago)
|
308
|
+
@new = ChecksumAuditLog.create(:pid=>@f.pid, :dsid=>@version.dsid, :version=>@version.versionID, :pass=>0)
|
309
|
+
end
|
310
|
+
it "should not prune failed audits" do
|
311
|
+
@version.should_receive(:dsChecksumValid).and_return(true)
|
312
|
+
GenericFile.run_audit(@version)
|
313
|
+
|
314
|
+
@version.should_receive(:dsChecksumValid).and_return(false)
|
315
|
+
GenericFile.run_audit(@version)
|
316
|
+
|
317
|
+
@version.should_receive(:dsChecksumValid).and_return(false)
|
318
|
+
GenericFile.run_audit(@version)
|
319
|
+
|
320
|
+
@version.should_receive(:dsChecksumValid).and_return(true)
|
321
|
+
GenericFile.run_audit(@version)
|
322
|
+
|
323
|
+
@version.should_receive(:dsChecksumValid).and_return(false)
|
324
|
+
GenericFile.run_audit(@version)
|
325
|
+
|
326
|
+
@f.logs(@version.dsid).map(&:pass).should == [0, 1, 0, 0, 1, 0, 1]
|
327
|
+
end
|
328
|
+
|
329
|
+
end
|
330
|
+
|
284
331
|
describe "save" do
|
285
332
|
after(:each) do
|
286
333
|
@file.delete
|
287
334
|
end
|
288
335
|
it "should schedule a characterization job" do
|
289
336
|
@file.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
290
|
-
|
337
|
+
Sufia.queue.should_receive(:push).once
|
291
338
|
@file.save
|
292
339
|
end
|
293
340
|
end
|
@@ -334,8 +381,8 @@ describe GenericFile do
|
|
334
381
|
@f1.save
|
335
382
|
@f2.save
|
336
383
|
mock_batch = mock("batch")
|
337
|
-
mock_batch.
|
338
|
-
@f1.
|
384
|
+
mock_batch.stub(:generic_files => [@f1, @f2])
|
385
|
+
@f1.should_receive(:batch).and_return(mock_batch)
|
339
386
|
@f1.related_files.should == [@f2]
|
340
387
|
end
|
341
388
|
it "should work when batch is not defined by querying solr" do
|
@@ -343,7 +390,7 @@ describe GenericFile do
|
|
343
390
|
@f2.add_relationship("isPartOf", "info:fedora/#{@batch_id}")
|
344
391
|
@f1.save
|
345
392
|
@f2.save
|
346
|
-
@f1.
|
393
|
+
@f1.should_receive(:batch).twice.and_raise(NoMethodError)
|
347
394
|
lambda { @f1.related_files }.should_not raise_error
|
348
395
|
@f1.related_files.should == [@f2]
|
349
396
|
end
|
@@ -352,7 +399,7 @@ describe GenericFile do
|
|
352
399
|
@f2.add_relationship(:is_part_of, "info:fedora/#{@batch_id}")
|
353
400
|
@f1.save
|
354
401
|
@f2.save
|
355
|
-
@f1.
|
402
|
+
@f1.should_receive(:batch).twice.and_raise(NoMethodError)
|
356
403
|
lambda { @f1.related_files }.should_not raise_error
|
357
404
|
@f1.related_files.should == [@f2]
|
358
405
|
end
|
@@ -362,16 +409,16 @@ describe GenericFile do
|
|
362
409
|
@f1.save
|
363
410
|
@f2.save
|
364
411
|
mock_batch = mock("batch")
|
365
|
-
mock_batch.
|
366
|
-
@f1.
|
412
|
+
mock_batch.stub(:generic_files).and_raise(NoMethodError)
|
413
|
+
@f1.should_receive(:batch).twice
|
367
414
|
lambda { @f1.related_files }.should_not raise_error
|
368
415
|
@f1.related_files.should == [@f2]
|
369
416
|
end
|
370
417
|
end
|
371
418
|
describe "noid integration" do
|
372
419
|
before(:all) do
|
373
|
-
GenericFile.any_instance.
|
374
|
-
GenericFile.any_instance.
|
420
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
421
|
+
GenericFile.any_instance.should_receive(:characterize_if_changed).and_yield
|
375
422
|
@new_file = GenericFile.new(:pid => 'ns:123')
|
376
423
|
@new_file.apply_depositor_metadata('mjg36')
|
377
424
|
@new_file.save
|
@@ -399,19 +446,19 @@ describe GenericFile do
|
|
399
446
|
doc.root.xpath('//ns:imageWidth/text()', {'ns'=>'http://hul.harvard.edu/ois/xml/ns/fits/fits_output'}).inner_text.should == '50'
|
400
447
|
end
|
401
448
|
it "should not be triggered unless the content ds is changed" do
|
402
|
-
|
449
|
+
Sufia.queue.should_receive(:push).once
|
403
450
|
@file.content.content = "hey"
|
404
451
|
@file.save
|
405
452
|
@file.related_url = 'http://example.com'
|
406
|
-
|
453
|
+
Sufia.queue.should_receive(:push).never
|
407
454
|
@file.save
|
408
455
|
@file.delete
|
409
456
|
end
|
410
457
|
describe "after job runs" do
|
411
458
|
before(:all) do
|
412
|
-
GenericFile.any_instance.
|
459
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
413
460
|
myfile = GenericFile.new
|
414
|
-
myfile.add_file_datastream(File.new(fixture_path + '/
|
461
|
+
myfile.add_file_datastream(File.new(fixture_path + '/sufia/sufia_test4.pdf'), :dsid=>'content')
|
415
462
|
myfile.label = 'label123'
|
416
463
|
myfile.thumbnail.size.nil?.should be_true
|
417
464
|
myfile.apply_depositor_metadata('mjg36')
|
@@ -493,7 +540,7 @@ describe GenericFile do
|
|
493
540
|
describe "permissions validation" do
|
494
541
|
context "depositor must have edit access" do
|
495
542
|
before(:each) do
|
496
|
-
GenericFile.any_instance.
|
543
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
497
544
|
@file = GenericFile.new
|
498
545
|
@file.apply_depositor_metadata('mjg36')
|
499
546
|
@rightsmd = @file.rightsMetadata
|
@@ -593,7 +640,7 @@ describe GenericFile do
|
|
593
640
|
end
|
594
641
|
context "public must not have edit access" do
|
595
642
|
before(:each) do
|
596
|
-
GenericFile.any_instance.
|
643
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
597
644
|
@file = GenericFile.new
|
598
645
|
@file.apply_depositor_metadata('mjg36')
|
599
646
|
@file.read_groups = ['public']
|
@@ -694,7 +741,7 @@ describe GenericFile do
|
|
694
741
|
end
|
695
742
|
context "registered must not have edit access" do
|
696
743
|
before(:each) do
|
697
|
-
GenericFile.any_instance.
|
744
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
698
745
|
@file = GenericFile.new
|
699
746
|
@file.apply_depositor_metadata('mjg36')
|
700
747
|
@file.read_groups = ['registered']
|
@@ -795,7 +842,7 @@ describe GenericFile do
|
|
795
842
|
end
|
796
843
|
context "everything is copacetic" do
|
797
844
|
before(:each) do
|
798
|
-
GenericFile.any_instance.
|
845
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
799
846
|
@file = GenericFile.new
|
800
847
|
@file.apply_depositor_metadata('mjg36')
|
801
848
|
@file.read_groups = ['public']
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SingleUseLink do
|
4
4
|
before (:all) do
|
5
|
-
GenericFile.any_instance.
|
5
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
6
6
|
@file = GenericFile.new
|
7
7
|
@file.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
8
8
|
@file.apply_depositor_metadata('mjg36')
|
@@ -16,9 +16,9 @@ describe SingleUseLink do
|
|
16
16
|
describe "create" do
|
17
17
|
before do
|
18
18
|
@now = DateTime.now
|
19
|
-
DateTime.
|
19
|
+
DateTime.stub(:now).and_return(@now)
|
20
20
|
@hash = "sha2hash"+@now.to_f.to_s
|
21
|
-
Digest::SHA2.
|
21
|
+
Digest::SHA2.should_receive(:new).and_return(@hash)
|
22
22
|
|
23
23
|
end
|
24
24
|
it "should create show link" do
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TranscodeVideoJob do
|
4
|
+
before do
|
5
|
+
@generic_file = GenericFile.new(:terms_of_service=>'1')
|
6
|
+
@generic_file.apply_depositor_metadata('jcoyne@example.com')
|
7
|
+
@generic_file.add_file_datastream(File.new(fixture_path + '/countdown.avi'), :dsid=>'content')
|
8
|
+
@generic_file.save!
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
@generic_file.delete
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { TranscodeVideoJob.new(@generic_file.id, 'content')}
|
16
|
+
it "should put content in datastream_out" do
|
17
|
+
subject.run
|
18
|
+
reloaded = GenericFile.find(@generic_file.pid)
|
19
|
+
derivative = reloaded.datastreams['webm']
|
20
|
+
derivative.should_not be_nil
|
21
|
+
derivative.content.should_not be_nil
|
22
|
+
derivative.mimeType.should == 'video/webm'
|
23
|
+
|
24
|
+
derivative2 = reloaded.datastreams['mp4']
|
25
|
+
derivative2.should_not be_nil
|
26
|
+
derivative2.content.should_not be_nil
|
27
|
+
derivative2.mimeType.should == 'video/mp4'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -17,8 +17,7 @@ require 'spec_helper'
|
|
17
17
|
describe UnzipJob do
|
18
18
|
before(:all) do
|
19
19
|
@batch = Batch.create
|
20
|
-
GenericFile.any_instance.
|
21
|
-
GenericFile.any_instance.stubs(:terms_of_service).returns('1')
|
20
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
22
21
|
@generic_file = GenericFile.new(:batch=>@batch)
|
23
22
|
@generic_file.add_file_datastream(File.new(fixture_path + '/icons.zip'), :dsid=>'content')
|
24
23
|
@generic_file.apply_depositor_metadata('mjg36')
|
@@ -32,10 +31,13 @@ describe UnzipJob do
|
|
32
31
|
|
33
32
|
it "should create GenericFiles for each file in the zipfile" do
|
34
33
|
one = GenericFile.new
|
34
|
+
#one.should_receive(:characterize_if_changed)
|
35
35
|
two = GenericFile.new
|
36
|
+
#two.should_receive(:characterize_if_changed)
|
36
37
|
three = GenericFile.new
|
37
|
-
|
38
|
-
|
38
|
+
#three.should_receive(:characterize_if_changed)
|
39
|
+
GenericFile.should_receive(:new).exactly(3).times.and_return(one, two, three)
|
40
|
+
UnzipJob.new(@generic_file.pid).run
|
39
41
|
|
40
42
|
one.content.size.should == 13024 #bread
|
41
43
|
one.content.label.should == 'spec/fixtures/bread-icon.png'
|
@@ -12,15 +12,15 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
# Used to test the
|
15
|
+
# Used to test the sufia-fixtures rake task
|
16
16
|
#
|
17
17
|
require "spec_helper"
|
18
18
|
require "rake"
|
19
19
|
|
20
|
-
describe "
|
20
|
+
describe "sufia:fixtures" do
|
21
21
|
|
22
22
|
def loaded_files_excluding_current_rake_file
|
23
|
-
$".reject { |file| file.include? "tasks/
|
23
|
+
$".reject { |file| file.include? "tasks/sufia-fixtures" }
|
24
24
|
end
|
25
25
|
|
26
26
|
# saves original $stdout in variable
|
@@ -42,11 +42,11 @@ describe "scholarsphere:fixtures" do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def delete_fixture_files
|
45
|
-
File.delete(File.join(File.expand_path("#{fixture_path}/
|
46
|
-
File.delete(File.join(File.expand_path("#{fixture_path}/
|
47
|
-
File.delete(File.join(File.expand_path("#{fixture_path}/
|
45
|
+
File.delete(File.join(File.expand_path("#{fixture_path}/sufia"), "sufia_rspecTestFixture.txt"))
|
46
|
+
File.delete(File.join(File.expand_path("#{fixture_path}/sufia"), "sufia_rspecTestFixture.descMeta.txt"))
|
47
|
+
File.delete(File.join(File.expand_path("#{fixture_path}/sufia"), "sufia_rspecTestFixture.foxml.erb"))
|
48
48
|
begin
|
49
|
-
File.delete(File.join(File.expand_path("#{fixture_path}/
|
49
|
+
File.delete(File.join(File.expand_path("#{fixture_path}/sufia"), "sufia_rspecTestFixture.foxml.xml"))
|
50
50
|
rescue
|
51
51
|
# do nothing; this just means the generate task was not called
|
52
52
|
end
|
@@ -56,7 +56,7 @@ describe "scholarsphere:fixtures" do
|
|
56
56
|
before(:each) do
|
57
57
|
@rake = Rake::Application.new
|
58
58
|
Rake.application = @rake
|
59
|
-
Rake.application.rake_require("tasks/
|
59
|
+
Rake.application.rake_require("tasks/sufia-fixtures", ["."], loaded_files_excluding_current_rake_file)
|
60
60
|
Rake.application.rake_require("lib/tasks/fixtures", ["."], loaded_files_excluding_current_rake_file)
|
61
61
|
Rake.application.rake_require("lib/tasks/active_fedora", [activefedora_path], loaded_files_excluding_current_rake_file)
|
62
62
|
Rake::Task.define_task(:environment)
|
@@ -72,15 +72,15 @@ describe "scholarsphere:fixtures" do
|
|
72
72
|
ENV["FIXTURE_TITLE"] = "rspec Test Fixture"
|
73
73
|
ENV["FIXTURE_USER"] = "rspec"
|
74
74
|
o = capture_stdout do
|
75
|
-
@rake['
|
76
|
-
@rake['
|
77
|
-
@rake['
|
78
|
-
@rake['
|
75
|
+
@rake['sufia:fixtures:create'].invoke
|
76
|
+
@rake['sufia:fixtures:generate'].invoke
|
77
|
+
@rake['sufia:fixtures:load'].invoke
|
78
|
+
@rake['sufia:fixtures:delete'].invoke
|
79
79
|
end
|
80
|
-
Dir.glob(File.join(fixture_path, File.expand_path("/
|
81
|
-
Dir.glob(File.join(fixture_path, File.expand_path("/
|
82
|
-
Dir.glob(File.join(fixture_path, File.expand_path("/
|
83
|
-
Dir.glob(File.join(fixture_path, File.expand_path("/
|
80
|
+
Dir.glob(File.join(fixture_path, File.expand_path("/sufia"), "sufia_rspecTestFixture.txt")).length.should == 1
|
81
|
+
Dir.glob(File.join(fixture_path, File.expand_path("/sufia"), "sufia_rspecTestFixture.foxml.erb")).length.should == 1
|
82
|
+
Dir.glob(File.join(fixture_path, File.expand_path("/sufia"), "sufia_rspecTestFixture.descMeta.txt")).length.should == 1
|
83
|
+
Dir.glob(File.join(fixture_path, File.expand_path("/sufia"), "sufia_rspecTestFixture.foxml.xml")).length.should == 1
|
84
84
|
o.should include "Loaded 'sufia:rspecTestFixture'"
|
85
85
|
o.should include "Deleted 'sufia:rspecTestFixture'"
|
86
86
|
end
|