active-fedora 9.0.0.rc3 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +1054 -0
- data/active-fedora.gemspec +1 -1
- data/config/predicate_mappings.yml +2 -2
- data/lib/active_fedora.rb +3 -0
- data/lib/active_fedora/attached_files.rb +31 -14
- data/lib/active_fedora/base.rb +2 -0
- data/lib/active_fedora/caching_connection.rb +80 -0
- data/lib/active_fedora/callbacks.rb +13 -14
- data/lib/active_fedora/core.rb +9 -17
- data/lib/active_fedora/errors.rb +1 -1
- data/lib/active_fedora/fedora.rb +5 -1
- data/lib/active_fedora/file.rb +42 -39
- data/lib/active_fedora/ldp_cache.rb +46 -0
- data/lib/active_fedora/ldp_resource_service.rb +27 -0
- data/lib/active_fedora/loadable_from_json.rb +3 -1
- data/lib/active_fedora/log_subscriber.rb +38 -0
- data/lib/active_fedora/persistence.rb +22 -12
- data/lib/active_fedora/predicates.rb +3 -3
- data/lib/active_fedora/railtie.rb +3 -0
- data/lib/active_fedora/rdf.rb +0 -1
- data/lib/active_fedora/relation/finder_methods.rb +2 -3
- data/lib/active_fedora/validations.rb +1 -3
- data/lib/active_fedora/version.rb +1 -1
- data/lib/generators/active_fedora/config/solr/templates/jetty.yml +3 -2
- data/spec/fixtures/rails_root/config/predicate_mappings.yml +2 -2
- data/spec/integration/associations_spec.rb +19 -19
- data/spec/integration/attached_files_spec.rb +3 -3
- data/spec/integration/belongs_to_association_spec.rb +9 -9
- data/spec/integration/caching_spec.rb +59 -0
- data/spec/integration/collection_association_spec.rb +1 -1
- data/spec/integration/fedora_solr_sync_spec.rb +2 -2
- data/spec/integration/file_spec.rb +41 -43
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +8 -8
- data/spec/integration/has_many_associations_spec.rb +15 -15
- data/spec/integration/nested_attribute_spec.rb +2 -2
- data/spec/integration/relation_spec.rb +1 -1
- data/spec/integration/solr_instance_loader_spec.rb +2 -1
- data/spec/samples/special_thing.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/attached_files_spec.rb +41 -5
- data/spec/unit/attributes_spec.rb +1 -1
- data/spec/unit/change_set_spec.rb +1 -1
- data/spec/unit/code_configurator_spec.rb +3 -3
- data/spec/unit/core_spec.rb +16 -1
- data/spec/unit/file_spec.rb +14 -10
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +6 -6
- data/spec/unit/has_many_association_spec.rb +4 -4
- data/spec/unit/indexing_service_spec.rb +2 -2
- data/spec/unit/ldp_resource_spec.rb +17 -0
- data/spec/unit/logger_spec.rb +1 -1
- data/spec/unit/persistence_spec.rb +24 -20
- data/spec/unit/predicates_spec.rb +7 -7
- data/spec/unit/sparql_insert_spec.rb +2 -2
- data/spec/unit/validations_spec.rb +12 -2
- metadata +13 -8
- data/lib/active_fedora/rdf/rels_ext.rb +0 -26
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "NestedAttribute behavior" do
|
4
4
|
before do
|
5
5
|
class Bar < ActiveFedora::Base
|
6
|
-
belongs_to :car, predicate: ActiveFedora::RDF::RelsExt.hasMember
|
6
|
+
belongs_to :car, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasMember
|
7
7
|
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData" do |m|
|
8
8
|
m.field "uno", :string
|
9
9
|
m.field "dos", :string
|
@@ -13,7 +13,7 @@ describe "NestedAttribute behavior" do
|
|
13
13
|
|
14
14
|
# base Car class, used in test for association updates and :allow_destroy flag
|
15
15
|
class Car < ActiveFedora::Base
|
16
|
-
has_many :bars, predicate: ActiveFedora::RDF::RelsExt.hasMember
|
16
|
+
has_many :bars, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasMember
|
17
17
|
accepts_nested_attributes_for :bars, :allow_destroy=>true
|
18
18
|
end
|
19
19
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe ActiveFedora::Base do
|
4
4
|
before :all do
|
5
5
|
class Library < ActiveFedora::Base
|
6
|
-
has_many :books, predicate: ActiveFedora::RDF::RelsExt.isPartOf
|
6
|
+
has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
7
7
|
end
|
8
8
|
class Book < ActiveFedora::Base; end
|
9
9
|
end
|
@@ -11,7 +11,7 @@ describe ActiveFedora::SolrInstanceLoader do
|
|
11
11
|
has_attributes :bar, datastream: 'descMetadata', multiple: false
|
12
12
|
property :title, predicate: ::RDF::DC.title, multiple: false
|
13
13
|
property :description, predicate: ::RDF::DC.description
|
14
|
-
belongs_to :another, predicate: ActiveFedora::RDF::RelsExt.isPartOf, class_name: 'Foo'
|
14
|
+
belongs_to :another, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'Foo'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -35,6 +35,7 @@ describe ActiveFedora::SolrInstanceLoader do
|
|
35
35
|
expect(subject.title).to eq 'My Title'
|
36
36
|
expect(subject.description).to match_array ['first desc', 'second desc']
|
37
37
|
expect(subject.another_id).to eq another.id
|
38
|
+
expect(subject.bar).to eq 'quix'
|
38
39
|
end
|
39
40
|
|
40
41
|
it "should not be mutable" do
|
@@ -37,8 +37,8 @@ class SpecialThing < ActiveFedora::Base
|
|
37
37
|
|
38
38
|
# This is an example of how you can add a custom relationship to a model
|
39
39
|
# This will allow you to call .derivation on instances of the model to get the _outbound_ "hasDerivation" relationship in the RELS-EXT datastream
|
40
|
-
belongs_to :derivation, predicate: ActiveFedora::RDF::RelsExt.hasDerivation, class_name: 'SpecialThing'
|
40
|
+
belongs_to :derivation, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasDerivation, class_name: 'SpecialThing'
|
41
41
|
|
42
42
|
# This will allow you to call .inspirations on instances of the model to get a list of all of the objects that assert "hasDerivation" relationships pointing at this object
|
43
|
-
has_many :inspirations, predicate: ActiveFedora::RDF::RelsExt.hasDerivation, class_name: 'SpecialThing'
|
43
|
+
has_many :inspirations, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasDerivation, class_name: 'SpecialThing'
|
44
44
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -20,6 +20,7 @@ require 'byebug' unless ENV['TRAVIS']
|
|
20
20
|
|
21
21
|
ActiveFedora::Base.logger = Logger.new(STDERR)
|
22
22
|
ActiveFedora::Base.logger.level = Logger::WARN
|
23
|
+
# require 'http_logger'
|
23
24
|
# HttpLogger.logger = Logger.new(STDOUT)
|
24
25
|
# HttpLogger.ignore = [/localhost:8983\/solr/]
|
25
26
|
# HttpLogger.colorize = false
|
@@ -92,7 +92,7 @@ describe ActiveFedora::AttachedFiles do
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
describe "#
|
95
|
+
describe "#add_file" do
|
96
96
|
before do
|
97
97
|
class Bar < ActiveFedora::File; end
|
98
98
|
|
@@ -107,17 +107,53 @@ describe ActiveFedora::AttachedFiles do
|
|
107
107
|
end
|
108
108
|
let(:container) { FooHistory.new }
|
109
109
|
|
110
|
-
|
110
|
+
describe "#add_file_datastream" do
|
111
|
+
context "a reflection matches the :dsid property" do
|
112
|
+
it "should build the reflection" do
|
113
|
+
expect(Deprecation).to receive(:warn)
|
114
|
+
container.add_file_datastream('blah', path: 'content')
|
115
|
+
expect(container.content).to be_instance_of Bar
|
116
|
+
expect(container.content.content).to eq 'blah'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
context "with the deprecated :dsid property" do
|
121
|
+
it "should build the reflection" do
|
122
|
+
expect(Deprecation).to receive(:warn)
|
123
|
+
container.add_file('blah', dsid: 'content')
|
124
|
+
expect(container.content).to be_instance_of Bar
|
125
|
+
expect(container.content.content).to eq 'blah'
|
126
|
+
end
|
127
|
+
end
|
128
|
+
context "a reflection matches the :path property" do
|
129
|
+
it "should build the reflection" do
|
130
|
+
container.add_file('blah', path: 'content')
|
131
|
+
expect(container.content).to be_instance_of Bar
|
132
|
+
expect(container.content.content).to eq 'blah'
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "the deprecated 3 args erasure" do
|
137
|
+
it "should build the reflection" do
|
138
|
+
expect(Deprecation).to receive(:warn)
|
139
|
+
container.add_file('blah', 'content', 'name.png')
|
140
|
+
expect(container.content).to be_instance_of Bar
|
141
|
+
expect(container.content.content).to eq 'blah'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context "the deprecated 4 args erasure" do
|
111
146
|
it "should build the reflection" do
|
112
|
-
|
147
|
+
expect(Deprecation).to receive(:warn)
|
148
|
+
container.add_file('blah', 'content', 'name.png', 'image/png')
|
113
149
|
expect(container.content).to be_instance_of Bar
|
114
150
|
expect(container.content.content).to eq 'blah'
|
115
151
|
end
|
116
152
|
end
|
117
153
|
|
118
|
-
context "no reflection matches the :
|
154
|
+
context "no reflection matches the :path property" do
|
119
155
|
it "should create a singleton reflection and build it" do
|
120
|
-
container.
|
156
|
+
container.add_file('blah', path: 'fizz')
|
121
157
|
expect(container.fizz).to be_instance_of ActiveFedora::File
|
122
158
|
expect(container.fizz.content).to eq 'blah'
|
123
159
|
end
|
@@ -105,7 +105,7 @@ describe ActiveFedora::Base do
|
|
105
105
|
describe "with relationships" do
|
106
106
|
before do
|
107
107
|
class BarHistory3 < BarHistory2
|
108
|
-
belongs_to :library, predicate: ActiveFedora::RDF::RelsExt.hasConstituent, class_name: 'BarHistory2'
|
108
|
+
belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent, class_name: 'BarHistory2'
|
109
109
|
end
|
110
110
|
subject.library = library
|
111
111
|
end
|
@@ -16,7 +16,7 @@ describe ActiveFedora::ChangeSet do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
class Book < ActiveFedora::Base
|
19
|
-
belongs_to :library, predicate: ActiveFedora::RDF::RelsExt.hasConstituent
|
19
|
+
belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent
|
20
20
|
property :title, predicate: ::RDF::DC.title
|
21
21
|
end
|
22
22
|
|
@@ -18,9 +18,9 @@ describe ActiveFedora::FileConfigurator do
|
|
18
18
|
:fedora_config => { :url => 'http://codeconfig.example.edu/fedora/', :user => 'fedoraAdmin', :password => 'configurator', :cert_file => '/path/to/cert/file' },
|
19
19
|
:solr_config => { :url => 'http://codeconfig.example.edu/solr/' },
|
20
20
|
:predicate_config => {
|
21
|
-
:default_namespace => '
|
21
|
+
:default_namespace => 'info:fedora/fedora-system:def/relations-external#',
|
22
22
|
:predicate_mapping => {
|
23
|
-
'
|
23
|
+
'info:fedora/fedora-system:def/relations-external#' => { :has_part => 'hasPart' }
|
24
24
|
}
|
25
25
|
}
|
26
26
|
}
|
@@ -45,7 +45,7 @@ describe ActiveFedora::FileConfigurator do
|
|
45
45
|
ActiveFedora.init(@config_params)
|
46
46
|
expect(ActiveFedora.fedora_config.credentials).to eq @config_params[:fedora_config]
|
47
47
|
expect(ActiveFedora.solr_config).to eq @config_params[:solr_config]
|
48
|
-
expect(ActiveFedora::Predicates.predicate_mappings['
|
48
|
+
expect(ActiveFedora::Predicates.predicate_mappings['info:fedora/fedora-system:def/relations-external#'].length).to eq 1
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
data/spec/unit/core_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe ActiveFedora::Base do
|
|
8
8
|
class Library < ActiveFedora::Base
|
9
9
|
end
|
10
10
|
class Book < ActiveFedora::Base
|
11
|
-
belongs_to :library, predicate: ActiveFedora::RDF::RelsExt.hasConstituent
|
11
|
+
belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent
|
12
12
|
has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m|
|
13
13
|
m.field "title", :string
|
14
14
|
end
|
@@ -104,6 +104,20 @@ describe ActiveFedora::Base do
|
|
104
104
|
|
105
105
|
it { should eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/123456w" }
|
106
106
|
end
|
107
|
+
|
108
|
+
context "with an empty base path" do
|
109
|
+
it "should produce a valid URI" do
|
110
|
+
allow(ActiveFedora.fedora).to receive(:base_path).and_return("/")
|
111
|
+
expect(subject).to eq("#{ActiveFedora.fedora.host}/#{id}")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context "with a really empty base path" do
|
116
|
+
it "should produce a valid URI" do
|
117
|
+
allow(ActiveFedora.fedora).to receive(:base_path).and_return("")
|
118
|
+
expect(subject).to eq("#{ActiveFedora.fedora.host}/#{id}")
|
119
|
+
end
|
120
|
+
end
|
107
121
|
end
|
108
122
|
|
109
123
|
describe "uri_to_id" do
|
@@ -123,4 +137,5 @@ describe ActiveFedora::Base do
|
|
123
137
|
it { should eq '123456w' }
|
124
138
|
end
|
125
139
|
end
|
140
|
+
|
126
141
|
end
|
data/spec/unit/file_spec.rb
CHANGED
@@ -27,13 +27,6 @@ describe ActiveFedora::Datastream do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
describe "to_param" do
|
31
|
-
before { allow(subject).to receive(:dsid).and_return('foo.bar') }
|
32
|
-
it "should escape dots" do
|
33
|
-
expect(subject.to_param).to eq 'foo%2ebar'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
30
|
describe "#uri" do
|
38
31
|
let(:parent) { ActiveFedora::Base.new(id: '1234') }
|
39
32
|
before { allow(Deprecation).to receive(:warn) }
|
@@ -189,12 +182,23 @@ describe ActiveFedora::Datastream do
|
|
189
182
|
context "when it's saved" do
|
190
183
|
let(:parent) { ActiveFedora::Base.create }
|
191
184
|
before do
|
192
|
-
parent.
|
185
|
+
parent.add_file('one1two2threfour', path: 'abcd', mime_type: 'video/webm', original_name: 'my image.png')
|
193
186
|
parent.save!
|
194
187
|
end
|
195
188
|
|
196
189
|
it "should have original_name" do
|
197
|
-
expect(parent.reload.abcd.original_name).to eq '
|
190
|
+
expect(parent.reload.abcd.original_name).to eq 'my image.png'
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context "with special characters" do
|
195
|
+
let(:parent) { ActiveFedora::Base.create }
|
196
|
+
before do
|
197
|
+
parent.add_file('one1two2threfour', path: 'abcd', mime_type: 'video/webm', original_name:'my "image".png')
|
198
|
+
parent.save!
|
199
|
+
end
|
200
|
+
it "should save OK and preserve name" do
|
201
|
+
expect(parent.reload.abcd.original_name).to eq 'my "image".png'
|
198
202
|
end
|
199
203
|
end
|
200
204
|
end
|
@@ -209,7 +213,7 @@ describe ActiveFedora::Datastream do
|
|
209
213
|
context "when it's saved" do
|
210
214
|
let(:parent) { ActiveFedora::Base.create }
|
211
215
|
before do
|
212
|
-
parent.
|
216
|
+
parent.add_file('one1two2threfour', path: 'abcd', mime_type: 'video/webm')
|
213
217
|
parent.save!
|
214
218
|
end
|
215
219
|
|
@@ -24,7 +24,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
24
24
|
context "a one way relationship " do
|
25
25
|
describe "adding memeber" do
|
26
26
|
it "should set the relationship attribute" do
|
27
|
-
reflection = Book.create_reflection(:has_and_belongs_to_many, :pages, {predicate: ActiveFedora::RDF::RelsExt.isMemberOfCollection}, Book)
|
27
|
+
reflection = Book.create_reflection(:has_and_belongs_to_many, :pages, {predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection}, Book)
|
28
28
|
allow(ActiveFedora::SolrService).to receive(:query).and_return([])
|
29
29
|
ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, reflection)
|
30
30
|
expect(ac).to receive(:callback).twice
|
@@ -46,7 +46,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
46
46
|
let(:query2) { ids.slice(10,10).map {|i| "_query_:\"{!raw f=id}#{i}\""}.join(" OR ") }
|
47
47
|
|
48
48
|
it "should call solr query multiple times" do
|
49
|
-
reflection = Book.create_reflection(:has_and_belongs_to_many, :pages, { predicate: ActiveFedora::RDF::RelsExt.isMemberOfCollection, solr_page_size: 10}, Book)
|
49
|
+
reflection = Book.create_reflection(:has_and_belongs_to_many, :pages, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection, solr_page_size: 10}, Book)
|
50
50
|
expect(subject).to receive(:[]).with('page_ids').and_return(ids)
|
51
51
|
expect(ActiveFedora::SolrService).to receive(:query).with(query1, rows: 10).and_return([])
|
52
52
|
expect(ActiveFedora::SolrService).to receive(:query).with(query2, rows: 10).and_return([])
|
@@ -58,8 +58,8 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
context "with an inverse reflection" do
|
61
|
-
let!(:inverse) { Page.create_reflection(:has_and_belongs_to_many, :books, { predicate: ActiveFedora::RDF::RelsExt.isMemberOfCollection }, Page) }
|
62
|
-
let(:reflection) { Book.create_reflection(:has_and_belongs_to_many, :pages, { predicate: ActiveFedora::RDF::RelsExt.hasCollectionMember, inverse_of: 'books'}, Book) }
|
61
|
+
let!(:inverse) { Page.create_reflection(:has_and_belongs_to_many, :books, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Page) }
|
62
|
+
let(:reflection) { Book.create_reflection(:has_and_belongs_to_many, :pages, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, inverse_of: 'books'}, Book) }
|
63
63
|
let(:ac) { ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, reflection) }
|
64
64
|
let(:object) { Page.new }
|
65
65
|
|
@@ -84,13 +84,13 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
84
84
|
context "class with association" do
|
85
85
|
before do
|
86
86
|
class Collection < ActiveFedora::Base
|
87
|
-
has_and_belongs_to_many :members, predicate: ActiveFedora::RDF::RelsExt.hasCollectionMember, class_name: "ActiveFedora::Base", after_remove: :remove_member
|
87
|
+
has_and_belongs_to_many :members, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, class_name: "ActiveFedora::Base", after_remove: :remove_member
|
88
88
|
def remove_member (m)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
class Thing < ActiveFedora::Base
|
93
|
-
has_many :collections, predicate: ActiveFedora::RDF::RelsExt.hasCollectionMember, class_name: "ActiveFedora::Base"
|
93
|
+
has_many :collections, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, class_name: "ActiveFedora::Base"
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -22,7 +22,7 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
22
22
|
allow(ActiveFedora::SolrService).to receive(:query).and_return([])
|
23
23
|
end
|
24
24
|
|
25
|
-
let(:reflection) { Book.create_reflection(:has_many, 'pages', { predicate: ActiveFedora::RDF::RelsExt.isPartOf }, Book) }
|
25
|
+
let(:reflection) { Book.create_reflection(:has_many, 'pages', { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
|
26
26
|
let(:association) { ActiveFedora::Associations::HasManyAssociation.new(book, reflection) }
|
27
27
|
|
28
28
|
it "should set the book_id attribute" do
|
@@ -36,10 +36,10 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
36
36
|
|
37
37
|
before do
|
38
38
|
# :books must come first, so that we can test that is being passed over in favor of :contents
|
39
|
-
Page.has_many :books, predicate: ActiveFedora::RDF::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
40
|
-
Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
39
|
+
Page.has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
40
|
+
Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
41
41
|
end
|
42
|
-
let(:book_reflection) { Book.create_reflection(:has_many, 'pages', { predicate: ActiveFedora::RDF::RelsExt.isPartOf }, Book) }
|
42
|
+
let(:book_reflection) { Book.create_reflection(:has_many, 'pages', { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
|
43
43
|
let(:association) { ActiveFedora::Associations::HasManyAssociation.new(book, book_reflection) }
|
44
44
|
|
45
45
|
subject { association.send(:find_polymorphic_inverse, page) }
|
@@ -10,8 +10,8 @@ describe ActiveFedora::IndexingService do
|
|
10
10
|
let(:location_reflection) { double('location', foreign_key: 'location_id', kind_of?: true, solr_key: part_of) }
|
11
11
|
let(:reflections) { { 'person' => person_reflection, 'location' => location_reflection } }
|
12
12
|
|
13
|
-
let(:member_of) { ActiveFedora::SolrQueryBuilder.solr_name("
|
14
|
-
let(:part_of) { ActiveFedora::SolrQueryBuilder.solr_name("
|
13
|
+
let(:member_of) { ActiveFedora::SolrQueryBuilder.solr_name("info:fedora/fedora-system:def/relations-external#isMemberOf", :symbol) }
|
14
|
+
let(:part_of) { ActiveFedora::SolrQueryBuilder.solr_name("info:fedora/fedora-system:def/relations-external#isPartOf", :symbol) }
|
15
15
|
|
16
16
|
before do
|
17
17
|
expect(object).to receive(:[]).with('person_id').and_return('info:fedora/demo:10')
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::LdpResource do
|
4
|
+
let(:obj) { ActiveFedora::Base.create! }
|
5
|
+
let!(:r1) { ActiveFedora::LdpResource.new(ActiveFedora.fedora.connection, obj.uri) }
|
6
|
+
let!(:r2) { ActiveFedora::LdpResource.new(ActiveFedora.fedora.connection, obj.uri) }
|
7
|
+
|
8
|
+
it "should cache requests" do
|
9
|
+
expect_any_instance_of(Faraday::Connection).to receive(:get).once.and_call_original
|
10
|
+
ActiveFedora::Base.cache do
|
11
|
+
r1.get
|
12
|
+
r2.get
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
end
|
data/spec/unit/logger_spec.rb
CHANGED
@@ -2,39 +2,43 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Persistence do
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
describe '.delete' do
|
6
|
+
context 'with an unsaved object' do
|
7
|
+
subject { ActiveFedora::Base.new }
|
8
|
+
before { subject.delete }
|
9
|
+
it { is_expected.to eq subject }
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'with a saved object' do
|
13
|
+
subject { ActiveFedora::Base.create! }
|
14
|
+
before { subject.delete }
|
15
|
+
it { is_expected.to be_frozen }
|
9
16
|
end
|
10
17
|
end
|
11
18
|
|
12
|
-
describe
|
13
|
-
context
|
14
|
-
it
|
19
|
+
describe '.create' do
|
20
|
+
context 'when a block is provided' do
|
21
|
+
it 'passes the block to initialize' do
|
15
22
|
expect_any_instance_of(ActiveFedora::Base).to receive(:save)
|
16
23
|
expect { |b| ActiveFedora::Base.create(&b) }.to yield_with_args(an_instance_of ActiveFedora::Base)
|
17
24
|
end
|
18
25
|
end
|
19
26
|
end
|
20
27
|
|
21
|
-
describe
|
28
|
+
describe '.destroy' do
|
22
29
|
subject { ActiveFedora::Base.create! }
|
23
|
-
|
24
|
-
before
|
25
|
-
|
26
|
-
|
27
|
-
it "should be frozen" do
|
28
|
-
expect(subject).to be_frozen
|
30
|
+
context 'with no options' do
|
31
|
+
before { subject.destroy }
|
32
|
+
it 'does not clear the id' do
|
33
|
+
expect(subject.id).not_to be_nil
|
29
34
|
end
|
30
35
|
end
|
31
|
-
end
|
32
36
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
context 'with option eradicate: true' do
|
38
|
+
it 'deletes the tombstone' do
|
39
|
+
expect(subject.class).to receive(:eradicate).with(subject.id).and_return(true)
|
40
|
+
subject.destroy(eradicate: true)
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
@@ -28,7 +28,7 @@ describe ActiveFedora::Predicates do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should provide .default_predicate_namespace' do
|
31
|
-
expect(ActiveFedora::Predicates.default_predicate_namespace).to eq '
|
31
|
+
expect(ActiveFedora::Predicates.default_predicate_namespace).to eq 'info:fedora/fedora-system:def/relations-external#'
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "#predicate_mappings" do
|
@@ -37,7 +37,7 @@ describe ActiveFedora::Predicates do
|
|
37
37
|
expect(ActiveFedora::Predicates.predicate_mappings).to be_kind_of Hash
|
38
38
|
end
|
39
39
|
|
40
|
-
it "should provide mappings to the fedora ontology via the
|
40
|
+
it "should provide mappings to the fedora ontology via the info:fedora/fedora-system:def/relations-external# default namespace mapping" do
|
41
41
|
expect(ActiveFedora::Predicates.predicate_mappings.keys.include?(ActiveFedora::Predicates.default_predicate_namespace)).to be true
|
42
42
|
expect(ActiveFedora::Predicates.predicate_mappings[ActiveFedora::Predicates.default_predicate_namespace]).to be_kind_of Hash
|
43
43
|
end
|
@@ -94,7 +94,7 @@ describe ActiveFedora::Predicates do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'should allow explicit initialization of predicates' do
|
97
|
-
expect(ActiveFedora::Predicates.find_predicate(:is_part_of)).to eq ["isPartOf", "
|
97
|
+
expect(ActiveFedora::Predicates.find_predicate(:is_part_of)).to eq ["isPartOf", "info:fedora/fedora-system:def/relations-external#"]
|
98
98
|
ActiveFedora::Predicates.predicate_config = {
|
99
99
|
:default_namespace => 'http://example.com/foo',
|
100
100
|
:predicate_mapping => {
|
@@ -112,17 +112,17 @@ describe ActiveFedora::Predicates do
|
|
112
112
|
it "should allow adding predicates without wiping out existing predicates" do
|
113
113
|
ActiveFedora::Predicates.set_predicates({
|
114
114
|
"http://projecthydra.org/ns/relations#"=>{has_profile:"hasProfile"},
|
115
|
-
"
|
115
|
+
"info:fedora/fedora-system:def/relations-external#"=>{
|
116
116
|
references:"references",
|
117
117
|
has_derivation: "cameFrom"
|
118
118
|
},
|
119
119
|
})
|
120
120
|
# New & Modified Predicates
|
121
121
|
expect(ActiveFedora::Predicates.find_predicate(:has_profile)).to eq ["hasProfile", "http://projecthydra.org/ns/relations#"]
|
122
|
-
expect(ActiveFedora::Predicates.find_predicate(:references)).to eq ["references", "
|
123
|
-
expect(ActiveFedora::Predicates.find_predicate(:has_derivation)).to eq ["cameFrom", "
|
122
|
+
expect(ActiveFedora::Predicates.find_predicate(:references)).to eq ["references", "info:fedora/fedora-system:def/relations-external#"]
|
123
|
+
expect(ActiveFedora::Predicates.find_predicate(:has_derivation)).to eq ["cameFrom", "info:fedora/fedora-system:def/relations-external#"]
|
124
124
|
# Pre-Existing predicates should be unharmed
|
125
|
-
expect(ActiveFedora::Predicates.find_predicate(:is_part_of)).to eq ["isPartOf", "
|
125
|
+
expect(ActiveFedora::Predicates.find_predicate(:is_part_of)).to eq ["isPartOf", "info:fedora/fedora-system:def/relations-external#"]
|
126
126
|
expect(ActiveFedora::Predicates.find_predicate(:is_governed_by)).to eq ["isGovernedBy", "http://projecthydra.org/ns/relations#"]
|
127
127
|
end
|
128
128
|
|