active-fedora 6.4.2 → 6.4.3
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.
- checksums.yaml +4 -4
- data/.mailmap +15 -6
- data/active-fedora.gemspec +2 -2
- data/gemfiles/gemfile.rails4 +1 -1
- data/lib/active_fedora.rb +8 -12
- data/lib/active_fedora/digital_object.rb +1 -0
- data/lib/active_fedora/model.rb +6 -6
- data/lib/active_fedora/om_datastream.rb +14 -3
- data/lib/active_fedora/querying.rb +6 -5
- data/lib/active_fedora/solr_service.rb +15 -10
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora_dev.rake +1 -17
- data/spec/config_helper.rb +1 -1
- data/spec/{unit → integration}/auditable_spec.rb +5 -7
- data/spec/integration/base_spec.rb +2 -1
- data/spec/integration/bug_spec.rb +6 -0
- data/spec/integration/complex_rdf_datastream_spec.rb +3 -3
- data/spec/integration/model_spec.rb +8 -7
- data/spec/integration/om_datastream_spec.rb +78 -73
- data/spec/integration/rdf_nested_attributes_spec.rb +2 -2
- data/spec/integration/solr_instance_loader_spec.rb +9 -4
- data/spec/integration/solr_service_spec.rb +2 -8
- data/spec/support/mock_fedora.rb +6 -6
- data/spec/unit/active_fedora_spec.rb +12 -1
- data/spec/unit/base_extra_spec.rb +10 -10
- data/spec/unit/base_spec.rb +18 -18
- data/spec/unit/content_model_spec.rb +6 -6
- data/spec/unit/datastream_spec.rb +1 -1
- data/spec/unit/datastreams_spec.rb +19 -19
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +6 -6
- data/spec/unit/has_many_collection_spec.rb +3 -3
- data/spec/unit/ntriples_datastream_spec.rb +2 -2
- data/spec/unit/om_datastream_spec.rb +6 -6
- data/spec/unit/query_spec.rb +11 -11
- data/spec/unit/rdf_list_spec.rb +2 -2
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +2 -2
- data/spec/unit/rels_ext_datastream_spec.rb +6 -6
- data/spec/unit/semantic_node_spec.rb +5 -5
- data/spec/unit/solr_config_options_spec.rb +1 -1
- data/spec/unit/solr_service_spec.rb +42 -20
- metadata +10 -23
- data/spec/fixtures/auditable.foxml.xml +0 -110
- data/spec/fixtures/changeme155.xml +0 -255
- data/spec/fixtures/test_12.foxml.xml +0 -60
- data/spec/fixtures/test_fixture_mods_article1.foxml.xml +0 -234
- data/spec/fixtures/test_fixture_mods_article2.foxml.xml +0 -234
- data/spec/hydrangea_fixture_mods_article1.foxml.xml +0 -225
- data/spec/integration/mods_article_integration_spec.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9395c7f327612946bfc5d90b4f8cdcf93af0a49
|
4
|
+
data.tar.gz: 13f08cd89e3b35e3b3b437cc13d5db8df934b022
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 036af5cc43ab70dcca4ca55da21f1961bb6e1047a96f48256019102adac6b43e35dacc6ed5b0776a44ff949c15c4c1144d1c54e6d8979dcbb6b51482cd0b66e7
|
7
|
+
data.tar.gz: 025ae1503457b5427a05d9bd408e84594d137fbb94bd2e7b8d98f433f505ee3988ccab442de9a5e67b421c30981a137024e18b3b513d2a30d0da54825b31982d
|
data/.mailmap
CHANGED
@@ -1,9 +1,18 @@
|
|
1
|
-
Mark Bussey <mark@curationexperts.com> mark-dce <mark@curationexperts.com>
|
2
1
|
Andrew Myers <andrew_myers@wgbh.org> afred <afredmyers@gmail.com>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
Justin Coyne <justin@curationexperts.com> jcoyne <digger250@gmail.com>
|
2
|
+
Chris Beer <chris@cbeer.info> <cabeer@stanford.edu>
|
3
|
+
Chris Beer <chris@cbeer.info> <chris@cbeer.info>
|
4
|
+
Chris Beer <chris@cbeer.info> <chris_beer@wgbh.org>
|
7
5
|
Chris Colvard <cjcolvar@indiana.edu> cjcolvar <cjcolvar@indiana.edu>
|
8
6
|
David Chandek-Stark <dchandekstark@gmail.com> dchandekstark <dchandekstark@gmail.com>
|
9
|
-
|
7
|
+
Justin Coyne <justin@curationexperts.com> <digger250@gmail.com>
|
8
|
+
Justin Coyne <justin@curationexperts.com> <justin.coyne@yourmediashelf.com>
|
9
|
+
Justin Coyne <justin@curationexperts.com> jcoyne <digger250@gmail.com>
|
10
|
+
Justin Coyne <justin@curationexperts.com> <jcoyne@justincoyne.com>
|
11
|
+
Jesse Keck <jessie.keck@gmail.com> <jkeck@stanford.edu>
|
12
|
+
Jesse Keck <jessie.keck@gmail.com> <jessie.keck@gmail.com>
|
13
|
+
Mark Bussey <mark@curationexperts.com> mark-dce <mark@curationexperts.com>
|
14
|
+
Matt Zumwalt <matt.zumwalt@yourmediashelf.com> flyingzumwalt <matt.zumwalt@gmail.com>
|
15
|
+
Richard Johnson <rick.johnson@nd.edu> rickjohnson <rick.johnson@nd.edu>
|
16
|
+
Richard Johnson <rick.johnson@nd.edu> rjohns14 <rjohns14@LIB-1224.library.nd.edu>
|
17
|
+
Richard Johnson <rick.johnson@nd.edu> rjohns14@github.com <rjohns14@LIB-1224.library.nd.edu>
|
18
|
+
Michael B. Klein <mbklein@gmail.com>
|
data/active-fedora.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = %q{https://github.com/projecthydra/active_fedora}
|
12
12
|
s.summary = %q{A convenience libary for manipulating documents in the Fedora Repository.}
|
13
13
|
s.description = %q{ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.}
|
14
|
-
|
14
|
+
s.license = "APACHE2"
|
15
15
|
s.required_ruby_version = '>= 1.9.3'
|
16
16
|
|
17
17
|
s.add_dependency('rsolr')
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency("mediashelf-loggable")
|
22
22
|
s.add_dependency("rubydora", '~>1.6', '>= 1.6.5')
|
23
23
|
s.add_dependency("rdf")
|
24
|
-
s.add_dependency("rdf-rdfxml", '
|
24
|
+
s.add_dependency("rdf-rdfxml", '1.0.1')
|
25
25
|
s.add_dependency("deprecation")
|
26
26
|
s.add_development_dependency("rdoc")
|
27
27
|
s.add_development_dependency("yard")
|
data/gemfiles/gemfile.rails4
CHANGED
data/lib/active_fedora.rb
CHANGED
@@ -157,20 +157,16 @@ module ActiveFedora #:nodoc:
|
|
157
157
|
# @example Search within ActiveFedora::RdfNode for a class called "TermProxy"
|
158
158
|
# ActiveFedora.class_from_string("TermProxy", ActiveFedora::RdfNode)
|
159
159
|
# => ActiveFedora::RdfNode::TermProxy
|
160
|
-
def self.class_from_string(class_name, container_class=
|
161
|
-
if
|
162
|
-
|
163
|
-
|
160
|
+
def self.class_from_string(class_name, container_class=Kernel)
|
161
|
+
container_class = container_class.name if container_class.is_a? Module
|
162
|
+
container_parts = container_class.split('::')
|
163
|
+
(container_parts + class_name.split('::')).flatten.inject(Kernel) do |mod, class_name|
|
164
|
+
if mod.const_defined? class_name.to_sym
|
164
165
|
mod.const_get(class_name)
|
166
|
+
else
|
167
|
+
container_parts.pop
|
168
|
+
class_from_string(class_name, container_parts.join('::'))
|
165
169
|
end
|
166
|
-
elsif !container_class.nil?
|
167
|
-
begin
|
168
|
-
container_class.const_get(class_name.to_sym)
|
169
|
-
rescue NameError
|
170
|
-
Kernel.const_get(class_name)
|
171
|
-
end
|
172
|
-
else
|
173
|
-
Kernel.const_get(class_name)
|
174
170
|
end
|
175
171
|
end
|
176
172
|
|
@@ -31,6 +31,7 @@ module ActiveFedora
|
|
31
31
|
include DatastreamBootstrap
|
32
32
|
|
33
33
|
def self.find(original_class, pid)
|
34
|
+
raise ActiveFedora::ObjectNotFoundError.new("Unable to find #{pid.inspect} in fedora. ") unless pid.present?
|
34
35
|
conn = original_class.connection_for_pid(pid)
|
35
36
|
obj = begin
|
36
37
|
super(pid, conn)
|
data/lib/active_fedora/model.rb
CHANGED
@@ -37,15 +37,15 @@ module ActiveFedora
|
|
37
37
|
# Returns a suitable uri object for :has_model
|
38
38
|
# Should reverse Model#from_class_uri
|
39
39
|
def to_class_uri(attrs = {})
|
40
|
-
|
41
|
-
pid_suffix = attrs.has_key?(:pid_suffix) ? attrs[:pid_suffix] : ContentModel::CMODEL_PID_SUFFIX
|
42
|
-
else
|
40
|
+
if self.respond_to? :pid_suffix
|
43
41
|
pid_suffix = self.pid_suffix
|
44
|
-
end
|
45
|
-
unless self.respond_to? :pid_namespace
|
46
|
-
namespace = attrs.has_key?(:namespace) ? attrs[:namespace] : ContentModel::CMODEL_NAMESPACE
|
47
42
|
else
|
43
|
+
pid_suffix = attrs.fetch(:pid_suffix, ContentModel::CMODEL_PID_SUFFIX)
|
44
|
+
end
|
45
|
+
if self.respond_to? :pid_namespace
|
48
46
|
namespace = self.pid_namespace
|
47
|
+
else
|
48
|
+
namespace = attrs.fetch(:namespace, ContentModel::CMODEL_NAMESPACE)
|
49
49
|
end
|
50
50
|
"info:fedora/#{namespace}:#{ContentModel.sanitized_class_name(self)}#{pid_suffix}"
|
51
51
|
end
|
@@ -108,9 +108,20 @@ module ActiveFedora
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def content=(new_content)
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
if inline?
|
112
|
+
# inline datastreams may be transformed by fedora 3, so we test for equivalence instead of equality
|
113
|
+
if !EquivalentXml.equivalent?(datastream_content, new_content)
|
114
|
+
ng_xml_will_change!
|
115
|
+
@ng_xml = Nokogiri::XML::Document.parse(new_content)
|
116
|
+
super(@ng_xml.to_s)
|
117
|
+
end
|
118
|
+
else
|
119
|
+
if datastream_content != new_content
|
120
|
+
ng_xml_will_change!
|
121
|
+
@ng_xml = Nokogiri::XML::Document.parse(new_content)
|
122
|
+
super(@ng_xml.to_s)
|
123
|
+
end
|
124
|
+
end
|
114
125
|
end
|
115
126
|
|
116
127
|
def content_changed?
|
@@ -68,13 +68,14 @@ module ActiveFedora
|
|
68
68
|
end
|
69
69
|
|
70
70
|
|
71
|
-
# Returns true if the pid exists in the repository
|
72
|
-
# @param[String] pid
|
73
|
-
# @return[boolean]
|
71
|
+
# Returns true if the pid exists in the repository
|
72
|
+
# @param[String] pid
|
73
|
+
# @return[boolean]
|
74
74
|
def exists?(pid)
|
75
75
|
return false if pid.nil? || pid.empty?
|
76
|
-
|
77
|
-
|
76
|
+
!!DigitalObject.find(self, pid)
|
77
|
+
rescue ActiveFedora::ObjectNotFoundError
|
78
|
+
false
|
78
79
|
end
|
79
80
|
|
80
81
|
# Returns a solr result matching the supplied conditions
|
@@ -32,18 +32,23 @@ module ActiveFedora
|
|
32
32
|
raise SolrNotInitialized unless Thread.current[:solr_service]
|
33
33
|
Thread.current[:solr_service]
|
34
34
|
end
|
35
|
-
|
36
|
-
def self.
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
if opts[:load_from_solr]
|
41
|
-
results << classname.load_instance_from_solr(hit[SOLR_DOCUMENT_ID])
|
42
|
-
else
|
43
|
-
results << classname.find(hit[SOLR_DOCUMENT_ID])
|
35
|
+
|
36
|
+
def self.lazy_reify_solr_results(solr_results, opts = {})
|
37
|
+
Enumerator.new do |yielder|
|
38
|
+
solr_results.each do |hit|
|
39
|
+
yielder.yield(reify_solr_result(hit, opts))
|
44
40
|
end
|
45
41
|
end
|
46
|
-
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.reify_solr_results(solr_results, opts = {})
|
45
|
+
solr_results.collect {|hit| reify_solr_result(hit, opts)}
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.reify_solr_result(hit, opts = {})
|
49
|
+
classname = class_from_solr_document(hit)
|
50
|
+
method = opts[:load_from_solr] ? :load_instance_from_solr : :find
|
51
|
+
classname.send(method, hit[SOLR_DOCUMENT_ID])
|
47
52
|
end
|
48
53
|
|
49
54
|
def self.class_from_solr_document(hit)
|
@@ -36,21 +36,6 @@ require 'rspec/core/rake_task'
|
|
36
36
|
spec.rcov = true
|
37
37
|
end
|
38
38
|
|
39
|
-
desc "Loads or refreshes the fixtures needed to run the tests"
|
40
|
-
task :fixtures => :environment do
|
41
|
-
ENV["pid"] = "test:fixture_mods_article1"
|
42
|
-
Rake::Task["repo:refresh"].invoke
|
43
|
-
ENV["pid"] = nil
|
44
|
-
|
45
|
-
Rake::Task["repo:delete"].reenable
|
46
|
-
Rake::Task["repo:load"].reenable
|
47
|
-
Rake::Task["repo:refresh"].reenable
|
48
|
-
|
49
|
-
ENV["pid"] = "test:fixture_mods_article2"
|
50
|
-
Rake::Task["repo:refresh"].invoke
|
51
|
-
ENV["pid"] = nil
|
52
|
-
end
|
53
|
-
|
54
39
|
desc "Copies the default SOLR config for the bundled Testing Server"
|
55
40
|
task :configure_jetty do
|
56
41
|
FileList['lib/generators/active_fedora/config/solr/templates/solr_conf/conf/*'].each do |f|
|
@@ -79,9 +64,8 @@ task :coverage do
|
|
79
64
|
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
|
80
65
|
ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
|
81
66
|
|
82
|
-
|
67
|
+
# Rake::Task["active_fedora:fixtures"].invoke
|
83
68
|
Rake::Task["active_fedora:rspec"].invoke
|
84
69
|
end
|
85
70
|
|
86
71
|
end
|
87
|
-
|
data/spec/config_helper.rb
CHANGED
@@ -6,25 +6,23 @@ describe ActiveFedora::Auditable do
|
|
6
6
|
class AuditableModel < ActiveFedora::Base
|
7
7
|
include ActiveFedora::Auditable
|
8
8
|
end
|
9
|
-
|
10
|
-
|
11
|
-
ActiveFedora::FixtureLoader.index(pid)
|
12
|
-
@test_object = AuditableModel.find(pid)
|
9
|
+
@test_object = AuditableModel.create
|
10
|
+
@test_object.reload
|
13
11
|
end
|
14
12
|
after(:all) do
|
15
13
|
@test_object.delete
|
16
14
|
end
|
17
15
|
it "should have the correct number of audit records" do
|
18
|
-
@test_object.audit_trail.records.length.should ==
|
16
|
+
@test_object.audit_trail.records.length.should == 1
|
19
17
|
end
|
20
18
|
it "should return all the data from each audit record" do
|
21
|
-
record = @test_object.audit_trail.records.
|
19
|
+
record = @test_object.audit_trail.records.last
|
22
20
|
record.id.should == "AUDREC1"
|
23
21
|
record.process_type.should == "Fedora API-M"
|
24
22
|
record.action.should == "addDatastream"
|
25
23
|
record.component_id.should == "RELS-EXT"
|
26
24
|
record.responsibility.should == "fedoraAdmin"
|
27
|
-
record.date.should ==
|
25
|
+
record.date.should == @test_object.modified_date
|
28
26
|
record.justification.should == ""
|
29
27
|
end
|
30
28
|
|
@@ -415,7 +415,8 @@ describe ActiveFedora::Base do
|
|
415
415
|
|
416
416
|
describe "#exists?" do
|
417
417
|
it "should return true for objects that exist" do
|
418
|
-
ActiveFedora::Base.
|
418
|
+
@obj = ActiveFedora::Base.create
|
419
|
+
ActiveFedora::Base.exists?(@obj.pid).should be_true
|
419
420
|
end
|
420
421
|
it "should return false for objects that don't exist" do
|
421
422
|
ActiveFedora::Base.exists?('test:missing_object').should be_false
|
@@ -20,6 +20,12 @@ describe 'bugs' do
|
|
20
20
|
Object.send(:remove_const, :FooHistory)
|
21
21
|
end
|
22
22
|
|
23
|
+
it 'should raise ActiveFedora::ObjectNotFoundError when find("")' do
|
24
|
+
expect {
|
25
|
+
FooHistory.find('')
|
26
|
+
}.to raise_error(ActiveFedora::ObjectNotFoundError)
|
27
|
+
end
|
28
|
+
|
23
29
|
it "should not clobber everything when setting a value" do
|
24
30
|
@test_object.someData.fubar=['initial']
|
25
31
|
@test_object.save!
|
@@ -23,7 +23,7 @@ describe "Nested Rdf Objects" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
let (:ds) do
|
26
|
-
mock_obj =
|
26
|
+
mock_obj = double(:mock_obj, :pid=>'test:124', :new? => true)
|
27
27
|
ds = SpecDatastream.new(mock_obj)
|
28
28
|
end
|
29
29
|
|
@@ -140,7 +140,7 @@ END
|
|
140
140
|
end
|
141
141
|
|
142
142
|
let (:ds) do
|
143
|
-
mock_obj =
|
143
|
+
mock_obj = double(:mock_obj, :pid=>'test:124', :new? => true)
|
144
144
|
ds = SpecDatastream.new(mock_obj)
|
145
145
|
end
|
146
146
|
|
@@ -209,7 +209,7 @@ END
|
|
209
209
|
end
|
210
210
|
|
211
211
|
let (:ds) do
|
212
|
-
mock_obj =
|
212
|
+
mock_obj = double(:mock_obj, :pid=>'test:124', :new? => true)
|
213
213
|
ds = SpecDatastream.new(mock_obj)
|
214
214
|
end
|
215
215
|
|
@@ -10,6 +10,7 @@ describe ActiveFedora::Model do
|
|
10
10
|
def self.pid_namespace
|
11
11
|
"foo"
|
12
12
|
end
|
13
|
+
has_metadata :name => "properties", :type => ActiveFedora::SimpleDatastream, :autocreate => true
|
13
14
|
end
|
14
15
|
class Basic < Base
|
15
16
|
end
|
@@ -38,28 +39,28 @@ describe ActiveFedora::Model do
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
describe "#find with a valid pid with cast" do
|
41
|
-
subject { ActiveFedora::Base.find(
|
42
|
-
it { should be_instance_of
|
42
|
+
subject { ActiveFedora::Base.find(@test_instance.pid, :cast=>true) }
|
43
|
+
it { should be_instance_of ModelIntegrationSpec::Basic}
|
43
44
|
end
|
44
45
|
describe "#find with a valid pid without cast" do
|
45
|
-
subject { ActiveFedora::Base.find(
|
46
|
+
subject { ActiveFedora::Base.find(@test_instance.pid) }
|
46
47
|
it { should be_instance_of ActiveFedora::Base}
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
51
|
describe "#load_instance_from_solr" do
|
51
52
|
describe "with a valid pid" do
|
52
|
-
subject { ActiveFedora::Base.load_instance_from_solr(
|
53
|
-
it { should be_instance_of
|
53
|
+
subject { ActiveFedora::Base.load_instance_from_solr(@test_instance.pid) }
|
54
|
+
it { should be_instance_of ModelIntegrationSpec::Basic}
|
54
55
|
end
|
55
56
|
describe "with metadata datastream spec" do
|
56
|
-
subject { ActiveFedora::Base.load_instance_from_solr(
|
57
|
+
subject { ActiveFedora::Base.load_instance_from_solr(@test_instance.pid) }
|
57
58
|
it "should create an xml datastream" do
|
58
59
|
subject.datastreams['properties'].should be_kind_of ActiveFedora::SimpleDatastream
|
59
60
|
end
|
60
61
|
|
61
62
|
it "should know the datastreams properties" do
|
62
|
-
subject.properties.dsSize.should ==
|
63
|
+
subject.properties.dsSize.should == 9
|
63
64
|
end
|
64
65
|
end
|
65
66
|
end
|
@@ -3,22 +3,32 @@ require "solrizer"
|
|
3
3
|
|
4
4
|
describe ActiveFedora::OmDatastream do
|
5
5
|
|
6
|
-
describe "
|
7
|
-
before do
|
6
|
+
describe "a new instance with an inline datastream" do
|
7
|
+
before(:all) do
|
8
8
|
class ModsArticle3 < ActiveFedora::Base
|
9
9
|
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
10
|
-
has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream, :control_group => 'X'
|
11
|
-
|
10
|
+
has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream, :control_group => 'X', :autocreate => true
|
12
11
|
end
|
12
|
+
end
|
13
13
|
|
14
|
+
after(:all) do
|
15
|
+
Object.send(:remove_const, :ModsArticle3)
|
16
|
+
end
|
17
|
+
|
18
|
+
before(:each) do
|
14
19
|
@obj = ModsArticle3.new
|
15
20
|
@obj.save
|
16
|
-
@obj.
|
21
|
+
@obj.reload
|
17
22
|
end
|
18
|
-
|
23
|
+
|
24
|
+
after(:each) do
|
19
25
|
@obj.destroy
|
20
|
-
Object.send(:remove_const, :ModsArticle3)
|
21
26
|
end
|
27
|
+
|
28
|
+
it "should report being inline" do
|
29
|
+
@obj.descMetadata.should be_inline
|
30
|
+
end
|
31
|
+
|
22
32
|
it "should not be changed when no fields have been set" do
|
23
33
|
@obj.descMetadata.should_not be_content_changed
|
24
34
|
end
|
@@ -28,30 +38,25 @@ describe ActiveFedora::OmDatastream do
|
|
28
38
|
end
|
29
39
|
describe "#changed?" do
|
30
40
|
it "should not be changed if the new xml matches the old xml" do
|
31
|
-
@
|
32
|
-
@
|
33
|
-
|
34
|
-
@test_object.descMetadata.ng_xml = @test_object.descMetadata.ng_xml
|
35
|
-
@test_object.descMetadata.should_not be_changed
|
41
|
+
@obj.descMetadata.content = @obj.descMetadata.content
|
42
|
+
@obj.descMetadata.should_not be_changed
|
36
43
|
end
|
37
44
|
|
38
45
|
it "should not be changed if there are minor differences in whitespace" do
|
39
|
-
obj =
|
40
|
-
obj.
|
41
|
-
obj.
|
42
|
-
obj.descMetadata.
|
43
|
-
obj.descMetadata.
|
44
|
-
obj.descMetadata.should_not be_changed
|
46
|
+
@obj.descMetadata.content = "<a><b>1</b></a>"
|
47
|
+
@obj.save
|
48
|
+
@obj.descMetadata.should_not be_changed
|
49
|
+
@obj.descMetadata.content = "<a>\n<b>1</b>\n</a>"
|
50
|
+
@obj.descMetadata.should_not be_changed
|
45
51
|
end
|
46
52
|
end
|
47
53
|
end
|
48
54
|
|
49
|
-
|
50
55
|
describe "an instance that is a managed datastream" do
|
51
56
|
before(:all) do
|
52
57
|
class ModsArticle2 < ActiveFedora::Base
|
53
58
|
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
54
|
-
has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream
|
59
|
+
has_metadata :name => "descMetadata", :type => Hydra::ModsArticleDatastream, :autocreate => true
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
@@ -59,67 +64,71 @@ describe ActiveFedora::OmDatastream do
|
|
59
64
|
Object.send(:remove_const, :ModsArticle2)
|
60
65
|
end
|
61
66
|
|
67
|
+
before(:each) do
|
68
|
+
@obj = ModsArticle2.new
|
69
|
+
@obj.save
|
70
|
+
@obj.reload
|
71
|
+
end
|
72
|
+
|
73
|
+
after(:each) do
|
74
|
+
@obj.destroy
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should not report being inline" do
|
78
|
+
@obj.descMetadata.should be_managed
|
79
|
+
end
|
80
|
+
|
62
81
|
describe "#changed?" do
|
63
82
|
it "should not be changed if the new xml matches the old xml" do
|
64
|
-
@
|
65
|
-
@
|
66
|
-
|
67
|
-
@test_object.descMetadata.ng_xml = @test_object.descMetadata.ng_xml
|
68
|
-
@test_object.descMetadata.should_not be_changed
|
83
|
+
@obj.descMetadata.content = @obj.descMetadata.content
|
84
|
+
@obj.descMetadata.should_not be_changed
|
69
85
|
end
|
70
86
|
|
71
87
|
it "should be changed if there are minor differences in whitespace" do
|
72
|
-
obj =
|
73
|
-
obj.
|
74
|
-
obj.
|
75
|
-
obj.descMetadata.
|
76
|
-
obj.descMetadata.
|
77
|
-
obj.descMetadata.should be_changed
|
88
|
+
@obj.descMetadata.content = "<a><b>1</b></a>"
|
89
|
+
@obj.save
|
90
|
+
@obj.descMetadata.should_not be_changed
|
91
|
+
@obj.descMetadata.content = "<a>\n<b>1</b>\n</a>"
|
92
|
+
@obj.descMetadata.should be_changed
|
78
93
|
end
|
79
94
|
end
|
80
95
|
|
81
|
-
|
82
|
-
|
83
96
|
describe "empty datastream content" do
|
84
97
|
it "should not break when there is empty datastream content" do
|
85
|
-
obj =
|
86
|
-
obj.
|
87
|
-
obj.save
|
88
|
-
|
98
|
+
@obj.descMetadata.content = ""
|
99
|
+
@obj.save
|
89
100
|
end
|
90
101
|
end
|
91
102
|
|
92
103
|
describe '.term_values' do
|
93
104
|
before do
|
94
|
-
@
|
95
|
-
@
|
96
|
-
@
|
97
|
-
@
|
98
|
-
@test_object = ModsArticle2.find(@pid)
|
99
|
-
@test_solr_object = ActiveFedora::Base.load_instance_from_solr(@pid)
|
105
|
+
@obj.descMetadata.content = File.read(fixture('mods_articles/mods_article1.xml'))
|
106
|
+
@obj.save
|
107
|
+
@obj.reload
|
108
|
+
@solr_obj = ActiveFedora::Base.load_instance_from_solr(@obj.pid)
|
100
109
|
end
|
101
110
|
|
102
111
|
it "should return the same values whether getting from solr or Fedora" do
|
103
|
-
@
|
104
|
-
@
|
105
|
-
@
|
106
|
-
@
|
107
|
-
@
|
108
|
-
@
|
109
|
-
ar = @
|
112
|
+
@solr_obj.datastreams["descMetadata"].term_values(:name,:role,:text).should == ["Creator","Contributor","Funder","Host"]
|
113
|
+
@solr_obj.datastreams["descMetadata"].term_values({:name=>0},:role,:text).should == ["Creator"]
|
114
|
+
@solr_obj.datastreams["descMetadata"].term_values({:name=>1},:role,:text).should == ["Contributor"]
|
115
|
+
@solr_obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Creator"]
|
116
|
+
@solr_obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>0},:text).should == ["Contributor"]
|
117
|
+
@solr_obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>1},:text).should == []
|
118
|
+
ar = @solr_obj.datastreams["descMetadata"].term_values(:name,{:role=>0},:text)
|
110
119
|
ar.length.should == 4
|
111
120
|
ar.include?("Creator").should == true
|
112
121
|
ar.include?("Contributor").should == true
|
113
122
|
ar.include?("Funder").should == true
|
114
123
|
ar.include?("Host").should == true
|
115
124
|
|
116
|
-
@
|
117
|
-
@
|
118
|
-
@
|
119
|
-
@
|
120
|
-
@
|
121
|
-
@
|
122
|
-
ar = @
|
125
|
+
@obj.datastreams["descMetadata"].term_values(:name,:role,:text).should == ["Creator","Contributor","Funder","Host"]
|
126
|
+
@obj.datastreams["descMetadata"].term_values({:name=>0},:role,:text).should == ["Creator"]
|
127
|
+
@obj.datastreams["descMetadata"].term_values({:name=>1},:role,:text).should == ["Contributor"]
|
128
|
+
@obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Creator"]
|
129
|
+
@obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>0},:text).should == ["Contributor"]
|
130
|
+
@obj.datastreams["descMetadata"].term_values({:name=>1},{:role=>1},:text).should == []
|
131
|
+
ar = @obj.datastreams["descMetadata"].term_values(:name,{:role=>0},:text)
|
123
132
|
ar.length.should == 4
|
124
133
|
ar.include?("Creator").should == true
|
125
134
|
ar.include?("Contributor").should == true
|
@@ -130,33 +139,29 @@ describe ActiveFedora::OmDatastream do
|
|
130
139
|
|
131
140
|
describe '.update_values' do
|
132
141
|
before do
|
133
|
-
@
|
134
|
-
@
|
135
|
-
@
|
136
|
-
@test_object.save
|
137
|
-
@test_object = ModsArticle2.find(@pid)
|
142
|
+
@obj.descMetadata.content = File.read(fixture('mods_articles/mods_article1.xml'))
|
143
|
+
@obj.save
|
144
|
+
@obj.reload
|
138
145
|
end
|
139
146
|
|
140
147
|
it "should not be dirty after .update_values is saved" do
|
141
|
-
@
|
142
|
-
@
|
143
|
-
@
|
144
|
-
@
|
145
|
-
@
|
148
|
+
@obj.datastreams["descMetadata"].update_values([{:name=>0},{:role=>0},:text] =>"Funder")
|
149
|
+
@obj.datastreams["descMetadata"].should be_changed
|
150
|
+
@obj.save
|
151
|
+
@obj.datastreams["descMetadata"].should_not be_changed
|
152
|
+
@obj.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Funder"]
|
146
153
|
end
|
147
154
|
end
|
148
155
|
|
149
156
|
|
150
157
|
describe ".to_solr" do
|
151
158
|
before do
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
@test_object = ModsArticle2.find(object.pid)
|
156
|
-
|
159
|
+
@obj.descMetadata.journal.issue.publication_date = Date.parse('2012-11-02')
|
160
|
+
@obj.save!
|
161
|
+
@obj.reload
|
157
162
|
end
|
158
163
|
it "should solrize terms with :type=>'date' to *_dt solr terms" do
|
159
|
-
@
|
164
|
+
@obj.to_solr[ActiveFedora::SolrService.solr_name('mods_journal_issue_publication_date', type: :date)].should == ['2012-11-02T00:00:00Z']
|
160
165
|
end
|
161
166
|
end
|
162
167
|
end
|