sufia 0.0.3 → 0.0.4
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 +1 -4
- data/README.md +1 -1
- data/app/assets/javascripts/sufia.js +5 -312
- data/app/assets/javascripts/sufia/permissions.js +216 -0
- data/app/assets/javascripts/sufia/tabs.js +58 -0
- data/app/assets/stylesheets/generic_files.css +4 -0
- data/app/assets/stylesheets/jquery-ui.css +474 -0
- data/app/assets/stylesheets/{sufia.css → sufia.css.scss} +4 -1
- data/app/controllers/directory_controller.rb +17 -11
- data/app/controllers/users_controller.rb +5 -3
- data/app/models/datastreams/file_content_datastream.rb +2 -53
- data/app/views/batch/_metadata.html.erb +0 -1
- data/app/views/batch_edits/_metadata.html.erb +0 -1
- data/app/views/batch_edits/edit.html.erb +0 -1
- data/app/views/dashboard/_facet_pagination.html.erb +20 -39
- data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +1 -1
- data/app/views/dashboard/facet.html.erb +29 -34
- data/app/views/generic_files/_descriptions.html.erb +0 -1
- data/app/views/generic_files/_groups_description.html.erb +5 -0
- data/app/views/generic_files/_multiple_upload.html.erb +135 -0
- data/app/views/generic_files/_permission.html.erb +2 -5
- data/app/views/generic_files/_versioning.html.erb +0 -1
- data/app/views/generic_files/edit.html.erb +0 -3
- data/app/views/generic_files/new.html.erb +2 -138
- data/app/views/layouts/hydra-head.html.erb +1 -0
- data/app/views/users/index.html.erb +6 -4
- data/config/locales/sufia.en.yml +2 -0
- data/lib/sufia.rb +1 -1
- data/lib/sufia/file_content.rb +8 -0
- data/lib/sufia/file_content/extract_metadata.rb +53 -0
- data/lib/sufia/file_content/versions.rb +23 -0
- data/lib/sufia/files_controller_behavior.rb +17 -33
- data/lib/sufia/generic_file.rb +0 -8
- data/lib/sufia/generic_file/characterization.rb +0 -1
- data/lib/sufia/generic_file/thumbnail.rb +2 -4
- data/lib/sufia/jobs/unzip_job.rb +0 -1
- data/lib/sufia/user.rb +0 -3
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/batch_controller_spec.rb +11 -12
- data/spec/controllers/catalog_controller_spec.rb +2 -3
- data/spec/controllers/generic_files_controller_spec.rb +14 -16
- data/spec/controllers/single_use_link_controller_spec.rb +0 -1
- data/spec/models/batch_update_job_spec.rb +2 -3
- data/spec/models/checksum_audit_log_spec.rb +1 -2
- data/spec/models/file_content_datastream_spec.rb +1 -6
- data/spec/models/generic_file_spec.rb +2 -9
- data/spec/models/single_use_link_spec.rb +0 -2
- data/spec/models/transcode_video_job_spec.rb +1 -1
- data/spec/support/Gemfile +3 -5
- data/sufia.gemspec +2 -2
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.effect-highlight.js +50 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.effect.js +1276 -0
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.position.js +498 -0
- metadata +26 -21
- data/app/assets/stylesheets/font-awesome-ie7.css +0 -645
- data/app/assets/stylesheets/font-awesome.css +0 -303
- data/app/views/catalog/_facet_pagination.html.erb +0 -28
- data/app/views/catalog/facet.html.erb +0 -27
- data/public/robots.txt +0 -4
- data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
@@ -26,7 +26,6 @@ module Sufia
|
|
26
26
|
thumb = first.scale(338, 493)
|
27
27
|
self.thumbnail.content = thumb.to_blob { self.format = "PNG" }
|
28
28
|
#logger.debug "Has the content changed before saving? #{self.content.changed?}"
|
29
|
-
self.terms_of_service = '1'
|
30
29
|
stat = self.save
|
31
30
|
break
|
32
31
|
rescue => e
|
@@ -41,8 +40,8 @@ module Sufia
|
|
41
40
|
img = Magick::ImageList.new
|
42
41
|
img.from_blob(content.content)
|
43
42
|
# horizontal img
|
44
|
-
height = self.height.first.to_i
|
45
|
-
width = self.width.first.to_i
|
43
|
+
height = Float(self.height.first.to_i)
|
44
|
+
width = Float(self.width.first.to_i)
|
46
45
|
scale = height / width
|
47
46
|
if width > height
|
48
47
|
if width > 150 and height > 105
|
@@ -59,7 +58,6 @@ module Sufia
|
|
59
58
|
end
|
60
59
|
end
|
61
60
|
self.thumbnail.content = thumb.to_blob
|
62
|
-
self.terms_of_service = '1'
|
63
61
|
#logger.debug "Has the content before saving? #{self.content.changed?}"
|
64
62
|
self.save
|
65
63
|
end
|
data/lib/sufia/jobs/unzip_job.rb
CHANGED
data/lib/sufia/user.rb
CHANGED
@@ -41,9 +41,6 @@ module Sufia::User
|
|
41
41
|
validates :avatar, :attachment_content_type => { :content_type => /^image\/(jpg|jpeg|pjpeg|png|x-png|gif)$/ }, :if => Proc.new { |p| p.avatar.file? }
|
42
42
|
validates :avatar, :attachment_size => { :less_than => 2.megabytes }, :if => Proc.new { |p| p.avatar.file? }
|
43
43
|
|
44
|
-
# Pagination hook
|
45
|
-
self.per_page = 5
|
46
|
-
|
47
44
|
end
|
48
45
|
|
49
46
|
# This method should display the unique identifier for this user as defined by devise.
|
data/lib/sufia/version.rb
CHANGED
@@ -17,7 +17,6 @@ require 'spec_helper'
|
|
17
17
|
describe BatchController do
|
18
18
|
before do
|
19
19
|
controller.stub(:has_access?).and_return(true)
|
20
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
21
20
|
@user = FactoryGirl.find_or_create(:user)
|
22
21
|
sign_in @user
|
23
22
|
User.any_instance.stub(:groups).and_return([])
|
@@ -43,16 +42,16 @@ describe BatchController do
|
|
43
42
|
@file2.delete
|
44
43
|
end
|
45
44
|
it "should equeue a batch update job" do
|
46
|
-
params = {'generic_file' => {'
|
45
|
+
params = {'generic_file' => {'read_groups_string' => '', 'read_users_string' => 'archivist1, archivist2', 'tag' => ['']}, 'id' => @batch.pid, 'controller' => 'batch', 'action' => 'update'}
|
47
46
|
s1 = stub('one')
|
48
47
|
BatchUpdateJob.should_receive(:new).with(@user.user_key, params).and_return(s1)
|
49
48
|
Sufia.queue.should_receive(:push).with(s1).once
|
50
|
-
post :update, :id=>@batch.pid, "generic_file"=>{"
|
49
|
+
post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"", "read_users_string"=>"archivist1, archivist2", "tag"=>[""]}
|
51
50
|
end
|
52
51
|
describe "when views are shown" do
|
53
52
|
render_views
|
54
53
|
it "should show flash messages" do
|
55
|
-
post :update, :id=>@batch.pid, "generic_file"=>{"
|
54
|
+
post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"","read_users_string"=>"archivist1, archivist2", "tag"=>[""]}
|
56
55
|
response.should redirect_to @routes.url_helpers.dashboard_index_path
|
57
56
|
flash[:notice].should_not be_nil
|
58
57
|
flash[:notice].should_not be_empty
|
@@ -61,41 +60,41 @@ describe BatchController do
|
|
61
60
|
end
|
62
61
|
describe "when user has edit permissions on a file" do
|
63
62
|
it "should set the users with read access" do
|
64
|
-
post :update, :id=>@batch.pid, "generic_file"=>{"
|
63
|
+
post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"", "read_users_string"=>"archivist1, archivist2", "tag"=>[""]}
|
65
64
|
file = GenericFile.find(@file.pid)
|
66
65
|
file.read_users.should == ['archivist1', 'archivist2']
|
67
66
|
|
68
67
|
response.should redirect_to @routes.url_helpers.dashboard_index_path
|
69
68
|
end
|
70
69
|
it "should set the groups with read access" do
|
71
|
-
post :update, :id=>@batch.pid, "generic_file"=>{"
|
70
|
+
post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}
|
72
71
|
file = GenericFile.find(@file.pid)
|
73
72
|
file.read_groups.should == ['group1', 'group2']
|
74
73
|
end
|
75
74
|
it "should set public read access" do
|
76
|
-
post :update, :id=>@batch.pid, "visibility"=>"open", "generic_file"=>{"
|
75
|
+
post :update, :id=>@batch.pid, "visibility"=>"open", "generic_file"=>{"read_groups_string"=>"", "read_users_string"=>"", "tag"=>[""]}
|
77
76
|
file = GenericFile.find(@file.pid)
|
78
77
|
file.read_groups.should == ['public']
|
79
78
|
end
|
80
79
|
it "should set public read access and groups at the same time" do
|
81
|
-
post :update, :id=>@batch.pid, "visibility"=>"open", "generic_file"=>{"
|
80
|
+
post :update, :id=>@batch.pid, "visibility"=>"open", "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}
|
82
81
|
file = GenericFile.find(@file.pid)
|
83
82
|
file.read_groups.should == ['group1', 'group2', 'public']
|
84
83
|
end
|
85
84
|
it "should set public discover access and groups at the same time" do
|
86
|
-
post :update, :id=>@batch.pid, "permission"=>{"group"=>{"public"=>"none"}}, "generic_file"=>{"
|
85
|
+
post :update, :id=>@batch.pid, "permission"=>{"group"=>{"public"=>"none"}}, "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}
|
87
86
|
file = GenericFile.find(@file.pid)
|
88
87
|
file.read_groups.should == ['group1', 'group2']
|
89
88
|
file.discover_groups.should == []
|
90
89
|
end
|
91
90
|
it "should set metadata like title" do
|
92
|
-
post :update, :id=>@batch.pid, "generic_file"=>{"
|
91
|
+
post :update, :id=>@batch.pid, "generic_file"=>{"tag"=>["footag", "bartag"]}, "title"=>{@file.pid=>"New Title"}
|
93
92
|
file = GenericFile.find(@file.pid)
|
94
93
|
file.title.should == ["New Title"]
|
95
94
|
file.tag.should == ["footag", "bartag"]
|
96
95
|
end
|
97
96
|
it "should not set any tags" do
|
98
|
-
post :update, :id=>@batch.pid, "generic_file"=>{"
|
97
|
+
post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"", "read_users_string"=>"archivist1", "tag"=>[""]}
|
99
98
|
file = GenericFile.find(@file.pid)
|
100
99
|
file.tag.should be_empty
|
101
100
|
end
|
@@ -106,7 +105,7 @@ describe BatchController do
|
|
106
105
|
file.title = "Original Title"
|
107
106
|
file.read_groups.should == []
|
108
107
|
file.save
|
109
|
-
post :update, :id=>@batch.pid, "generic_file"=>{"
|
108
|
+
post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"group1, group2", "read_users_string"=>"", "tag"=>[""]}, "title"=>{@file2.pid=>"Title Wont Change"}
|
110
109
|
file = GenericFile.find(@file2.pid)
|
111
110
|
file.title.should == ["Original Title"]
|
112
111
|
file.read_groups.should == []
|
@@ -16,7 +16,6 @@ require 'spec_helper'
|
|
16
16
|
|
17
17
|
describe CatalogController do
|
18
18
|
before do
|
19
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
20
19
|
GenericFile.any_instance.stub(:characterize_if_changed).and_yield
|
21
20
|
@user = FactoryGirl.find_or_create(:user)
|
22
21
|
sign_in @user
|
@@ -29,10 +28,10 @@ describe CatalogController do
|
|
29
28
|
describe "#index" do
|
30
29
|
before (:all) do
|
31
30
|
GenericFile.find_each { |f| f.delete }
|
32
|
-
@gf1 = GenericFile.new(title:'Test Document PDF', filename:'test.pdf', read_groups:['public']
|
31
|
+
@gf1 = GenericFile.new(title:'Test Document PDF', filename:'test.pdf', read_groups:['public'])
|
33
32
|
@gf1.apply_depositor_metadata('mjg36')
|
34
33
|
@gf1.save
|
35
|
-
@gf2 = GenericFile.new(title:'Test 2 Document', filename:'test2.doc', contributor:'Contrib1', read_groups:['public']
|
34
|
+
@gf2 = GenericFile.new(title:'Test 2 Document', filename:'test2.doc', contributor:'Contrib1', read_groups:['public'])
|
36
35
|
@gf2.apply_depositor_metadata('mjg36')
|
37
36
|
@gf2.save
|
38
37
|
end
|
@@ -18,7 +18,6 @@ describe GenericFilesController do
|
|
18
18
|
before do
|
19
19
|
controller.stub(:has_access?).and_return(true)
|
20
20
|
|
21
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
22
21
|
@user = FactoryGirl.find_or_create(:user)
|
23
22
|
sign_in @user
|
24
23
|
User.any_instance.stub(:groups).and_return([])
|
@@ -26,7 +25,6 @@ describe GenericFilesController do
|
|
26
25
|
end
|
27
26
|
describe "#create" do
|
28
27
|
before do
|
29
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
30
28
|
@file_count = GenericFile.count
|
31
29
|
@mock = GenericFile.new({:pid => 'test:123'})
|
32
30
|
GenericFile.stub(:new).and_return(@mock)
|
@@ -48,7 +46,7 @@ describe GenericFilesController do
|
|
48
46
|
s2 = stub('one')
|
49
47
|
CharacterizeJob.should_receive(:new).with('test:123').and_return(s2)
|
50
48
|
Sufia.queue.should_receive(:push).with(s2).once
|
51
|
-
xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>
|
49
|
+
xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service => '1'
|
52
50
|
end
|
53
51
|
|
54
52
|
it "should expand zip files" do
|
@@ -65,12 +63,12 @@ describe GenericFilesController do
|
|
65
63
|
UnzipJob.should_receive(:new).with('test:123').and_return(s3)
|
66
64
|
Sufia.queue.should_receive(:push).with(s3).once
|
67
65
|
|
68
|
-
xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>
|
66
|
+
xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service => '1'
|
69
67
|
end
|
70
68
|
|
71
69
|
it "should create and save a file asset from the given params" do
|
72
70
|
file = fixture_file_upload('/world.png','image/png')
|
73
|
-
xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service=>
|
71
|
+
xhr :post, :create, :files=>[file], :Filename=>"The world", :batch_id => "sample:batch_id", :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service => '1'
|
74
72
|
response.should be_success
|
75
73
|
GenericFile.count.should == @file_count + 1
|
76
74
|
|
@@ -188,7 +186,7 @@ describe GenericFilesController do
|
|
188
186
|
|
189
187
|
describe "destroy" do
|
190
188
|
before(:each) do
|
191
|
-
@generic_file = GenericFile.new
|
189
|
+
@generic_file = GenericFile.new
|
192
190
|
@generic_file.apply_depositor_metadata(@user.user_key)
|
193
191
|
@generic_file.save
|
194
192
|
@user = FactoryGirl.find_or_create(:user)
|
@@ -213,7 +211,7 @@ describe GenericFilesController do
|
|
213
211
|
describe "update" do
|
214
212
|
before do
|
215
213
|
#controller.should_receive(:virus_check).and_return(0)
|
216
|
-
@generic_file = GenericFile.new
|
214
|
+
@generic_file = GenericFile.new
|
217
215
|
@generic_file.apply_depositor_metadata(@user.user_key)
|
218
216
|
@generic_file.save
|
219
217
|
end
|
@@ -227,7 +225,7 @@ describe GenericFilesController do
|
|
227
225
|
Sufia.queue.should_receive(:push).with(s1).once
|
228
226
|
@user = FactoryGirl.find_or_create(:user)
|
229
227
|
sign_in @user
|
230
|
-
post :update, :id=>@generic_file.pid, :generic_file=>{:
|
228
|
+
post :update, :id=>@generic_file.pid, :generic_file=>{:title=>'new_title', :tag=>[''], :permissions=>{:new_user_name=>{'archivist1'=>'edit'}}}
|
231
229
|
@user.delete
|
232
230
|
end
|
233
231
|
|
@@ -242,7 +240,7 @@ describe GenericFilesController do
|
|
242
240
|
sign_in @user
|
243
241
|
|
244
242
|
file = fixture_file_upload('/world.png','image/png')
|
245
|
-
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:
|
243
|
+
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:tag=>[''], :permissions=>{:new_user_name=>{'archivist1'=>'edit'}}}
|
246
244
|
@user.delete
|
247
245
|
end
|
248
246
|
|
@@ -251,7 +249,7 @@ describe GenericFilesController do
|
|
251
249
|
sign_in @user
|
252
250
|
|
253
251
|
file = fixture_file_upload('/world.png','image/png')
|
254
|
-
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:
|
252
|
+
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:tag=>[''], :permissions=>{:new_user_name=>{'archivist1@example.com'=>'edit'}}}
|
255
253
|
|
256
254
|
posted_file = GenericFile.find(@generic_file.pid)
|
257
255
|
version1 = posted_file.content.latest_version
|
@@ -272,7 +270,7 @@ describe GenericFilesController do
|
|
272
270
|
CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
|
273
271
|
Sufia.queue.should_receive(:push).with(s2).once
|
274
272
|
file = fixture_file_upload('/image.jp2','image/jp2')
|
275
|
-
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:
|
273
|
+
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:tag=>[''] }
|
276
274
|
|
277
275
|
edited_file = GenericFile.find(@generic_file.pid)
|
278
276
|
version2 = edited_file.content.latest_version
|
@@ -290,7 +288,7 @@ describe GenericFilesController do
|
|
290
288
|
s2 = stub('one')
|
291
289
|
CharacterizeJob.should_receive(:new).with(@generic_file.pid).and_return(s2)
|
292
290
|
Sufia.queue.should_receive(:push).with(s2).once
|
293
|
-
post :update, :id=>@generic_file.pid, :revision=>'content.0', :generic_file=>{:
|
291
|
+
post :update, :id=>@generic_file.pid, :revision=>'content.0', :generic_file=>{:tag=>['']}
|
294
292
|
|
295
293
|
restored_file = GenericFile.find(@generic_file.pid)
|
296
294
|
version3 = restored_file.content.latest_version
|
@@ -301,7 +299,7 @@ describe GenericFilesController do
|
|
301
299
|
end
|
302
300
|
|
303
301
|
it "should add a new groups and users" do
|
304
|
-
post :update, :id=>@generic_file.pid, :generic_file=>{:
|
302
|
+
post :update, :id=>@generic_file.pid, :generic_file=>{:tag=>[''], :permissions=>{:new_group_name=>{'group1'=>'read'}, :new_user_name=>{'user1'=>'edit'}}}
|
305
303
|
|
306
304
|
assigns[:generic_file].read_groups.should == ["group1"]
|
307
305
|
assigns[:generic_file].edit_users.should include("user1", @user.user_key)
|
@@ -309,7 +307,7 @@ describe GenericFilesController do
|
|
309
307
|
it "should update existing groups and users" do
|
310
308
|
@generic_file.read_groups = ['group3']
|
311
309
|
@generic_file.save
|
312
|
-
post :update, :id=>@generic_file.pid, :generic_file=>{:
|
310
|
+
post :update, :id=>@generic_file.pid, :generic_file=>{:tag=>[''], :permissions=>{:new_group_name=>'', :new_group_permission=>'', :new_user_name=>'', :new_user_permission=>'', :group=>{'group3' =>'read'}}}
|
313
311
|
|
314
312
|
assigns[:generic_file].read_groups.should == ["group3"]
|
315
313
|
end
|
@@ -327,14 +325,14 @@ describe GenericFilesController do
|
|
327
325
|
@user = FactoryGirl.find_or_create(:user)
|
328
326
|
sign_in @user
|
329
327
|
file = fixture_file_upload('/world.png','image/png')
|
330
|
-
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:
|
328
|
+
post :update, :id=>@generic_file.pid, :filedata=>file, :Filename=>"The world", :generic_file=>{:tag=>[''], :permissions=>{:new_user_name=>{'archivist1'=>'edit'}}}
|
331
329
|
end
|
332
330
|
|
333
331
|
end
|
334
332
|
|
335
333
|
describe "someone elses files" do
|
336
334
|
before do
|
337
|
-
f = GenericFile.new(:pid => 'sufia:test5'
|
335
|
+
f = GenericFile.new(:pid => 'sufia:test5')
|
338
336
|
f.apply_depositor_metadata('archivist1@example.com')
|
339
337
|
f.set_title_and_label('world.png')
|
340
338
|
f.add_file_datastream(File.new(fixture_path + '/world.png'))
|
@@ -4,7 +4,6 @@ describe SingleUseLinkController do
|
|
4
4
|
before(:all) do
|
5
5
|
User.any_instance.stub(:groups).and_return([])
|
6
6
|
|
7
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
8
7
|
@user = FactoryGirl.find_or_create(:user)
|
9
8
|
@file = GenericFile.new
|
10
9
|
@file.set_title_and_label('world.png')
|
@@ -17,7 +17,6 @@ require 'spec_helper'
|
|
17
17
|
|
18
18
|
describe BatchUpdateJob do
|
19
19
|
before do
|
20
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
21
20
|
@user = FactoryGirl.find_or_create(:user)
|
22
21
|
@batch = Batch.new
|
23
22
|
@batch.save
|
@@ -37,7 +36,7 @@ describe BatchUpdateJob do
|
|
37
36
|
it "should check permissions for each file before updating" do
|
38
37
|
BatchUpdateJob.any_instance.stub(:get_permissions_solr_response_for_doc_id).and_return(["","mock solr permissions"])
|
39
38
|
User.any_instance.should_receive(:can?).with(:edit, "mock solr permissions").exactly(2).times
|
40
|
-
params = {'generic_file' => {'
|
39
|
+
params = {'generic_file' => {'read_groups_string' => '', 'read_users_string' => 'archivist1, archivist2', 'tag' => ['']}, 'id' => @batch.pid, 'controller' => 'batch', 'action' => 'update'}.with_indifferent_access
|
41
40
|
BatchUpdateJob.new(@user.user_key, params).run
|
42
41
|
@user.mailbox.inbox[0].messages[0].subject.should == "Batch upload permission denied"
|
43
42
|
@user.mailbox.inbox[0].messages[0].move_to_trash @user
|
@@ -54,7 +53,7 @@ describe BatchUpdateJob do
|
|
54
53
|
s2 = stub('two')
|
55
54
|
ContentUpdateEventJob.should_receive(:new).with(@file2.pid, @user.user_key).and_return(s2)
|
56
55
|
Sufia.queue.should_receive(:push).with(s2).once
|
57
|
-
params = {'generic_file' => {'
|
56
|
+
params = {'generic_file' => {'read_groups_string' => '', 'read_users_string' => 'archivist1, archivist2', 'tag' => ['']}, 'id' => @batch.pid, 'controller' => 'batch', 'action' => 'update'}.with_indifferent_access
|
58
57
|
BatchUpdateJob.new(@user.user_key, params).run
|
59
58
|
@user.mailbox.inbox[0].messages[0].subject.should == "Batch upload complete"
|
60
59
|
@user.mailbox.inbox[0].messages[0].move_to_trash @user
|
@@ -16,7 +16,7 @@ require 'spec_helper'
|
|
16
16
|
|
17
17
|
describe ChecksumAuditLog do
|
18
18
|
before(:all) do
|
19
|
-
@f = GenericFile.new
|
19
|
+
@f = GenericFile.new
|
20
20
|
@f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
21
21
|
@f.apply_depositor_metadata('mjg36')
|
22
22
|
@f.save!
|
@@ -29,7 +29,6 @@ describe ChecksumAuditLog do
|
|
29
29
|
ChecksumAuditLog.all.each(&:delete)
|
30
30
|
end
|
31
31
|
before(:each) do
|
32
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
33
32
|
GenericFile.any_instance.stub(:characterize).and_return(true) # stub out characterization so it does not get audited
|
34
33
|
end
|
35
34
|
it "should return a list of logs for this datastream sorted by date descending" do
|
@@ -16,17 +16,14 @@ require 'spec_helper'
|
|
16
16
|
|
17
17
|
describe FileContentDatastream do
|
18
18
|
before do
|
19
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
20
19
|
@subject = FileContentDatastream.new(nil, 'content')
|
21
20
|
@subject.stub(:pid=>'my_pid')
|
22
21
|
@subject.stub(:dsVersionID=>'content.7')
|
23
22
|
end
|
24
23
|
describe "version control" do
|
25
24
|
before(:all) do
|
26
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
27
25
|
f = GenericFile.new
|
28
26
|
f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
29
|
-
f.should_receive(:characterize_if_changed).and_yield
|
30
27
|
f.apply_depositor_metadata('mjg36')
|
31
28
|
f.save
|
32
29
|
@file = GenericFile.find(f.pid)
|
@@ -52,7 +49,6 @@ describe FileContentDatastream do
|
|
52
49
|
describe "add a version" do
|
53
50
|
before(:all) do
|
54
51
|
@file.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
55
|
-
@file.should_receive(:characterize_if_changed).and_yield
|
56
52
|
@file.save
|
57
53
|
end
|
58
54
|
it "should return two versions" do
|
@@ -68,8 +64,7 @@ describe FileContentDatastream do
|
|
68
64
|
end
|
69
65
|
describe "extract_metadata" do
|
70
66
|
it "should have the path" do
|
71
|
-
@subject.fits_path.
|
72
|
-
@subject.fits_path.should_not == ''
|
67
|
+
@subject.send(:fits_path).should be_present
|
73
68
|
end
|
74
69
|
it "should return an xml document" do
|
75
70
|
repo = mock("repo")
|
@@ -16,7 +16,6 @@ require 'spec_helper'
|
|
16
16
|
|
17
17
|
describe GenericFile do
|
18
18
|
before(:each) do
|
19
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
20
19
|
@file = GenericFile.new
|
21
20
|
@file.apply_depositor_metadata('jcoyne')
|
22
21
|
end
|
@@ -250,7 +249,7 @@ describe GenericFile do
|
|
250
249
|
describe "audit" do
|
251
250
|
before(:each) do
|
252
251
|
u = FactoryGirl.create(:user)
|
253
|
-
f = GenericFile.new
|
252
|
+
f = GenericFile.new
|
254
253
|
f.stub(:characterize).and_return(true)
|
255
254
|
f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
256
255
|
f.apply_depositor_metadata(u.user_key)
|
@@ -301,7 +300,7 @@ describe GenericFile do
|
|
301
300
|
|
302
301
|
describe "run_audit" do
|
303
302
|
before do
|
304
|
-
@f = GenericFile.new
|
303
|
+
@f = GenericFile.new
|
305
304
|
@f.add_file_datastream(File.new(fixture_path + '/world.png'), :dsid=>'content')
|
306
305
|
@f.apply_depositor_metadata('mjg36')
|
307
306
|
@f.save!
|
@@ -419,7 +418,6 @@ describe GenericFile do
|
|
419
418
|
end
|
420
419
|
describe "noid integration" do
|
421
420
|
before(:all) do
|
422
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
423
421
|
GenericFile.any_instance.should_receive(:characterize_if_changed).and_yield
|
424
422
|
@new_file = GenericFile.new(:pid => 'ns:123')
|
425
423
|
@new_file.apply_depositor_metadata('mjg36')
|
@@ -458,7 +456,6 @@ describe GenericFile do
|
|
458
456
|
end
|
459
457
|
describe "after job runs" do
|
460
458
|
before(:all) do
|
461
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
462
459
|
myfile = GenericFile.new
|
463
460
|
myfile.add_file_datastream(File.new(fixture_path + '/sufia/sufia_test4.pdf'), :dsid=>'content')
|
464
461
|
myfile.label = 'label123'
|
@@ -542,7 +539,6 @@ describe GenericFile do
|
|
542
539
|
describe "permissions validation" do
|
543
540
|
context "depositor must have edit access" do
|
544
541
|
before(:each) do
|
545
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
546
542
|
@file = GenericFile.new
|
547
543
|
@file.apply_depositor_metadata('mjg36')
|
548
544
|
@rightsmd = @file.rightsMetadata
|
@@ -642,7 +638,6 @@ describe GenericFile do
|
|
642
638
|
end
|
643
639
|
context "public must not have edit access" do
|
644
640
|
before(:each) do
|
645
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
646
641
|
@file = GenericFile.new
|
647
642
|
@file.apply_depositor_metadata('mjg36')
|
648
643
|
@file.read_groups = ['public']
|
@@ -743,7 +738,6 @@ describe GenericFile do
|
|
743
738
|
end
|
744
739
|
context "registered must not have edit access" do
|
745
740
|
before(:each) do
|
746
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
747
741
|
@file = GenericFile.new
|
748
742
|
@file.apply_depositor_metadata('mjg36')
|
749
743
|
@file.read_groups = ['registered']
|
@@ -844,7 +838,6 @@ describe GenericFile do
|
|
844
838
|
end
|
845
839
|
context "everything is copacetic" do
|
846
840
|
before(:each) do
|
847
|
-
GenericFile.any_instance.stub(:terms_of_service).and_return('1')
|
848
841
|
@file = GenericFile.new
|
849
842
|
@file.apply_depositor_metadata('mjg36')
|
850
843
|
@file.read_groups = ['public']
|