hydra-batch-edit 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -58,7 +58,7 @@ module Hydra::BatchEditBehavior
|
|
58
58
|
batch.each do |doc_id|
|
59
59
|
obj = ActiveFedora::Base.find(doc_id, :cast=>true)
|
60
60
|
type = obj.class.to_s.underscore.to_sym
|
61
|
-
obj.update_attributes(params[type])
|
61
|
+
obj.update_attributes(params[type].reject{|k, v| v.blank?})
|
62
62
|
obj.save
|
63
63
|
end
|
64
64
|
flash[:notice] = "Batch update complete"
|
@@ -98,17 +98,24 @@ describe BatchEditsController do
|
|
98
98
|
@two.save
|
99
99
|
put :add, :id =>@one.pid
|
100
100
|
put :add, :id => @two.pid
|
101
|
-
end
|
102
|
-
it "should update all the field" do
|
103
101
|
controller.should_receive(:can?).with(:edit, @one.pid).and_return(true)
|
104
102
|
controller.should_receive(:can?).with(:edit, @two.pid).and_return(true)
|
105
103
|
ActiveFedora::Base.should_receive(:find).with( @one.pid, :cast=>true).and_return(@one)
|
106
104
|
ActiveFedora::Base.should_receive(:find).with( @two.pid, :cast=>true).and_return(@two)
|
105
|
+
end
|
106
|
+
it "should update all the field" do
|
107
107
|
put :update, :sample=>{:titleSet_display=>'My title' }
|
108
108
|
response.should redirect_to '/catalog'
|
109
109
|
flash[:notice].should == "Batch update complete"
|
110
110
|
Sample.find(@one.pid).titleSet_display.should == "My title"
|
111
111
|
end
|
112
|
+
it "should not update blank values" do
|
113
|
+
@one.titleSet_display = 'Original value'
|
114
|
+
put :update, :sample=>{:titleSet_display=>'' }
|
115
|
+
response.should redirect_to '/catalog'
|
116
|
+
flash[:notice].should == "Batch update complete"
|
117
|
+
Sample.find(@one.pid).titleSet_display.should == "Original value"
|
118
|
+
end
|
112
119
|
end
|
113
120
|
end
|
114
121
|
|
@@ -16,11 +16,10 @@ class Sample
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def update_attributes(attributes)
|
19
|
-
metaclass = class << self; self; end
|
20
19
|
attributes.each do |k, v|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
instance_variable_set "@#{k.to_s}".to_sym, v
|
21
|
+
|
22
|
+
self.class.send :attr_accessor, k
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-batch-edit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-06-
|
13
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: blacklight
|
@@ -153,3 +153,4 @@ test_files:
|
|
153
153
|
- spec/support/app/models/solr_document.rb
|
154
154
|
- spec/support/db/migrate/20111101221803_create_searches.rb
|
155
155
|
- spec/support/lib/generators/test_app_generator.rb
|
156
|
+
has_rdoc:
|