active-fedora 6.0.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/History.txt +16 -0
- data/README.textile +12 -7
- data/active-fedora.gemspec +2 -2
- data/lib/active_fedora.rb +1 -0
- data/lib/active_fedora/associations/association_collection.rb +1 -1
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +12 -3
- data/lib/active_fedora/associations/has_many_association.rb +4 -0
- data/lib/active_fedora/attributes.rb +6 -0
- data/lib/active_fedora/auditable.rb +9 -0
- data/lib/active_fedora/base.rb +2 -0
- data/lib/active_fedora/delegating.rb +5 -3
- data/lib/active_fedora/indexing.rb +1 -1
- data/lib/active_fedora/nokogiri_datastream.rb +1 -2
- data/lib/active_fedora/querying.rb +1 -0
- data/lib/active_fedora/version.rb +1 -1
- data/lib/generators/active_fedora/config/solr/solr_generator.rb +1 -0
- data/lib/generators/active_fedora/config/solr/templates/jetty.yml +5 -0
- data/lib/generators/active_fedora/config/solr/templates/solr_conf/conf/schema.xml +1 -161
- data/lib/generators/active_fedora/config/solr/templates/solr_conf/conf/solrconfig.xml +16 -7
- data/lib/tasks/active_fedora_dev.rake +1 -1
- data/spec/fixtures/auditable.foxml.xml +110 -0
- data/spec/integration/base_spec.rb +7 -1
- data/spec/unit/auditable_spec.rb +31 -0
- data/spec/unit/base_delegate_spec.rb +74 -38
- data/spec/unit/base_spec.rb +6 -1
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +59 -0
- data/spec/unit/has_many_collection_spec.rb +26 -0
- metadata +96 -45
- checksums.yaml +0 -7
- data/solr/conf/schema.xml +0 -432
- data/solr/conf/solrconfig.xml +0 -158
@@ -37,23 +37,27 @@
|
|
37
37
|
-->
|
38
38
|
<str name="qf">
|
39
39
|
id
|
40
|
-
all_text_timv
|
41
40
|
active_fedora_model_ssi
|
42
|
-
|
41
|
+
title_tesim
|
42
|
+
author_tesim
|
43
|
+
subject_tesim
|
43
44
|
</str>
|
44
45
|
<str name="pf">
|
45
46
|
all_text_timv^10
|
46
47
|
</str>
|
47
48
|
|
48
49
|
<str name="author_qf">
|
50
|
+
author_tesim
|
49
51
|
</str>
|
50
52
|
<str name="author_pf">
|
51
53
|
</str>
|
52
54
|
<str name="title_qf">
|
55
|
+
title_tesim
|
53
56
|
</str>
|
54
57
|
<str name="title_pf">
|
55
58
|
</str>
|
56
59
|
<str name="subject_qf">
|
60
|
+
subject_tesim
|
57
61
|
</str>
|
58
62
|
<str name="subject_pf">
|
59
63
|
</str>
|
@@ -67,7 +71,7 @@
|
|
67
71
|
<str name="facet.mincount">1</str>
|
68
72
|
<str name="facet.limit">10</str>
|
69
73
|
<str name="facet.field">active_fedora_model_ssi</str>
|
70
|
-
<str name="facet.field">
|
74
|
+
<str name="facet.field">subject_sim</str>
|
71
75
|
|
72
76
|
<str name="spellcheck">true</str>
|
73
77
|
<str name="spellcheck.dictionary">default</str>
|
@@ -90,12 +94,17 @@
|
|
90
94
|
<str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
|
91
95
|
<str name="fl">
|
92
96
|
id,
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
+
access_ssim,
|
98
|
+
discover_access_group_ssim,discover_access_person_ssim,
|
99
|
+
read_access_group_ssim,read_access_person_ssim,
|
100
|
+
edit_access_group_ssim,edit_access_person_ssim,
|
97
101
|
depositor_ti,
|
98
102
|
embargo_release_date_dtsi
|
103
|
+
inheritable_access_ssim,
|
104
|
+
inheritable_discover_access_group_ssim,inheritable_discover_access_person_ssim,
|
105
|
+
inheritable_read_access_group_ssim,inheritable_read_access_person_ssim,
|
106
|
+
inheritable_edit_access_group_ssim,inheritable_edit_access_person_ssim,
|
107
|
+
inheritable_embargo_release_date_dtsi
|
99
108
|
</str>
|
100
109
|
</lst>
|
101
110
|
</requestHandler>
|
@@ -53,7 +53,7 @@ require 'rspec/core/rake_task'
|
|
53
53
|
|
54
54
|
desc "Copies the default SOLR config for the bundled Testing Server"
|
55
55
|
task :configure_jetty do
|
56
|
-
FileList['solr/conf/*'].each do |f|
|
56
|
+
FileList['lib/generators/active_fedora/config/solr/templates/solr_conf/conf/*'].each do |f|
|
57
57
|
cp("#{f}", 'jetty/solr/development-core/conf/', :verbose => true)
|
58
58
|
cp("#{f}", 'jetty/solr/test-core/conf/', :verbose => true)
|
59
59
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<foxml:digitalObject VERSION="1.1" PID="changeme:242"
|
3
|
+
xmlns:foxml="info:fedora/fedora-system:def/foxml#"
|
4
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5
|
+
xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
|
6
|
+
<foxml:objectProperties>
|
7
|
+
<foxml:property NAME="info:fedora/fedora-system:def/model#state" VALUE="Active"/>
|
8
|
+
<foxml:property NAME="info:fedora/fedora-system:def/model#label" VALUE=""/>
|
9
|
+
<foxml:property NAME="info:fedora/fedora-system:def/model#ownerId" VALUE="fedoraAdmin"/>
|
10
|
+
<foxml:property NAME="info:fedora/fedora-system:def/model#createdDate" VALUE="2013-02-25T16:43:05.802Z"/>
|
11
|
+
<foxml:property NAME="info:fedora/fedora-system:def/view#lastModifiedDate" VALUE="2013-02-25T16:43:06.379Z"/>
|
12
|
+
</foxml:objectProperties>
|
13
|
+
<foxml:datastream ID="AUDIT" STATE="A" CONTROL_GROUP="X" VERSIONABLE="false">
|
14
|
+
<foxml:datastreamVersion ID="AUDIT.0" LABEL="Audit Trail for this object" CREATED="2013-02-25T16:43:05.802Z" MIMETYPE="text/xml" FORMAT_URI="info:fedora/fedora-system:format/xml.fedora.audit">
|
15
|
+
<foxml:xmlContent>
|
16
|
+
<audit:auditTrail xmlns:audit="info:fedora/fedora-system:def/audit#">
|
17
|
+
<audit:record ID="AUDREC1">
|
18
|
+
<audit:process type="Fedora API-M"/>
|
19
|
+
<audit:action>addDatastream</audit:action>
|
20
|
+
<audit:componentID>RELS-EXT</audit:componentID>
|
21
|
+
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
22
|
+
<audit:date>2013-02-25T16:43:06.219Z</audit:date>
|
23
|
+
<audit:justification></audit:justification>
|
24
|
+
</audit:record>
|
25
|
+
<audit:record ID="AUDREC2">
|
26
|
+
<audit:process type="Fedora API-M"/>
|
27
|
+
<audit:action>addDatastream</audit:action>
|
28
|
+
<audit:componentID>descMetadata</audit:componentID>
|
29
|
+
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
30
|
+
<audit:date>2013-02-25T16:43:06.315Z</audit:date>
|
31
|
+
<audit:justification></audit:justification>
|
32
|
+
</audit:record>
|
33
|
+
<audit:record ID="AUDREC3">
|
34
|
+
<audit:process type="Fedora API-M"/>
|
35
|
+
<audit:action>addDatastream</audit:action>
|
36
|
+
<audit:componentID>rightsMetadata</audit:componentID>
|
37
|
+
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
38
|
+
<audit:date>2013-02-25T16:43:06.379Z</audit:date>
|
39
|
+
<audit:justification></audit:justification>
|
40
|
+
</audit:record>
|
41
|
+
</audit:auditTrail>
|
42
|
+
</foxml:xmlContent>
|
43
|
+
</foxml:datastreamVersion>
|
44
|
+
</foxml:datastream>
|
45
|
+
<foxml:datastream ID="DC" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
46
|
+
<foxml:datastreamVersion ID="DC1.0" LABEL="Dublin Core Record for this object" CREATED="2013-02-25T16:43:05.802Z" MIMETYPE="text/xml" FORMAT_URI="http://www.openarchives.org/OAI/2.0/oai_dc/" SIZE="341">
|
47
|
+
<foxml:contentDigest TYPE="SHA-256" DIGEST="eb075bf6da5903e54464631dc998f66f95bffde9f4137132796457d31de5cd44"/>
|
48
|
+
<foxml:xmlContent>
|
49
|
+
<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">
|
50
|
+
<dc:identifier>changeme:242</dc:identifier>
|
51
|
+
</oai_dc:dc>
|
52
|
+
</foxml:xmlContent>
|
53
|
+
</foxml:datastreamVersion>
|
54
|
+
</foxml:datastream>
|
55
|
+
<foxml:datastream ID="RELS-EXT" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
56
|
+
<foxml:datastreamVersion ID="RELS-EXT.0" LABEL="Fedora Object-to-Object Relationship Metadata" CREATED="2013-02-25T16:43:06.219Z" MIMETYPE="application/rdf+xml" SIZE="284">
|
57
|
+
<foxml:contentDigest TYPE="SHA-256" DIGEST="013d2229de7bd91c61256563eff1b475cd1e8f7e45a2f15de5a36f2d20ec2852"/>
|
58
|
+
<foxml:xmlContent>
|
59
|
+
<rdf:RDF xmlns:ns0="info:fedora/fedora-system:def/model#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
60
|
+
<rdf:Description rdf:about="info:fedora/changeme:242">
|
61
|
+
<ns0:hasModel rdf:resource="info:fedora/afmodel:TestModel"></ns0:hasModel>
|
62
|
+
</rdf:Description>
|
63
|
+
</rdf:RDF>
|
64
|
+
</foxml:xmlContent>
|
65
|
+
</foxml:datastreamVersion>
|
66
|
+
</foxml:datastream>
|
67
|
+
<foxml:datastream ID="descMetadata" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
68
|
+
<foxml:datastreamVersion ID="descMetadata.0" LABEL="" CREATED="2013-02-25T16:43:06.315Z" MIMETYPE="text/xml" SIZE="215">
|
69
|
+
<foxml:contentDigest TYPE="SHA-256" DIGEST="3f588eca58dea77b31c9ed0b90e4560288a419856c4bb744fab9c7fe8749ad19"/>
|
70
|
+
<foxml:xmlContent>
|
71
|
+
<dc xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
72
|
+
<dcterms:title>DulHydra Test Object</dcterms:title>
|
73
|
+
<dcterms:identifier>test00001</dcterms:identifier>
|
74
|
+
</dc>
|
75
|
+
</foxml:xmlContent>
|
76
|
+
</foxml:datastreamVersion>
|
77
|
+
</foxml:datastream>
|
78
|
+
<foxml:datastream ID="rightsMetadata" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
79
|
+
<foxml:datastreamVersion ID="rightsMetadata.0" LABEL="" CREATED="2013-02-25T16:43:06.379Z" MIMETYPE="text/xml" SIZE="596">
|
80
|
+
<foxml:contentDigest TYPE="SHA-256" DIGEST="472f8634b31bd425dadd9206531ab02a70c08c22e4250bb2b0d3dd0314cfb240"/>
|
81
|
+
<foxml:xmlContent>
|
82
|
+
<rightsMetadata xmlns="http://hydra-collab.stanford.edu/schemas/rightsMetadata/v1" version="0.1">
|
83
|
+
<copyright>
|
84
|
+
<human type="title"></human>
|
85
|
+
<human type="description"></human>
|
86
|
+
<machine type="uri"></machine>
|
87
|
+
</copyright>
|
88
|
+
<access type="discover">
|
89
|
+
<human></human>
|
90
|
+
<machine></machine>
|
91
|
+
</access>
|
92
|
+
<access type="read">
|
93
|
+
<human></human>
|
94
|
+
<machine>
|
95
|
+
<group>public</group>
|
96
|
+
</machine>
|
97
|
+
</access>
|
98
|
+
<access type="edit">
|
99
|
+
<human></human>
|
100
|
+
<machine></machine>
|
101
|
+
</access>
|
102
|
+
<embargo>
|
103
|
+
<human></human>
|
104
|
+
<machine></machine>
|
105
|
+
</embargo>
|
106
|
+
</rightsMetadata>
|
107
|
+
</foxml:xmlContent>
|
108
|
+
</foxml:datastreamVersion>
|
109
|
+
</foxml:datastream>
|
110
|
+
</foxml:digitalObject>
|
@@ -431,8 +431,14 @@ describe ActiveFedora::Base do
|
|
431
431
|
it "should return true for objects that exist" do
|
432
432
|
ActiveFedora::Base.exists?('hydrangea:fixture_mods_article1').should be_true
|
433
433
|
end
|
434
|
-
it "should return false for objects that
|
434
|
+
it "should return false for objects that don't exist" do
|
435
435
|
ActiveFedora::Base.exists?('nil:object').should be_false
|
436
436
|
end
|
437
|
+
it "should return false for nil" do
|
438
|
+
ActiveFedora::Base.exists?(nil).should be_false
|
439
|
+
end
|
440
|
+
it "should return false for empty" do
|
441
|
+
ActiveFedora::Base.exists?('').should be_false
|
442
|
+
end
|
437
443
|
end
|
438
444
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::Auditable do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
class AuditableModel < ActiveFedora::Base
|
7
|
+
include ActiveFedora::Auditable
|
8
|
+
end
|
9
|
+
path = File.join(File.dirname(__FILE__), '..', 'fixtures', 'auditable.foxml.xml')
|
10
|
+
pid = ActiveFedora::FixtureLoader.import_to_fedora(path)
|
11
|
+
ActiveFedora::FixtureLoader.index(pid)
|
12
|
+
@test_object = AuditableModel.find(pid)
|
13
|
+
end
|
14
|
+
after(:all) do
|
15
|
+
@test_object.delete
|
16
|
+
end
|
17
|
+
it "should have the correct number of audit records" do
|
18
|
+
@test_object.audit_trail.records.length.should == 3
|
19
|
+
end
|
20
|
+
it "should return all the data from each audit record" do
|
21
|
+
record = @test_object.audit_trail.records.first
|
22
|
+
record.id.should == "AUDREC1"
|
23
|
+
record.process_type.should == "Fedora API-M"
|
24
|
+
record.action.should == "addDatastream"
|
25
|
+
record.component_id.should == "RELS-EXT"
|
26
|
+
record.responsibility.should == "fedoraAdmin"
|
27
|
+
record.date.should == "2013-02-25T16:43:06.219Z"
|
28
|
+
record.justification.should == ""
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -1,56 +1,68 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
before :all do
|
5
|
+
class BarStream2 < ActiveFedora::OmDatastream
|
6
|
+
set_terminology do |t|
|
7
|
+
t.root(:path=>"animals", :xmlns=>"urn:zoobar")
|
8
|
+
t.waterfowl do
|
9
|
+
t.ducks do
|
10
|
+
t.duck
|
11
|
+
end
|
12
12
|
end
|
13
|
+
t.donkey()
|
14
|
+
t.cow()
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.xml_template
|
18
|
+
Nokogiri::XML::Document.parse '<animals xmlns="urn:zoobar">
|
19
|
+
<waterfowl>
|
20
|
+
<ducks>
|
21
|
+
<duck/>
|
22
|
+
</ducks>
|
23
|
+
</waterfowl>
|
24
|
+
<donkey></donkey>
|
25
|
+
<cow></cow>
|
26
|
+
</animals>'
|
13
27
|
end
|
14
|
-
t.donkey()
|
15
|
-
t.cow()
|
16
28
|
end
|
29
|
+
end
|
30
|
+
after :all do
|
31
|
+
Object.send(:remove_const, :BarStream2)
|
32
|
+
end
|
17
33
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
34
|
+
describe "first level delegation" do
|
35
|
+
before :all do
|
36
|
+
class BarHistory2 < ActiveFedora::Base
|
37
|
+
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData" do |m|
|
38
|
+
m.field "fubar", :string
|
39
|
+
m.field "bandana", :string
|
40
|
+
m.field "swank", :text
|
41
|
+
end
|
42
|
+
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText" do |m|
|
43
|
+
m.field "fubar", :text
|
44
|
+
end
|
45
|
+
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText2", :label=>"withLabel" do |m|
|
46
|
+
m.field "fubar", :text
|
47
|
+
end
|
48
|
+
|
49
|
+
has_metadata :type=>BarStream2, :name=>"xmlish"
|
50
|
+
delegate :fubar, :to=>'withText', :unique=>true
|
51
|
+
delegate :donkey, :to=>'xmlish', :unique=>true
|
52
|
+
delegate :cow, :to=>'xmlish'
|
53
|
+
delegate :duck, :to=>'xmlish', :at=>[:waterfowl, :ducks]
|
28
54
|
end
|
29
55
|
end
|
30
56
|
|
31
|
-
|
32
|
-
|
33
|
-
m.field "fubar", :string
|
34
|
-
m.field "bandana", :string
|
35
|
-
m.field "swank", :text
|
36
|
-
end
|
37
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText" do |m|
|
38
|
-
m.field "fubar", :text
|
39
|
-
end
|
40
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText2", :label=>"withLabel" do |m|
|
41
|
-
m.field "fubar", :text
|
42
|
-
end
|
43
|
-
|
44
|
-
has_metadata :type=>BarStream2, :name=>"xmlish"
|
45
|
-
delegate :fubar, :to=>'withText', :unique=>true
|
46
|
-
delegate :donkey, :to=>'xmlish', :unique=>true
|
47
|
-
delegate :cow, :to=>'xmlish'
|
48
|
-
delegate :duck, :to=>'xmlish', :at=>[:waterfowl, :ducks]
|
57
|
+
after :all do
|
58
|
+
Object.send(:remove_const, :BarHistory2)
|
49
59
|
end
|
60
|
+
|
50
61
|
before :each do
|
51
62
|
@n = BarHistory2.new()
|
52
63
|
end
|
53
64
|
|
65
|
+
|
54
66
|
it "should save a delegated property uniquely" do
|
55
67
|
@n.fubar="Quack"
|
56
68
|
@n.fubar.should == "Quack"
|
@@ -74,6 +86,30 @@ describe ActiveFedora::Base do
|
|
74
86
|
@n[:duck]= ["Cluck", "Gobble"]
|
75
87
|
@n[:duck].should == ["Cluck", "Gobble"]
|
76
88
|
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "with a superclass" do
|
93
|
+
before :all do
|
94
|
+
class BarHistory2 < ActiveFedora::Base
|
95
|
+
has_metadata 'xmlish', :type=>BarStream2
|
96
|
+
delegate_to 'xmlish', [:donkey, :cow]
|
97
|
+
end
|
98
|
+
class BarHistory3 < BarHistory2
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
after :all do
|
103
|
+
Object.send(:remove_const, :BarHistory3)
|
104
|
+
Object.send(:remove_const, :BarHistory2)
|
105
|
+
end
|
106
|
+
|
107
|
+
subject { BarHistory3.new }
|
108
|
+
|
109
|
+
it "should be able to delegate deeply into the terminology" do
|
110
|
+
subject.donkey=["Bray", "Hee-haw"]
|
111
|
+
subject.donkey.should == ["Bray", "Hee-haw"]
|
112
|
+
end
|
77
113
|
end
|
78
114
|
end
|
79
115
|
|
data/spec/unit/base_spec.rb
CHANGED
@@ -2,6 +2,11 @@ require 'spec_helper'
|
|
2
2
|
@@last_pid = 0
|
3
3
|
|
4
4
|
describe ActiveFedora::Base do
|
5
|
+
describe 'descendants' do
|
6
|
+
it "should record the decendants" do
|
7
|
+
ActiveFedora::Base.descendants.should include(HydrangeaArticle, SpecialThing)
|
8
|
+
end
|
9
|
+
end
|
5
10
|
describe "sharding" do
|
6
11
|
it "should have a shard_index" do
|
7
12
|
ActiveFedora::Base.shard_index(@this_pid).should == 0
|
@@ -424,7 +429,7 @@ describe ActiveFedora::Base do
|
|
424
429
|
stub_get_content(@this_pid, ['RELS-EXT', 'someData', 'withText2', 'withText'])
|
425
430
|
@test_history = FooHistory.new()
|
426
431
|
solr_doc = @test_history.to_solr
|
427
|
-
solr_doc[ActiveFedora::SolrService.solr_name("active_fedora_model", :
|
432
|
+
solr_doc[ActiveFedora::SolrService.solr_name("active_fedora_model", :stored_sortable)].should eql(["FooHistory"])
|
428
433
|
end
|
429
434
|
|
430
435
|
it "should call .to_solr on all SimpleDatastreams and OmDatastreams, passing the resulting document to solr" do
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
4
|
+
it "should call add_relationship" do
|
5
|
+
subject = stub("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a', :ids_for_outbound => [])
|
6
|
+
predicate = stub(:klass => mock.class, :options=>{:property=>'predicate'}, :class_name=> nil)
|
7
|
+
ActiveFedora::SolrService.stub(:query).and_return([])
|
8
|
+
ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
|
9
|
+
object = stub("object", :new_record? => false, :pid => 'object:b', :save => nil)
|
10
|
+
|
11
|
+
subject.should_receive(:add_relationship).with('predicate', object)
|
12
|
+
|
13
|
+
ac << object
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should call add_relationship on subject and object when inverse_of given" do
|
18
|
+
subject = stub("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a', :ids_for_outbound => [])
|
19
|
+
predicate = stub(:klass => mock.class, :options=>{:property=>'predicate', :inverse_of => 'inverse_predicate'}, :class_name=> nil)
|
20
|
+
ActiveFedora::SolrService.stub(:query).and_return([])
|
21
|
+
ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
|
22
|
+
object = stub("object", :new_record? => false, :pid => 'object:b', :save => nil)
|
23
|
+
|
24
|
+
subject.should_receive(:add_relationship).with('predicate', object)
|
25
|
+
|
26
|
+
object.should_receive(:add_relationship).with('inverse_predicate', subject)
|
27
|
+
|
28
|
+
ac << object
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should call remove_relationship" do
|
33
|
+
subject = stub("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a')
|
34
|
+
predicate = stub(:klass => mock.class, :options=>{:property=>'predicate'}, :class_name=> nil)
|
35
|
+
ActiveFedora::SolrService.stub(:query).and_return([])
|
36
|
+
ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
|
37
|
+
object = stub("object", :new_record? => false, :pid => 'object:b', :save => nil)
|
38
|
+
|
39
|
+
subject.should_receive(:remove_relationship).with('predicate', object)
|
40
|
+
|
41
|
+
ac.delete(object)
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should call remove_relationship on subject and object when inverse_of given" do
|
46
|
+
subject = stub("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a')
|
47
|
+
predicate = stub(:klass => mock.class, :options=>{:property=>'predicate', :inverse_of => 'inverse_predicate'}, :class_name=> nil)
|
48
|
+
ActiveFedora::SolrService.stub(:query).and_return([])
|
49
|
+
ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
|
50
|
+
object = stub("object", :new_record? => false, :pid => 'object:b', :save => nil)
|
51
|
+
|
52
|
+
subject.should_receive(:remove_relationship).with('predicate', object)
|
53
|
+
object.should_receive(:remove_relationship).with('inverse_predicate', subject)
|
54
|
+
|
55
|
+
ac.delete(object)
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|