active-fedora 6.2.0 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mailmap +9 -0
- data/CONTRIBUTORS.md +25 -0
- data/History.txt +52 -0
- data/active-fedora.gemspec +1 -1
- data/config/jetty.yml +1 -1
- data/gemfiles/gemfile.rails4 +1 -1
- data/lib/active_fedora/associations.rb +16 -1
- data/lib/active_fedora/associations/association_collection.rb +20 -2
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +7 -0
- data/lib/active_fedora/base.rb +32 -8
- data/lib/active_fedora/datastream.rb +7 -0
- data/lib/active_fedora/datastreams.rb +1 -0
- data/lib/active_fedora/nested_attributes.rb +34 -9
- data/lib/active_fedora/reflection.rb +7 -25
- data/lib/active_fedora/solr_digital_object.rb +4 -0
- data/lib/active_fedora/solr_service.rb +12 -9
- data/lib/active_fedora/unsaved_digital_object.rb +3 -0
- data/lib/active_fedora/validations.rb +7 -0
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora_dev.rake +2 -11
- data/spec/fixtures/mods_articles/{hydrangea_article1.xml → mods_article1.xml} +0 -0
- data/spec/fixtures/{hydrangea_fixture_mods_article1.foxml.xml → test_fixture_mods_article1.foxml.xml} +5 -5
- data/spec/fixtures/{hydrangea_fixture_mods_article2.foxml.xml → test_fixture_mods_article2.foxml.xml} +5 -5
- data/spec/integration/associations_spec.rb +116 -33
- data/spec/integration/base_spec.rb +13 -35
- data/spec/integration/datastream_collections_spec.rb +6 -5
- data/spec/integration/datastream_spec.rb +21 -18
- data/spec/integration/datastreams_spec.rb +1 -3
- data/spec/integration/model_spec.rb +6 -6
- data/spec/integration/mods_article_integration_spec.rb +2 -2
- data/spec/integration/nested_attribute_spec.rb +88 -10
- data/spec/integration/ntriples_datastream_spec.rb +1 -1
- data/spec/integration/om_datastream_spec.rb +22 -22
- data/spec/integration/solr_instance_loader_spec.rb +4 -4
- data/spec/integration/solr_service_spec.rb +1 -1
- data/spec/samples/models/{hydrangea_article.rb → mods_article.rb} +2 -2
- data/spec/samples/samples.rb +1 -1
- data/spec/unit/base_spec.rb +12 -12
- data/spec/unit/datastreams_spec.rb +0 -10
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +0 -27
- data/spec/unit/has_many_collection_spec.rb +0 -28
- data/spec/unit/om_datastream_spec.rb +6 -6
- data/spec/unit/query_spec.rb +2 -2
- data/spec/unit/solr_config_options_spec.rb +1 -1
- data/spec/unit/solr_service_spec.rb +9 -1
- data/spec/unit/validations_spec.rb +18 -11
- metadata +18 -10
@@ -58,13 +58,14 @@ module ActiveFedora
|
|
58
58
|
# If the pid_array is empty, defaults to a query of "id:NEVER_USE_THIS_ID", which will return an empty solr response
|
59
59
|
# @param [Array] pid_array the pids that you want included in the query
|
60
60
|
def self.construct_query_for_pids(pid_array)
|
61
|
-
|
62
|
-
pid_array.
|
63
|
-
|
64
|
-
query << " OR " if i != pid_array.length-1
|
61
|
+
|
62
|
+
q = pid_array.reject { |x| x.empty? }.map do |pid|
|
63
|
+
"_query_:\"{!raw f=#{SOLR_DOCUMENT_ID}}#{pid.gsub('"', '\"')}\""
|
65
64
|
end
|
66
|
-
|
67
|
-
return
|
65
|
+
|
66
|
+
return "id:NEVER_USE_THIS_ID" if q.empty?
|
67
|
+
|
68
|
+
return q.join(" OR ")
|
68
69
|
end
|
69
70
|
|
70
71
|
def self.solr_name(*args)
|
@@ -79,7 +80,7 @@ module ActiveFedora
|
|
79
80
|
# @param [Hash] args key is the predicate, value is the target_uri
|
80
81
|
def self.construct_query_for_rel(args)
|
81
82
|
clauses = args.map do |predicate, target_uri|
|
82
|
-
"
|
83
|
+
"_query_:\"{!raw f=#{solr_name(predicate, :symbol)}}#{target_uri.gsub('"', '\"')}\""
|
83
84
|
end
|
84
85
|
clauses.join(" AND ")
|
85
86
|
end
|
@@ -94,9 +95,11 @@ module ActiveFedora
|
|
94
95
|
|
95
96
|
# Get the count of records that match the query
|
96
97
|
# @param [String] query a solr query
|
98
|
+
# @param [Hash] args arguments to pass through to `args' param of SolrService.query (note that :rows will be overwritten to 0)
|
97
99
|
# @return [Integer] number of records matching
|
98
|
-
def self.count(query)
|
99
|
-
|
100
|
+
def self.count(query, args={})
|
101
|
+
args = args.merge(:raw=>true, :rows=>0)
|
102
|
+
SolrService.query(query, args)['response']['numFound'].to_i
|
100
103
|
end
|
101
104
|
|
102
105
|
def self.add(doc)
|
@@ -69,6 +69,13 @@ module ActiveFedora
|
|
69
69
|
output = super(context)
|
70
70
|
errors.empty? && output
|
71
71
|
end
|
72
|
+
|
73
|
+
# Test to see if the given field is required
|
74
|
+
# @param [Symbol] key a field
|
75
|
+
# @return [Boolean] is it required or not
|
76
|
+
def required?(key)
|
77
|
+
self.class.validators_on(key).any?{|v| v.kind_of? ActiveModel::Validations::PresenceValidator}
|
78
|
+
end
|
72
79
|
|
73
80
|
protected
|
74
81
|
|
@@ -38,7 +38,7 @@ require 'rspec/core/rake_task'
|
|
38
38
|
|
39
39
|
desc "Loads or refreshes the fixtures needed to run the tests"
|
40
40
|
task :fixtures => :environment do
|
41
|
-
ENV["pid"] = "
|
41
|
+
ENV["pid"] = "test:fixture_mods_article1"
|
42
42
|
Rake::Task["repo:refresh"].invoke
|
43
43
|
ENV["pid"] = nil
|
44
44
|
|
@@ -46,7 +46,7 @@ require 'rspec/core/rake_task'
|
|
46
46
|
Rake::Task["repo:load"].reenable
|
47
47
|
Rake::Task["repo:refresh"].reenable
|
48
48
|
|
49
|
-
ENV["pid"] = "
|
49
|
+
ENV["pid"] = "test:fixture_mods_article2"
|
50
50
|
Rake::Task["repo:refresh"].invoke
|
51
51
|
ENV["pid"] = nil
|
52
52
|
end
|
@@ -65,7 +65,6 @@ task :ci do
|
|
65
65
|
ENV['environment'] = "test"
|
66
66
|
Rake::Task["active_fedora:configure_jetty"].invoke
|
67
67
|
jetty_params = Jettywrapper.load_config
|
68
|
-
jetty_params[:startup_wait]= 60
|
69
68
|
error = Jettywrapper.wrap(jetty_params) do
|
70
69
|
Rake::Task['active_fedora:coverage'].invoke
|
71
70
|
end
|
@@ -84,13 +83,5 @@ task :coverage do
|
|
84
83
|
Rake::Task["active_fedora:rspec"].invoke
|
85
84
|
end
|
86
85
|
|
87
|
-
# Provides an :environment task for use while working within a working copy of active-fedora
|
88
|
-
# You should never load this rake file into any other application
|
89
|
-
desc 'Set up ActiveFedora environment. !! Only for use while working within a working copy of active-fedora'
|
90
|
-
task :environment do
|
91
|
-
puts "Initializing ActiveFedora Rake environment. This should only be called when working within a workign copy of the active-fedora code."
|
92
|
-
require "#{APP_ROOT}/spec/samples/models/hydrangea_article"
|
93
|
-
end
|
94
|
-
|
95
86
|
end
|
96
87
|
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<foxml:digitalObject VERSION="1.1" PID="
|
2
|
+
<foxml:digitalObject VERSION="1.1" PID="test:fixture_mods_article1"
|
3
3
|
xmlns:foxml="info:fedora/fedora-system:def/foxml#"
|
4
4
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5
5
|
xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
|
@@ -62,7 +62,7 @@ xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/
|
|
62
62
|
<foxml:datastreamVersion ID="DC1.0" LABEL="Dublin Core Record for this object" CREATED="2010-06-17T19:56:19.301Z" MIMETYPE="text/xml" FORMAT_URI="http://www.openarchives.org/OAI/2.0/oai_dc/" SIZE="360">
|
63
63
|
<foxml:xmlContent>
|
64
64
|
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
|
65
|
-
<dc:identifier>
|
65
|
+
<dc:identifier>test:fixture_mods_article1</dc:identifier>
|
66
66
|
</oai_dc:dc>
|
67
67
|
</foxml:xmlContent>
|
68
68
|
</foxml:datastreamVersion>
|
@@ -175,8 +175,8 @@ xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/
|
|
175
175
|
<foxml:datastreamVersion ID="RELS-EXT.0" LABEL="" CREATED="2010-06-17T19:56:22.353Z" MIMETYPE="text/xml" SIZE="306">
|
176
176
|
<foxml:xmlContent>
|
177
177
|
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
178
|
-
<rdf:Description rdf:about="info:fedora/
|
179
|
-
<hasModel xmlns="info:fedora/fedora-system:def/relations-external#" rdf:resource="info:fedora/afmodel:
|
178
|
+
<rdf:Description rdf:about="info:fedora/test:fixture_mods_article1">
|
179
|
+
<hasModel xmlns="info:fedora/fedora-system:def/relations-external#" rdf:resource="info:fedora/afmodel:ModsArticle"></hasModel>
|
180
180
|
</rdf:Description>
|
181
181
|
</rdf:RDF>
|
182
182
|
</foxml:xmlContent>
|
@@ -231,4 +231,4 @@ xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/
|
|
231
231
|
</foxml:xmlContent>
|
232
232
|
</foxml:datastreamVersion>
|
233
233
|
</foxml:datastream>
|
234
|
-
</foxml:digitalObject>
|
234
|
+
</foxml:digitalObject>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<foxml:digitalObject VERSION="1.1" PID="
|
2
|
+
<foxml:digitalObject VERSION="1.1" PID="test:fixture_mods_article2"
|
3
3
|
xmlns:foxml="info:fedora/fedora-system:def/foxml#"
|
4
4
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5
5
|
xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
|
@@ -62,7 +62,7 @@ xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/
|
|
62
62
|
<foxml:datastreamVersion ID="DC1.0" LABEL="Dublin Core Record for this object" CREATED="2010-06-17T19:56:19.301Z" MIMETYPE="text/xml" FORMAT_URI="http://www.openarchives.org/OAI/2.0/oai_dc/" SIZE="360">
|
63
63
|
<foxml:xmlContent>
|
64
64
|
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
|
65
|
-
<dc:identifier>
|
65
|
+
<dc:identifier>test:fixture_mods_article2</dc:identifier>
|
66
66
|
</oai_dc:dc>
|
67
67
|
</foxml:xmlContent>
|
68
68
|
</foxml:datastreamVersion>
|
@@ -175,8 +175,8 @@ xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/
|
|
175
175
|
<foxml:datastreamVersion ID="RELS-EXT.0" LABEL="" CREATED="2010-06-17T19:56:22.353Z" MIMETYPE="text/xml" SIZE="306">
|
176
176
|
<foxml:xmlContent>
|
177
177
|
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
178
|
-
<rdf:Description rdf:about="info:fedora/
|
179
|
-
<hasModel xmlns="info:fedora/fedora-system:def/relations-external#" rdf:resource="info:fedora/afmodel:
|
178
|
+
<rdf:Description rdf:about="info:fedora/test:fixture_mods_article2">
|
179
|
+
<hasModel xmlns="info:fedora/fedora-system:def/relations-external#" rdf:resource="info:fedora/afmodel:ModsArticle"></hasModel>
|
180
180
|
</rdf:Description>
|
181
181
|
</rdf:RDF>
|
182
182
|
</foxml:xmlContent>
|
@@ -231,4 +231,4 @@ xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/
|
|
231
231
|
</foxml:xmlContent>
|
232
232
|
</foxml:datastreamVersion>
|
233
233
|
</foxml:datastream>
|
234
|
-
</foxml:digitalObject>
|
234
|
+
</foxml:digitalObject>
|
@@ -160,16 +160,20 @@ describe ActiveFedora::Base do
|
|
160
160
|
|
161
161
|
describe "of has_many_and_belongs_to" do
|
162
162
|
before do
|
163
|
-
@topic1 = Topic.
|
164
|
-
@
|
165
|
-
@
|
166
|
-
@topic2.save
|
163
|
+
@topic1 = Topic.create
|
164
|
+
@topic2 = Topic.create
|
165
|
+
@book = Book.create
|
167
166
|
end
|
168
|
-
it "habtm should set relationships bidirectionally" do
|
169
|
-
@book = Book.new
|
167
|
+
it "habtm should set and remove relationships bidirectionally" do
|
170
168
|
@book.topics << @topic1
|
171
|
-
@book.topics.
|
172
|
-
|
169
|
+
@book.topics.should == [@topic1]
|
170
|
+
@topic1.books.should == [@book]
|
171
|
+
@topic1.reload.books.should == [@book]
|
172
|
+
|
173
|
+
@book.topics.delete(@topic1)
|
174
|
+
#@topic1.books.delete(@book)
|
175
|
+
@book.topics.should == []
|
176
|
+
@topic1.books.should == []
|
173
177
|
end
|
174
178
|
after do
|
175
179
|
@topic1.delete
|
@@ -353,55 +357,134 @@ describe ActiveFedora::Base do
|
|
353
357
|
|
354
358
|
describe "single direction habtm" do
|
355
359
|
before :all do
|
356
|
-
class
|
357
|
-
has_and_belongs_to_many :
|
360
|
+
class Course < ActiveFedora::Base
|
361
|
+
has_and_belongs_to_many :textbooks, :property=>:is_part_of
|
358
362
|
end
|
359
|
-
class
|
360
|
-
has_many :
|
363
|
+
class Textbook < ActiveFedora::Base
|
364
|
+
has_many :courses, :property=>:is_part_of
|
361
365
|
end
|
362
366
|
|
363
367
|
end
|
364
368
|
after :all do
|
365
|
-
Object.send(:remove_const, :
|
366
|
-
Object.send(:remove_const, :
|
369
|
+
Object.send(:remove_const, :Course)
|
370
|
+
Object.send(:remove_const, :Textbook)
|
367
371
|
end
|
368
372
|
|
369
373
|
describe "with a parent that has two children" do
|
370
374
|
before do
|
371
|
-
@
|
372
|
-
@
|
373
|
-
@
|
374
|
-
@
|
375
|
-
@
|
375
|
+
@course = Course.create
|
376
|
+
@t1 = Textbook.create()
|
377
|
+
@t2 = Textbook.create()
|
378
|
+
@course.textbooks = [@t1, @t2]
|
379
|
+
@course.save
|
376
380
|
end
|
377
381
|
|
378
382
|
it "should load the association stored in the parent" do
|
379
|
-
@
|
380
|
-
@
|
383
|
+
@reloaded_course = Course.find(@course.pid)
|
384
|
+
@reloaded_course.textbooks.should == [@t1, @t2]
|
381
385
|
end
|
382
386
|
|
383
387
|
it "should allow a parent to be deleted from the has_many association" do
|
384
|
-
@
|
385
|
-
@
|
386
|
-
@
|
388
|
+
@reloaded_course = Course.find(@course.pid)
|
389
|
+
@t1.courses.delete(@reloaded_course)
|
390
|
+
@reloaded_course.save
|
387
391
|
|
388
|
-
@
|
389
|
-
@
|
392
|
+
@reloaded_course = Course.find(@course.pid)
|
393
|
+
@reloaded_course.textbooks.should == [@t2]
|
394
|
+
end
|
395
|
+
|
396
|
+
it "should allow replacing the children" do
|
397
|
+
@t3 = Textbook.create()
|
398
|
+
@t4 = Textbook.create()
|
399
|
+
@course.textbooks = [@t3, @t4]
|
400
|
+
@course.save
|
401
|
+
|
402
|
+
@course.reload.textbooks.should == [@t3, @t4]
|
390
403
|
end
|
391
404
|
|
392
405
|
it "should allow a child to be deleted from the has_and_belongs_to_many association" do
|
393
|
-
|
394
|
-
@
|
395
|
-
@
|
396
|
-
@
|
397
|
-
@p1.save
|
406
|
+
@reloaded_course = Course.find(@course.pid)
|
407
|
+
@reloaded_course.textbooks.delete(@t1)
|
408
|
+
@reloaded_course.save
|
409
|
+
@t1.save
|
398
410
|
|
399
|
-
@
|
400
|
-
@
|
411
|
+
@reloaded_course = Course.find(@course.pid)
|
412
|
+
@reloaded_course.textbooks.should == [@t2]
|
401
413
|
end
|
402
414
|
end
|
403
415
|
end
|
404
416
|
|
417
|
+
describe "association hooks" do
|
418
|
+
describe "for habtm" do
|
419
|
+
before :all do
|
420
|
+
class LibraryBook < ActiveFedora::Base
|
421
|
+
has_and_belongs_to_many :pages, :property=>:is_part_of, after_remove: :after_hook, before_remove: :before_hook
|
422
|
+
|
423
|
+
def before_hook(m)
|
424
|
+
say_hi(m)
|
425
|
+
m.reload.library_books.count.should == 1
|
426
|
+
end
|
427
|
+
|
428
|
+
def after_hook(m)
|
429
|
+
say_hi(m)
|
430
|
+
m.reload.library_books.count.should == 0
|
431
|
+
end
|
432
|
+
|
433
|
+
|
434
|
+
end
|
435
|
+
class Page < ActiveFedora::Base
|
436
|
+
has_many :library_books, :property=>:is_part_of
|
437
|
+
end
|
438
|
+
|
439
|
+
end
|
440
|
+
after :all do
|
441
|
+
Object.send(:remove_const, :LibraryBook)
|
442
|
+
Object.send(:remove_const, :Page)
|
443
|
+
end
|
444
|
+
|
445
|
+
describe "removing association" do
|
446
|
+
subject {LibraryBook.create}
|
447
|
+
before do
|
448
|
+
@p1 = Page.create
|
449
|
+
@p2 = Page.create
|
450
|
+
subject.pages << @p1 << @p2
|
451
|
+
subject.save!
|
452
|
+
end
|
453
|
+
it "should save between the before and after hooks" do
|
454
|
+
subject.should_receive(:say_hi).with(@p2).twice
|
455
|
+
subject.pages.delete(@p2)
|
456
|
+
end
|
457
|
+
end
|
458
|
+
end
|
459
|
+
describe "for has_many" do
|
460
|
+
before :all do
|
461
|
+
class LibraryBook < ActiveFedora::Base
|
462
|
+
has_many :pages, :property=>:is_part_of, after_remove: :say_hi
|
463
|
+
|
464
|
+
end
|
465
|
+
class Page < ActiveFedora::Base
|
466
|
+
belongs_to :library_book, :property=>:is_part_of
|
467
|
+
end
|
468
|
+
|
469
|
+
end
|
470
|
+
after :all do
|
471
|
+
Object.send(:remove_const, :LibraryBook)
|
472
|
+
Object.send(:remove_const, :Page)
|
473
|
+
end
|
474
|
+
|
475
|
+
describe "removing association" do
|
476
|
+
subject {LibraryBook.new}
|
477
|
+
before do
|
478
|
+
@p1 = subject.pages.build
|
479
|
+
@p2 = subject.pages.build
|
480
|
+
end
|
481
|
+
it "should run the hooks" do
|
482
|
+
subject.should_receive(:say_hi).with(@p2)
|
483
|
+
subject.pages.delete(@p2)
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
487
|
+
end
|
405
488
|
|
406
489
|
|
407
490
|
describe "when a object is deleted" do
|
@@ -21,14 +21,13 @@ describe "A base object with metadata" do
|
|
21
21
|
obj.foo.should_not be_new
|
22
22
|
obj.foo.person.should == ['bob']
|
23
23
|
person_field = ActiveFedora::SolrService.solr_name('person', type: :string)
|
24
|
-
ActiveFedora::SolrService.query("id
|
24
|
+
ActiveFedora::SolrService.query("{!raw f=id}#{@obj.pid}", :fl=>"id #{person_field}").first.should == {"id"=>@obj.pid, person_field =>['bob']}
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "setting object state" do
|
29
29
|
it "should store it" do
|
30
30
|
obj = MockAFBaseRelationship.create
|
31
|
-
obj.state.should == 'A'
|
32
31
|
obj.state='D'
|
33
32
|
obj.save!
|
34
33
|
obj.reload
|
@@ -39,8 +38,8 @@ describe "A base object with metadata" do
|
|
39
38
|
describe "that already exists in the repo" do
|
40
39
|
before do
|
41
40
|
@release = MockAFBaseRelationship.create()
|
42
|
-
@release.add_relationship(:is_governed_by, 'info:fedora/
|
43
|
-
@release.add_relationship(:is_part_of, 'info:fedora/
|
41
|
+
@release.add_relationship(:is_governed_by, 'info:fedora/test:catalog-fixture')
|
42
|
+
@release.add_relationship(:is_part_of, 'info:fedora/test:777')
|
44
43
|
@release.foo.person = "test foo content"
|
45
44
|
@release.save
|
46
45
|
end
|
@@ -58,21 +57,21 @@ describe "A base object with metadata" do
|
|
58
57
|
describe "clone_into a new object" do
|
59
58
|
before do
|
60
59
|
begin
|
61
|
-
new_object = MockAFBaseRelationship.find('
|
60
|
+
new_object = MockAFBaseRelationship.find('test:999')
|
62
61
|
new_object.delete
|
63
62
|
rescue ActiveFedora::ObjectNotFoundError
|
64
63
|
end
|
65
64
|
|
66
|
-
new_object = MockAFBaseRelationship.create(:pid => '
|
65
|
+
new_object = MockAFBaseRelationship.create(:pid => 'test:999')
|
67
66
|
@release.clone_into(new_object)
|
68
|
-
@new_object = MockAFBaseRelationship.find('
|
67
|
+
@new_object = MockAFBaseRelationship.find('test:999')
|
69
68
|
end
|
70
69
|
it "should have all the assertions" do
|
71
70
|
@new_object.rels_ext.content.should be_equivalent_to '<rdf:RDF xmlns:ns1="info:fedora/fedora-system:def/model#" xmlns:ns2="info:fedora/fedora-system:def/relations-external#" xmlns:ns0="http://projecthydra.org/ns/relations#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
72
|
-
<rdf:Description rdf:about="info:fedora/
|
73
|
-
<ns0:isGovernedBy rdf:resource="info:fedora/
|
71
|
+
<rdf:Description rdf:about="info:fedora/test:999">
|
72
|
+
<ns0:isGovernedBy rdf:resource="info:fedora/test:catalog-fixture"/>
|
74
73
|
<ns1:hasModel rdf:resource="info:fedora/afmodel:MockAFBaseRelationship"/>
|
75
|
-
<ns2:isPartOf rdf:resource="info:fedora/
|
74
|
+
<ns2:isPartOf rdf:resource="info:fedora/test:777"/>
|
76
75
|
|
77
76
|
</rdf:Description>
|
78
77
|
</rdf:RDF>'
|
@@ -89,9 +88,9 @@ describe "A base object with metadata" do
|
|
89
88
|
it "should have all the assertions" do
|
90
89
|
@new_object.rels_ext.content.should be_equivalent_to '<rdf:RDF xmlns:ns1="info:fedora/fedora-system:def/model#" xmlns:ns2="info:fedora/fedora-system:def/relations-external#" xmlns:ns0="http://projecthydra.org/ns/relations#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
91
90
|
<rdf:Description rdf:about="info:fedora/'+ @new_object.pid+'">
|
92
|
-
<ns0:isGovernedBy rdf:resource="info:fedora/
|
91
|
+
<ns0:isGovernedBy rdf:resource="info:fedora/test:catalog-fixture"/>
|
93
92
|
<ns1:hasModel rdf:resource="info:fedora/afmodel:MockAFBaseRelationship"/>
|
94
|
-
<ns2:isPartOf rdf:resource="info:fedora/
|
93
|
+
<ns2:isPartOf rdf:resource="info:fedora/test:777"/>
|
95
94
|
|
96
95
|
</rdf:Description>
|
97
96
|
</rdf:RDF>'
|
@@ -219,16 +218,6 @@ describe ActiveFedora::Base do
|
|
219
218
|
@test_object.pid.should_not be_nil
|
220
219
|
end
|
221
220
|
end
|
222
|
-
|
223
|
-
describe '.assign_pid' do
|
224
|
-
it "should get nextid" do
|
225
|
-
one = ActiveFedora::Base.assign_pid(ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'changeme'))
|
226
|
-
two = ActiveFedora::Base.assign_pid(ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'changeme'))
|
227
|
-
one = one.gsub('changeme:', '').to_i
|
228
|
-
two = two.gsub('changeme:', '').to_i
|
229
|
-
two.should == one + 1
|
230
|
-
end
|
231
|
-
end
|
232
221
|
|
233
222
|
describe "#save" do
|
234
223
|
before(:each) do
|
@@ -257,7 +246,6 @@ describe ActiveFedora::Base do
|
|
257
246
|
inner_object = @test_object2.inner_object
|
258
247
|
inner_object.pid.should == @test_object2.pid
|
259
248
|
inner_object.should respond_to(:lastModifiedDate)
|
260
|
-
inner_object.ownerId.should == "fedoraAdmin"
|
261
249
|
end
|
262
250
|
end
|
263
251
|
|
@@ -296,16 +284,6 @@ describe ActiveFedora::Base do
|
|
296
284
|
end
|
297
285
|
end
|
298
286
|
|
299
|
-
describe ".dc" do
|
300
|
-
it "should expose the DC datastream" do
|
301
|
-
dc = @test_object.dc
|
302
|
-
dc.should be_a_kind_of(ActiveFedora::Datastream)
|
303
|
-
rexml = REXML::Document.new(dc.content)
|
304
|
-
rexml.root.elements["dc:identifier"].get_text.should_not be_nil
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
|
309
287
|
describe '.rels_ext' do
|
310
288
|
it "should retrieve RelsExtDatastream object via rels_ext method" do
|
311
289
|
@test_object.rels_ext.should be_instance_of(ActiveFedora::RelsExtDatastream)
|
@@ -437,10 +415,10 @@ describe ActiveFedora::Base do
|
|
437
415
|
|
438
416
|
describe "#exists?" do
|
439
417
|
it "should return true for objects that exist" do
|
440
|
-
ActiveFedora::Base.exists?('
|
418
|
+
ActiveFedora::Base.exists?('test:fixture_mods_article1').should be_true
|
441
419
|
end
|
442
420
|
it "should return false for objects that don't exist" do
|
443
|
-
ActiveFedora::Base.exists?('
|
421
|
+
ActiveFedora::Base.exists?('test:missing_object').should be_false
|
444
422
|
end
|
445
423
|
it "should return false for nil" do
|
446
424
|
ActiveFedora::Base.exists?(nil).should be_false
|