sufia 0.0.7 → 0.0.8
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/.gitignore +5 -5
- data/Gemfile +0 -7
- data/app/assets/javascripts/sufia.js +8 -2
- data/app/controllers/batch_controller.rb +0 -5
- data/app/controllers/batch_edits_controller.rb +9 -5
- data/app/controllers/users_controller.rb +0 -1
- data/app/views/batch_edits/edit.html.erb +1 -6
- data/app/views/generic_files/_permission.html.erb +1 -2
- data/app/views/users/_notify_link.html.erb +3 -17
- data/app/views/users/edit.html.erb +2 -4
- data/lib/sufia/controller.rb +5 -0
- data/lib/sufia/files_controller_behavior.rb +21 -53
- data/lib/sufia/generic_file.rb +11 -11
- data/lib/sufia/generic_file/actions.rb +35 -0
- data/lib/sufia/model_methods.rb +4 -1
- data/lib/sufia/version.rb +1 -1
- data/lib/tasks/fixtures.rake +1 -0
- data/spec/controllers/batch_edits_controller_spec.rb +38 -0
- data/spec/controllers/generic_files_controller_spec.rb +8 -1
- data/spec/support/Gemfile +2 -2
- data/sufia.gemspec +3 -5
- data/vendor/assets/javascripts/fileupload/application.js +1 -1
- metadata +17 -46
data/.gitignore
CHANGED
@@ -6,6 +6,8 @@ config/solr.yml
|
|
6
6
|
config/hydra-ldap.yml
|
7
7
|
config/redis.yml
|
8
8
|
|
9
|
+
# bad gem etiquette, man
|
10
|
+
.rvmrc
|
9
11
|
Gemfile.lock
|
10
12
|
|
11
13
|
# This file is generated automatically by: rake scholarsphere:generate_secret
|
@@ -78,13 +80,11 @@ db/schema.rb
|
|
78
80
|
/.bundle
|
79
81
|
/.yardoc
|
80
82
|
/doc
|
83
|
+
|
81
84
|
## PROJECT::SPECIFIC
|
82
85
|
|
83
|
-
##
|
84
|
-
spec/fixtures/
|
85
|
-
spec/fixtures/scholarsphere/scholarsphere_rspecTestFixture.descMeta.txt
|
86
|
-
spec/fixtures/scholarsphere/scholarsphere_rspecTestFixture.foxml.erb
|
87
|
-
spec/fixtures/scholarsphere/scholarsphere_rspecTestFixture.txt
|
86
|
+
## fixtures for dev
|
87
|
+
spec/fixtures/sufia/sufia_sufia1.*
|
88
88
|
|
89
89
|
## ASSET PIPELINE
|
90
90
|
.sass-cache/
|
data/Gemfile
CHANGED
@@ -6,14 +6,8 @@ gemspec
|
|
6
6
|
#gem 'mail_form', :git => 'git://github.com/psu-stewardship/mail_form.git', :ref => '50c00f0'
|
7
7
|
group :development, :test do
|
8
8
|
gem 'sqlite3'
|
9
|
-
gem 'unicorn-rails'
|
10
|
-
gem "debugger"
|
11
|
-
gem 'activerecord-import'
|
12
|
-
# gem "rails_indexes", :git => "git://github.com/warpc/rails_indexes.git", :ref => '4a550270'
|
13
9
|
gem 'selenium-webdriver'
|
14
|
-
gem 'headless'
|
15
10
|
gem 'rspec-rails', '~> 2.12.0'
|
16
|
-
gem 'ruby-prof'
|
17
11
|
gem 'cucumber-rails', '~> 1.0', :require => false
|
18
12
|
gem 'database_cleaner'
|
19
13
|
gem 'devise'
|
@@ -21,5 +15,4 @@ group :development, :test do
|
|
21
15
|
gem 'bcrypt-ruby'
|
22
16
|
gem "jettywrapper"
|
23
17
|
gem "factory_girl_rails", "~> 4.1.0"
|
24
|
-
gem 'launchy'
|
25
18
|
end # (leave this comment here to catch a stray line inserted by blacklight!)
|
@@ -55,15 +55,20 @@ Blacklight.do_select_submit = function() {
|
|
55
55
|
};
|
56
56
|
Blacklight.do_select_submit.selector = "form.sort select, form.per_page select";
|
57
57
|
|
58
|
+
function notify_update_link() {
|
59
|
+
$('#notify_update_link').click();
|
60
|
+
}
|
61
|
+
|
58
62
|
// short hand for $(document).ready();
|
59
63
|
$(function() {
|
60
64
|
|
61
65
|
// set up global batch edit options to override the ones in the gem
|
62
66
|
window.batch_edits_options = { checked_label: "",unchecked_label: "",progress_label: "",status_label: "",css_class: "batch_toggle"};
|
63
|
-
|
67
|
+
|
68
|
+
setInterval(notify_update_link, 30*1000);
|
64
69
|
|
65
70
|
// bootstrap alerts are closed this function
|
66
|
-
$('.alert .close'
|
71
|
+
$(document).on('click', '.alert .close' , function(){
|
67
72
|
$(this).parent().hide();
|
68
73
|
});
|
69
74
|
|
@@ -301,3 +306,4 @@ function initialize_audio() {
|
|
301
306
|
});
|
302
307
|
};
|
303
308
|
}
|
309
|
+
|
@@ -25,11 +25,6 @@ class BatchController < ApplicationController
|
|
25
25
|
@generic_file = GenericFile.new
|
26
26
|
@generic_file.creator = current_user.name
|
27
27
|
@generic_file.title = @batch.generic_files.map(&:label)
|
28
|
-
begin
|
29
|
-
@groups = current_user.groups
|
30
|
-
rescue
|
31
|
-
logger.warn "Can not get to LDAP for user groups"
|
32
|
-
end
|
33
28
|
end
|
34
29
|
|
35
30
|
def update
|
@@ -6,8 +6,7 @@ class BatchEditsController < ApplicationController
|
|
6
6
|
super
|
7
7
|
@generic_file = GenericFile.new
|
8
8
|
@generic_file.depositor = current_user.user_key
|
9
|
-
@
|
10
|
-
@terms = @generic_file.editable_terms - [:title] # +:format, :resource_type
|
9
|
+
@terms = @generic_file.terms_for_editing - [:title] # +:format, :resource_type
|
11
10
|
|
12
11
|
# do we want to show the original values for anything...
|
13
12
|
@show_file = GenericFile.new
|
@@ -15,19 +14,24 @@ class BatchEditsController < ApplicationController
|
|
15
14
|
h = {}
|
16
15
|
@names = []
|
17
16
|
permissions = []
|
17
|
+
|
18
|
+
# For each of the files in the batch, set the attributes to be the concatination of all the attributes
|
18
19
|
batch.each do |doc_id|
|
19
20
|
gf = GenericFile.find(doc_id)
|
20
|
-
|
21
|
+
gf.terms_for_editing.each do |key|
|
22
|
+
h[key] ||= []
|
23
|
+
h[key] = (h[key] + gf.send(key)).uniq
|
24
|
+
end
|
21
25
|
@names << display_title(gf)
|
22
26
|
permissions = (permissions+gf.permissions).uniq
|
23
27
|
end
|
24
28
|
|
25
29
|
# why am I doing this you may ask... Well... if truth be told I have no idea, but if I use just a single item in the batch
|
26
30
|
# my h arrays get converted into strings in update attributes unless I do this first....
|
27
|
-
h.keys.each {|key| h[key] = h[key].to_a} if (batch.size == 1)
|
31
|
+
#h.keys.each {|key| h[key] = h[key].to_a} if (batch.size == 1)
|
28
32
|
# end of wierd fix...
|
29
33
|
|
30
|
-
@show_file.
|
34
|
+
@show_file.attributes = h
|
31
35
|
# map the permissions to parameter like input so that the assign will work
|
32
36
|
# todo sort the access level some how...
|
33
37
|
perm_param ={'user'=>{},'group'=>{"public"=>"1"}}
|
@@ -6,7 +6,7 @@
|
|
6
6
|
var clearState = $.ajax({
|
7
7
|
headers: {Accept : "application/javascript"},
|
8
8
|
type: 'POST',
|
9
|
-
url: '<%=batch_edits_clear_path %>',
|
9
|
+
url: '<%=sufia.batch_edits_clear_path %>',
|
10
10
|
async: false,
|
11
11
|
});
|
12
12
|
}
|
@@ -259,11 +259,6 @@ h2 small {
|
|
259
259
|
<%=get_label(term)%> <i class="toggle icon-chevron-right grey"></i>
|
260
260
|
</a>
|
261
261
|
</th>
|
262
|
-
<!--td width="30%" class="scrollx" id="data_<%= key%>">
|
263
|
-
<% vals.each do |val| %>
|
264
|
-
<%= val%><br />
|
265
|
-
<% end %>
|
266
|
-
</td -->
|
267
262
|
<td width="50%" class="scrolly">
|
268
263
|
|
269
264
|
<div id="collapse_<%=term.to_s%>" class="accordion-body collapse scrolly">
|
@@ -104,8 +104,7 @@ limitations under the License.
|
|
104
104
|
<div class="row control-group">
|
105
105
|
<div id="new-group" >
|
106
106
|
<div class="input-append">
|
107
|
-
|
108
|
-
<%= select_tag 'new_group_name_skel', options_for_select(@groups), :class => 'span38' %>
|
107
|
+
<%= select_tag 'new_group_name_skel', options_for_select(["Select a group"] + groups), :class => 'span38' %>
|
109
108
|
<%= select_tag 'new_group_permission_skel', options_for_select(Sufia::Engine.config.permission_levels), :class => 'span17' %>
|
110
109
|
<button class="btn btn-mini btn-inverse" id="add_new_group_skel" ><i class="icon-plus-sign"></i> Add</button>
|
111
110
|
<br /><span id="directory_group_result"></span>
|
@@ -13,23 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
14
14
|
limitations under the License.
|
15
15
|
%>
|
16
|
-
|
17
|
-
<script type = "text/javascript">
|
18
|
-
|
19
|
-
|
20
|
-
$(document).ready(function() {
|
21
|
-
|
22
|
-
// periodically update the recent documents
|
23
|
-
setInterval( function() { $('#notify_update_link').click();}, 30*1000 );
|
24
|
-
|
25
|
-
});
|
26
|
-
|
27
|
-
</script>
|
28
|
-
<div class='hide'>
|
29
|
-
<%= link_to "notify", sufia.user_notify_path, :remote => true, :id => 'notify_update_link' %>
|
30
|
-
</div>
|
31
|
-
|
32
|
-
|
33
16
|
<a id="notify_link" href="<%= sufia.mailbox_path %>" class="icon-btn btn btn-small" title="click for User Notifications">
|
34
17
|
<%= render :partial => 'users/notify_number' %>
|
35
18
|
</a>
|
19
|
+
<div class='hide'>
|
20
|
+
<%= link_to "notify", sufia.user_notify_path, :remote => true, :id => 'notify_update_link' %>
|
21
|
+
</div>
|
@@ -90,10 +90,8 @@ $("a[rel=popover]").popover();
|
|
90
90
|
<hr />
|
91
91
|
|
92
92
|
<h3><i class="icon-group"></i> User Managed Groups Info (UMG) <%= link_to 'Manage UMG', 'http://umg.its.psu.edu/', :class => 'btn btn-mini btn-primary' %> </h3>
|
93
|
-
<%
|
94
|
-
|
95
|
-
<i class="icon-caret-right"></i> <%= g %><br />
|
96
|
-
<% end %>
|
93
|
+
<% groups.each do |g| %>
|
94
|
+
<i class="icon-caret-right"></i> <%= g %><br />
|
97
95
|
<% end %>
|
98
96
|
</div>
|
99
97
|
|
data/lib/sufia/controller.rb
CHANGED
@@ -20,6 +20,7 @@ module Sufia::Controller
|
|
20
20
|
include Hydra::Controller::ControllerBehavior
|
21
21
|
|
22
22
|
before_filter :notifications_number
|
23
|
+
helper_method :groups
|
23
24
|
|
24
25
|
end
|
25
26
|
|
@@ -27,6 +28,10 @@ module Sufia::Controller
|
|
27
28
|
current_user ? current_user.ability : super
|
28
29
|
end
|
29
30
|
|
31
|
+
def groups
|
32
|
+
@groups ||= current_user ? current_user.groups : []
|
33
|
+
end
|
34
|
+
|
30
35
|
def render_404(exception)
|
31
36
|
logger.error("Rendering 404 page due to exception: #{exception.inspect} - #{exception.backtrace if exception.respond_to? :backtrace}")
|
32
37
|
render :template => '/error/404', :layout => "error", :formats => [:html], :status => 404
|
@@ -19,7 +19,6 @@ module Sufia
|
|
19
19
|
|
20
20
|
included do
|
21
21
|
include Hydra::Controller::ControllerBehavior
|
22
|
-
include Hydra::Controller::UploadBehavior # for add_posted_blob_to_asset method
|
23
22
|
include Blacklight::Configurable # comply with BL 3.7
|
24
23
|
include Sufia::Noid # for normalize_identifier method
|
25
24
|
|
@@ -46,7 +45,6 @@ module Sufia
|
|
46
45
|
load_and_authorize_resource :except=>[:index, :audit]
|
47
46
|
end
|
48
47
|
|
49
|
-
|
50
48
|
# routed to /files/new
|
51
49
|
def new
|
52
50
|
@generic_file = ::GenericFile.new
|
@@ -80,7 +78,12 @@ module Sufia
|
|
80
78
|
# check error condition No files
|
81
79
|
return render(:json => [{:error => "Error! No file to save"}].to_json) if !params.has_key?(:files)
|
82
80
|
|
83
|
-
file = params[:files]
|
81
|
+
file = params[:files].detect {|f| f.respond_to?(:original_filename) }
|
82
|
+
if !file
|
83
|
+
render :json => [{:name => 'unknown file', :error => "Error! No file for upload"}], :status => :unprocessable_entity
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
|
84
87
|
# check error condition empty file
|
85
88
|
if ((file.respond_to?(:tempfile)) && (file.tempfile.size == 0))
|
86
89
|
retval = render :json => [{ :name => file.original_filename, :error => "Error! Zero Length File!"}].to_json
|
@@ -91,10 +94,11 @@ module Sufia
|
|
91
94
|
|
92
95
|
# process file
|
93
96
|
else
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
97
|
+
if virus_check(file) == 0
|
98
|
+
@generic_file = ::GenericFile.new
|
99
|
+
# Relative path is set by the jquery uploader when uploading a directory
|
100
|
+
@generic_file.relative_path = params[:relative_path] if params[:relative_path]
|
101
|
+
Sufia::GenericFile::Actions.create(@generic_file, file, params[:batch_id], file.original_filename, datastream_id, current_user)
|
98
102
|
respond_to do |format|
|
99
103
|
format.html {
|
100
104
|
retval = render :json => [@generic_file.to_jq_upload].to_json,
|
@@ -106,6 +110,7 @@ module Sufia
|
|
106
110
|
}
|
107
111
|
end
|
108
112
|
else
|
113
|
+
puts "Returned false"
|
109
114
|
retval = render :json => [{:error => "Error creating generic file."}].to_json
|
110
115
|
end
|
111
116
|
end
|
@@ -152,8 +157,9 @@ module Sufia
|
|
152
157
|
end
|
153
158
|
|
154
159
|
if params.has_key?(:filedata)
|
155
|
-
|
156
|
-
|
160
|
+
file = params[:filedata]
|
161
|
+
return unless virus_check(file) == 0
|
162
|
+
@generic_file.add_file(file, datastream_id, file.original_filename)
|
157
163
|
version_event = true
|
158
164
|
Sufia.queue.push(ContentNewVersionEventJob.new(@generic_file.pid, current_user.user_key))
|
159
165
|
end
|
@@ -162,13 +168,18 @@ module Sufia
|
|
162
168
|
|
163
169
|
# do not trigger an update event if a version event has already been triggered
|
164
170
|
Sufia.queue.push(ContentUpdateEventJob.new(@generic_file.pid, current_user.user_key)) unless version_event
|
165
|
-
record_version_committer(
|
171
|
+
@generic_file.record_version_committer(current_user)
|
166
172
|
redirect_to sufia.edit_generic_file_path(:tab => params[:redirect_tab]), :notice => render_to_string(:partial=>'generic_files/asset_updated_flash', :locals => { :generic_file => @generic_file })
|
167
173
|
|
168
174
|
end
|
169
175
|
|
170
176
|
protected
|
171
177
|
|
178
|
+
# The name of the datastream where we store the file data
|
179
|
+
def datastream_id
|
180
|
+
'content'
|
181
|
+
end
|
182
|
+
|
172
183
|
# this is provided so that implementing application can override this behavior and map params to different attributes
|
173
184
|
def update_metadata
|
174
185
|
valid_attributes = params[:generic_file].select { |k,v| (@generic_file.terms_for_editing + [:permissions]).include? k.to_sym}
|
@@ -178,15 +189,6 @@ module Sufia
|
|
178
189
|
@generic_file.save!
|
179
190
|
end
|
180
191
|
|
181
|
-
def record_version_committer(generic_file, user)
|
182
|
-
version = generic_file.content.latest_version
|
183
|
-
# content datastream not (yet?) present
|
184
|
-
return if version.nil?
|
185
|
-
VersionCommitter.create(:obj_id => version.pid,
|
186
|
-
:datastream_id => version.dsid,
|
187
|
-
:version_id => version.versionID,
|
188
|
-
:committer_login => user.user_key)
|
189
|
-
end
|
190
192
|
|
191
193
|
def virus_check( file)
|
192
194
|
if defined? ClamAV
|
@@ -200,39 +202,5 @@ module Sufia
|
|
200
202
|
end
|
201
203
|
end
|
202
204
|
|
203
|
-
def create_and_save_generic_file(file, relative_path, batch_id, file_name)
|
204
|
-
return nil unless virus_check(file) == 0
|
205
|
-
|
206
|
-
@generic_file = ::GenericFile.new
|
207
|
-
#This depends on the 3 arg constructor in hh 5.2.0
|
208
|
-
add_posted_blob_to_asset(@generic_file,file, file_name)
|
209
|
-
|
210
|
-
@generic_file.apply_depositor_metadata(user_key)
|
211
|
-
@generic_file.date_uploaded = Date.today
|
212
|
-
@generic_file.date_modified = Date.today
|
213
|
-
@generic_file.relative_path = relative_path if relative_path
|
214
|
-
@generic_file.creator = current_user.name
|
215
|
-
|
216
|
-
if batch_id
|
217
|
-
@generic_file.add_relationship("isPartOf", "info:fedora/#{Sufia::Noid.namespaceize(batch_id)}")
|
218
|
-
else
|
219
|
-
logger.warn "unable to find batch to attach to"
|
220
|
-
end
|
221
|
-
|
222
|
-
save_tries = 0
|
223
|
-
begin
|
224
|
-
@generic_file.save
|
225
|
-
rescue RSolr::Error::Http => error
|
226
|
-
logger.warn "GenericFilesController::create_and_save_generic_file Caught RSOLR error #{error.inspect}"
|
227
|
-
save_tries+=1
|
228
|
-
# fail for good if the tries is greater than 3
|
229
|
-
raise error if save_tries >=3
|
230
|
-
sleep 0.01
|
231
|
-
retry
|
232
|
-
end
|
233
|
-
|
234
|
-
record_version_committer(@generic_file, current_user)
|
235
|
-
return @generic_file
|
236
|
-
end
|
237
205
|
end
|
238
206
|
end
|
data/lib/sufia/generic_file.rb
CHANGED
@@ -10,6 +10,7 @@ module Sufia
|
|
10
10
|
autoload :Thumbnail
|
11
11
|
autoload :Characterization
|
12
12
|
autoload :Audit
|
13
|
+
autoload :Actions
|
13
14
|
autoload :Permissions
|
14
15
|
include Sufia::ModelMethods
|
15
16
|
include Sufia::Noid
|
@@ -43,6 +44,16 @@ module Sufia
|
|
43
44
|
end
|
44
45
|
|
45
46
|
|
47
|
+
def record_version_committer(user)
|
48
|
+
version = content.latest_version
|
49
|
+
# content datastream not (yet?) present
|
50
|
+
return if version.nil?
|
51
|
+
VersionCommitter.create(:obj_id => version.pid,
|
52
|
+
:datastream_id => version.dsid,
|
53
|
+
:version_id => version.versionID,
|
54
|
+
:committer_login => user.user_key)
|
55
|
+
end
|
56
|
+
|
46
57
|
def pdf?
|
47
58
|
["application/pdf"].include? self.mime_type
|
48
59
|
end
|
@@ -157,17 +168,6 @@ module Sufia
|
|
157
168
|
self.descMetadata.class.config.keys
|
158
169
|
end
|
159
170
|
|
160
|
-
def get_values
|
161
|
-
terms = get_terms
|
162
|
-
values = {}
|
163
|
-
terms.each do |t|
|
164
|
-
next if t.empty?
|
165
|
-
next if ['part_of', 'date_modified', 'date_uploaded'].include?(t)
|
166
|
-
values[t] = self.send(key) if self.respond_to?(key)
|
167
|
-
end
|
168
|
-
values
|
169
|
-
end
|
170
|
-
|
171
171
|
# Is this file in the middle of being processed by a batch?
|
172
172
|
def processing?
|
173
173
|
return false if self.batch.blank?
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Sufia::GenericFile
|
2
|
+
# Actions are decoupled from controller logic so that they may be called from a controller or a background job.
|
3
|
+
module Actions
|
4
|
+
def self.create(generic_file, file, batch_id, file_name, dsid, user)
|
5
|
+
generic_file.add_file(file, dsid, file_name)
|
6
|
+
|
7
|
+
generic_file.apply_depositor_metadata(user.user_key)
|
8
|
+
generic_file.date_uploaded = Date.today
|
9
|
+
generic_file.date_modified = Date.today
|
10
|
+
generic_file.creator = user.name
|
11
|
+
|
12
|
+
if batch_id
|
13
|
+
generic_file.add_relationship("isPartOf", "info:fedora/#{Sufia::Noid.namespaceize(batch_id)}")
|
14
|
+
else
|
15
|
+
logger.warn "unable to find batch to attach to"
|
16
|
+
end
|
17
|
+
|
18
|
+
save_tries = 0
|
19
|
+
begin
|
20
|
+
generic_file.save!
|
21
|
+
rescue RSolr::Error::Http => error
|
22
|
+
logger.warn "GenericFilesController::create_and_save_generic_file Caught RSOLR error #{error.inspect}"
|
23
|
+
save_tries+=1
|
24
|
+
# fail for good if the tries is greater than 3
|
25
|
+
raise error if save_tries >=3
|
26
|
+
sleep 0.01
|
27
|
+
retry
|
28
|
+
end
|
29
|
+
|
30
|
+
generic_file.record_version_committer(user)
|
31
|
+
Sufia.queue.push(UnzipJob.new(generic_file.pid)) if generic_file.content.mimeType == 'application/zip'
|
32
|
+
Sufia.queue.push(ContentDepositEventJob.new(generic_file.pid, user.user_key))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/sufia/model_methods.rb
CHANGED
@@ -16,7 +16,10 @@ require 'hydra/model_methods'
|
|
16
16
|
module Sufia
|
17
17
|
module ModelMethods
|
18
18
|
extend ActiveSupport::Concern
|
19
|
-
|
19
|
+
|
20
|
+
included do
|
21
|
+
include Hydra::ModelMethods
|
22
|
+
end
|
20
23
|
|
21
24
|
# OVERRIDE to support Hydra::Datastream::Properties which does not
|
22
25
|
# respond to :depositor_values but :depositor
|
data/lib/sufia/version.rb
CHANGED
data/lib/tasks/fixtures.rake
CHANGED
@@ -198,6 +198,7 @@ namespace :sufia do
|
|
198
198
|
loader = ActiveFedora::FixtureLoader.new(dir)
|
199
199
|
fixtures = find_fixtures(@dir)
|
200
200
|
fixtures.each do |fixture|
|
201
|
+
puts "Fixture is #{fixture}"
|
201
202
|
loader.import_and_index(fixture)
|
202
203
|
puts "Loaded '#{fixture}'"
|
203
204
|
# Rake::Task["repo:load"].reenable
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BatchEditsController do
|
4
|
+
before do
|
5
|
+
controller.stub(:has_access?).and_return(true)
|
6
|
+
@user = FactoryGirl.find_or_create(:user)
|
7
|
+
sign_in @user
|
8
|
+
User.any_instance.stub(:groups).and_return([])
|
9
|
+
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
10
|
+
request.env["HTTP_REFERER"] = 'test.host/original_page'
|
11
|
+
@routes = Internal::Application.routes
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "edit" do
|
16
|
+
before do
|
17
|
+
@one = GenericFile.new(:creator=>"Fred", :language=>'en')
|
18
|
+
@one.apply_depositor_metadata('mjg36')
|
19
|
+
@two = GenericFile.new(:creator=>"Wilma", :publisher=>'Rand McNally', :language=>'en')
|
20
|
+
@two.apply_depositor_metadata('mjg36')
|
21
|
+
@one.save!
|
22
|
+
@two.save!
|
23
|
+
put :add, :id =>@one.pid
|
24
|
+
put :add, :id =>@two.pid
|
25
|
+
controller.should_receive(:can?).with(:edit, @one.pid).and_return(true)
|
26
|
+
controller.should_receive(:can?).with(:edit, @two.pid).and_return(true)
|
27
|
+
end
|
28
|
+
it "should be successful" do
|
29
|
+
get :edit
|
30
|
+
response.should be_successful
|
31
|
+
assigns[:terms].should == [:contributor, :creator, :description, :publisher,
|
32
|
+
:date_created, :subject, :language, :rights, :identifier, :based_near, :tag, :related_url]
|
33
|
+
assigns[:show_file].creator.should == ["Fred", "Wilma"]
|
34
|
+
assigns[:show_file].publisher.should == ["Rand McNally"]
|
35
|
+
assigns[:show_file].language.should == ["en"]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -37,6 +37,13 @@ describe GenericFilesController do
|
|
37
37
|
@mock.delete unless @mock.inner_object.class == ActiveFedora::UnsavedDigitalObject
|
38
38
|
end
|
39
39
|
|
40
|
+
it "should render error the file wasn't actually a file" do
|
41
|
+
file = 'hello'
|
42
|
+
xhr :post, :create, :files=>[file], :Filename=>"The World", :batch_id=>'sample:batch_id', :permission=>{"group"=>{"public"=>"read"} }, :terms_of_service => '1'
|
43
|
+
response.status.should == 422
|
44
|
+
JSON.parse(response.body).first['error'].should match(/no file for upload/i)
|
45
|
+
end
|
46
|
+
|
40
47
|
it "should spawn a content deposit event job" do
|
41
48
|
file = fixture_file_upload('/world.png','image/png')
|
42
49
|
s1 = stub('one')
|
@@ -50,7 +57,7 @@ describe GenericFilesController do
|
|
50
57
|
end
|
51
58
|
|
52
59
|
it "should expand zip files" do
|
53
|
-
file = fixture_file_upload('/
|
60
|
+
file = fixture_file_upload('/icons.zip','application/zip')
|
54
61
|
s1 = stub('one')
|
55
62
|
ContentDepositEventJob.should_receive(:new).with('test:123', 'jilluser@example.com').and_return(s1)
|
56
63
|
Sufia.queue.should_receive(:push).with(s1).once
|
data/spec/support/Gemfile
CHANGED
@@ -4,9 +4,9 @@ gem 'rails', '3.2.11'
|
|
4
4
|
|
5
5
|
gem 'sqlite3'
|
6
6
|
|
7
|
-
gem 'devise'
|
7
|
+
gem 'devise' #BL adds this later, so check to see if we can remove this
|
8
8
|
gem 'blacklight'
|
9
|
-
gem "hydra-head"
|
9
|
+
gem "hydra-head"
|
10
10
|
|
11
11
|
gem 'sufia', :path=>'../../'
|
12
12
|
gem 'rspec-rails', :group=>:test
|
data/sufia.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_dependency 'rails', '~> 3.2.8'
|
19
19
|
gem.add_dependency 'blacklight', '~> 4.0.0'
|
20
20
|
gem.add_dependency 'blacklight_advanced_search'
|
21
|
-
gem.add_dependency "hydra-head", "
|
22
|
-
gem.add_dependency "active-fedora", "
|
21
|
+
gem.add_dependency "hydra-head", ">= 5.3"
|
22
|
+
gem.add_dependency "active-fedora", ">= 5.5"
|
23
23
|
|
24
24
|
gem.add_dependency 'noid', '0.5.5'
|
25
25
|
gem.add_dependency 'hydra-batch-edit', '~> 0.1.0'
|
@@ -29,11 +29,9 @@ Gem::Specification.new do |gem|
|
|
29
29
|
gem.add_dependency 'resque-pool', '0.3.0'
|
30
30
|
# NOTE: the :require arg is necessary on Linux-based hosts
|
31
31
|
gem.add_dependency 'rmagick', '2.13.1'#, :require => 'RMagick'
|
32
|
-
gem.add_dependency 'devise'
|
32
|
+
gem.add_dependency 'devise'
|
33
33
|
gem.add_dependency 'paperclip', '3.3.0'
|
34
34
|
gem.add_dependency 'daemons', '1.1.9'
|
35
|
-
gem.add_dependency 'execjs', '1.4.0'
|
36
|
-
gem.add_dependency 'therubyracer', '0.10.2'
|
37
35
|
gem.add_dependency 'zipruby', '0.3.6'
|
38
36
|
gem.add_dependency 'mail_form'
|
39
37
|
gem.add_dependency 'rails_autolink', '1.0.9'
|
@@ -176,7 +176,7 @@ $(function () {
|
|
176
176
|
|
177
177
|
// Open download dialogs via iframes,
|
178
178
|
// to prevent aborting current uploads:
|
179
|
-
$('#fileupload .files a:not([target^=_blank])'
|
179
|
+
$(document).on('click', '#fileupload .files a:not([target^=_blank])', function (e) {
|
180
180
|
e.preventDefault();
|
181
181
|
$('<iframe style="display:none;"></iframe>')
|
182
182
|
.prop('src', this.href)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sufia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -64,33 +64,33 @@ dependencies:
|
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ! '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '5.
|
69
|
+
version: '5.3'
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '5.
|
77
|
+
version: '5.3'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: active-fedora
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ! '>='
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 5.5
|
85
|
+
version: '5.5'
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 5.5
|
93
|
+
version: '5.5'
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: noid
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,17 +176,17 @@ dependencies:
|
|
176
176
|
requirement: !ruby/object:Gem::Requirement
|
177
177
|
none: false
|
178
178
|
requirements:
|
179
|
-
- - '
|
179
|
+
- - ! '>='
|
180
180
|
- !ruby/object:Gem::Version
|
181
|
-
version:
|
181
|
+
version: '0'
|
182
182
|
type: :runtime
|
183
183
|
prerelease: false
|
184
184
|
version_requirements: !ruby/object:Gem::Requirement
|
185
185
|
none: false
|
186
186
|
requirements:
|
187
|
-
- - '
|
187
|
+
- - ! '>='
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
189
|
+
version: '0'
|
190
190
|
- !ruby/object:Gem::Dependency
|
191
191
|
name: paperclip
|
192
192
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,38 +219,6 @@ dependencies:
|
|
219
219
|
- - '='
|
220
220
|
- !ruby/object:Gem::Version
|
221
221
|
version: 1.1.9
|
222
|
-
- !ruby/object:Gem::Dependency
|
223
|
-
name: execjs
|
224
|
-
requirement: !ruby/object:Gem::Requirement
|
225
|
-
none: false
|
226
|
-
requirements:
|
227
|
-
- - '='
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: 1.4.0
|
230
|
-
type: :runtime
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
none: false
|
234
|
-
requirements:
|
235
|
-
- - '='
|
236
|
-
- !ruby/object:Gem::Version
|
237
|
-
version: 1.4.0
|
238
|
-
- !ruby/object:Gem::Dependency
|
239
|
-
name: therubyracer
|
240
|
-
requirement: !ruby/object:Gem::Requirement
|
241
|
-
none: false
|
242
|
-
requirements:
|
243
|
-
- - '='
|
244
|
-
- !ruby/object:Gem::Version
|
245
|
-
version: 0.10.2
|
246
|
-
type: :runtime
|
247
|
-
prerelease: false
|
248
|
-
version_requirements: !ruby/object:Gem::Requirement
|
249
|
-
none: false
|
250
|
-
requirements:
|
251
|
-
- - '='
|
252
|
-
- !ruby/object:Gem::Version
|
253
|
-
version: 0.10.2
|
254
222
|
- !ruby/object:Gem::Dependency
|
255
223
|
name: zipruby
|
256
224
|
requirement: !ruby/object:Gem::Requirement
|
@@ -792,6 +760,7 @@ files:
|
|
792
760
|
- lib/sufia/file_content/versions.rb
|
793
761
|
- lib/sufia/files_controller_behavior.rb
|
794
762
|
- lib/sufia/generic_file.rb
|
763
|
+
- lib/sufia/generic_file/actions.rb
|
795
764
|
- lib/sufia/generic_file/audit.rb
|
796
765
|
- lib/sufia/generic_file/characterization.rb
|
797
766
|
- lib/sufia/generic_file/export.rb
|
@@ -833,6 +802,7 @@ files:
|
|
833
802
|
- spec/controllers/_sort_and_per_page.html.erb
|
834
803
|
- spec/controllers/authorities_controller_spec.rb
|
835
804
|
- spec/controllers/batch_controller_spec.rb
|
805
|
+
- spec/controllers/batch_edits_controller_spec.rb
|
836
806
|
- spec/controllers/catalog_controller_spec.rb
|
837
807
|
- spec/controllers/dashboard_controller_spec.rb
|
838
808
|
- spec/controllers/downloads_controller_spec.rb
|
@@ -1000,6 +970,7 @@ test_files:
|
|
1000
970
|
- spec/controllers/_sort_and_per_page.html.erb
|
1001
971
|
- spec/controllers/authorities_controller_spec.rb
|
1002
972
|
- spec/controllers/batch_controller_spec.rb
|
973
|
+
- spec/controllers/batch_edits_controller_spec.rb
|
1003
974
|
- spec/controllers/catalog_controller_spec.rb
|
1004
975
|
- spec/controllers/dashboard_controller_spec.rb
|
1005
976
|
- spec/controllers/downloads_controller_spec.rb
|