active-fedora 9.12.0 → 9.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/active-fedora.gemspec +1 -0
- data/lib/active_fedora.rb +1 -0
- data/lib/active_fedora/associations.rb +38 -3
- data/lib/active_fedora/associations/basic_contains_association.rb +12 -51
- data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
- data/lib/active_fedora/associations/builder/basic_contains.rb +7 -0
- data/lib/active_fedora/associations/builder/{contains.rb → has_subresource.rb} +2 -2
- data/lib/active_fedora/associations/contains_association.rb +19 -1
- data/lib/active_fedora/associations/directly_contains_association.rb +1 -15
- data/lib/active_fedora/associations/has_subresource_association.rb +61 -0
- data/lib/active_fedora/attached_files.rb +6 -9
- data/lib/active_fedora/autosave_association.rb +1 -1
- data/lib/active_fedora/base.rb +0 -1
- data/lib/active_fedora/common.rb +1 -0
- data/lib/active_fedora/fedora.rb +14 -19
- data/lib/active_fedora/file.rb +1 -1
- data/lib/active_fedora/file/attributes.rb +4 -0
- data/lib/active_fedora/file_persistence.rb +9 -1
- data/lib/active_fedora/initializing_connection.rb +64 -0
- data/lib/active_fedora/ldp_cache.rb +1 -2
- data/lib/active_fedora/ldp_resource_service.rb +7 -1
- data/lib/active_fedora/persistence.rb +12 -1
- data/lib/active_fedora/reflection.rb +22 -6
- data/lib/active_fedora/simple_datastream.rb +2 -0
- data/lib/active_fedora/version.rb +1 -1
- data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +1 -0
- data/lib/generators/active_fedora/config/fedora/templates/.fcrepo_wrapper +1 -0
- data/lib/generators/active_fedora/config/fedora/templates/fcrepo_wrapper_test.yml +4 -0
- data/lib/generators/active_fedora/config/solr/solr_generator.rb +1 -0
- data/lib/generators/active_fedora/config/solr/templates/.solr_wrapper +3 -0
- data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +8 -0
- data/spec/integration/attached_files_spec.rb +77 -18
- data/spec/integration/attributes_spec.rb +3 -4
- data/spec/integration/autosave_association_spec.rb +0 -1
- data/spec/integration/base_spec.rb +19 -66
- data/spec/integration/basic_contains_association_spec.rb +108 -0
- data/spec/integration/complex_rdf_datastream_spec.rb +1 -1
- data/spec/integration/field_to_solr_name_spec.rb +12 -11
- data/spec/integration/file_fixity_spec.rb +1 -1
- data/spec/integration/file_spec.rb +4 -1
- data/spec/integration/generators/fedora_generator_spec.rb +26 -0
- data/spec/integration/generators/solr_generator_spec.rb +26 -0
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +6 -16
- data/spec/integration/has_many_associations_spec.rb +6 -16
- data/spec/integration/{contains_association_spec.rb → has_subresource_spec.rb} +1 -1
- data/spec/integration/json_serialization_spec.rb +11 -5
- data/spec/integration/model_spec.rb +7 -13
- data/spec/integration/ntriples_datastream_spec.rb +2 -2
- data/spec/integration/om_datastream_spec.rb +1 -1
- data/spec/integration/persistence_spec.rb +0 -3
- data/spec/integration/query_result_builder_spec.rb +1 -1
- data/spec/integration/relation_delegation_spec.rb +3 -8
- data/spec/integration/scoped_query_spec.rb +5 -7
- data/spec/integration/solr_hit_spec.rb +10 -4
- data/spec/integration/solr_instance_loader_spec.rb +11 -4
- data/spec/integration/versionable_spec.rb +3 -3
- data/spec/spec_helper.rb +5 -1
- data/spec/unit/active_fedora_spec.rb +1 -1
- data/spec/unit/attached_files_spec.rb +32 -21
- data/spec/unit/attributes_spec.rb +21 -23
- data/spec/unit/base_active_model_spec.rb +13 -10
- data/spec/unit/base_spec.rb +2 -24
- data/spec/unit/callback_spec.rb +0 -8
- data/spec/unit/core_spec.rb +3 -5
- data/spec/unit/inheritance_spec.rb +15 -9
- data/spec/unit/ntriples_datastream_spec.rb +1 -1
- data/spec/unit/om_datastream_spec.rb +1 -1
- data/spec/unit/persistence_spec.rb +21 -0
- data/spec/unit/query_spec.rb +8 -0
- data/spec/unit/rdf_datastream_spec.rb +1 -1
- data/spec/unit/rdf_resource_datastream_spec.rb +1 -1
- data/spec/unit/simple_datastream_spec.rb +8 -2
- data/spec/unit/solr_config_options_spec.rb +1 -1
- data/spec/unit/validations_spec.rb +2 -8
- metadata +27 -6
- data/spec/integration/bug_spec.rb +0 -40
- data/spec/integration/full_featured_model_spec.rb +0 -160
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe ActiveFedora::Base do
|
4
4
|
before do
|
5
5
|
class Source < ActiveFedora::Base
|
6
|
-
|
6
|
+
has_subresource :sub_resource, class_name: "Source"
|
7
7
|
property :title, predicate: ::RDF::Vocab::DC.title, multiple: false
|
8
8
|
end
|
9
9
|
end
|
@@ -7,11 +7,16 @@ describe "Objects should be serialized to JSON" do
|
|
7
7
|
|
8
8
|
context "with properties and datastream attributes" do
|
9
9
|
before do
|
10
|
-
class
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
class MyDS < ActiveFedora::OmDatastream
|
11
|
+
set_terminology do |t|
|
12
|
+
t.root(path: "durh")
|
13
|
+
t.foo
|
14
|
+
t.bar
|
14
15
|
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Foo < ActiveFedora::Base
|
19
|
+
has_subresource 'descMetadata', class_name: 'MyDS'
|
15
20
|
Deprecation.silence(ActiveFedora::Attributes) do
|
16
21
|
has_attributes :foo, datastream: 'descMetadata', multiple: true
|
17
22
|
has_attributes :bar, datastream: 'descMetadata', multiple: false
|
@@ -22,6 +27,7 @@ describe "Objects should be serialized to JSON" do
|
|
22
27
|
|
23
28
|
after do
|
24
29
|
Object.send(:remove_const, :Foo)
|
30
|
+
Object.send(:remove_const, :MyDS)
|
25
31
|
end
|
26
32
|
|
27
33
|
let(:obj) { Foo.new(foo: ["baz"], bar: 'quix', title: ['My Title']) }
|
@@ -56,7 +62,7 @@ describe "Objects should be serialized to JSON" do
|
|
56
62
|
end
|
57
63
|
|
58
64
|
class DummyAsset < ActiveFedora::Base
|
59
|
-
|
65
|
+
has_subresource 'descMetadata', class_name: 'DummyResource'
|
60
66
|
Deprecation.silence(ActiveFedora::Attributes) do
|
61
67
|
has_attributes :relation, datastream: 'descMetadata', at: [:license, :relation], multiple: false
|
62
68
|
end
|
@@ -1,25 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Model do
|
4
|
-
before
|
4
|
+
before do
|
5
5
|
module ModelIntegrationSpec
|
6
6
|
class Base < ActiveFedora::Base
|
7
7
|
include ActiveFedora::Model
|
8
|
-
def self.id_namespace
|
9
|
-
"foo"
|
10
|
-
end
|
11
|
-
has_metadata name: "properties", type: ActiveFedora::SimpleDatastream, autocreate: true
|
12
8
|
end
|
13
9
|
class Basic < Base
|
14
10
|
end
|
15
11
|
end
|
16
|
-
|
17
|
-
@test_instance = ModelIntegrationSpec::Basic.new
|
18
|
-
@test_instance.save
|
19
12
|
end
|
13
|
+
let!(:test_instance) { ModelIntegrationSpec::Basic.create! }
|
20
14
|
|
21
|
-
after
|
22
|
-
|
15
|
+
after do
|
16
|
+
test_instance.delete
|
23
17
|
Object.send(:remove_const, :ModelIntegrationSpec)
|
24
18
|
end
|
25
19
|
|
@@ -37,15 +31,15 @@ describe ActiveFedora::Model do
|
|
37
31
|
|
38
32
|
describe '#find' do
|
39
33
|
describe "#find with a valid id without cast" do
|
40
|
-
subject { ActiveFedora::Base.find(
|
34
|
+
subject { ActiveFedora::Base.find(test_instance.id) }
|
41
35
|
it { should be_instance_of ModelIntegrationSpec::Basic }
|
42
36
|
end
|
43
37
|
describe "#find with a valid id with cast of false" do
|
44
|
-
subject { ActiveFedora::Base.find(
|
38
|
+
subject { ActiveFedora::Base.find(test_instance.id, cast: false) }
|
45
39
|
it { should be_instance_of ActiveFedora::Base }
|
46
40
|
end
|
47
41
|
describe "#find with a valid id without cast on a model extending Base" do
|
48
|
-
subject { ModelIntegrationSpec::Basic.find(
|
42
|
+
subject { ModelIntegrationSpec::Basic.find(test_instance.id) }
|
49
43
|
it { should be_instance_of ModelIntegrationSpec::Basic }
|
50
44
|
end
|
51
45
|
end
|
@@ -26,7 +26,7 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
class RdfTest < ActiveFedora::Base
|
29
|
-
|
29
|
+
has_subresource 'rdf', class_name: 'MyDatastream'
|
30
30
|
Deprecation.silence(ActiveFedora::Attributes) do
|
31
31
|
has_attributes :based_near, :related_url, :part, :date_uploaded, datastream: 'rdf', multiple: true
|
32
32
|
has_attributes :title, :filesize, datastream: 'rdf', multiple: false
|
@@ -227,7 +227,7 @@ EOF
|
|
227
227
|
property :title, predicate: ::RDF::Vocab::DC.title
|
228
228
|
end
|
229
229
|
class Foobar < ActiveFedora::Base
|
230
|
-
|
230
|
+
has_subresource 'rdf', class_name: 'TitleDatastream'
|
231
231
|
Deprecation.silence(ActiveFedora::Attributes) do
|
232
232
|
has_attributes :title, datastream: 'rdf', multiple: true
|
233
233
|
end
|
@@ -4,7 +4,7 @@ describe ActiveFedora::OmDatastream do
|
|
4
4
|
before(:all) do
|
5
5
|
class ModsArticle2 < ActiveFedora::Base
|
6
6
|
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
7
|
-
|
7
|
+
has_subresource "descMetadata", class_name: 'Hydra::ModsArticleDatastream'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -4,9 +4,6 @@ describe "persisting objects" do
|
|
4
4
|
describe "#create!" do
|
5
5
|
before do
|
6
6
|
class MockAFBaseRelationship < ActiveFedora::Base
|
7
|
-
has_metadata type: ActiveFedora::SimpleDatastream, name: "foo" do |m|
|
8
|
-
m.field "name", :string
|
9
|
-
end
|
10
7
|
property :name, predicate: ::RDF::Vocab::DC.title, multiple: false
|
11
8
|
validates :name, presence: true
|
12
9
|
end
|
@@ -8,7 +8,7 @@ describe ActiveFedora::QueryResultBuilder do
|
|
8
8
|
"foo"
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
has_subresource :descMetadata, class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
|
12
12
|
end
|
13
13
|
@test_object = ActiveFedora::Base.new
|
14
14
|
@foo_object = FooObject.new
|
@@ -4,14 +4,9 @@ describe ActiveFedora::Model do
|
|
4
4
|
before(:all) do
|
5
5
|
module ModelIntegrationSpec
|
6
6
|
class Basic < ActiveFedora::Base
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
m.field "baz", :string
|
11
|
-
end
|
12
|
-
|
13
|
-
Deprecation.silence(ActiveFedora::Attributes) do
|
14
|
-
has_attributes :foo, :bar, :baz, datastream: 'properties', multiple: true
|
7
|
+
property :foo, predicate: ::RDF::URI('http://example.com/foo')
|
8
|
+
property :bar, predicate: ::RDF::URI('http://example.com/bar') do |index|
|
9
|
+
index.as :stored_searchable
|
15
10
|
end
|
16
11
|
|
17
12
|
def to_solr(doc = {})
|
@@ -4,15 +4,13 @@ describe ActiveFedora::Querying do
|
|
4
4
|
before do
|
5
5
|
module ModelIntegrationSpec
|
6
6
|
class Basic < ActiveFedora::Base
|
7
|
-
|
8
|
-
|
9
|
-
m.field "bar", :string
|
10
|
-
m.field "baz", :string
|
7
|
+
property :foo, predicate: ::RDF::URI('http://example.com/foo') do |index|
|
8
|
+
index.as :stored_searchable
|
11
9
|
end
|
12
|
-
|
13
|
-
|
14
|
-
has_attributes :foo, :bar, :baz, datastream: 'properties', multiple: true
|
10
|
+
property :bar, predicate: ::RDF::URI('http://example.com/bar') do |index|
|
11
|
+
index.as :stored_searchable
|
15
12
|
end
|
13
|
+
property :baz, predicate: ::RDF::URI('http://example.com/baz')
|
16
14
|
|
17
15
|
def to_solr(doc = {})
|
18
16
|
doc = super
|
@@ -2,11 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::SolrHit do
|
4
4
|
before do
|
5
|
-
class
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
class MyDS < ActiveFedora::OmDatastream
|
6
|
+
set_terminology do |t|
|
7
|
+
t.root(path: "durh")
|
8
|
+
t.foo
|
9
|
+
t.bar
|
9
10
|
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Foo < ActiveFedora::Base
|
14
|
+
has_subresource 'descMetadata', class_name: 'MyDS'
|
10
15
|
Deprecation.silence(ActiveFedora::Attributes) do
|
11
16
|
has_attributes :foo, datastream: 'descMetadata', multiple: true
|
12
17
|
has_attributes :bar, datastream: 'descMetadata', multiple: false
|
@@ -29,6 +34,7 @@ describe ActiveFedora::SolrHit do
|
|
29
34
|
|
30
35
|
after do
|
31
36
|
Object.send(:remove_const, :Foo)
|
37
|
+
Object.send(:remove_const, :MyDS)
|
32
38
|
end
|
33
39
|
|
34
40
|
describe "#reify" do
|
@@ -2,11 +2,17 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::SolrInstanceLoader do
|
4
4
|
before do
|
5
|
-
class
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
class MyDS < ActiveFedora::OmDatastream
|
6
|
+
set_terminology do |t|
|
7
|
+
t.root(path: "durh")
|
8
|
+
t.foo
|
9
|
+
t.bar
|
9
10
|
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Foo < ActiveFedora::Base
|
14
|
+
extend Deprecation
|
15
|
+
has_subresource 'descMetadata', class_name: 'MyDS'
|
10
16
|
Deprecation.silence(ActiveFedora::Attributes) do
|
11
17
|
has_attributes :foo, datastream: 'descMetadata', multiple: true
|
12
18
|
has_attributes :bar, datastream: 'descMetadata', multiple: false
|
@@ -38,6 +44,7 @@ describe ActiveFedora::SolrInstanceLoader do
|
|
38
44
|
after do
|
39
45
|
Object.send(:remove_const, :Foo)
|
40
46
|
Object.send(:remove_const, :Bar)
|
47
|
+
Object.send(:remove_const, :MyDS)
|
41
48
|
end
|
42
49
|
|
43
50
|
context "without a solr doc" do
|
@@ -142,7 +142,7 @@ describe ActiveFedora::Versionable do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
class MockAFBase < ActiveFedora::Base
|
145
|
-
|
145
|
+
has_subresource "descMetadata", class_name: 'VersionableDatastream', autocreate: true
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -272,7 +272,7 @@ describe ActiveFedora::Versionable do
|
|
272
272
|
end
|
273
273
|
|
274
274
|
class MockAFBase < ActiveFedora::Base
|
275
|
-
|
275
|
+
has_subresource "descMetadata", class_name: 'VersionableDatastream', autocreate: true
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
@@ -395,7 +395,7 @@ describe ActiveFedora::Versionable do
|
|
395
395
|
end
|
396
396
|
|
397
397
|
class MockAFBase < ActiveFedora::Base
|
398
|
-
|
398
|
+
has_subresource "content", class_name: 'BinaryDatastream', autocreate: true
|
399
399
|
end
|
400
400
|
end
|
401
401
|
|
data/spec/spec_helper.rb
CHANGED
@@ -42,7 +42,11 @@ require 'active_fedora/cleaner'
|
|
42
42
|
RSpec.configure do |config|
|
43
43
|
# Stub out test stuff.
|
44
44
|
config.before(:each) do
|
45
|
-
|
45
|
+
begin
|
46
|
+
ActiveFedora::Cleaner.clean!
|
47
|
+
rescue Faraday::ConnectionFailed, RSolr::Error::ConnectionRefused => e
|
48
|
+
$stderr.puts e.message
|
49
|
+
end
|
46
50
|
end
|
47
51
|
config.after(:each) do
|
48
52
|
# cleanout_fedora
|
@@ -28,7 +28,7 @@ describe ActiveFedora do
|
|
28
28
|
it "does not connect and warn" do
|
29
29
|
expect(ActiveFedora::Base.logger).to receive(:warn)
|
30
30
|
expect {
|
31
|
-
ActiveFedora::Fedora.new(url: bad_url, base_path: '/test', user: user, password: password).connection
|
31
|
+
ActiveFedora::Fedora.new(url: bad_url, base_path: '/test', user: user, password: password).connection.head
|
32
32
|
}.to raise_error Ldp::HttpError
|
33
33
|
end
|
34
34
|
end
|
@@ -2,15 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::AttachedFiles do
|
4
4
|
subject { ActiveFedora::Base.new }
|
5
|
-
describe "
|
5
|
+
describe "has_subresource" do
|
6
6
|
before do
|
7
7
|
class Z < ActiveFedora::File
|
8
8
|
end
|
9
9
|
class FooHistory < ActiveFedora::Base
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
has_subresource 'dsid', class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
|
11
|
+
has_subresource 'complex_ds', autocreate: true, class_name: 'Z'
|
12
|
+
has_subresource 'thumbnail'
|
13
|
+
has_subresource 'child_resource', class_name: 'ActiveFedora::Base'
|
14
14
|
end
|
15
15
|
end
|
16
16
|
after do
|
@@ -30,24 +30,24 @@ describe ActiveFedora::AttachedFiles do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "raises an error if you don't give a dsid" do
|
33
|
-
expect { FooHistory.
|
34
|
-
|
33
|
+
expect { FooHistory.has_subresource nil, type: ActiveFedora::QualifiedDublinCoreDatastream }.to raise_error ArgumentError,
|
34
|
+
"You must provide a path name (f.k.a. dsid) for the resource"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe '.has_metadata' do
|
39
39
|
before do
|
40
|
-
@original_behavior = Deprecation.default_deprecation_behavior
|
41
|
-
Deprecation.default_deprecation_behavior = :silence
|
42
40
|
class Z < ActiveFedora::File
|
43
41
|
end
|
44
42
|
class FooHistory < ActiveFedora::Base
|
45
|
-
|
46
|
-
|
43
|
+
extend Deprecation
|
44
|
+
Deprecation.silence(FooHistory) do
|
45
|
+
has_metadata name: 'dsid', type: ActiveFedora::QualifiedDublinCoreDatastream
|
46
|
+
has_metadata 'complex_ds', autocreate: true, type: 'Z'
|
47
|
+
end
|
47
48
|
end
|
48
49
|
end
|
49
50
|
after do
|
50
|
-
Deprecation.default_deprecation_behavior = @original_behavior
|
51
51
|
Object.send(:remove_const, :FooHistory)
|
52
52
|
Object.send(:remove_const, :Z)
|
53
53
|
end
|
@@ -57,7 +57,7 @@ describe ActiveFedora::AttachedFiles do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it "has reasonable defaults" do
|
60
|
-
expect(FooHistory.child_resource_reflections[:dsid].options).to include(class_name: 'ActiveFedora::
|
60
|
+
expect(FooHistory.child_resource_reflections[:dsid].options).to include(class_name: 'ActiveFedora::QualifiedDublinCoreDatastream')
|
61
61
|
end
|
62
62
|
|
63
63
|
it "lets you override defaults" do
|
@@ -66,13 +66,21 @@ describe ActiveFedora::AttachedFiles do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "raises an error if you don't give a type" do
|
69
|
-
expect {
|
70
|
-
|
69
|
+
expect {
|
70
|
+
Deprecation.silence(FooHistory) do
|
71
|
+
FooHistory.has_metadata "bob"
|
72
|
+
end
|
73
|
+
}.to raise_error ArgumentError,
|
74
|
+
"You must provide a :type property for the datastream 'bob'"
|
71
75
|
end
|
72
76
|
|
73
77
|
it "raises an error if you don't give a dsid" do
|
74
|
-
expect {
|
75
|
-
|
78
|
+
expect {
|
79
|
+
Deprecation.silence(FooHistory) do
|
80
|
+
FooHistory.has_metadata type: ActiveFedora::QualifiedDublinCoreDatastream
|
81
|
+
end
|
82
|
+
}.to raise_error ArgumentError,
|
83
|
+
"You must provide a path name (f.k.a. dsid) for the resource"
|
76
84
|
end
|
77
85
|
|
78
86
|
describe "creates accessors" do
|
@@ -86,8 +94,11 @@ describe ActiveFedora::AttachedFiles do
|
|
86
94
|
describe '.has_file_datastream' do
|
87
95
|
before do
|
88
96
|
class FooHistory < ActiveFedora::Base
|
89
|
-
|
90
|
-
|
97
|
+
extend Deprecation
|
98
|
+
Deprecation.silence(FooHistory) do
|
99
|
+
has_file_datastream name: 'dsid'
|
100
|
+
has_file_datastream 'another'
|
101
|
+
end
|
91
102
|
end
|
92
103
|
end
|
93
104
|
after do
|
@@ -105,7 +116,7 @@ describe ActiveFedora::AttachedFiles do
|
|
105
116
|
class Bar < ActiveFedora::File; end
|
106
117
|
|
107
118
|
class FooHistory < ActiveFedora::Base
|
108
|
-
|
119
|
+
has_subresource :content, class_name: 'Bar'
|
109
120
|
end
|
110
121
|
end
|
111
122
|
|
@@ -183,7 +194,7 @@ describe ActiveFedora::AttachedFiles do
|
|
183
194
|
context "when there are declared attached files" do
|
184
195
|
before do
|
185
196
|
class FooHistory < ActiveFedora::Base
|
186
|
-
|
197
|
+
has_subresource 'thumbnail'
|
187
198
|
end
|
188
199
|
end
|
189
200
|
|
@@ -37,7 +37,7 @@ describe ActiveFedora::Base do
|
|
37
37
|
context "with an xml property (default cardinality)" do
|
38
38
|
before do
|
39
39
|
class BarHistory4 < ActiveFedora::Base
|
40
|
-
|
40
|
+
has_subresource 'xmlish', class_name: 'BarStream2'
|
41
41
|
Deprecation.silence(ActiveFedora::Attributes) do
|
42
42
|
property :cow, delegate_to: 'xmlish'
|
43
43
|
end
|
@@ -64,7 +64,7 @@ describe ActiveFedora::Base do
|
|
64
64
|
context "with multiple set to false" do
|
65
65
|
before do
|
66
66
|
class BarHistory4 < ActiveFedora::Base
|
67
|
-
|
67
|
+
has_subresource 'xmlish', class_name: 'BarStream2'
|
68
68
|
Deprecation.silence(ActiveFedora::Attributes) do
|
69
69
|
property :cow, delegate_to: 'xmlish', multiple: false
|
70
70
|
end
|
@@ -86,7 +86,7 @@ describe ActiveFedora::Base do
|
|
86
86
|
context "when updating and saving a property" do
|
87
87
|
before do
|
88
88
|
class BarHistory4 < ActiveFedora::Base
|
89
|
-
|
89
|
+
has_subresource 'xmlish', class_name: 'BarStream2'
|
90
90
|
Deprecation.silence(ActiveFedora::Attributes) do
|
91
91
|
property :cow, delegate_to: 'xmlish', multiple: false
|
92
92
|
end
|
@@ -113,22 +113,20 @@ describe ActiveFedora::Base do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
describe "first level delegation" do
|
116
|
-
before
|
117
|
-
class
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
has_metadata type: ActiveFedora::SimpleDatastream, name: "withText" do |m|
|
125
|
-
m.field "fubar", :text
|
126
|
-
end
|
127
|
-
has_metadata type: ActiveFedora::SimpleDatastream, name: "withText2" do |m|
|
128
|
-
m.field "fubar", :text
|
116
|
+
before do
|
117
|
+
class MyDS1 < ActiveFedora::NtriplesRDFDatastream
|
118
|
+
property :animal_id, predicate: ::RDF::Vocab::DC.publisher
|
119
|
+
end
|
120
|
+
class MyDS2 < ActiveFedora::OmDatastream
|
121
|
+
set_terminology do |t|
|
122
|
+
t.root(path: "durh")
|
123
|
+
t.fubar
|
129
124
|
end
|
130
|
-
|
131
|
-
|
125
|
+
end
|
126
|
+
class BarHistory2 < ActiveFedora::Base
|
127
|
+
has_subresource 'someData', class_name: 'MyDS1'
|
128
|
+
has_subresource "withText", class_name: 'MyDS2'
|
129
|
+
has_subresource 'xmlish', class_name: 'BarStream2'
|
132
130
|
Deprecation.silence(ActiveFedora::Attributes) do
|
133
131
|
has_attributes :cow, datastream: 'xmlish' # for testing the default value of multiple
|
134
132
|
has_attributes :fubar, datastream: 'withText', multiple: true # test alternate datastream
|
@@ -142,7 +140,7 @@ describe ActiveFedora::Base do
|
|
142
140
|
end
|
143
141
|
end
|
144
142
|
|
145
|
-
after
|
143
|
+
after do
|
146
144
|
Object.send(:remove_const, :BarHistory2)
|
147
145
|
end
|
148
146
|
|
@@ -342,7 +340,7 @@ describe ActiveFedora::Base do
|
|
342
340
|
|
343
341
|
describe ".datastream_class_for_name" do
|
344
342
|
it "returns the specifed class" do
|
345
|
-
expect(BarHistory2.send(:datastream_class_for_name, 'someData')).to eq
|
343
|
+
expect(BarHistory2.send(:datastream_class_for_name, 'someData')).to eq MyDS1
|
346
344
|
end
|
347
345
|
end
|
348
346
|
end
|
@@ -350,7 +348,7 @@ describe ActiveFedora::Base do
|
|
350
348
|
describe "with a superclass" do
|
351
349
|
before :all do
|
352
350
|
class BarHistory2 < ActiveFedora::Base
|
353
|
-
|
351
|
+
has_subresource 'xmlish', class_name: 'BarStream2'
|
354
352
|
Deprecation.silence(ActiveFedora::Attributes) do
|
355
353
|
has_attributes :donkey, :cow, datastream: 'xmlish', multiple: true
|
356
354
|
end
|
@@ -386,7 +384,7 @@ describe ActiveFedora::Base do
|
|
386
384
|
property :description, predicate: ::RDF::Vocab::DC.description
|
387
385
|
end
|
388
386
|
class BarHistory4 < ActiveFedora::Base
|
389
|
-
|
387
|
+
has_subresource 'rdfish', class_name: 'BarRdfDatastream'
|
390
388
|
Deprecation.silence(ActiveFedora::Attributes) do
|
391
389
|
has_attributes :title, datastream: 'rdfish', multiple: true
|
392
390
|
has_attributes :description, datastream: 'rdfish', multiple: false
|
@@ -478,7 +476,7 @@ describe ActiveFedora::Base do
|
|
478
476
|
property :description, predicate: ::RDF::Vocab::DC.description
|
479
477
|
end
|
480
478
|
class BarHistory4 < ActiveFedora::Base
|
481
|
-
|
479
|
+
has_subresource 'rdfish', class_name: 'BarRdfDatastream'
|
482
480
|
Deprecation.silence(ActiveFedora::Attributes) do
|
483
481
|
has_attributes :description, datastream: :rdfish
|
484
482
|
end
|