active-fedora 10.0.0 → 11.0.0
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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -7
- data/.rubocop_todo.yml +55 -0
- data/.solr_wrapper +6 -0
- data/README.md +1 -3
- data/active-fedora.gemspec +6 -11
- data/lib/active_fedora/aggregation/list_source.rb +2 -0
- data/lib/active_fedora/associations/association_scope.rb +1 -1
- data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
- data/lib/active_fedora/associations/builder/association.rb +1 -1
- data/lib/active_fedora/associations/builder/orders.rb +11 -3
- data/lib/active_fedora/associations/collection_association.rb +3 -3
- data/lib/active_fedora/associations/contained_finder.rb +2 -2
- data/lib/active_fedora/associations/has_many_association.rb +2 -2
- data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
- data/lib/active_fedora/associations/orders_association.rb +4 -0
- data/lib/active_fedora/associations/rdf.rb +2 -0
- data/lib/active_fedora/attribute_assignment.rb +0 -1
- data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
- data/lib/active_fedora/attributes.rb +1 -1
- data/lib/active_fedora/base.rb +4 -8
- data/lib/active_fedora/change_set.rb +6 -2
- data/lib/active_fedora/containers/container.rb +1 -1
- data/lib/active_fedora/core.rb +22 -25
- data/lib/active_fedora/fedora_attributes.rb +1 -1
- data/lib/active_fedora/file/streaming.rb +1 -1
- data/lib/active_fedora/file.rb +1 -9
- data/lib/active_fedora/indexing.rb +0 -15
- data/lib/active_fedora/indexing_service.rb +0 -9
- data/lib/active_fedora/loadable_from_json.rb +12 -1
- data/lib/active_fedora/nested_attributes.rb +2 -2
- data/lib/active_fedora/orders/list_node.rb +2 -2
- data/lib/active_fedora/orders/ordered_list.rb +7 -3
- data/lib/active_fedora/orders/target_proxy.rb +4 -0
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/railtie.rb +2 -2
- data/lib/active_fedora/rake_support.rb +1 -1
- data/lib/active_fedora/rdf/persistence.rb +1 -0
- data/lib/active_fedora/rdf.rb +0 -2
- data/lib/active_fedora/relation/delegation.rb +4 -0
- data/lib/active_fedora/relation/finder_methods.rb +3 -3
- data/lib/active_fedora/scoping/named.rb +1 -0
- data/lib/active_fedora/solr_hit.rb +0 -13
- data/lib/active_fedora/solr_query_builder.rb +24 -13
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora.rb +0 -12
- data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +11 -0
- data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +1 -1
- data/lib/generators/active_fedora/model/model_generator.rb +1 -1
- data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
- data/lib/tasks/active_fedora_dev.rake +1 -9
- data/spec/config_helper.rb +1 -1
- data/spec/integration/associations_spec.rb +23 -24
- data/spec/integration/attached_files_spec.rb +18 -8
- data/spec/integration/attributes_spec.rb +12 -16
- data/spec/integration/autosave_association_spec.rb +6 -6
- data/spec/integration/base_spec.rb +3 -3
- data/spec/integration/basic_contains_association_spec.rb +1 -1
- data/spec/integration/clean_connection_spec.rb +1 -1
- data/spec/integration/collection_association_spec.rb +2 -5
- data/spec/integration/date_time_properties_spec.rb +1 -16
- data/spec/integration/direct_container_spec.rb +12 -12
- data/spec/integration/directly_contains_one_association_spec.rb +11 -13
- data/spec/integration/eradicate_spec.rb +1 -1
- data/spec/integration/fedora_solr_sync_spec.rb +2 -2
- data/spec/integration/file_fixity_spec.rb +6 -8
- data/spec/integration/file_spec.rb +32 -34
- data/spec/integration/generators/solr_generator_spec.rb +7 -10
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +5 -5
- data/spec/integration/has_many_associations_spec.rb +9 -11
- data/spec/integration/indexing_spec.rb +2 -2
- data/spec/integration/indirect_container_spec.rb +11 -12
- data/spec/integration/json_serialization_spec.rb +4 -4
- data/spec/integration/query_result_builder_spec.rb +9 -21
- data/spec/integration/rdf_nested_attributes_spec.rb +7 -7
- data/spec/integration/relation_delegation_spec.rb +8 -10
- data/spec/integration/relation_spec.rb +13 -16
- data/spec/integration/scoped_query_spec.rb +4 -3
- data/spec/integration/solr_hit_spec.rb +4 -15
- data/spec/integration/versionable_spec.rb +73 -327
- data/spec/integration/with_metadata_spec.rb +1 -1
- data/spec/spec_helper.rb +52 -4
- data/spec/unit/active_fedora_spec.rb +1 -1
- data/spec/unit/aggregation/list_source_spec.rb +37 -37
- data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
- data/spec/unit/association_hash_spec.rb +17 -31
- data/spec/unit/attached_files_spec.rb +35 -32
- data/spec/unit/attributes_spec.rb +25 -25
- data/spec/unit/base_active_model_spec.rb +8 -8
- data/spec/unit/base_cma_spec.rb +1 -1
- data/spec/unit/base_extra_spec.rb +7 -22
- data/spec/unit/base_spec.rb +16 -22
- data/spec/unit/callback_spec.rb +2 -2
- data/spec/unit/change_set_spec.rb +5 -5
- data/spec/unit/checksum_spec.rb +2 -2
- data/spec/unit/code_configurator_spec.rb +1 -1
- data/spec/unit/core_spec.rb +62 -26
- data/spec/unit/default_model_mapper_spec.rb +6 -6
- data/spec/unit/fedora_spec.rb +3 -4
- data/spec/unit/file_configurator_spec.rb +96 -96
- data/spec/unit/file_path_builder_spec.rb +1 -1
- data/spec/unit/file_spec.rb +61 -61
- data/spec/unit/files_hash_spec.rb +9 -9
- data/spec/unit/filter_spec.rb +3 -3
- data/spec/unit/finder_methods_spec.rb +5 -5
- data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +14 -15
- data/spec/unit/has_many_association_spec.rb +28 -13
- data/spec/unit/indexers/global_indexer_spec.rb +6 -6
- data/spec/unit/indexing_service_spec.rb +5 -5
- data/spec/unit/indexing_spec.rb +6 -6
- data/spec/unit/inheritance_spec.rb +11 -7
- data/spec/unit/loadable_from_json_spec.rb +4 -4
- data/spec/unit/logger_spec.rb +1 -1
- data/spec/unit/model_classifier_spec.rb +5 -5
- data/spec/unit/ordered_spec.rb +144 -146
- data/spec/unit/orders/list_node_spec.rb +22 -22
- data/spec/unit/orders/ordered_list_spec.rb +96 -96
- data/spec/unit/orders/reflection_spec.rb +4 -4
- data/spec/unit/pathing_spec.rb +4 -4
- data/spec/unit/persistence_spec.rb +28 -28
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/query_spec.rb +20 -20
- data/spec/unit/rdf/indexing_service_spec.rb +29 -29
- data/spec/unit/readonly_spec.rb +5 -4
- data/spec/unit/reflection_spec.rb +3 -3
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
- data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
- data/spec/unit/serializers_spec.rb +3 -4
- data/spec/unit/solr_config_options_spec.rb +13 -16
- data/spec/unit/solr_hit_spec.rb +9 -9
- data/spec/unit/solr_service_spec.rb +4 -10
- data/spec/unit/sparql_insert_spec.rb +2 -2
- data/spec/unit/validations_spec.rb +9 -9
- data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
- data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
- metadata +18 -122
- data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
- data/lib/active_fedora/datastreams.rb +0 -6
- data/lib/active_fedora/nom_datastream.rb +0 -67
- data/lib/active_fedora/om_datastream.rb +0 -126
- data/lib/active_fedora/profile_indexing_service.rb +0 -11
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
- data/lib/active_fedora/rdf/datastream_indexing.rb +0 -43
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -9
- data/lib/active_fedora/rdf/rdf_datastream.rb +0 -158
- data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
- data/lib/active_fedora/solr_instance_loader.rb +0 -47
- data/solr/config/_rest_managed.json +0 -3
- data/solr/config/admin-extra.html +0 -31
- data/solr/config/elevate.xml +0 -36
- data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
- data/solr/config/protwords.txt +0 -21
- data/solr/config/schema.xml +0 -372
- data/solr/config/scripts.conf +0 -24
- data/solr/config/solrconfig.xml +0 -311
- data/solr/config/spellings.txt +0 -2
- data/solr/config/stopwords.txt +0 -58
- data/solr/config/stopwords_en.txt +0 -58
- data/solr/config/synonyms.txt +0 -31
- data/solr/config/xslt/example.xsl +0 -132
- data/solr/config/xslt/example_atom.xsl +0 -67
- data/solr/config/xslt/example_rss.xsl +0 -66
- data/solr/config/xslt/luke.xsl +0 -337
- data/spec/fixtures/damsObjectModel.xml +0 -38
- data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
- data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
- data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
- data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
- data/spec/integration/complex_rdf_datastream_spec.rb +0 -228
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -179
- data/spec/integration/ntriples_datastream_spec.rb +0 -203
- data/spec/integration/om_datastream_spec.rb +0 -78
- data/spec/integration/solr_instance_loader_spec.rb +0 -155
- data/spec/samples/hydra-mods_article_datastream.rb +0 -517
- data/spec/samples/models/mods_article.rb +0 -9
- data/spec/samples/oral_history_sample.xml +0 -38
- data/spec/samples/oral_history_xml.xml +0 -35
- data/spec/samples/samples.rb +0 -2
- data/spec/unit/nom_datastream_spec.rb +0 -60
- data/spec/unit/ntriples_datastream_spec.rb +0 -170
- data/spec/unit/om_datastream_spec.rb +0 -325
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
- data/spec/unit/rdf_datastream_spec.rb +0 -84
- data/spec/unit/rdf_resource_datastream_spec.rb +0 -204
- data/spec/unit/rdfxml_datastream_spec.rb +0 -106
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe ActiveFedora::QualifiedDublinCoreDatastream do
|
|
4
|
-
DC_ELEMENTS = [:contributor, :coverage, :creator, :date, :description, :identifier, :language, :publisher, :relation, :rights, :source].freeze
|
|
5
|
-
|
|
6
|
-
let(:sample_xml) do "<dc xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:dcterms='http://purl.org/dc/terms/'>
|
|
7
|
-
<dcterms:type xsi:type='DCMITYPE'>sound</dcterms:type>
|
|
8
|
-
<dcterms:medium>medium</dcterms:medium>
|
|
9
|
-
<dcterms:rights>rights</dcterms:rights>
|
|
10
|
-
<dcterms:language>English</dcterms:language>
|
|
11
|
-
<dcterms:temporal>tmp</dcterms:temporal>
|
|
12
|
-
<dcterms:subject>kw1</dcterms:subject>
|
|
13
|
-
<dcterms:subject>kw2</dcterms:subject>
|
|
14
|
-
<dcterms:creator>creator</dcterms:creator>
|
|
15
|
-
<dcterms:creator>creator</dcterms:creator>
|
|
16
|
-
<dcterms:contributor>contributor</dcterms:contributor>
|
|
17
|
-
<dcterms:coverage>coverage</dcterms:coverage>
|
|
18
|
-
<dcterms:identifier>identifier</dcterms:identifier>
|
|
19
|
-
<dcterms:relation>relation</dcterms:relation>
|
|
20
|
-
<dcterms:source>source</dcterms:source>
|
|
21
|
-
<dcterms:title>title</dcterms:title>
|
|
22
|
-
<dcterms:extent>extent</dcterms:extent>
|
|
23
|
-
<dcterms:format>audio/x-wav</dcterms:format>
|
|
24
|
-
<dcterms:subject xsi:type='LCSH'>sh1</dcterms:subject>
|
|
25
|
-
<dcterms:subject xsi:type='LCSH'>sh2</dcterms:subject>
|
|
26
|
-
<dcterms:spatial>sp1</dcterms:spatial>
|
|
27
|
-
<dcterms:spatial>sp2</dcterms:spatial>
|
|
28
|
-
<dcterms:publisher>jwa</dcterms:publisher>
|
|
29
|
-
<dcterms:alternative>alt</dcterms:alternative>
|
|
30
|
-
<dcterms:description>desc</dcterms:description>
|
|
31
|
-
<dcterms:date>datestr</dcterms:date>
|
|
32
|
-
</dc>"
|
|
33
|
-
end
|
|
34
|
-
before do
|
|
35
|
-
@test_ds = described_class.new
|
|
36
|
-
@test_ds.content = sample_xml
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "creates the right number of fields" do
|
|
40
|
-
expect(ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS.size).to eq 54
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "has unmodifiable constants" do
|
|
44
|
-
expect { ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS << :foo }.to raise_error(RuntimeError, /can't modify frozen array/i)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "defaults dc elements to :multiple=>true" do
|
|
48
|
-
@test_ds.fields.values.each do |s|
|
|
49
|
-
expect(s.key?(:multiple)).to be true
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe '#new' do
|
|
54
|
-
it 'provides #new' do
|
|
55
|
-
expect(described_class).to respond_to(:new)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
describe "model methods" do
|
|
59
|
-
DC_ELEMENTS.each do |el|
|
|
60
|
-
it "should respond to getters and setters for #{el} element" do
|
|
61
|
-
pending if el == :type
|
|
62
|
-
value = "Hey #{el}"
|
|
63
|
-
@test_ds.send("#{el}=", value)
|
|
64
|
-
expect(@test_ds.send(el).first).to eq value # Looking at first because creator has 2 nodes
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
describe '.to_xml' do
|
|
71
|
-
it 'outputs the fields hash as Qualified Dublin Core XML' do
|
|
72
|
-
@test_ds = described_class.new
|
|
73
|
-
|
|
74
|
-
@test_ds.field :publisher
|
|
75
|
-
@test_ds.field :creator
|
|
76
|
-
@test_ds.field :title
|
|
77
|
-
|
|
78
|
-
@test_ds.publisher = ["publisher1"]
|
|
79
|
-
@test_ds.creator = ["creator1", "creator2"]
|
|
80
|
-
@test_ds.title = ["title1"]
|
|
81
|
-
|
|
82
|
-
expect(@test_ds.to_xml).to be_equivalent_to('
|
|
83
|
-
<dc xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
84
|
-
<dcterms:publisher>publisher1</dcterms:publisher>
|
|
85
|
-
<dcterms:creator>creator1</dcterms:creator>
|
|
86
|
-
<dcterms:creator>creator2</dcterms:creator>
|
|
87
|
-
<dcterms:title>title1</dcterms:title>
|
|
88
|
-
</dc>')
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
describe "#to_solr" do
|
|
93
|
-
it "has title" do
|
|
94
|
-
@test_ds = described_class.new
|
|
95
|
-
@test_ds.title = "War and Peace"
|
|
96
|
-
solr = @test_ds.to_solr
|
|
97
|
-
expect(solr[ActiveFedora.index_field_mapper.solr_name('title', type: :string)]).to eq "War and Peace"
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
describe 'custom fields' do
|
|
102
|
-
subject { described_class.new }
|
|
103
|
-
it 'grabs the term' do
|
|
104
|
-
sample_xml = "<dc xmlns:dcterms='http://purl.org/dc/terms/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><dcterms:cust>custom</dcterms:cust></dc>"
|
|
105
|
-
subject.content = sample_xml
|
|
106
|
-
subject.field :cust
|
|
107
|
-
expect(subject.cust).to eq ['custom']
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
describe "#field should accept :path option" do
|
|
112
|
-
subject { described_class.new }
|
|
113
|
-
it "is able to map :dc_type to the path 'type'" do
|
|
114
|
-
subject.content = sample_xml
|
|
115
|
-
subject.field :dc_type, :string, path: "type", multiple: true
|
|
116
|
-
expect(subject.dc_type).to eq ['sound']
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
end
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
describe ActiveFedora::RDFDatastream do
|
|
5
|
-
describe "a new instance" do
|
|
6
|
-
subject { described_class.new }
|
|
7
|
-
it { should be_metadata }
|
|
8
|
-
it { should_not be_content_changed }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe "an instance that exists in the datastore, but hasn't been loaded" do
|
|
12
|
-
before do
|
|
13
|
-
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
|
14
|
-
property :title, predicate: ::RDF::Vocab::DC.title
|
|
15
|
-
property :description, predicate: ::RDF::Vocab::DC.description
|
|
16
|
-
end
|
|
17
|
-
class MyObj < ActiveFedora::Base
|
|
18
|
-
has_subresource 'descMetadata', class_name: 'MyDatastream'
|
|
19
|
-
end
|
|
20
|
-
@obj = MyObj.new
|
|
21
|
-
@obj.descMetadata.title = 'Foobar'
|
|
22
|
-
@obj.save
|
|
23
|
-
end
|
|
24
|
-
after do
|
|
25
|
-
@obj.destroy
|
|
26
|
-
Object.send(:remove_const, :MyDatastream)
|
|
27
|
-
Object.send(:remove_const, :MyObj)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
subject { @obj.reload.descMetadata }
|
|
31
|
-
|
|
32
|
-
it "does not load the descMetadata datastream when calling content_changed?" do
|
|
33
|
-
expect(subject).to_not receive(:retrieve_content)
|
|
34
|
-
expect(subject).to_not be_content_changed
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "allows asserting an empty string" do
|
|
38
|
-
subject.title = ['']
|
|
39
|
-
expect(subject.title).to eq ['']
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "clears stuff" do
|
|
43
|
-
subject.title = ['one', 'two', 'three']
|
|
44
|
-
subject.title.clear
|
|
45
|
-
expect(subject.graph.query([subject.rdf_subject, ::RDF::Vocab::DC.title, nil]).first).to be_nil
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "has a list of fields" do
|
|
49
|
-
expect(MyDatastream.fields).to eq [:title, :description]
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe "deserialize" do
|
|
54
|
-
subject { ActiveFedora::NtriplesRDFDatastream.new }
|
|
55
|
-
it "is able to handle non-utf-8 characters" do
|
|
56
|
-
# see https://github.com/ruby-rdf/rdf/issues/142
|
|
57
|
-
data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
|
|
58
|
-
|
|
59
|
-
result = subject.deserialize(data)
|
|
60
|
-
expect(result.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
describe 'content=' do
|
|
65
|
-
let(:ds) { ActiveFedora::NtriplesRDFDatastream.new }
|
|
66
|
-
it "is able to handle non-utf-8 characters" do
|
|
67
|
-
data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
|
|
68
|
-
ds.content = data
|
|
69
|
-
expect(ds.resource.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
describe 'legacy non-utf-8 characters' do
|
|
74
|
-
let(:ds) do
|
|
75
|
-
ActiveFedora::NtriplesRDFDatastream.new.tap do |datastream|
|
|
76
|
-
allow(datastream).to receive(:new_record?).and_return(false)
|
|
77
|
-
allow(datastream).to receive(:remote_content).and_return("<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT'))
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
it "does not error on access" do
|
|
81
|
-
expect(ds.resource.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe ActiveFedora::RDFDatastream do
|
|
4
|
-
before do
|
|
5
|
-
class DummySubnode < ActiveTriples::Resource
|
|
6
|
-
property :title, predicate: ::RDF::Vocab::DC[:title], class_name: ::RDF::Literal
|
|
7
|
-
property :relation, predicate: ::RDF::Vocab::DC[:relation]
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
class DummyResource < ActiveFedora::RDFDatastream
|
|
11
|
-
property :title, predicate: ::RDF::Vocab::DC[:title], class_name: ::RDF::Literal
|
|
12
|
-
property :license, predicate: ::RDF::Vocab::DC[:license], class_name: DummySubnode
|
|
13
|
-
property :creator, predicate: ::RDF::Vocab::DC[:creator], class_name: 'DummyAsset'
|
|
14
|
-
|
|
15
|
-
def serialization_format
|
|
16
|
-
:ntriples
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
class DummyAsset < ActiveFedora::Base
|
|
21
|
-
has_subresource 'descMetadata', class_name: 'DummyResource'
|
|
22
|
-
property :something, predicate: ::RDF::URI('http://example.com/thing')
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
after do
|
|
27
|
-
Object.send(:remove_const, "DummyAsset")
|
|
28
|
-
Object.send(:remove_const, "DummyResource")
|
|
29
|
-
Object.send(:remove_const, "DummySubnode")
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
subject { DummyResource.new("#{ActiveFedora.fedora.host}/test/test:1") }
|
|
33
|
-
|
|
34
|
-
describe "attribute setting" do
|
|
35
|
-
context "on text attributes" do
|
|
36
|
-
before do
|
|
37
|
-
subject.title = "bla"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "lets you access" do
|
|
41
|
-
expect(subject.title).to eq ["bla"]
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "marks it as changed" do
|
|
45
|
-
expect(subject).to be_changed
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context "after it is persisted" do
|
|
49
|
-
before do
|
|
50
|
-
subject.save
|
|
51
|
-
subject.reload
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "is persisted" do
|
|
55
|
-
expect(subject.resource).to be_persisted
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
context "and it's reloaded" do
|
|
59
|
-
before do
|
|
60
|
-
subject.reload
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "is accessible after being saved" do
|
|
64
|
-
expect(subject.title).to eq ["bla"]
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "serializes to content" do
|
|
68
|
-
expect(subject.content).not_to be_blank
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
context "and it is found again" do
|
|
73
|
-
before do
|
|
74
|
-
@object = DummyResource.new(subject.uri)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "serializes to content" do
|
|
78
|
-
expect(@object.content).not_to be_blank
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "is accessible after being saved" do
|
|
82
|
-
expect(@object.title).to eq ["bla"]
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it "has datastream content" do
|
|
86
|
-
expect(@object.remote_content).not_to be_blank
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
context "on rdf resource attributes" do
|
|
93
|
-
context "persisted to parent" do
|
|
94
|
-
before do
|
|
95
|
-
dummy = DummySubnode.new
|
|
96
|
-
dummy.title = 'subbla'
|
|
97
|
-
subject.license = dummy
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it "lets you access" do
|
|
101
|
-
expect(subject.license.first.title).to eq ['subbla']
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "marks it as changed" do
|
|
105
|
-
expect(subject).to be_changed
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
context "persisted to repository" do
|
|
109
|
-
before do
|
|
110
|
-
allow_any_instance_of(DummySubnode).to receive(:repository).and_return(RDF::Repository.new)
|
|
111
|
-
dummy = DummySubnode.new(RDF::URI('http://example.org/dummy/blah'))
|
|
112
|
-
dummy.title = 'subbla'
|
|
113
|
-
# We want to have to manually persist to the repository.
|
|
114
|
-
# Parent objects shouldn't be persisting children they share with other parents
|
|
115
|
-
dummy.persist!
|
|
116
|
-
subject.license = dummy
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it "lets you access" do
|
|
120
|
-
expect(subject.license.first.title).to eq ['subbla']
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it "marks it as changed" do
|
|
124
|
-
expect(subject).to be_changed
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
describe "relationships" do
|
|
131
|
-
before do
|
|
132
|
-
@new_object = DummyAsset.create(something: ["subbla"])
|
|
133
|
-
subject.title = ["bla"]
|
|
134
|
-
subject.creator = @new_object
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
it "has accessible relationship attributes" do
|
|
138
|
-
expect(subject.creator.first.something).to eq ["subbla"]
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it "lets me get to an AF:Base object" do
|
|
142
|
-
subject.save
|
|
143
|
-
resource = DummyResource.new(subject.uri)
|
|
144
|
-
expect(resource.creator.first).to be_kind_of(ActiveFedora::Base)
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
context "when the AF:Base object is deleted" do
|
|
148
|
-
before do
|
|
149
|
-
subject.save
|
|
150
|
-
@resource = DummyResource.new(subject.uri)
|
|
151
|
-
@new_object.destroy
|
|
152
|
-
end
|
|
153
|
-
it "gives back an ActiveTriples::Resource" do
|
|
154
|
-
expect(@resource.creator.first).to be_kind_of(ActiveTriples::Resource)
|
|
155
|
-
expect(@resource.creator.first.rdf_subject).to eq @new_object.resource.rdf_subject
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
it "allows for deep attributes to be set directly" do
|
|
160
|
-
subject.creator.first.something = ["Bla"]
|
|
161
|
-
expect(subject.creator.first.something).to eq ["Bla"]
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
context "when the subject is set with base_uri" do
|
|
165
|
-
before do
|
|
166
|
-
@old_uri = DummyResource.resource_class.base_uri
|
|
167
|
-
DummyResource.resource_class.configure base_uri: 'http://example.org/'
|
|
168
|
-
new_object = DummyAsset.new
|
|
169
|
-
new_object.save
|
|
170
|
-
subject.creator = new_object
|
|
171
|
-
end
|
|
172
|
-
after do
|
|
173
|
-
DummyResource.resource_class.configure base_uri: @old_uri
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
it "lets me get to an AF:Base object" do
|
|
177
|
-
subject.save
|
|
178
|
-
resource = DummyResource.new(subject.uri)
|
|
179
|
-
expect(resource.creator.first).to be_kind_of(ActiveFedora::Base)
|
|
180
|
-
end
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
context "when the object with a relationship is saved" do
|
|
184
|
-
before do
|
|
185
|
-
subject.save
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
it "is retrievable" do
|
|
189
|
-
expect(subject.creator.first.something).to eq ["subbla"]
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
context "when the object with a relationship is frozen" do
|
|
194
|
-
before do
|
|
195
|
-
subject.save
|
|
196
|
-
subject.freeze
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
it "is retrievable" do
|
|
200
|
-
expect(subject.creator.first.something).to eq ["subbla"]
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
end
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe ActiveFedora::RDFXMLDatastream do
|
|
4
|
-
describe "a new instance" do
|
|
5
|
-
before(:each) do
|
|
6
|
-
class MyRdfxmlDatastream < ActiveFedora::RDFXMLDatastream
|
|
7
|
-
property :publisher, predicate: ::RDF::Vocab::DC.publisher
|
|
8
|
-
end
|
|
9
|
-
@subject = MyRdfxmlDatastream.new
|
|
10
|
-
allow(@subject).to receive(:id).and_return('test:1')
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
after(:each) do
|
|
14
|
-
Object.send(:remove_const, :MyRdfxmlDatastream)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "saves and reload" do
|
|
18
|
-
@subject.publisher = ["St. Martin's Press"]
|
|
19
|
-
expect(@subject.serialize).to match(/<rdf:RDF/)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
describe "a complex data model" do
|
|
24
|
-
before do
|
|
25
|
-
class DAMS < RDF::Vocabulary("http://library.ucsd.edu/ontology/dams#")
|
|
26
|
-
property :title
|
|
27
|
-
property :relatedTitle
|
|
28
|
-
property :type
|
|
29
|
-
property :date
|
|
30
|
-
property :beginDate
|
|
31
|
-
property :endDate
|
|
32
|
-
property :language
|
|
33
|
-
property :typeOfResource
|
|
34
|
-
property :otherResource
|
|
35
|
-
property :RelatedResource
|
|
36
|
-
property :description
|
|
37
|
-
property :uri
|
|
38
|
-
property :relationship
|
|
39
|
-
property :Relationship
|
|
40
|
-
property :role
|
|
41
|
-
property :name
|
|
42
|
-
property :assembledCollection
|
|
43
|
-
property :Object
|
|
44
|
-
property :value
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
module RDF
|
|
48
|
-
# This enables RDF to respond_to? :value
|
|
49
|
-
def self.value
|
|
50
|
-
self[:value]
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
class MyDatastream < ActiveFedora::RDFXMLDatastream
|
|
55
|
-
property :resource_type, predicate: DAMS.typeOfResource
|
|
56
|
-
property :title, predicate: DAMS.title, class_name: 'Description'
|
|
57
|
-
|
|
58
|
-
rdf_subject { |ds| RDF::URI.new(ds.about) }
|
|
59
|
-
|
|
60
|
-
attr_accessor :about
|
|
61
|
-
|
|
62
|
-
def initialize(options = {})
|
|
63
|
-
@about = options.delete(:about)
|
|
64
|
-
super
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
class Description < ActiveTriples::Resource
|
|
68
|
-
configure type: DAMS.Description
|
|
69
|
-
property :value, predicate: ::RDF.value do |index|
|
|
70
|
-
index.as :searchable
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
after do
|
|
77
|
-
Object.send(:remove_const, :MyDatastream)
|
|
78
|
-
Object.send(:remove_const, :DAMS)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
describe "a new instance" do
|
|
82
|
-
subject { MyDatastream.new(about: "http://library.ucsd.edu/ark:/20775/") }
|
|
83
|
-
it "has a subject" do
|
|
84
|
-
expect(subject.rdf_subject.to_s).to eq "http://library.ucsd.edu/ark:/20775/"
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
describe "an instance with content" do
|
|
89
|
-
subject do
|
|
90
|
-
subject = MyDatastream.new(about: "http://library.ucsd.edu/ark:/20775/")
|
|
91
|
-
subject.content = File.new('spec/fixtures/damsObjectModel.xml').read
|
|
92
|
-
subject
|
|
93
|
-
end
|
|
94
|
-
it "has a subject" do
|
|
95
|
-
expect(subject.rdf_subject.to_s).to eq "http://library.ucsd.edu/ark:/20775/"
|
|
96
|
-
end
|
|
97
|
-
it "has mimeType" do
|
|
98
|
-
expect(subject.mime_type).to eq 'text/xml'
|
|
99
|
-
end
|
|
100
|
-
it "has fields" do
|
|
101
|
-
expect(subject.resource_type).to eq ["image"]
|
|
102
|
-
expect(subject.title.first.value).to eq ["example title"]
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|