active-fedora 11.1.3 → 11.2.1
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 +5 -5
- data/.rubocop.yml +3 -2
- data/.rubocop_todo.yml +73 -18
- data/.travis.yml +4 -4
- data/History.txt +6 -0
- data/README.md +1 -1
- data/active-fedora.gemspec +5 -4
- data/lib/active_fedora.rb +3 -3
- data/lib/active_fedora/aggregation/list_source.rb +1 -1
- data/lib/active_fedora/associations/association.rb +1 -2
- data/lib/active_fedora/associations/basic_contains_association.rb +3 -1
- data/lib/active_fedora/associations/builder/association.rb +1 -2
- data/lib/active_fedora/associations/null_validator.rb +1 -2
- data/lib/active_fedora/attached_files.rb +4 -0
- data/lib/active_fedora/attributes/property_builder.rb +3 -3
- data/lib/active_fedora/containers/container.rb +1 -2
- data/lib/active_fedora/file.rb +2 -3
- data/lib/active_fedora/file_configurator.rb +2 -2
- data/lib/active_fedora/fixity_service.rb +36 -5
- data/lib/active_fedora/indexers/null_indexer.rb +1 -2
- data/lib/active_fedora/indexing.rb +34 -15
- data/lib/active_fedora/indexing/descendant_fetcher.rb +101 -0
- data/lib/active_fedora/indexing/map.rb +11 -3
- data/lib/active_fedora/indexing_service.rb +6 -1
- data/lib/active_fedora/inheritance.rb +1 -1
- data/lib/active_fedora/null_logger.rb +2 -4
- data/lib/active_fedora/persistence.rb +2 -2
- data/lib/active_fedora/property.rb +1 -2
- data/lib/active_fedora/rake_support.rb +1 -1
- data/lib/active_fedora/rdf/field_map.rb +2 -2
- data/lib/active_fedora/rdf/field_map_entry.rb +7 -5
- data/lib/active_fedora/rdf/indexing_service.rb +9 -7
- data/lib/active_fedora/relation/finder_methods.rb +2 -1
- data/lib/active_fedora/solr_service.rb +2 -1
- data/lib/active_fedora/type/value.rb +2 -4
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/with_metadata/metadata_node.rb +2 -0
- data/spec/integration/associations_spec.rb +8 -8
- data/spec/integration/attached_files_spec.rb +1 -2
- data/spec/integration/collection_association_spec.rb +1 -1
- data/spec/integration/direct_container_spec.rb +2 -2
- data/spec/integration/fedora_solr_sync_spec.rb +1 -1
- data/spec/integration/generators/fedora_generator_spec.rb +1 -1
- data/spec/integration/generators/solr_generator_spec.rb +1 -1
- data/spec/integration/has_many_associations_spec.rb +4 -5
- data/spec/integration/indexing_spec.rb +21 -1
- data/spec/integration/indirect_container_spec.rb +2 -2
- data/spec/integration/solr_hit_spec.rb +1 -1
- data/spec/integration/versionable_spec.rb +2 -2
- data/spec/unit/attached_files_spec.rb +36 -8
- data/spec/unit/attributes_spec.rb +5 -13
- data/spec/unit/base_spec.rb +2 -2
- data/spec/unit/callback_spec.rb +2 -2
- data/spec/unit/change_set_spec.rb +1 -2
- data/spec/unit/collection_proxy_spec.rb +2 -1
- data/spec/unit/core_spec.rb +3 -3
- data/spec/unit/default_model_mapper_spec.rb +1 -1
- data/spec/unit/file_path_builder_spec.rb +1 -1
- data/spec/unit/file_spec.rb +23 -25
- data/spec/unit/files_hash_spec.rb +1 -2
- data/spec/unit/filter_spec.rb +2 -2
- data/spec/unit/fixity_service_spec.rb +65 -5
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +1 -2
- data/spec/unit/has_many_association_spec.rb +2 -2
- data/spec/unit/indexing/map/index_object_spec.rb +25 -0
- data/spec/unit/indexing/map_spec.rb +27 -0
- data/spec/unit/indexing_spec.rb +1 -2
- data/spec/unit/inheritance_spec.rb +28 -1
- data/spec/unit/model_classifier_spec.rb +1 -1
- data/spec/unit/pathing_spec.rb +1 -2
- data/spec/unit/query_result_builder_spec.rb +1 -2
- data/spec/unit/query_spec.rb +1 -1
- data/spec/unit/rdf/indexing_service_spec.rb +17 -3
- data/spec/unit/reflection_spec.rb +2 -2
- data/spec/unit/solr_hit_spec.rb +1 -2
- data/spec/unit/solr_service_spec.rb +6 -0
- data/spec/unit/sparql_insert_spec.rb +1 -1
- data/spec/unit/with_metadata/metadata_node_spec.rb +26 -1
- metadata +28 -12
data/spec/unit/file_spec.rb
CHANGED
@@ -1,29 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::File do
|
4
|
-
|
5
|
-
|
6
|
-
subject(:af_file) { file }
|
4
|
+
subject(:af_file) { described_class.new }
|
7
5
|
|
8
6
|
it { is_expected.not_to be_metadata }
|
9
7
|
|
10
8
|
describe "#save!" do
|
11
9
|
context "when updating metadata" do
|
12
10
|
before do
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
af_file.content = 'foo'
|
12
|
+
af_file.save!
|
13
|
+
af_file.mime_type = 'application/pdf'
|
16
14
|
end
|
17
15
|
|
18
16
|
it "Updates metadata" do
|
19
|
-
expect(
|
20
|
-
|
17
|
+
expect(af_file.metadata).to receive(:save)
|
18
|
+
af_file.save!
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
25
23
|
describe "#behaves_like_io?" do
|
26
|
-
subject {
|
24
|
+
subject { af_file.send(:behaves_like_io?, object) }
|
27
25
|
|
28
26
|
context "with a File" do
|
29
27
|
let(:object) { File.new __FILE__ }
|
@@ -43,20 +41,20 @@ describe ActiveFedora::File do
|
|
43
41
|
end
|
44
42
|
|
45
43
|
describe "#uri" do
|
46
|
-
subject(:uri) {
|
44
|
+
subject(:uri) { af_file.uri }
|
47
45
|
|
48
46
|
context "when the file is in an ldp:BasicContainer" do
|
49
47
|
let(:parent) { ActiveFedora::Base.new(id: '1234') }
|
50
48
|
|
51
49
|
context "and it's initialized with the URI" do
|
52
|
-
let(:
|
50
|
+
let(:af_file) { described_class.new(parent.uri + "/FOO1") }
|
53
51
|
it "works" do
|
54
52
|
expect(uri.to_s).to eq "#{ActiveFedora.fedora.base_uri}/1234/FOO1"
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
58
56
|
context "and it's initialized with an ID" do
|
59
|
-
let(:
|
57
|
+
let(:af_file) { described_class.new(parent.id + "/FOO1") }
|
60
58
|
it "works" do
|
61
59
|
expect(uri.to_s).to eq "#{ActiveFedora.fedora.base_uri}/1234/FOO1"
|
62
60
|
end
|
@@ -184,12 +182,12 @@ describe ActiveFedora::File do
|
|
184
182
|
|
185
183
|
context "when the file has local content" do
|
186
184
|
before do
|
187
|
-
|
188
|
-
|
185
|
+
af_file.uri = "http://localhost:8983/fedora/rest/test/1234/abcd"
|
186
|
+
af_file.content = "hi there"
|
189
187
|
end
|
190
188
|
|
191
189
|
describe "#inspect" do
|
192
|
-
subject {
|
190
|
+
subject { af_file.inspect }
|
193
191
|
it { is_expected.to eq "#<ActiveFedora::File uri=\"http://localhost:8983/fedora/rest/test/1234/abcd\" >" }
|
194
192
|
end
|
195
193
|
end
|
@@ -214,11 +212,11 @@ describe ActiveFedora::File do
|
|
214
212
|
end
|
215
213
|
|
216
214
|
context "original_name" do
|
217
|
-
subject {
|
215
|
+
subject { af_file.original_name }
|
218
216
|
|
219
217
|
context "on a new file" do
|
220
218
|
context "that has a name set locally" do
|
221
|
-
before {
|
219
|
+
before { af_file.original_name = "my_image.png" }
|
222
220
|
it { is_expected.to eq "my_image.png" }
|
223
221
|
end
|
224
222
|
|
@@ -252,7 +250,7 @@ describe ActiveFedora::File do
|
|
252
250
|
end
|
253
251
|
|
254
252
|
context "digest" do
|
255
|
-
subject {
|
253
|
+
subject(:digest) { af_file.digest }
|
256
254
|
|
257
255
|
context "on a new file" do
|
258
256
|
it { is_expected.to be_empty }
|
@@ -274,11 +272,11 @@ describe ActiveFedora::File do
|
|
274
272
|
predicate = ::RDF::URI("http://fedora.info/definitions/v4/repository#digest")
|
275
273
|
object = RDF::URI.new("urn:sha1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15")
|
276
274
|
graph = ActiveTriples::Resource.new
|
277
|
-
graph << RDF::Statement.new(
|
278
|
-
allow(
|
275
|
+
graph << RDF::Statement.new(af_file.uri, predicate, object)
|
276
|
+
allow(af_file).to receive_message_chain(:metadata, :ldp_source, :graph).and_return(graph)
|
279
277
|
end
|
280
278
|
it "falls back on fedora:digest if premis:hasMessageDigest is not present" do
|
281
|
-
expect(
|
279
|
+
expect(digest.first).to be_kind_of RDF::URI
|
282
280
|
end
|
283
281
|
end
|
284
282
|
end
|
@@ -308,14 +306,14 @@ describe ActiveFedora::File do
|
|
308
306
|
end
|
309
307
|
|
310
308
|
describe "#create_date" do
|
311
|
-
subject {
|
309
|
+
subject { af_file.create_date }
|
312
310
|
describe "when new record" do
|
313
311
|
it { is_expected.to be_nil }
|
314
312
|
end
|
315
313
|
describe "when persisted" do
|
316
314
|
before do
|
317
|
-
|
318
|
-
|
315
|
+
af_file.content = "foo"
|
316
|
+
af_file.save!
|
319
317
|
end
|
320
318
|
it { is_expected.to be_a(DateTime) }
|
321
319
|
end
|
@@ -453,7 +451,7 @@ describe ActiveFedora::File do
|
|
453
451
|
|
454
452
|
context "when Array passed to new" do
|
455
453
|
it "raises an expection" do
|
456
|
-
expect { described_class.new([]) }.to raise_error
|
454
|
+
expect { described_class.new([]) }.to raise_error(RuntimeError)
|
457
455
|
end
|
458
456
|
end
|
459
457
|
end
|
@@ -10,13 +10,12 @@ describe ActiveFedora::FilesHash do
|
|
10
10
|
|
11
11
|
after { Object.send(:remove_const, :FilesContainer) }
|
12
12
|
|
13
|
+
subject(:file_hash) { described_class.new(container) }
|
13
14
|
let(:reflection) { instance_double(ActiveFedora::Reflection::MacroReflection) }
|
14
15
|
let(:association) { instance_double(ActiveFedora::Associations::SingularAssociation, reader: object) }
|
15
16
|
let(:object) { double('object') }
|
16
17
|
let(:container) { FilesContainer.new }
|
17
18
|
|
18
|
-
subject(:file_hash) { described_class.new(container) }
|
19
|
-
|
20
19
|
describe "#key?" do
|
21
20
|
context 'when the key is present' do
|
22
21
|
it "is true" do
|
data/spec/unit/filter_spec.rb
CHANGED
@@ -120,14 +120,14 @@ describe ActiveFedora::Associations::FilterAssociation do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
describe "#delete" do
|
123
|
+
subject { image.members }
|
124
|
+
|
123
125
|
let(:another_object) { TestObject.new }
|
124
126
|
before do
|
125
127
|
image.members = [test_object, test_collection, another_object]
|
126
128
|
image.child_objects.delete(test_object)
|
127
129
|
end
|
128
130
|
|
129
|
-
subject { image.members }
|
130
|
-
|
131
131
|
it { is_expected.to contain_exactly test_collection, another_object }
|
132
132
|
end
|
133
133
|
end
|
@@ -4,6 +4,32 @@ describe ActiveFedora::FixityService do
|
|
4
4
|
let(:service) { described_class.new(uri) }
|
5
5
|
let(:uri) { RDF::URI("http://path/to/resource") }
|
6
6
|
|
7
|
+
let(:passing_fedora44_response_body) {
|
8
|
+
<<-EOF
|
9
|
+
@prefix premis: <http://www.loc.gov/premis/rdf/v1#> .
|
10
|
+
|
11
|
+
<http://127.0.0.1:8080/rest/dev/0k/22/5b/04/0k225b04p/files/9f296a1f-10e7-44a3-83eb-4811d611edc6/fcr:versions/version1> premis:hasFixity <http://127.0.0.1:8080/rest/dev/0k/22/5b/04/0k225b04p/files/9f296a1f-10e7-44a3-83eb-4811d611edc6/fcr:versions/version1#fixity/1493843767961> .
|
12
|
+
|
13
|
+
<http://127.0.0.1:8080/rest/dev/0k/22/5b/04/0k225b04p/files/9f296a1f-10e7-44a3-83eb-4811d611edc6/fcr:versions/version1#fixity/1493843767961> a premis:Fixity , premis:EventOutcomeDetail ;
|
14
|
+
premis:hasEventOutcome "SUCCESS"^^<http://www.w3.org/2001/XMLSchema#string> ;
|
15
|
+
premis:hasMessageDigest <urn:sha1:b995eef5262dd1c74f0ed9c96be1f404394d45dc> ;
|
16
|
+
premis:hasSize "103945"^^<http://www.w3.org/2001/XMLSchema#long> .
|
17
|
+
EOF
|
18
|
+
}
|
19
|
+
|
20
|
+
let(:failing_fedora44_response_body) {
|
21
|
+
<<-EOF
|
22
|
+
@prefix premis: <http://www.loc.gov/premis/rdf/v1#> .
|
23
|
+
|
24
|
+
<http://127.0.0.1:8080/rest/dev/ks/65/hc/20/ks65hc20t/files/e316b4b5-4627-44f8-9fdb-d2016e0e7380/fcr:versions/version3> premis:hasFixity <http://127.0.0.1:8080/rest/dev/ks/65/hc/20/ks65hc20t/files/e316b4b5-4627-44f8-9fdb-d2016e0e7380/fcr:versions/version3#fixity/1493844791463> .
|
25
|
+
|
26
|
+
<http://127.0.0.1:8080/rest/dev/ks/65/hc/20/ks65hc20t/files/e316b4b5-4627-44f8-9fdb-d2016e0e7380/fcr:versions/version3#fixity/1493844791463> a premis:Fixity , premis:EventOutcomeDetail ;
|
27
|
+
premis:hasEventOutcome "BAD_CHECKSUM"^^<http://www.w3.org/2001/XMLSchema#string> , "BAD_SIZE"^^<http://www.w3.org/2001/XMLSchema#string> ;
|
28
|
+
premis:hasMessageDigest <urn:sha1:1a89571e25dd372563a10740a883e93f8af2d146> ;
|
29
|
+
premis:hasSize "1878582"^^<http://www.w3.org/2001/XMLSchema#long> .
|
30
|
+
EOF
|
31
|
+
}
|
32
|
+
|
7
33
|
describe "the instance" do
|
8
34
|
subject { described_class.new(uri) }
|
9
35
|
it { is_expected.to respond_to(:response) }
|
@@ -11,8 +37,8 @@ describe ActiveFedora::FixityService do
|
|
11
37
|
|
12
38
|
describe "initialize" do
|
13
39
|
context "with a string" do
|
14
|
-
let(:uri) { 'http://path/to/resource' }
|
15
40
|
subject { service.target }
|
41
|
+
let(:uri) { 'http://path/to/resource' }
|
16
42
|
it { is_expected.to eq 'http://path/to/resource' }
|
17
43
|
end
|
18
44
|
|
@@ -22,21 +48,21 @@ describe ActiveFedora::FixityService do
|
|
22
48
|
end
|
23
49
|
end
|
24
50
|
|
25
|
-
describe "#
|
51
|
+
describe "#verified?" do
|
26
52
|
before { allow(service).to receive(:fixity_response_from_fedora).and_return(response) }
|
27
|
-
subject { service.
|
53
|
+
subject { service.verified? }
|
28
54
|
|
29
55
|
context "with Fedora version >= 4.4.0" do
|
30
56
|
context "with a passing result" do
|
31
57
|
let(:response) do
|
32
|
-
instance_double("Response", body:
|
58
|
+
instance_double("Response", body: passing_fedora44_response_body)
|
33
59
|
end
|
34
60
|
it { is_expected.to be true }
|
35
61
|
end
|
36
62
|
|
37
63
|
context "with a failing result" do
|
38
64
|
let(:response) do
|
39
|
-
instance_double("Response", body:
|
65
|
+
instance_double("Response", body: failing_fedora44_response_body)
|
40
66
|
end
|
41
67
|
it { is_expected.to be false }
|
42
68
|
end
|
@@ -65,4 +91,38 @@ describe ActiveFedora::FixityService do
|
|
65
91
|
it { is_expected.to be false }
|
66
92
|
end
|
67
93
|
end
|
94
|
+
|
95
|
+
describe "expected_message_digest" do
|
96
|
+
before { allow(service).to receive(:fixity_response_from_fedora).and_return(response) }
|
97
|
+
subject { service.expected_message_digest }
|
98
|
+
context "with success response" do
|
99
|
+
let(:response) do
|
100
|
+
instance_double("Response", body: passing_fedora44_response_body)
|
101
|
+
end
|
102
|
+
it { is_expected.to match(/urn:sha1:[a-f0-9]+/) }
|
103
|
+
end
|
104
|
+
context "with failure response" do
|
105
|
+
let(:response) do
|
106
|
+
instance_double("Response", body: failing_fedora44_response_body)
|
107
|
+
end
|
108
|
+
it { is_expected.to match(/urn:sha1:[a-f0-9]+/) }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "expected_size" do
|
113
|
+
before { allow(service).to receive(:fixity_response_from_fedora).and_return(response) }
|
114
|
+
subject { service.expected_size }
|
115
|
+
context "with success response" do
|
116
|
+
let(:response) do
|
117
|
+
instance_double("Response", body: passing_fedora44_response_body)
|
118
|
+
end
|
119
|
+
it { is_expected.to be_kind_of Numeric }
|
120
|
+
end
|
121
|
+
context "with failure response" do
|
122
|
+
let(:response) do
|
123
|
+
instance_double("Response", body: failing_fedora44_response_body)
|
124
|
+
end
|
125
|
+
it { is_expected.to be_kind_of Numeric }
|
126
|
+
end
|
127
|
+
end
|
68
128
|
end
|
@@ -77,8 +77,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
77
77
|
before do
|
78
78
|
class Collection < ActiveFedora::Base
|
79
79
|
has_and_belongs_to_many :members, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, class_name: "ActiveFedora::Base", after_remove: :remove_member
|
80
|
-
def remove_member(_m)
|
81
|
-
end
|
80
|
+
def remove_member(_m); end
|
82
81
|
end
|
83
82
|
|
84
83
|
class Thing < ActiveFedora::Base
|
@@ -33,11 +33,11 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "#find_polymorphic_inverse" do
|
36
|
+
subject(:af_page) { association.send(:find_polymorphic_inverse, page) }
|
37
|
+
|
36
38
|
let(:book_reflection) { ActiveFedora::Reflection.create(:has_many, 'pages', nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
|
37
39
|
let(:association) { described_class.new(book, book_reflection) }
|
38
40
|
|
39
|
-
subject(:af_page) { association.send(:find_polymorphic_inverse, page) }
|
40
|
-
|
41
41
|
context "when a has_many is present" do
|
42
42
|
before do
|
43
43
|
# :books must come first, so that we can test that is being passed over in favor of :contents
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe ActiveFedora::Indexing::Map::IndexObject do
|
4
|
+
describe "with a block" do
|
5
|
+
subject(:instance) do
|
6
|
+
described_class.new(:name) do |index|
|
7
|
+
index.as :stored_searchable, :facetable
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "can set behaviors" do
|
12
|
+
expect(instance.behaviors).to eq [:stored_searchable, :facetable]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "with an initializer parameters" do
|
17
|
+
subject(:instance) do
|
18
|
+
described_class.new(:name, behaviors: [:stored_searchable, :facetable])
|
19
|
+
end
|
20
|
+
|
21
|
+
it "can set behaviors" do
|
22
|
+
expect(instance.behaviors).to eq [:stored_searchable, :facetable]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe ActiveFedora::Indexing::Map do
|
4
|
+
describe ".merge" do
|
5
|
+
subject(:merged) { first_map.merge(extra) }
|
6
|
+
let(:index_object1) { instance_double(described_class::IndexObject) }
|
7
|
+
let(:index_object2) { instance_double(described_class::IndexObject) }
|
8
|
+
let(:index_object3) { instance_double(described_class::IndexObject) }
|
9
|
+
let(:first_map) { described_class.new(one: index_object1, two: index_object2) }
|
10
|
+
|
11
|
+
context "with a hash" do
|
12
|
+
let(:extra) { { three: index_object3 } }
|
13
|
+
it "merges with a hash" do
|
14
|
+
expect(merged).to be_instance_of described_class
|
15
|
+
expect(merged.keys).to match_array [:one, :two, :three]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with another Indexing::Map" do
|
20
|
+
let(:extra) { described_class.new(three: index_object3) }
|
21
|
+
it "merges with the other map" do
|
22
|
+
expect(merged).to be_instance_of described_class
|
23
|
+
expect(merged.keys).to match_array [:one, :two, :three]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/unit/indexing_spec.rb
CHANGED
@@ -53,9 +53,8 @@ describe ActiveFedora::Indexing do
|
|
53
53
|
Object.send(:remove_const, :SpecNode)
|
54
54
|
end
|
55
55
|
|
56
|
-
let(:test_object) { SpecNode.new(title: ['first title'], abstract: 'The abstract') }
|
57
|
-
|
58
56
|
subject(:solr_doc) { test_object.to_solr }
|
57
|
+
let(:test_object) { SpecNode.new(title: ['first title'], abstract: 'The abstract') }
|
59
58
|
|
60
59
|
it "indexs the rdf properties" do
|
61
60
|
expect(solr_doc).to include('title_tesim' => ['first title'], 'abstract_ssi' => 'The abstract')
|
@@ -8,6 +8,9 @@ describe ActiveFedora::Base do
|
|
8
8
|
class MySample < ActiveFedora::File
|
9
9
|
end
|
10
10
|
|
11
|
+
class MyDeepSample < MySample
|
12
|
+
end
|
13
|
+
|
11
14
|
class Foo < ActiveFedora::Base
|
12
15
|
has_subresource 'foostream', class_name: 'MyDS'
|
13
16
|
has_subresource 'dcstream', class_name: 'MySample'
|
@@ -16,18 +19,42 @@ describe ActiveFedora::Base do
|
|
16
19
|
class Bar < ActiveFedora::Base
|
17
20
|
has_subresource 'barstream', class_name: 'MyDS'
|
18
21
|
end
|
22
|
+
|
23
|
+
class Baz < Bar
|
24
|
+
end
|
19
25
|
end
|
20
|
-
|
26
|
+
|
21
27
|
subject(:attached_files) { f.attached_files }
|
28
|
+
let(:f) { Foo.new }
|
22
29
|
|
23
30
|
it "doesn't overwrite stream specs" do
|
24
31
|
expect(attached_files.values).to match_array [MyDS, MySample]
|
25
32
|
end
|
26
33
|
|
34
|
+
context 'base_class' do
|
35
|
+
it 'shallow < Base' do
|
36
|
+
expect(Bar.base_class).to eq(Bar)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'deep < Base' do
|
40
|
+
expect(Baz.base_class).to eq(Bar)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'shallow < File' do
|
44
|
+
expect(MySample.base_class).to eq(ActiveFedora::File)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'deep < File' do
|
48
|
+
expect(MyDeepSample.base_class).to eq(ActiveFedora::File)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
27
52
|
after do
|
53
|
+
Object.send(:remove_const, :Baz)
|
28
54
|
Object.send(:remove_const, :Bar)
|
29
55
|
Object.send(:remove_const, :Foo)
|
30
56
|
Object.send(:remove_const, :MyDS)
|
57
|
+
Object.send(:remove_const, :MyDeepSample)
|
31
58
|
Object.send(:remove_const, :MySample)
|
32
59
|
end
|
33
60
|
end
|
@@ -10,8 +10,8 @@ describe ActiveFedora::ModelClassifier do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
let(:class_names) { ["ParentClass::SiblingClass", "ParentClass::OtherSiblingClass", "ParentClass::SubclassClass", "ParentClass::NoSuchClass"] }
|
14
13
|
subject(:classifier) { described_class.new class_names }
|
14
|
+
let(:class_names) { ["ParentClass::SiblingClass", "ParentClass::OtherSiblingClass", "ParentClass::SubclassClass", "ParentClass::NoSuchClass"] }
|
15
15
|
|
16
16
|
describe ".class_from_string" do
|
17
17
|
it "returns class constants based on strings" do
|
data/spec/unit/pathing_spec.rb
CHANGED
@@ -2,8 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
4
|
describe ".uri_prefix" do
|
5
|
-
let(:path) { "foo" }
|
6
|
-
|
7
5
|
before do
|
8
6
|
class FooHistory < ActiveFedora::Base
|
9
7
|
def uri_prefix
|
@@ -18,6 +16,7 @@ describe ActiveFedora::Base do
|
|
18
16
|
end
|
19
17
|
|
20
18
|
subject(:history) { FooHistory.new(title: ["Root foo"]) }
|
19
|
+
let(:path) { "foo" }
|
21
20
|
|
22
21
|
it { is_expected.to have_uri_prefix }
|
23
22
|
|