active-fedora 6.7.8 → 6.8.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/.rspec +1 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +938 -0
- data/.travis.yml +5 -6
- data/Gemfile +3 -1
- data/Rakefile +7 -5
- data/active-fedora.gemspec +7 -8
- data/lib/active_fedora/om_datastream.rb +1 -0
- data/lib/active_fedora/rdf_xml_writer.rb +31 -62
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +14 -14
- data/spec/integration/associations_spec.rb +232 -232
- data/spec/integration/attributes_spec.rb +11 -12
- data/spec/integration/auditable_spec.rb +10 -10
- data/spec/integration/base_spec.rb +163 -163
- data/spec/integration/bug_spec.rb +7 -7
- data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
- data/spec/integration/datastream_collections_spec.rb +69 -69
- data/spec/integration/datastream_spec.rb +43 -43
- data/spec/integration/datastreams_spec.rb +63 -63
- data/spec/integration/delegating_spec.rb +14 -14
- data/spec/integration/delete_all_spec.rb +38 -42
- data/spec/integration/fedora_solr_sync_spec.rb +5 -5
- data/spec/integration/full_featured_model_spec.rb +101 -101
- data/spec/integration/has_many_associations_spec.rb +24 -24
- data/spec/integration/model_spec.rb +30 -30
- data/spec/integration/nested_attribute_spec.rb +41 -41
- data/spec/integration/ntriples_datastream_spec.rb +107 -107
- data/spec/integration/om_datastream_spec.rb +67 -67
- data/spec/integration/persistence_spec.rb +6 -6
- data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
- data/spec/integration/relation_delegation_spec.rb +24 -26
- data/spec/integration/rels_ext_datastream_spec.rb +20 -20
- data/spec/integration/scoped_query_spec.rb +40 -41
- data/spec/integration/solr_instance_loader_spec.rb +4 -4
- data/spec/integration/solr_service_spec.rb +46 -46
- data/spec/rails3_test_app/config/application.rb +1 -1
- data/spec/rails3_test_app/config/environments/development.rb +0 -1
- data/spec/rails3_test_app/config/environments/production.rb +1 -1
- data/spec/rails3_test_app/spec/spec_helper.rb +3 -3
- data/spec/rails3_test_app/spec/unit/rails_3_init.rb +4 -4
- data/spec/samples/hydra-mods_article_datastream.rb +334 -334
- data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
- data/spec/samples/marpa-dc_datastream.rb +17 -17
- data/spec/samples/models/audio_record.rb +16 -16
- data/spec/samples/models/image.rb +2 -2
- data/spec/samples/models/mods_article.rb +5 -5
- data/spec/samples/models/oral_history.rb +18 -18
- data/spec/samples/models/seminar.rb +24 -24
- data/spec/samples/models/seminar_audio_file.rb +17 -17
- data/spec/samples/oral_history_sample_model.rb +21 -21
- data/spec/samples/special_thing.rb +14 -14
- data/spec/spec_helper.rb +7 -11
- data/spec/support/an_active_model.rb +2 -2
- data/spec/support/mock_fedora.rb +16 -17
- data/spec/unit/active_fedora_spec.rb +58 -58
- data/spec/unit/association_proxy_spec.rb +5 -7
- data/spec/unit/base_active_model_spec.rb +25 -26
- data/spec/unit/base_cma_spec.rb +5 -5
- data/spec/unit/base_datastream_management_spec.rb +27 -27
- data/spec/unit/base_delegate_spec.rb +80 -82
- data/spec/unit/base_delegate_to_spec.rb +37 -39
- data/spec/unit/base_extra_spec.rb +48 -48
- data/spec/unit/base_spec.rb +300 -300
- data/spec/unit/callback_spec.rb +19 -19
- data/spec/unit/code_configurator_spec.rb +17 -17
- data/spec/unit/config_spec.rb +16 -8
- data/spec/unit/content_model_spec.rb +60 -60
- data/spec/unit/datastream_collections_spec.rb +229 -229
- data/spec/unit/datastream_spec.rb +57 -54
- data/spec/unit/datastreams_spec.rb +77 -77
- data/spec/unit/file_configurator_spec.rb +217 -217
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +26 -26
- data/spec/unit/has_many_collection_spec.rb +9 -9
- data/spec/unit/inheritance_spec.rb +12 -13
- data/spec/unit/model_spec.rb +41 -51
- data/spec/unit/nom_datastream_spec.rb +15 -15
- data/spec/unit/ntriples_datastream_spec.rb +112 -112
- data/spec/unit/om_datastream_spec.rb +233 -227
- data/spec/unit/persistence_spec.rb +6 -6
- data/spec/unit/predicates_spec.rb +73 -73
- data/spec/unit/property_spec.rb +9 -17
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
- data/spec/unit/query_spec.rb +188 -217
- data/spec/unit/rdf_datastream_spec.rb +28 -21
- data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
- data/spec/unit/rdf_list_spec.rb +80 -104
- data/spec/unit/rdf_node_spec.rb +7 -7
- data/spec/unit/rdf_xml_writer_spec.rb +10 -10
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
- data/spec/unit/relationship_graph_spec.rb +51 -51
- data/spec/unit/rels_ext_datastream_spec.rb +75 -69
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
- data/spec/unit/rubydora_connection_spec.rb +5 -5
- data/spec/unit/semantic_node_spec.rb +59 -59
- data/spec/unit/serializers_spec.rb +4 -4
- data/spec/unit/service_definitions_spec.rb +26 -26
- data/spec/unit/simple_datastream_spec.rb +17 -17
- data/spec/unit/solr_config_options_spec.rb +27 -28
- data/spec/unit/solr_digital_object_spec.rb +21 -21
- data/spec/unit/solr_service_spec.rb +81 -81
- data/spec/unit/unsaved_digital_object_spec.rb +20 -20
- data/spec/unit/validations_spec.rb +21 -21
- metadata +70 -58
- data/gemfiles/gemfile.rails3 +0 -11
- data/gemfiles/gemfile.rails4 +0 -10
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require
|
|
2
|
+
require 'solrizer'
|
|
3
3
|
|
|
4
4
|
describe ActiveFedora::OmDatastream do
|
|
5
|
-
|
|
6
|
-
describe
|
|
7
|
-
before(:all) do
|
|
5
|
+
|
|
6
|
+
describe 'a new instance with an inline datastream' do
|
|
7
|
+
before(:all) do
|
|
8
8
|
class ModsArticle3 < ActiveFedora::Base
|
|
9
9
|
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
|
10
|
-
has_metadata
|
|
10
|
+
has_metadata 'descMetadata', type: Hydra::ModsArticleDatastream, control_group: 'X', autocreate: true
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -25,38 +25,38 @@ describe ActiveFedora::OmDatastream do
|
|
|
25
25
|
@obj.destroy
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
it
|
|
29
|
-
@obj.descMetadata.
|
|
28
|
+
it 'should report being inline' do
|
|
29
|
+
expect(@obj.descMetadata).to be_inline
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
it
|
|
33
|
-
@obj.descMetadata.
|
|
32
|
+
it 'should not be changed when no fields have been set' do
|
|
33
|
+
expect(@obj.descMetadata).not_to be_content_changed
|
|
34
34
|
end
|
|
35
|
-
it
|
|
35
|
+
it 'should be changed when a field has been set' do
|
|
36
36
|
@obj.descMetadata.title = 'Foobar'
|
|
37
|
-
@obj.descMetadata.
|
|
37
|
+
expect(@obj.descMetadata).to be_content_changed
|
|
38
38
|
end
|
|
39
|
-
describe
|
|
40
|
-
it
|
|
39
|
+
describe '#changed?' do
|
|
40
|
+
it 'should not be changed if the new xml matches the old xml' do
|
|
41
41
|
@obj.descMetadata.content = @obj.descMetadata.content
|
|
42
|
-
@obj.descMetadata.
|
|
42
|
+
expect(@obj.descMetadata).not_to be_changed
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
it
|
|
46
|
-
@obj.descMetadata.content =
|
|
45
|
+
it 'should not be changed if there are minor differences in whitespace' do
|
|
46
|
+
@obj.descMetadata.content = '<a><b>1</b></a>'
|
|
47
47
|
@obj.save
|
|
48
|
-
@obj.descMetadata.
|
|
48
|
+
expect(@obj.descMetadata).not_to be_changed
|
|
49
49
|
@obj.descMetadata.content = "<a>\n<b>1</b>\n</a>"
|
|
50
|
-
@obj.descMetadata.
|
|
50
|
+
expect(@obj.descMetadata).not_to be_changed
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
describe
|
|
55
|
+
describe 'an instance that is a managed datastream' do
|
|
56
56
|
before(:all) do
|
|
57
57
|
class ModsArticle2 < ActiveFedora::Base
|
|
58
58
|
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
|
59
|
-
has_metadata
|
|
59
|
+
has_metadata 'descMetadata', type: Hydra::ModsArticleDatastream, autocreate: true
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -74,28 +74,28 @@ describe ActiveFedora::OmDatastream do
|
|
|
74
74
|
@obj.destroy
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
it
|
|
78
|
-
@obj.descMetadata.
|
|
77
|
+
it 'should not report being inline' do
|
|
78
|
+
expect(@obj.descMetadata).to be_managed
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
describe
|
|
82
|
-
it
|
|
81
|
+
describe '#changed?' do
|
|
82
|
+
it 'should not be changed if the new xml matches the old xml' do
|
|
83
83
|
@obj.descMetadata.content = @obj.descMetadata.content
|
|
84
|
-
@obj.descMetadata.
|
|
84
|
+
expect(@obj.descMetadata).not_to be_changed
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
it
|
|
88
|
-
@obj.descMetadata.content =
|
|
87
|
+
it 'should be changed if there are minor differences in whitespace' do
|
|
88
|
+
@obj.descMetadata.content = '<a><b>1</b></a>'
|
|
89
89
|
@obj.save
|
|
90
|
-
@obj.descMetadata.
|
|
90
|
+
expect(@obj.descMetadata).not_to be_changed
|
|
91
91
|
@obj.descMetadata.content = "<a>\n<b>1</b>\n</a>"
|
|
92
|
-
@obj.descMetadata.
|
|
92
|
+
expect(@obj.descMetadata).to be_changed
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
-
describe
|
|
97
|
-
it
|
|
98
|
-
@obj.descMetadata.content =
|
|
96
|
+
describe 'empty datastream content' do
|
|
97
|
+
it 'should not break when there is empty datastream content' do
|
|
98
|
+
@obj.descMetadata.content = ''
|
|
99
99
|
@obj.save
|
|
100
100
|
end
|
|
101
101
|
end
|
|
@@ -108,35 +108,35 @@ describe ActiveFedora::OmDatastream do
|
|
|
108
108
|
@solr_obj = ActiveFedora::Base.load_instance_from_solr(@obj.pid)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
it
|
|
112
|
-
@solr_obj.datastreams[
|
|
113
|
-
@solr_obj.datastreams[
|
|
114
|
-
@solr_obj.datastreams[
|
|
115
|
-
@solr_obj.datastreams[
|
|
116
|
-
@solr_obj.datastreams[
|
|
117
|
-
@solr_obj.datastreams[
|
|
118
|
-
ar = @solr_obj.datastreams[
|
|
119
|
-
ar.length.
|
|
120
|
-
ar.include?(
|
|
121
|
-
ar.include?(
|
|
122
|
-
ar.include?(
|
|
123
|
-
ar.include?(
|
|
124
|
-
|
|
125
|
-
@obj.datastreams[
|
|
126
|
-
@obj.datastreams[
|
|
127
|
-
@obj.datastreams[
|
|
128
|
-
@obj.datastreams[
|
|
129
|
-
@obj.datastreams[
|
|
130
|
-
@obj.datastreams[
|
|
131
|
-
ar = @obj.datastreams[
|
|
132
|
-
ar.length.
|
|
133
|
-
ar.include?(
|
|
134
|
-
ar.include?(
|
|
135
|
-
ar.include?(
|
|
136
|
-
ar.include?(
|
|
111
|
+
it 'should return the same values whether getting from solr or Fedora' do
|
|
112
|
+
expect(@solr_obj.datastreams['descMetadata'].term_values(:name, :role, :text)).to eq(['Creator', 'Contributor', 'Funder', 'Host'])
|
|
113
|
+
expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 0}, :role, :text)).to eq(['Creator'])
|
|
114
|
+
expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 1}, :role, :text)).to eq(['Contributor'])
|
|
115
|
+
expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 0}, {:role => 0}, :text)).to eq(['Creator'])
|
|
116
|
+
expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 0}, :text)).to eq(['Contributor'])
|
|
117
|
+
expect(@solr_obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 1}, :text)).to eq([])
|
|
118
|
+
ar = @solr_obj.datastreams['descMetadata'].term_values(:name, {:role => 0}, :text)
|
|
119
|
+
expect(ar.length).to eq(4)
|
|
120
|
+
expect(ar.include?('Creator')).to eq(true)
|
|
121
|
+
expect(ar.include?('Contributor')).to eq(true)
|
|
122
|
+
expect(ar.include?('Funder')).to eq(true)
|
|
123
|
+
expect(ar.include?('Host')).to eq(true)
|
|
124
|
+
|
|
125
|
+
expect(@obj.datastreams['descMetadata'].term_values(:name, :role, :text)).to eq(['Creator', 'Contributor', 'Funder', 'Host'])
|
|
126
|
+
expect(@obj.datastreams['descMetadata'].term_values({:name => 0}, :role, :text)).to eq(['Creator'])
|
|
127
|
+
expect(@obj.datastreams['descMetadata'].term_values({:name => 1}, :role, :text)).to eq(['Contributor'])
|
|
128
|
+
expect(@obj.datastreams['descMetadata'].term_values({:name => 0}, {:role => 0}, :text)).to eq(['Creator'])
|
|
129
|
+
expect(@obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 0}, :text)).to eq(['Contributor'])
|
|
130
|
+
expect(@obj.datastreams['descMetadata'].term_values({:name => 1}, {:role => 1}, :text)).to eq([])
|
|
131
|
+
ar = @obj.datastreams['descMetadata'].term_values(:name, {:role => 0}, :text)
|
|
132
|
+
expect(ar.length).to eq(4)
|
|
133
|
+
expect(ar.include?('Creator')).to eq(true)
|
|
134
|
+
expect(ar.include?('Contributor')).to eq(true)
|
|
135
|
+
expect(ar.include?('Funder')).to eq(true)
|
|
136
|
+
expect(ar.include?('Host')).to eq(true)
|
|
137
137
|
end
|
|
138
138
|
end
|
|
139
|
-
|
|
139
|
+
|
|
140
140
|
describe '.update_values' do
|
|
141
141
|
before do
|
|
142
142
|
@obj.descMetadata.content = File.read(fixture('mods_articles/mods_article1.xml'))
|
|
@@ -144,24 +144,24 @@ describe ActiveFedora::OmDatastream do
|
|
|
144
144
|
@obj.reload
|
|
145
145
|
end
|
|
146
146
|
|
|
147
|
-
it
|
|
148
|
-
@obj.datastreams[
|
|
149
|
-
@obj.datastreams[
|
|
147
|
+
it 'should not be dirty after .update_values is saved' do
|
|
148
|
+
@obj.datastreams['descMetadata'].update_values([{:name => 0}, {:role => 0}, :text] => 'Funder')
|
|
149
|
+
expect(@obj.datastreams['descMetadata']).to be_changed
|
|
150
150
|
@obj.save
|
|
151
|
-
@obj.datastreams[
|
|
152
|
-
@obj.datastreams[
|
|
153
|
-
end
|
|
151
|
+
expect(@obj.datastreams['descMetadata']).not_to be_changed
|
|
152
|
+
expect(@obj.datastreams['descMetadata'].term_values({:name => 0}, {:role => 0}, :text)).to eq(['Funder'])
|
|
153
|
+
end
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
|
|
157
|
-
describe
|
|
157
|
+
describe '.to_solr' do
|
|
158
158
|
before do
|
|
159
159
|
@obj.descMetadata.journal.issue.publication_date = Date.parse('2012-11-02')
|
|
160
160
|
@obj.save!
|
|
161
161
|
@obj.reload
|
|
162
162
|
end
|
|
163
163
|
it "should solrize terms with :type=>'date' to *_dt solr terms" do
|
|
164
|
-
@obj.to_solr[ActiveFedora::SolrService.solr_name('journal_issue_publication_date', type: :date)].
|
|
164
|
+
expect(@obj.to_solr[ActiveFedora::SolrService.solr_name('journal_issue_publication_date', type: :date)]).to eq(['2012-11-02T00:00:00Z'])
|
|
165
165
|
end
|
|
166
166
|
end
|
|
167
167
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe 'persisting objects' do
|
|
4
4
|
before :all do
|
|
5
5
|
class MockAFBaseRelationship < ActiveFedora::Base
|
|
6
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>
|
|
7
|
-
m.field
|
|
6
|
+
has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'foo' do |m|
|
|
7
|
+
m.field 'name', :string
|
|
8
8
|
end
|
|
9
9
|
delegate :name, to: 'foo', multiple: false
|
|
10
10
|
validates :name, presence: true
|
|
@@ -14,9 +14,9 @@ describe "persisting objects" do
|
|
|
14
14
|
Object.send(:remove_const, :MockAFBaseRelationship)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
describe
|
|
18
|
-
it
|
|
19
|
-
|
|
17
|
+
describe '#create!' do
|
|
18
|
+
it 'should validate' do
|
|
19
|
+
expect { MockAFBaseRelationship.create!}.to raise_error ActiveFedora::RecordInvalid, "Validation failed: Name can't be blank"
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
4
|
-
describe
|
|
5
|
-
describe
|
|
6
|
-
before do
|
|
7
|
-
class DummyMADS < RDF::Vocabulary(
|
|
3
|
+
describe 'Nesting attribute behavior of RDFDatastream' do
|
|
4
|
+
describe '.attributes=' do
|
|
5
|
+
describe 'complex properties' do
|
|
6
|
+
before do
|
|
7
|
+
class DummyMADS < RDF::Vocabulary('http://www.loc.gov/mads/rdf/v1#')
|
|
8
8
|
# componentList and Types of components
|
|
9
9
|
property :componentList
|
|
10
10
|
property :Topic
|
|
@@ -12,8 +12,8 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
|
12
12
|
property :PersonalName
|
|
13
13
|
property :CorporateName
|
|
14
14
|
property :ComplexSubject
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
|
|
16
|
+
|
|
17
17
|
# elementList and elementList values
|
|
18
18
|
property :elementList
|
|
19
19
|
property :elementValue
|
|
@@ -26,8 +26,8 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
|
26
26
|
|
|
27
27
|
class ComplexRDFDatastream < ActiveFedora::NtriplesRDFDatastream
|
|
28
28
|
map_predicates do |map|
|
|
29
|
-
map.topic(in: DummyMADS, to:
|
|
30
|
-
map.personalName(in: DummyMADS, to:
|
|
29
|
+
map.topic(in: DummyMADS, to: 'Topic', class_name: 'Topic')
|
|
30
|
+
map.personalName(in: DummyMADS, to: 'PersonalName', class_name: 'PersonalName')
|
|
31
31
|
map.title(in: RDF::DC)
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -36,15 +36,15 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
|
36
36
|
class Topic
|
|
37
37
|
include ActiveFedora::RdfObject
|
|
38
38
|
map_predicates do |map|
|
|
39
|
-
map.elementList(in: DummyMADS, class_name:
|
|
39
|
+
map.elementList(in: DummyMADS, class_name: 'ComplexRDFDatastream::ElementList')
|
|
40
40
|
end
|
|
41
41
|
accepts_nested_attributes_for :elementList
|
|
42
42
|
end
|
|
43
43
|
class PersonalName
|
|
44
44
|
include ActiveFedora::RdfObject
|
|
45
45
|
map_predicates do |map|
|
|
46
|
-
map.elementList(in: DummyMADS, to:
|
|
47
|
-
map.extraProperty(in: DummyMADS, to:
|
|
46
|
+
map.elementList(in: DummyMADS, to: 'elementList', class_name: 'ComplexRDFDatastream::ElementList')
|
|
47
|
+
map.extraProperty(in: DummyMADS, to: 'elementValue', class_name: 'ComplexRDFDatastream::Topic')
|
|
48
48
|
end
|
|
49
49
|
accepts_nested_attributes_for :elementList, :extraProperty
|
|
50
50
|
end
|
|
@@ -52,11 +52,11 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
|
52
52
|
include ActiveFedora::RdfList
|
|
53
53
|
rdf_type DummyMADS.elementList
|
|
54
54
|
map_predicates do |map|
|
|
55
|
-
map.topicElement(in: DummyMADS, to:
|
|
56
|
-
map.temporalElement(in: DummyMADS, to:
|
|
57
|
-
map.fullNameElement(in: DummyMADS, to:
|
|
58
|
-
map.dateNameElement(in: DummyMADS, to:
|
|
59
|
-
map.nameElement(in: DummyMADS, to:
|
|
55
|
+
map.topicElement(in: DummyMADS, to: 'TopicElement', :class_name => 'MadsTopicElement')
|
|
56
|
+
map.temporalElement(in: DummyMADS, to: 'TemporalElement')
|
|
57
|
+
map.fullNameElement(in: DummyMADS, to: 'FullNameElement')
|
|
58
|
+
map.dateNameElement(in: DummyMADS, to: 'DateNameElement')
|
|
59
|
+
map.nameElement(in: DummyMADS, to: 'NameElement')
|
|
60
60
|
map.elementValue(in: DummyMADS)
|
|
61
61
|
end
|
|
62
62
|
accepts_nested_attributes_for :topicElement
|
|
@@ -74,58 +74,58 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
|
74
74
|
Object.send(:remove_const, :ComplexRDFDatastream)
|
|
75
75
|
Object.send(:remove_const, :DummyMADS)
|
|
76
76
|
end
|
|
77
|
-
subject { ComplexRDFDatastream.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMetadata') }
|
|
78
|
-
let(:params) do
|
|
79
|
-
{ myResource:
|
|
77
|
+
subject { ComplexRDFDatastream.new(double('inner object', :pid => 'foo', :new_record? => true), 'descMetadata') }
|
|
78
|
+
let(:params) do
|
|
79
|
+
{ myResource:
|
|
80
80
|
{
|
|
81
81
|
topic_attributes: {
|
|
82
82
|
'0' =>
|
|
83
83
|
{
|
|
84
84
|
elementList_attributes: [{
|
|
85
|
-
topicElement_attributes: [{elementValue:
|
|
85
|
+
topicElement_attributes: [{elementValue: 'Cosmology'}]
|
|
86
86
|
}]
|
|
87
87
|
},
|
|
88
88
|
'1' =>
|
|
89
89
|
{
|
|
90
90
|
elementList_attributes: [{
|
|
91
|
-
topicElement_attributes: {'0' => {elementValue:
|
|
91
|
+
topicElement_attributes: {'0' => {elementValue: 'Quantum Behavior'}}
|
|
92
92
|
}]
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
personalName_attributes: [
|
|
96
|
-
{
|
|
96
|
+
{
|
|
97
97
|
elementList_attributes: [{
|
|
98
|
-
fullNameElement:
|
|
99
|
-
dateNameElement:
|
|
98
|
+
fullNameElement: 'Jefferson, Thomas',
|
|
99
|
+
dateNameElement: '1743-1826'
|
|
100
100
|
}]
|
|
101
|
-
}
|
|
101
|
+
}
|
|
102
102
|
#, "Hemings, Sally"
|
|
103
|
-
]
|
|
103
|
+
]
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
describe
|
|
109
|
-
subject { ComplexRDFDatastream::PersonalName.new(RDF::Graph.new) }
|
|
110
|
-
it
|
|
111
|
-
subject.elementList_attributes = [{ topicElement_attributes: {'0' => { elementValue:
|
|
112
|
-
subject.elementList.first[0].elementValue.
|
|
113
|
-
subject.elementList.first[1].elementValue.
|
|
108
|
+
describe 'on lists' do
|
|
109
|
+
subject { ComplexRDFDatastream::PersonalName.new(RDF::Graph.new) }
|
|
110
|
+
it 'should accept a hash' do
|
|
111
|
+
subject.elementList_attributes = [{ topicElement_attributes: {'0' => { elementValue: 'Quantum Behavior' }, '1' => { elementValue: 'Wave Function' }}}]
|
|
112
|
+
expect(subject.elementList.first[0].elementValue).to eq(['Quantum Behavior'])
|
|
113
|
+
expect(subject.elementList.first[1].elementValue).to eq(['Wave Function'])
|
|
114
114
|
|
|
115
115
|
end
|
|
116
|
-
it
|
|
117
|
-
subject.elementList_attributes = [{ topicElement_attributes: [{ elementValue:
|
|
118
|
-
subject.elementList.first[0].elementValue.
|
|
119
|
-
subject.elementList.first[1].elementValue.
|
|
116
|
+
it 'should accept an array' do
|
|
117
|
+
subject.elementList_attributes = [{ topicElement_attributes: [{ elementValue: 'Quantum Behavior' }, { elementValue: 'Wave Function' }]}]
|
|
118
|
+
expect(subject.elementList.first[0].elementValue).to eq(['Quantum Behavior'])
|
|
119
|
+
expect(subject.elementList.first[1].elementValue).to eq(['Wave Function'])
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
it
|
|
123
|
+
it 'should create nested objects' do
|
|
124
124
|
# Replace the graph's contents with the Hash
|
|
125
125
|
subject.attributes = params[:myResource]
|
|
126
126
|
|
|
127
127
|
# Here's how this would happen if we didn't have attributes=
|
|
128
|
-
# personal_name = subject.personalName.build
|
|
128
|
+
# personal_name = subject.personalName.build
|
|
129
129
|
# elem_list = personal_name.elementList.build
|
|
130
130
|
# elem_list.fullNameElement = "Jefferson, Thomas"
|
|
131
131
|
# elem_list.dateNameElement = "1743-1826"
|
|
@@ -133,35 +133,35 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
|
133
133
|
# elem_list = topic.elementList.build
|
|
134
134
|
# elem_list.fullNameElement = 'Cosmology'
|
|
135
135
|
|
|
136
|
-
subject.topic[0].elementList.first[0].elementValue.
|
|
137
|
-
subject.topic[1].elementList.first[0].elementValue.
|
|
138
|
-
subject.personalName.first.elementList.first.fullNameElement.
|
|
139
|
-
subject.personalName.first.elementList.first.dateNameElement.
|
|
136
|
+
expect(subject.topic[0].elementList.first[0].elementValue).to eq(['Cosmology'])
|
|
137
|
+
expect(subject.topic[1].elementList.first[0].elementValue).to eq(['Quantum Behavior'])
|
|
138
|
+
expect(subject.personalName.first.elementList.first.fullNameElement).to eq(['Jefferson, Thomas'])
|
|
139
|
+
expect(subject.personalName.first.elementList.first.dateNameElement).to eq(['1743-1826'])
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
142
|
|
|
143
|
-
describe
|
|
144
|
-
before(:each) do
|
|
143
|
+
describe 'with an existing object' do
|
|
144
|
+
before(:each) do
|
|
145
145
|
class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
|
|
146
146
|
map_predicates do |map|
|
|
147
|
-
map.parts(:in=> RDF::DC, :to=>'hasPart', :class_name=>'Component')
|
|
147
|
+
map.parts(:in => RDF::DC, :to => 'hasPart', :class_name => 'Component')
|
|
148
148
|
end
|
|
149
149
|
accepts_nested_attributes_for :parts, allow_destroy: true
|
|
150
150
|
|
|
151
151
|
class Component
|
|
152
152
|
include ActiveFedora::RdfObject
|
|
153
153
|
map_predicates do |map|
|
|
154
|
-
map.label(:in=> RDF::DC, :to=>'title')
|
|
154
|
+
map.label(:in => RDF::DC, :to => 'title')
|
|
155
155
|
end
|
|
156
156
|
end
|
|
157
157
|
end
|
|
158
158
|
|
|
159
159
|
end
|
|
160
|
-
|
|
160
|
+
|
|
161
161
|
after(:each) do
|
|
162
162
|
Object.send(:remove_const, :SpecDatastream)
|
|
163
163
|
end
|
|
164
|
-
subject { SpecDatastream.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMetadata') }
|
|
164
|
+
subject { SpecDatastream.new(double('inner object', :pid => 'foo', :new_record? => true), 'descMetadata') }
|
|
165
165
|
before do
|
|
166
166
|
subject.attributes = { parts_attributes: [
|
|
167
167
|
{label: 'Alternator'},
|
|
@@ -172,16 +172,16 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
|
172
172
|
let (:replace_object_id) { subject.parts[1].rdf_subject.to_s }
|
|
173
173
|
let (:remove_object_id) { subject.parts[3].rdf_subject.to_s }
|
|
174
174
|
|
|
175
|
-
it
|
|
176
|
-
subject.parts_attributes= [{id: replace_object_id, label:
|
|
175
|
+
it 'should update nested objects' do
|
|
176
|
+
subject.parts_attributes = [{id: replace_object_id, label: 'Universal Joint'}, {label: 'Oil Pump'}, {id: remove_object_id, _destroy: '1', label: 'bar1 uno'}]
|
|
177
177
|
|
|
178
|
-
subject.parts.map{|p| p.label.first}.
|
|
178
|
+
expect(subject.parts.map{|p| p.label.first}).to eq(['Alternator', 'Universal Joint', 'Transmission', 'Oil Pump'])
|
|
179
179
|
|
|
180
180
|
end
|
|
181
|
-
it
|
|
182
|
-
subject.parts_attributes= [{id: 'http://example.com/part#1', label:
|
|
183
|
-
subject.parts.last.rdf_subject.
|
|
181
|
+
it 'create a new object when the id is provided' do
|
|
182
|
+
subject.parts_attributes = [{id: 'http://example.com/part#1', label: 'Universal Joint'}]
|
|
183
|
+
expect(subject.parts.last.rdf_subject).to eq('http://example.com/part#1')
|
|
184
184
|
end
|
|
185
|
-
end
|
|
185
|
+
end
|
|
186
186
|
end
|
|
187
187
|
end
|