sufia 0.0.1.pre2 → 0.0.1
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.
- 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
data/solr_conf/solr.xml
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
adminPath: RequestHandler path to manage cores.
|
|
29
29
|
If 'null' (or absent), cores will not be manageable via REST
|
|
30
30
|
-->
|
|
31
|
-
<cores adminPath="/admin/cores">
|
|
31
|
+
<cores adminPath="/admin/cores" defaultCoreName="development">
|
|
32
32
|
<core name="development" instanceDir="development-core" />
|
|
33
33
|
<core name="test" instanceDir="test-core" />
|
|
34
34
|
</cores>
|
|
@@ -21,7 +21,7 @@ describe ActiveFedora::UnsavedDigitalObject do
|
|
|
21
21
|
Sufia::IdService.valid?(@obj.pid).should be_true
|
|
22
22
|
end
|
|
23
23
|
it "should not use Fedora's pid service" do
|
|
24
|
-
ActiveFedora::RubydoraConnection.any_instance.
|
|
24
|
+
ActiveFedora::RubydoraConnection.any_instance.should_receive(:nextid).never
|
|
25
25
|
@obj = ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'id')
|
|
26
26
|
@obj.save
|
|
27
27
|
end
|
|
@@ -39,9 +39,9 @@ describe ActiveFedora::UnsavedDigitalObject do
|
|
|
39
39
|
it "should not assign a pid that already exists in Fedora" do
|
|
40
40
|
mock_pid = 'scholarsphere:ef12ef12f'
|
|
41
41
|
unique_pid = 'scholarsphere:bb22bb22b'
|
|
42
|
-
Sufia::IdService.
|
|
43
|
-
ActiveFedora::Base.
|
|
44
|
-
ActiveFedora::Base.
|
|
42
|
+
Sufia::IdService.stub(:next_id).and_return(mock_pid, unique_pid)
|
|
43
|
+
ActiveFedora::Base.stub(:exists?).with(mock_pid).and_return(true)
|
|
44
|
+
ActiveFedora::Base.stub(:exists?).with(unique_pid).and_return(false)
|
|
45
45
|
@obj = ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'id')
|
|
46
46
|
pid = @obj.assign_pid
|
|
47
47
|
@obj.pid.should == unique_pid
|
|
@@ -16,22 +16,22 @@ require 'spec_helper'
|
|
|
16
16
|
|
|
17
17
|
describe 'host_to_vhost' do
|
|
18
18
|
it "should return the proper vhost on fedora1test" do
|
|
19
|
-
Socket.
|
|
19
|
+
Socket.stub(:gethostname).and_return('fedora1test')
|
|
20
20
|
Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[0].should == 'scholarsphere-integration.dlt.psu.edu-8443'
|
|
21
21
|
Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[1].should == 'https://scholarsphere-integration.dlt.psu.edu:8443/'
|
|
22
22
|
end
|
|
23
23
|
it "should return the proper vhost on fedora2test" do
|
|
24
|
-
Socket.
|
|
24
|
+
Socket.stub(:gethostname).and_return('fedora2test')
|
|
25
25
|
Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[0].should == 'scholarsphere-test.dlt.psu.edu'
|
|
26
26
|
Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[1].should == 'https://scholarsphere-test.dlt.psu.edu/'
|
|
27
27
|
end
|
|
28
28
|
it "should return the proper vhost on ss1stage" do
|
|
29
|
-
Socket.
|
|
29
|
+
Socket.stub(:gethostname).and_return('ss1stage')
|
|
30
30
|
Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[0].should == 'scholarsphere-staging.dlt.psu.edu'
|
|
31
31
|
Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[1].should == 'https://scholarsphere-staging.dlt.psu.edu/'
|
|
32
32
|
end
|
|
33
33
|
it "should return the proper vhost on dev" do
|
|
34
|
-
Socket.
|
|
34
|
+
Socket.stub(:gethostname).and_return('some1host')
|
|
35
35
|
Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[0].should == 'some1host'
|
|
36
36
|
Sufia::HttpHeaderAuth.get_vhost_by_host(Sufia.config)[1].should == 'https://some1host/'
|
|
37
37
|
end
|
|
@@ -23,7 +23,7 @@ describe AuthoritiesController do
|
|
|
23
23
|
{:label => "Edgar", :uri => "http://example.org/edga"},
|
|
24
24
|
{:label => "Eddie", :uri => "http://example.org/edd"},
|
|
25
25
|
{:label => "Economics", :uri => "http://example.org/eco"}]
|
|
26
|
-
LocalAuthority.
|
|
26
|
+
LocalAuthority.should_receive(:entries_by_term).and_return(mock_hits)
|
|
27
27
|
xhr :get, :query, :model=>"generic_files", :term=>"subject", :q=>"E"
|
|
28
28
|
response.should be_success
|
|
29
29
|
JSON.parse(response.body).count.should == 6
|
|
@@ -16,12 +16,12 @@ require 'spec_helper'
|
|
|
16
16
|
|
|
17
17
|
describe BatchController do
|
|
18
18
|
before do
|
|
19
|
-
controller.
|
|
20
|
-
GenericFile.any_instance.
|
|
19
|
+
controller.stub(:has_access?).and_return(true)
|
|
20
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
21
21
|
@user = FactoryGirl.find_or_create(:user)
|
|
22
22
|
sign_in @user
|
|
23
|
-
User.any_instance.
|
|
24
|
-
controller.
|
|
23
|
+
User.any_instance.stub(:groups).and_return([])
|
|
24
|
+
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
|
25
25
|
end
|
|
26
26
|
after do
|
|
27
27
|
@user.delete
|
|
@@ -44,14 +44,16 @@ describe BatchController do
|
|
|
44
44
|
end
|
|
45
45
|
it "should equeue a batch update job" do
|
|
46
46
|
params = {'generic_file' => {'terms_of_service' => '1', 'read_groups_string' => '', 'read_users_string' => 'archivist1, archivist2', 'tag' => ['']}, 'id' => @batch.pid, 'controller' => 'batch', 'action' => 'update'}
|
|
47
|
-
|
|
47
|
+
s1 = stub('one')
|
|
48
|
+
BatchUpdateJob.should_receive(:new).with(@user.user_key, params).and_return(s1)
|
|
49
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
|
48
50
|
post :update, :id=>@batch.pid, "generic_file"=>{"terms_of_service"=>"1", "read_groups_string"=>"", "read_users_string"=>"archivist1, archivist2", "tag"=>[""]}
|
|
49
51
|
end
|
|
50
52
|
describe "when views are shown" do
|
|
51
53
|
render_views
|
|
52
54
|
it "should show flash messages" do
|
|
53
55
|
post :update, :id=>@batch.pid, "generic_file"=>{"terms_of_service"=>"1", "read_groups_string"=>"","read_users_string"=>"archivist1, archivist2", "tag"=>[""]}
|
|
54
|
-
response.should redirect_to @routes.url_helpers.
|
|
56
|
+
response.should redirect_to @routes.url_helpers.dashboard_index_path
|
|
55
57
|
flash[:notice].should_not be_nil
|
|
56
58
|
flash[:notice].should_not be_empty
|
|
57
59
|
flash[:notice].should include("Your files are being processed")
|
|
@@ -63,7 +65,7 @@ describe BatchController do
|
|
|
63
65
|
file = GenericFile.find(@file.pid)
|
|
64
66
|
file.read_users.should == ['archivist1', 'archivist2']
|
|
65
67
|
|
|
66
|
-
response.should redirect_to @routes.url_helpers.
|
|
68
|
+
response.should redirect_to @routes.url_helpers.dashboard_index_path
|
|
67
69
|
end
|
|
68
70
|
it "should set the groups with read access" do
|
|
69
71
|
post :update, :id=>@batch.pid, "generic_file"=>{"terms_of_service"=>"1", "read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}
|
|
@@ -113,8 +115,8 @@ describe BatchController do
|
|
|
113
115
|
end
|
|
114
116
|
describe "#edit" do
|
|
115
117
|
before do
|
|
116
|
-
User.any_instance.
|
|
117
|
-
GenericFile.any_instance.
|
|
118
|
+
User.any_instance.stub(:display_name).and_return("Jill Z. User")
|
|
119
|
+
GenericFile.any_instance.stub(:characterize_if_changed).and_yield
|
|
118
120
|
@b1 = Batch.new
|
|
119
121
|
@b1.save
|
|
120
122
|
@file = GenericFile.new(:batch=>@b1, :label=>'f1')
|
|
@@ -123,7 +125,7 @@ describe BatchController do
|
|
|
123
125
|
@file2 = GenericFile.new(:batch=>@b1, :label=>'f2')
|
|
124
126
|
@file2.apply_depositor_metadata(@user.user_key)
|
|
125
127
|
@file2.save
|
|
126
|
-
controller.
|
|
128
|
+
controller.stub(:params).and_return({id:@b1.id})
|
|
127
129
|
end
|
|
128
130
|
after do
|
|
129
131
|
@b1.delete
|
|
@@ -16,23 +16,23 @@ require 'spec_helper'
|
|
|
16
16
|
|
|
17
17
|
describe CatalogController do
|
|
18
18
|
before do
|
|
19
|
-
GenericFile.any_instance.
|
|
20
|
-
GenericFile.any_instance.
|
|
19
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
20
|
+
GenericFile.any_instance.stub(:characterize_if_changed).and_yield
|
|
21
21
|
@user = FactoryGirl.find_or_create(:user)
|
|
22
22
|
sign_in @user
|
|
23
|
-
User.any_instance.
|
|
24
|
-
controller.
|
|
23
|
+
User.any_instance.stub(:groups).and_return([])
|
|
24
|
+
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
|
25
25
|
end
|
|
26
26
|
after do
|
|
27
27
|
@user.delete
|
|
28
28
|
end
|
|
29
29
|
describe "#index" do
|
|
30
30
|
before (:all) do
|
|
31
|
-
GenericFile.
|
|
32
|
-
@gf1 = GenericFile.new(title:'Test Document PDF', filename:'test.pdf', read_groups:['public'])
|
|
31
|
+
GenericFile.find_each { |f| f.delete }
|
|
32
|
+
@gf1 = GenericFile.new(title:'Test Document PDF', filename:'test.pdf', read_groups:['public'], :terms_of_service=>'1')
|
|
33
33
|
@gf1.apply_depositor_metadata('mjg36')
|
|
34
34
|
@gf1.save
|
|
35
|
-
@gf2 = GenericFile.new(title:'Test 2 Document', filename:'test2.doc', contributor:'Contrib1', read_groups:['public'])
|
|
35
|
+
@gf2 = GenericFile.new(title:'Test 2 Document', filename:'test2.doc', contributor:'Contrib1', read_groups:['public'], :terms_of_service=>'1')
|
|
36
36
|
@gf2.apply_depositor_metadata('mjg36')
|
|
37
37
|
@gf2.save
|
|
38
38
|
end
|
|
@@ -55,12 +55,12 @@ describe CatalogController do
|
|
|
55
55
|
end
|
|
56
56
|
describe "facet search" do
|
|
57
57
|
before do
|
|
58
|
-
xhr :get, :index, :
|
|
58
|
+
xhr :get, :index, :q=>"{f=generic_file__contributor_facet}Contrib1"
|
|
59
59
|
end
|
|
60
60
|
it "should find facet files" do
|
|
61
61
|
response.should be_success
|
|
62
62
|
response.should render_template('catalog/index')
|
|
63
|
-
assigns(:document_list).count.should eql(
|
|
63
|
+
assigns(:document_list).count.should eql(1)
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -69,19 +69,19 @@ describe CatalogController do
|
|
|
69
69
|
before do
|
|
70
70
|
@gf1 = GenericFile.new(title:'Generic File 1', contributor:'contributor 1', resource_type:'type 1', read_groups:['public'])
|
|
71
71
|
@gf1.apply_depositor_metadata('mjg36')
|
|
72
|
-
@gf1.save
|
|
72
|
+
@gf1.save!
|
|
73
73
|
sleep 1 # make sure next file is not at the same time compare
|
|
74
74
|
@gf2 = GenericFile.new(title:'Generic File 2', contributor:'contributor 2', resource_type:'type 2', read_groups:['public'])
|
|
75
75
|
@gf2.apply_depositor_metadata('mjg36')
|
|
76
|
-
@gf2.save
|
|
76
|
+
@gf2.save!
|
|
77
77
|
sleep 1 # make sure next file is not at the same time compare
|
|
78
78
|
@gf3 = GenericFile.new(title:'Generic File 3', contributor:'contributor 3', resource_type:'type 3', read_groups:['public'])
|
|
79
79
|
@gf3.apply_depositor_metadata('mjg36')
|
|
80
|
-
@gf3.save
|
|
80
|
+
@gf3.save!
|
|
81
81
|
sleep 1 # make sure next file is not at the same time compare
|
|
82
82
|
@gf4 = GenericFile.new(title:'Generic File 4', contributor:'contributor 4', resource_type:'type 4', read_groups:['public'])
|
|
83
83
|
@gf4.apply_depositor_metadata('mjg36')
|
|
84
|
-
@gf4.save
|
|
84
|
+
@gf4.save!
|
|
85
85
|
xhr :get, :recent
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -16,27 +16,27 @@ require 'spec_helper'
|
|
|
16
16
|
|
|
17
17
|
describe DashboardController do
|
|
18
18
|
before do
|
|
19
|
-
GenericFile.any_instance.
|
|
20
|
-
User.any_instance.
|
|
21
|
-
controller.
|
|
19
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
20
|
+
User.any_instance.stub(:groups).and_return([])
|
|
21
|
+
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
|
22
22
|
end
|
|
23
23
|
# This doesn't really belong here, but it works for now
|
|
24
24
|
describe "authenticate!" do
|
|
25
25
|
# move to scholarsphere
|
|
26
26
|
# before(:each) do
|
|
27
27
|
# @user = FactoryGirl.find_or_create(:archivist)
|
|
28
|
-
# request.
|
|
28
|
+
# request.stub(:headers).and_return('REMOTE_USER' => @user.login).at_least(:once)
|
|
29
29
|
# @strategy = Devise::Strategies::HttpHeaderAuthenticatable.new(nil)
|
|
30
|
-
# @strategy.
|
|
30
|
+
# @strategy.should_receive(:request).and_return(request).at_least(:once)
|
|
31
31
|
# end
|
|
32
32
|
# after(:each) do
|
|
33
33
|
# @user.delete
|
|
34
34
|
# end
|
|
35
35
|
it "should populate LDAP attrs if user is new" do
|
|
36
36
|
pending "This should only be in scholarsphere"
|
|
37
|
-
User.
|
|
38
|
-
User.
|
|
39
|
-
User.any_instance.
|
|
37
|
+
User.stub(:find_by_login).with(@user.login).and_return(nil)
|
|
38
|
+
User.should_receive(:create).with(login: @user.login).and_return(@user).once
|
|
39
|
+
User.any_instance.should_receive(:populate_attributes).once
|
|
40
40
|
@strategy.should be_valid
|
|
41
41
|
@strategy.authenticate!.should == :success
|
|
42
42
|
sign_in @user
|
|
@@ -44,9 +44,9 @@ describe DashboardController do
|
|
|
44
44
|
end
|
|
45
45
|
it "should not populate LDAP attrs if user is not new" do
|
|
46
46
|
pending "This should only be in scholarsphere"
|
|
47
|
-
User.
|
|
48
|
-
User.
|
|
49
|
-
User.any_instance.
|
|
47
|
+
User.stub(:find_by_login).with(@user.login).and_return(@user)
|
|
48
|
+
User.should_receive(:create).with(login: @user.login).never
|
|
49
|
+
User.any_instance.should_receive(:populate_attributes).never
|
|
50
50
|
@strategy.should be_valid
|
|
51
51
|
@strategy.authenticate!.should == :success
|
|
52
52
|
sign_in @user
|
|
@@ -57,8 +57,8 @@ describe DashboardController do
|
|
|
57
57
|
before (:each) do
|
|
58
58
|
@user = FactoryGirl.find_or_create(:archivist)
|
|
59
59
|
sign_in @user
|
|
60
|
-
controller.
|
|
61
|
-
User.any_instance.
|
|
60
|
+
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
|
61
|
+
User.any_instance.stub(:groups).and_return([])
|
|
62
62
|
end
|
|
63
63
|
describe "#index" do
|
|
64
64
|
before (:each) do
|
|
@@ -69,8 +69,8 @@ describe DashboardController do
|
|
|
69
69
|
response.should render_template('dashboard/index')
|
|
70
70
|
end
|
|
71
71
|
it "should return an array of documents I can edit" do
|
|
72
|
-
@user_results = Blacklight.solr.
|
|
73
|
-
assigns(:document_list).count.should eql(@user_results
|
|
72
|
+
@user_results = Blacklight.solr.get "select", :params=>{:fq=>["edit_access_group_t:public OR edit_access_person_t:#{@user.user_key}"]}
|
|
73
|
+
assigns(:document_list).count.should eql(@user_results["response"]["numFound"])
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
end
|
|
@@ -17,12 +17,12 @@ require 'spec_helper'
|
|
|
17
17
|
describe DownloadsController do
|
|
18
18
|
|
|
19
19
|
before(:all) do
|
|
20
|
-
GenericFile.any_instance.
|
|
20
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
21
21
|
f = GenericFile.new(:pid => 'sufia:test1')
|
|
22
22
|
f.apply_depositor_metadata('archivist1@example.com')
|
|
23
23
|
f.set_title_and_label('world.png')
|
|
24
24
|
f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content', :mimeType => 'image/png')
|
|
25
|
-
f.
|
|
25
|
+
f.should_receive(:characterize_if_changed).and_yield
|
|
26
26
|
f.save
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -39,8 +39,8 @@ describe DownloadsController do
|
|
|
39
39
|
describe "when logged in as reader" do
|
|
40
40
|
before do
|
|
41
41
|
sign_in FactoryGirl.find_or_create(:archivist)
|
|
42
|
-
User.any_instance.
|
|
43
|
-
controller.
|
|
42
|
+
User.any_instance.stub(:groups).and_return([])
|
|
43
|
+
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
|
44
44
|
end
|
|
45
45
|
after do
|
|
46
46
|
arch = FactoryGirl.find(:archivist) rescue
|
|
@@ -49,30 +49,30 @@ describe DownloadsController do
|
|
|
49
49
|
describe "show" do
|
|
50
50
|
it "should default to returning configured default download" do
|
|
51
51
|
DownloadsController.default_content_dsid.should == "content"
|
|
52
|
-
controller.
|
|
52
|
+
controller.stub(:render)
|
|
53
53
|
expected_content = ActiveFedora::Base.find("sufia:test1").content.content
|
|
54
|
-
controller.
|
|
54
|
+
controller.should_receive(:send_data).with(expected_content, {:filename => 'world.png', :disposition => 'inline', :type => 'image/png' })
|
|
55
55
|
get "show", :id => "test1"
|
|
56
56
|
response.should be_success
|
|
57
57
|
end
|
|
58
58
|
it "should return requested datastreams" do
|
|
59
|
-
controller.
|
|
59
|
+
controller.stub(:render)
|
|
60
60
|
expected_content = ActiveFedora::Base.find("sufia:test1").descMetadata.content
|
|
61
|
-
controller.
|
|
61
|
+
controller.should_receive(:send_data).with(expected_content, {:filename => 'descMetadata', :disposition => 'inline', :type => "text/plain"})
|
|
62
62
|
get "show", :id => "test1", :datastream_id => "descMetadata"
|
|
63
63
|
response.should be_success
|
|
64
64
|
end
|
|
65
65
|
it "should support setting disposition to inline" do
|
|
66
|
-
controller.
|
|
66
|
+
controller.stub(:render)
|
|
67
67
|
expected_content = ActiveFedora::Base.find("sufia:test1").content.content
|
|
68
|
-
controller.
|
|
68
|
+
controller.should_receive(:send_data).with(expected_content, {:filename => 'world.png', :type => 'image/png', :disposition => "inline"})
|
|
69
69
|
get "show", :id => "test1", :disposition => "inline"
|
|
70
70
|
response.should be_success
|
|
71
71
|
end
|
|
72
72
|
it "should allow you to specify filename for download" do
|
|
73
|
-
controller.
|
|
73
|
+
controller.stub(:render)
|
|
74
74
|
expected_content = ActiveFedora::Base.find("sufia:test1").content.content
|
|
75
|
-
controller.
|
|
75
|
+
controller.should_receive(:send_data).with(expected_content, {:filename => "my%20dog.png", :disposition => 'inline', :type => 'image/png'})
|
|
76
76
|
get "show", :id => "test1", "filename" => "my%20dog.png"
|
|
77
77
|
end
|
|
78
78
|
end
|
|
@@ -81,8 +81,8 @@ describe DownloadsController do
|
|
|
81
81
|
describe "when not logged in as reader" do
|
|
82
82
|
before do
|
|
83
83
|
sign_in FactoryGirl.find_or_create(:user)
|
|
84
|
-
User.any_instance.
|
|
85
|
-
controller.
|
|
84
|
+
User.any_instance.stub(:groups).and_return([])
|
|
85
|
+
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
|
86
86
|
end
|
|
87
87
|
after do
|
|
88
88
|
user = FactoryGirl.find(:user) rescue
|
|
@@ -16,20 +16,20 @@ require 'spec_helper'
|
|
|
16
16
|
|
|
17
17
|
describe GenericFilesController do
|
|
18
18
|
before do
|
|
19
|
-
controller.
|
|
19
|
+
controller.stub(:has_access?).and_return(true)
|
|
20
20
|
|
|
21
|
-
GenericFile.any_instance.
|
|
21
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
22
22
|
@user = FactoryGirl.find_or_create(:user)
|
|
23
23
|
sign_in @user
|
|
24
|
-
User.any_instance.
|
|
25
|
-
controller.
|
|
24
|
+
User.any_instance.stub(:groups).and_return([])
|
|
25
|
+
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
|
26
26
|
end
|
|
27
27
|
describe "#create" do
|
|
28
28
|
before do
|
|
29
|
-
GenericFile.any_instance.
|
|
29
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
30
30
|
@file_count = GenericFile.count
|
|
31
31
|
@mock = GenericFile.new({:pid => 'test:123'})
|
|
32
|
-
GenericFile.
|
|
32
|
+
GenericFile.stub(:new).and_return(@mock)
|
|
33
33
|
end
|
|
34
34
|
after do
|
|
35
35
|
begin
|
|
@@ -40,19 +40,31 @@ describe GenericFilesController do
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "should spawn a content deposit event job" do
|
|
43
|
-
#GenericFile.any_instance.stubs(:to_solr).returns({})
|
|
44
43
|
file = fixture_file_upload('/world.png','image/png')
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
s1 = stub('one')
|
|
45
|
+
ContentDepositEventJob.should_receive(:new).with('test:123', 'jilluser@example.com').and_return(s1)
|
|
46
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
|
47
|
+
|
|
48
|
+
s2 = stub('one')
|
|
49
|
+
CharacterizeJob.should_receive(:new).with('test:123').and_return(s2)
|
|
50
|
+
Sufia.queue.should_receive(:push).with(s2).once
|
|
47
51
|
xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
|
|
48
52
|
end
|
|
49
53
|
|
|
50
54
|
it "should expand zip files" do
|
|
51
|
-
#GenericFile.any_instance.stubs(:to_solr).returns({})
|
|
52
55
|
file = fixture_file_upload('/world.png','application/zip')
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
s1 = stub('one')
|
|
57
|
+
ContentDepositEventJob.should_receive(:new).with('test:123', 'jilluser@example.com').and_return(s1)
|
|
58
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
|
59
|
+
|
|
60
|
+
s2 = stub('one')
|
|
61
|
+
CharacterizeJob.should_receive(:new).with('test:123').and_return(s2)
|
|
62
|
+
Sufia.queue.should_receive(:push).with(s2).once
|
|
63
|
+
|
|
64
|
+
s3 = stub('one')
|
|
65
|
+
UnzipJob.should_receive(:new).with('test:123').and_return(s3)
|
|
66
|
+
Sufia.queue.should_receive(:push).with(s3).once
|
|
67
|
+
|
|
56
68
|
xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
|
|
57
69
|
end
|
|
58
70
|
|
|
@@ -75,7 +87,7 @@ describe GenericFilesController do
|
|
|
75
87
|
end
|
|
76
88
|
|
|
77
89
|
it "should record what user created the first version of content" do
|
|
78
|
-
#GenericFile.any_instance.
|
|
90
|
+
#GenericFile.any_instance.stub(:to_solr).and_return({})
|
|
79
91
|
file = fixture_file_upload('/world.png','image/png')
|
|
80
92
|
xhr :post, :create, :files=>[file], :Filename=>"The world", :terms_of_service=>"1"
|
|
81
93
|
|
|
@@ -86,9 +98,9 @@ describe GenericFilesController do
|
|
|
86
98
|
end
|
|
87
99
|
|
|
88
100
|
it "should create batch associations from batch_id" do
|
|
89
|
-
Sufia::Engine.config.
|
|
101
|
+
Sufia::Engine.config.stub(:id_namespace).and_return('sample')
|
|
90
102
|
file = fixture_file_upload('/world.png','image/png')
|
|
91
|
-
controller.
|
|
103
|
+
controller.stub(:add_posted_blob_to_asset)
|
|
92
104
|
xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
|
|
93
105
|
lambda {Batch.find("sample:batch_id")}.should raise_error(ActiveFedora::ObjectNotFoundError) # The controller shouldn't actually save the Batch, but it should write the batch id to the files.
|
|
94
106
|
b = Batch.create(pid: "sample:batch_id")
|
|
@@ -115,10 +127,16 @@ describe GenericFilesController do
|
|
|
115
127
|
saved_file.to_solr['depositor_t'].should == ['jilluser@example.com']
|
|
116
128
|
end
|
|
117
129
|
it "Should call virus check" do
|
|
118
|
-
controller.
|
|
130
|
+
controller.should_receive(:virus_check).and_return(0)
|
|
119
131
|
file = fixture_file_upload('/world.png','image/png')
|
|
120
|
-
|
|
121
|
-
|
|
132
|
+
|
|
133
|
+
s1 = stub('one')
|
|
134
|
+
ContentDepositEventJob.should_receive(:new).with('test:123', 'jilluser@example.com').and_return(s1)
|
|
135
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
|
136
|
+
|
|
137
|
+
s2 = stub('one')
|
|
138
|
+
CharacterizeJob.should_receive(:new).with('test:123').and_return(s2)
|
|
139
|
+
Sufia.queue.should_receive(:push).with(s2).once
|
|
122
140
|
xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>"1"
|
|
123
141
|
end
|
|
124
142
|
|
|
@@ -137,8 +155,8 @@ describe GenericFilesController do
|
|
|
137
155
|
Object.send(:remove_const, :ClamAV) if @stubbed_clamav
|
|
138
156
|
end
|
|
139
157
|
it "failing virus check should create flash" do
|
|
140
|
-
GenericFile.any_instance.
|
|
141
|
-
ClamAV.any_instance.
|
|
158
|
+
GenericFile.any_instance.stub(:to_solr).and_return({})
|
|
159
|
+
ClamAV.any_instance.should_receive(:scanfile).and_return(1)
|
|
142
160
|
file = fixture_file_upload('/world.png','image/png')
|
|
143
161
|
controller.send :virus_check, file
|
|
144
162
|
flash[:error].should_not be_empty
|
|
@@ -150,7 +168,7 @@ describe GenericFilesController do
|
|
|
150
168
|
|
|
151
169
|
describe "audit" do
|
|
152
170
|
before do
|
|
153
|
-
#GenericFile.any_instance.
|
|
171
|
+
#GenericFile.any_instance.stub(:to_solr).and_return({})
|
|
154
172
|
@generic_file = GenericFile.new
|
|
155
173
|
@generic_file.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
|
156
174
|
@generic_file.apply_depositor_metadata('mjg36')
|
|
@@ -170,7 +188,7 @@ describe GenericFilesController do
|
|
|
170
188
|
|
|
171
189
|
describe "destroy" do
|
|
172
190
|
before(:each) do
|
|
173
|
-
GenericFile.any_instance.
|
|
191
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
174
192
|
@generic_file = GenericFile.new
|
|
175
193
|
@generic_file.apply_depositor_metadata(@user.user_key)
|
|
176
194
|
@generic_file.save
|
|
@@ -186,15 +204,17 @@ describe GenericFilesController do
|
|
|
186
204
|
lambda { GenericFile.find(@generic_file.pid) }.should raise_error(ActiveFedora::ObjectNotFoundError)
|
|
187
205
|
end
|
|
188
206
|
it "should spawn a content delete event job" do
|
|
189
|
-
|
|
207
|
+
s1 = stub('one')
|
|
208
|
+
ContentDeleteEventJob.should_receive(:new).with(@generic_file.noid, @user.user_key).and_return(s1)
|
|
209
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
|
190
210
|
delete :destroy, :id=>@generic_file.pid
|
|
191
211
|
end
|
|
192
212
|
end
|
|
193
213
|
|
|
194
214
|
describe "update" do
|
|
195
215
|
before do
|
|
196
|
-
GenericFile.any_instance.
|
|
197
|
-
#controller.
|
|
216
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
217
|
+
#controller.should_receive(:virus_check).and_return(0)
|
|
198
218
|
@generic_file = GenericFile.new
|
|
199
219
|
@generic_file.apply_depositor_metadata(@user.user_key)
|
|
200
220
|
@generic_file.save
|
|
@@ -204,7 +224,9 @@ describe GenericFilesController do
|
|
|
204
224
|
end
|
|
205
225
|
|
|
206
226
|
it "should spawn a content update event job" do
|
|
207
|
-
|
|
227
|
+
s1 = stub('one')
|
|
228
|
+
ContentUpdateEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').and_return(s1)
|
|
229
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
|
208
230
|
@user = FactoryGirl.find_or_create(:user)
|
|
209
231
|
sign_in @user
|
|
210
232
|
post :update, :id=>@generic_file.pid, :generic_file=>{:terms_of_service=>"1", :title=>'new_title', :tag=>[''], :permissions=>{:new_user_name=>{'archivist1'=>'edit'}}}
|
|
@@ -212,8 +234,12 @@ describe GenericFilesController do
|
|
|
212
234
|
end
|
|
213
235
|
|
|
214
236
|
it "should spawn a content new version event job" do
|
|
215
|
-
|
|
216
|
-
|
|
237
|
+
s1 = stub('one')
|
|
238
|
+
ContentNewVersionEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').and_return(s1)
|
|
239
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
|
240
|
+
s2 = stub('one')
|
|
241
|
+
CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
|
|
242
|
+
Sufia.queue.should_receive(:push).with(s2).once
|
|
217
243
|
@user = FactoryGirl.find_or_create(:user)
|
|
218
244
|
sign_in @user
|
|
219
245
|
|
|
@@ -236,11 +262,17 @@ describe GenericFilesController do
|
|
|
236
262
|
# other user uploads new version
|
|
237
263
|
# TODO this should be a separate test
|
|
238
264
|
archivist = FactoryGirl.find_or_create(:archivist)
|
|
239
|
-
controller.
|
|
265
|
+
controller.stub(:current_user).and_return(archivist)
|
|
266
|
+
|
|
267
|
+
ContentUpdateEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').never
|
|
268
|
+
|
|
269
|
+
s1 = stub('one')
|
|
270
|
+
ContentNewVersionEventJob.should_receive(:new).with(@generic_file.pid, archivist.user_key).and_return(s1)
|
|
271
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
|
240
272
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
273
|
+
s2 = stub('one')
|
|
274
|
+
CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
|
|
275
|
+
Sufia.queue.should_receive(:push).with(s2).once
|
|
244
276
|
file = fixture_file_upload('/image.jp2','image/jp2')
|
|
245
277
|
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:terms_of_service=>"1", :tag=>[''] }
|
|
246
278
|
|
|
@@ -250,11 +282,16 @@ describe GenericFilesController do
|
|
|
250
282
|
edited_file.content.version_committer(version2).should == archivist.user_key
|
|
251
283
|
|
|
252
284
|
# original user restores his or her version
|
|
253
|
-
controller.
|
|
285
|
+
controller.stub(:current_user).and_return(@user)
|
|
254
286
|
sign_in @user
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
287
|
+
ContentUpdateEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').never
|
|
288
|
+
s1 = stub('one')
|
|
289
|
+
ContentRestoredVersionEventJob.should_receive(:new).with(@generic_file.pid, @user.user_key, 'content.0').and_return(s1)
|
|
290
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
|
291
|
+
|
|
292
|
+
s2 = stub('one')
|
|
293
|
+
CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
|
|
294
|
+
Sufia.queue.should_receive(:push).with(s2).once
|
|
258
295
|
post :update, :id=>@generic_file.pid, :revision=>'content.0', :generic_file=>{:terms_of_service=>"1", :tag=>['']}
|
|
259
296
|
|
|
260
297
|
restored_file = GenericFile.find(@generic_file.pid)
|
|
@@ -280,10 +317,15 @@ describe GenericFilesController do
|
|
|
280
317
|
end
|
|
281
318
|
it "should spawn a virus check" do
|
|
282
319
|
# The expectation is in the begin block
|
|
283
|
-
controller.
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
320
|
+
controller.should_receive(:virus_check).and_return(0)
|
|
321
|
+
s1 = stub('one')
|
|
322
|
+
ContentNewVersionEventJob.should_receive(:new).with(@generic_file.pid, 'jilluser@example.com').and_return(s1)
|
|
323
|
+
Sufia.queue.should_receive(:push).with(s1).once
|
|
324
|
+
|
|
325
|
+
s2 = stub('one')
|
|
326
|
+
CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
|
|
327
|
+
Sufia.queue.should_receive(:push).with(s2).once
|
|
328
|
+
GenericFile.stub(:save).and_return({})
|
|
287
329
|
@user = FactoryGirl.find_or_create(:user)
|
|
288
330
|
sign_in @user
|
|
289
331
|
file = fixture_file_upload('/world.png','image/png')
|
|
@@ -294,14 +336,14 @@ describe GenericFilesController do
|
|
|
294
336
|
|
|
295
337
|
describe "someone elses files" do
|
|
296
338
|
before(:all) do
|
|
297
|
-
GenericFile.any_instance.
|
|
339
|
+
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
|
298
340
|
f = GenericFile.new(:pid => 'sufia:test5')
|
|
299
341
|
f.apply_depositor_metadata('archivist1@example.com')
|
|
300
342
|
f.set_title_and_label('world.png')
|
|
301
343
|
f.add_file_datastream(File.new(fixture_path + '/world.png'))
|
|
302
344
|
# grant public read access explicitly
|
|
303
345
|
f.read_groups = ['public']
|
|
304
|
-
f.
|
|
346
|
+
f.should_receive(:characterize_if_changed).and_yield
|
|
305
347
|
f.save
|
|
306
348
|
@file = f
|
|
307
349
|
end
|
|
@@ -334,7 +376,7 @@ describe GenericFilesController do
|
|
|
334
376
|
flash[:alert].should include("You need to sign in or sign up before continuing")
|
|
335
377
|
end
|
|
336
378
|
it "should filter flash if they signin" do
|
|
337
|
-
request.env['warden'].
|
|
379
|
+
request.env['warden'].stub(:user).and_return(@user)
|
|
338
380
|
sign_out @user
|
|
339
381
|
get :new
|
|
340
382
|
sign_in @user
|
|
@@ -343,7 +385,7 @@ describe GenericFilesController do
|
|
|
343
385
|
end
|
|
344
386
|
describe "failing audit" do
|
|
345
387
|
before(:all) do
|
|
346
|
-
ActiveFedora::RelsExtDatastream.any_instance.
|
|
388
|
+
ActiveFedora::RelsExtDatastream.any_instance.stub(:dsChecksumValid).and_return(false)
|
|
347
389
|
@archivist = FactoryGirl.find_or_create(:archivist)
|
|
348
390
|
end
|
|
349
391
|
after(:all) do
|
|
@@ -353,7 +395,7 @@ describe GenericFilesController do
|
|
|
353
395
|
sign_out @user
|
|
354
396
|
sign_in @archivist
|
|
355
397
|
@ds = @file.datastreams.first
|
|
356
|
-
AuditJob.
|
|
398
|
+
AuditJob.new(@file.pid, @ds[0], @ds[1].versionID).run
|
|
357
399
|
get :show, id:"test5"
|
|
358
400
|
assigns[:notify_number].should == 1
|
|
359
401
|
response.body.should include('<span id="notify_number" class="overlay"> 1</span>') # notify should be 1 for failing job
|