active-fedora 10.3.0 → 11.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.rubocop_todo.yml +24 -0
  4. data/README.md +3 -1
  5. data/active-fedora.gemspec +4 -4
  6. data/lib/active_fedora.rb +0 -2
  7. data/lib/active_fedora/aggregation/list_source.rb +2 -0
  8. data/lib/active_fedora/associations/association_scope.rb +1 -1
  9. data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
  10. data/lib/active_fedora/associations/builder/association.rb +1 -1
  11. data/lib/active_fedora/associations/builder/orders.rb +11 -3
  12. data/lib/active_fedora/associations/collection_association.rb +2 -2
  13. data/lib/active_fedora/associations/has_many_association.rb +2 -2
  14. data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
  15. data/lib/active_fedora/associations/orders_association.rb +4 -0
  16. data/lib/active_fedora/associations/rdf.rb +2 -0
  17. data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
  18. data/lib/active_fedora/base.rb +1 -1
  19. data/lib/active_fedora/containers/container.rb +1 -1
  20. data/lib/active_fedora/core.rb +7 -9
  21. data/lib/active_fedora/fedora.rb +2 -6
  22. data/lib/active_fedora/fedora_attributes.rb +1 -1
  23. data/lib/active_fedora/file.rb +1 -1
  24. data/lib/active_fedora/file/streaming.rb +1 -1
  25. data/lib/active_fedora/indexing.rb +1 -18
  26. data/lib/active_fedora/indexing_service.rb +0 -5
  27. data/lib/active_fedora/loadable_from_json.rb +12 -1
  28. data/lib/active_fedora/nested_attributes.rb +2 -2
  29. data/lib/active_fedora/orders/list_node.rb +2 -2
  30. data/lib/active_fedora/orders/ordered_list.rb +7 -3
  31. data/lib/active_fedora/orders/target_proxy.rb +4 -0
  32. data/lib/active_fedora/rake_support.rb +1 -1
  33. data/lib/active_fedora/rdf/persistence.rb +1 -0
  34. data/lib/active_fedora/rdf/rdf_datastream.rb +7 -1
  35. data/lib/active_fedora/solr_hit.rb +0 -9
  36. data/lib/active_fedora/solr_query_builder.rb +1 -1
  37. data/lib/active_fedora/version.rb +1 -1
  38. data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +0 -11
  39. data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +1 -1
  40. data/lib/generators/active_fedora/model/model_generator.rb +1 -1
  41. data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
  42. data/lib/tasks/active_fedora_dev.rake +1 -1
  43. data/solr/config/_rest_managed.json +3 -0
  44. data/solr/config/admin-extra.html +31 -0
  45. data/solr/config/elevate.xml +36 -0
  46. data/solr/config/mapping-ISOLatin1Accent.txt +246 -0
  47. data/solr/config/protwords.txt +21 -0
  48. data/solr/config/schema.xml +372 -0
  49. data/solr/config/scripts.conf +24 -0
  50. data/solr/config/solrconfig.xml +311 -0
  51. data/solr/config/spellings.txt +2 -0
  52. data/solr/config/stopwords.txt +58 -0
  53. data/solr/config/stopwords_en.txt +58 -0
  54. data/solr/config/synonyms.txt +31 -0
  55. data/solr/config/xslt/example.xsl +132 -0
  56. data/solr/config/xslt/example_atom.xsl +67 -0
  57. data/solr/config/xslt/example_rss.xsl +66 -0
  58. data/solr/config/xslt/luke.xsl +337 -0
  59. data/spec/integration/associations_spec.rb +6 -6
  60. data/spec/integration/basic_contains_association_spec.rb +1 -1
  61. data/spec/integration/clean_connection_spec.rb +1 -1
  62. data/spec/integration/complex_rdf_datastream_spec.rb +4 -5
  63. data/spec/integration/datastream_rdf_nested_attributes_spec.rb +15 -14
  64. data/spec/integration/date_time_properties_spec.rb +0 -15
  65. data/spec/integration/direct_container_spec.rb +4 -4
  66. data/spec/integration/directly_contains_one_association_spec.rb +1 -1
  67. data/spec/integration/eradicate_spec.rb +1 -1
  68. data/spec/integration/generators/solr_generator_spec.rb +10 -7
  69. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +5 -5
  70. data/spec/integration/has_many_associations_spec.rb +4 -4
  71. data/spec/integration/indexing_spec.rb +1 -1
  72. data/spec/integration/indirect_container_spec.rb +3 -3
  73. data/spec/integration/ntriples_datastream_spec.rb +35 -23
  74. data/spec/integration/rdf_nested_attributes_spec.rb +3 -3
  75. data/spec/integration/relation_delegation_spec.rb +2 -2
  76. data/spec/integration/scoped_query_spec.rb +3 -3
  77. data/spec/integration/solr_hit_spec.rb +0 -11
  78. data/spec/integration/versionable_spec.rb +6 -6
  79. data/spec/integration/with_metadata_spec.rb +1 -1
  80. data/spec/samples/hydra-mods_article_datastream.rb +2 -4
  81. data/spec/unit/base_spec.rb +3 -4
  82. data/spec/unit/core/fedora_id_translator_spec.rb +2 -2
  83. data/spec/unit/core/fedora_uri_translator_spec.rb +2 -2
  84. data/spec/unit/core_spec.rb +5 -5
  85. data/spec/unit/fedora_spec.rb +1 -2
  86. data/spec/unit/file_spec.rb +2 -2
  87. data/spec/unit/filter_spec.rb +3 -3
  88. data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
  89. data/spec/unit/has_and_belongs_to_many_association_spec.rb +2 -2
  90. data/spec/unit/has_many_association_spec.rb +11 -26
  91. data/spec/unit/ntriples_datastream_spec.rb +6 -9
  92. data/spec/unit/ordered_spec.rb +8 -11
  93. data/spec/unit/orders/list_node_spec.rb +2 -2
  94. data/spec/unit/orders/ordered_list_spec.rb +1 -1
  95. data/spec/unit/query_spec.rb +4 -4
  96. data/spec/unit/rdf/indexing_service_spec.rb +5 -5
  97. data/spec/unit/rdf_resource_datastream_spec.rb +4 -0
  98. metadata +44 -17
  99. data/.solr_wrapper +0 -6
  100. data/lib/active_fedora/profile_indexing_service.rb +0 -11
  101. data/lib/active_fedora/solr_instance_loader.rb +0 -47
  102. data/spec/integration/solr_instance_loader_spec.rb +0 -156
@@ -197,7 +197,7 @@ describe ActiveFedora::Base do
197
197
 
198
198
  it "lets you set an array of objects" do
199
199
  @library.books = [@book, @book2]
200
- expect(@library.books).to eq [@book, @book2]
200
+ expect(@library.books).to contain_exactly @book, @book2
201
201
  @library.save
202
202
 
203
203
  @library.books = [@book]
@@ -205,7 +205,7 @@ describe ActiveFedora::Base do
205
205
  end
206
206
  it "lets you set an array of object ids" do
207
207
  @library.book_ids = [@book.id, @book2.id]
208
- expect(@library.books).to eq [@book, @book2]
208
+ expect(@library.books).to contain_exactly @book, @book2
209
209
  end
210
210
 
211
211
  it "setter should wipe out previously saved relations" do
@@ -219,7 +219,7 @@ describe ActiveFedora::Base do
219
219
  @library.books = [@book, @book2]
220
220
  @library.save
221
221
  @library = Library.find(@library.id)
222
- expect(@library.books).to eq [@book, @book2]
222
+ expect(@library.books).to contain_exactly @book, @book2
223
223
  end
224
224
 
225
225
  it "lets you lookup an array of objects with solr" do
@@ -230,7 +230,7 @@ describe ActiveFedora::Base do
230
230
  @book2.save
231
231
 
232
232
  @library = Library.find(@library.id)
233
- expect(@library.books).to eq [@book, @book2]
233
+ expect(@library.books).to contain_exactly @book, @book2
234
234
 
235
235
  solr_resp = @library.books(response_format: :solr)
236
236
  expect(solr_resp.size).to eq 2
@@ -462,7 +462,7 @@ describe ActiveFedora::Base do
462
462
 
463
463
  it "loads the association stored in the parent" do
464
464
  @reloaded_course = Course.find(@course.id)
465
- expect(@reloaded_course.textbooks).to eq [@t1, @t2]
465
+ expect(@reloaded_course.textbooks).to contain_exactly @t1, @t2
466
466
  end
467
467
 
468
468
  it "allows a parent to be deleted from the has_many association" do
@@ -480,7 +480,7 @@ describe ActiveFedora::Base do
480
480
  @course.textbooks = [@t3, @t4]
481
481
  @course.save
482
482
 
483
- expect(@course.reload.textbooks).to eq [@t3, @t4]
483
+ expect(@course.reload.textbooks).to contain_exactly @t3, @t4
484
484
  end
485
485
 
486
486
  it "allows a child to be deleted from the has_and_belongs_to_many association" do
@@ -86,7 +86,7 @@ describe ActiveFedora::Base do
86
86
 
87
87
  it "has the two contained objects" do
88
88
  expect(model.contains.size).to eq 2
89
- expect(model.contains.map(&:title)).to eq [['title 1'], ['title 2']]
89
+ expect(model.contains.map(&:title)).to contain_exactly ['title 1'], ['title 2']
90
90
  end
91
91
  end
92
92
 
@@ -14,7 +14,7 @@ RSpec.describe ActiveFedora::CleanConnection do
14
14
  it "returns a clean graph" do
15
15
  graph = result.graph
16
16
  expect(graph.statements.to_a.length).to eq 1
17
- expect(graph.statements.to_a.first).to eq [asset.rdf_subject, RDF::Vocab::DC.title, "test"]
17
+ expect(graph.statements.to_a.first).to contain_exactly asset.rdf_subject, RDF::Vocab::DC.title, RDF::Literal.new("test")
18
18
  end
19
19
  end
20
20
  end
@@ -64,8 +64,7 @@ describe "Nested Rdf Objects" do
64
64
  comp2 = SpecDatastream::Component.new nil, ds.graph
65
65
  comp2.label = ["Crankshaft"]
66
66
  ds.parts = [comp1, comp2]
67
- expect(ds.parts.first.label).to eq ["Alternator"]
68
- expect(ds.parts.last.label).to eq ["Crankshaft"]
67
+ expect(ds.parts.map(&:label)).to contain_exactly ["Alternator"], ["Crankshaft"]
69
68
  end
70
69
 
71
70
  it "is able to clear complex objects" do
@@ -85,7 +84,7 @@ _:g70350851837440 <http://purl.org/dc/terms/title> "Alternator" .
85
84
  <#{ActiveFedora.fedora.host}/test/test:124> <http://purl.org/dc/terms/hasPart> _:g70350851833380 .
86
85
  _:g70350851833380 <http://purl.org/dc/terms/title> "Crankshaft" .
87
86
  END
88
- expect(ds.parts.first.label).to eq ["Alternator"]
87
+ expect(ds.parts.map(&:label)).to contain_exactly ["Alternator"], ["Crankshaft"]
89
88
  end
90
89
 
91
90
  it "builds complex objects when a parent node doesn't exist" do
@@ -111,7 +110,6 @@ END
111
110
  describe "#first_or_create" do
112
111
  it "returns a result if the predicate exists" do
113
112
  part1 = ds.parts.build
114
- ds.parts.build
115
113
  expect(ds.parts.first_or_create).to eq part1
116
114
  end
117
115
 
@@ -165,7 +163,7 @@ END
165
163
  _:g70350851837440 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.ebu.ch/metadata/ontologies/ebucore#Organisation> .
166
164
  <#{ActiveFedora.fedora.host}/test/test:124> <http://purl.org/dc/terms/mediator> _:g70350851837440 .
167
165
  END
168
- expect(ds.mediator.first.type.first.to_s).to eq "http://www.ebu.ch/metadata/ontologies/ebucore#Organisation"
166
+ expect(ds.mediator.first.type.map(&:to_s)).to include "http://www.ebu.ch/metadata/ontologies/ebucore#Organisation"
169
167
  end
170
168
  end
171
169
 
@@ -205,6 +203,7 @@ END
205
203
  let(:file) { parent.info }
206
204
 
207
205
  it "stores the type of complex objects when type is specified" do
206
+ pending "This is no longer supported by ActiveTriples - can we deprecate this altogether?"
208
207
  series = SpecDatastream::Series.new nil, file.graph
209
208
  series.title = ["renovating bathrooms"]
210
209
  file.series = series
@@ -91,8 +91,7 @@ describe "Nesting attribute behavior of RDFDatastream" do
91
91
  }
92
92
  # , "Hemings, Sally"
93
93
  ]
94
- }
95
- }
94
+ } }
96
95
  end
97
96
 
98
97
  describe "on lists" do
@@ -104,8 +103,8 @@ describe "Nesting attribute behavior of RDFDatastream" do
104
103
  end
105
104
  it "accepts an array" do
106
105
  subject.elementList_attributes = [{ topicElement_attributes: [{ elementValue: "Quantum Behavior" }, { elementValue: "Wave Function" }] }]
107
- expect(subject.elementList.first[0].elementValue).to eq ["Quantum Behavior"]
108
- expect(subject.elementList.first[1].elementValue).to eq ["Wave Function"]
106
+ element_values = subject.elementList.first.map(&:elementValue)
107
+ expect(element_values).to contain_exactly ["Quantum Behavior"], ["Wave Function"]
109
108
  end
110
109
  end
111
110
 
@@ -116,14 +115,15 @@ describe "Nesting attribute behavior of RDFDatastream" do
116
115
  end
117
116
 
118
117
  it 'has attributes' do
119
- expect(subject.topic[0].elementList.first[0].elementValue).to eq ["Cosmology"]
120
- expect(subject.topic[1].elementList.first[0].elementValue).to eq ["Quantum Behavior"]
121
- expect(subject.personalName.first.elementList.first.fullNameElement).to eq ["Jefferson, Thomas"]
122
- expect(subject.personalName.first.elementList.first.dateNameElement).to eq ["1743-1826"]
118
+ element_values = subject.topic.map { |x| x.elementList.first[0].elementValue }
119
+ expect(element_values).to contain_exactly ["Cosmology"], ["Quantum Behavior"]
120
+ expect(subject.personalName.first.elementList.first.fullNameElement).to contain_exactly "Jefferson, Thomas"
121
+ expect(subject.personalName.first.elementList.first.dateNameElement).to contain_exactly "1743-1826"
123
122
  end
124
123
 
125
124
  it 'builds nodes with ids' do
126
- expect(subject.topic[0].elementList.first[0].rdf_subject).to eq 'http://library.ucsd.edu/ark:/20775/bb3333333x'
125
+ element_list_elements = subject.topic.flat_map { |y| y.elementList.first[0].rdf_subject }
126
+ expect(element_list_elements).to include 'http://library.ucsd.edu/ark:/20775/bb3333333x'
127
127
  expect(subject.personalName.first.rdf_subject).to eq 'http://library.ucsd.edu/ark:20775/jefferson'
128
128
  end
129
129
 
@@ -160,19 +160,20 @@ describe "Nesting attribute behavior of RDFDatastream" do
160
160
  { label: 'Alternator' },
161
161
  { label: 'Distributor' },
162
162
  { label: 'Transmission' },
163
- { label: 'Fuel Filter' }] }
163
+ { label: 'Fuel Filter' }
164
+ ] }
164
165
  end
165
- let(:replace_object_id) { subject.parts[1].rdf_subject.to_s }
166
- let(:remove_object_id) { subject.parts[3].rdf_subject.to_s }
166
+ let(:replace_object_id) { subject.parts.find { |x| x.label == ['Distributor'] }.rdf_subject.to_s }
167
+ let(:remove_object_id) { subject.parts.find { |x| x.label == ['Fuel Filter'] }.rdf_subject.to_s }
167
168
 
168
169
  it "updates nested objects" do
169
170
  subject.parts_attributes = [{ id: replace_object_id, label: "Universal Joint" }, { label: "Oil Pump" }, { id: remove_object_id, _destroy: '1', label: "bar1 uno" }]
170
171
 
171
- expect(subject.parts.map { |p| p.label.first }).to eq ['Alternator', 'Universal Joint', 'Transmission', 'Oil Pump']
172
+ expect(subject.parts.map { |p| p.label.first }).to contain_exactly 'Alternator', 'Universal Joint', 'Transmission', 'Oil Pump'
172
173
  end
173
174
  it "create a new object when the id is provided" do
174
175
  subject.parts_attributes = [{ id: 'http://example.com/part#1', label: "Universal Joint" }]
175
- expect(subject.parts.last.rdf_subject).to eq RDF::URI('http://example.com/part#1')
176
+ expect(subject.parts.map(&:rdf_subject)).to include RDF::URI('http://example.com/part#1')
176
177
  end
177
178
  end
178
179
  end
@@ -39,19 +39,4 @@ describe ActiveFedora::Base do
39
39
  expect(subject).to match(/\+01:00/)
40
40
  end
41
41
  end
42
-
43
- describe "saving and loading in Solr" do
44
- let(:object) { Foo.create!(date: [date], single_date: date2, empty_date: '', integer: 1) }
45
- before { allow(Deprecation).to receive(:warn) }
46
-
47
- let(:subject_solr) { object.class.load_instance_from_solr(object.id) }
48
- it "uses DateTime objects" do
49
- expect(subject_solr.date.first).to be_a DateTime
50
- expect(subject_solr.single_date).to be_a DateTime
51
- end
52
- it "loads the correct time" do
53
- expect(subject_solr.date.first).to eql date
54
- expect(subject_solr.single_date).to eql date2
55
- end
56
- end
57
42
  end
@@ -48,7 +48,7 @@ describe "Direct containers" do
48
48
  describe "#append" do
49
49
  let(:file2) { o.files.build }
50
50
  it "has two files" do
51
- expect(o.files).to eq [file, file2]
51
+ expect(o.files).to contain_exactly file, file2
52
52
  end
53
53
 
54
54
  context "and then saved/reloaded" do
@@ -57,7 +57,7 @@ describe "Direct containers" do
57
57
  o.save!
58
58
  end
59
59
  it "has two files" do
60
- expect(reloaded.files).to eq [file, file2]
60
+ expect(reloaded.files).to contain_exactly file, file2
61
61
  end
62
62
  end
63
63
  end
@@ -171,7 +171,7 @@ describe "Direct containers" do
171
171
  end
172
172
 
173
173
  it "deletes the contained resource directly" do
174
- expect(history.files).to eq [file1, file2]
174
+ expect(history.files).to contain_exactly file1, file2
175
175
  file1.delete
176
176
  history.reload
177
177
  expect(history.files).to eq [file2]
@@ -191,7 +191,7 @@ describe "Direct containers" do
191
191
  end
192
192
 
193
193
  it "deletes the contained resource via the collection proxy" do
194
- expect(history.reload.files).to eq [file1, file2]
194
+ expect(history.reload.files).to contain_exactly file1, file2
195
195
  history.files.delete(file1)
196
196
  expect(history.reload.files).to eq [file2]
197
197
  end
@@ -91,7 +91,7 @@ describe ActiveFedora::Base do
91
91
  replacement_file.content = "I'm a replacement"
92
92
  page_image.save
93
93
  expect(subject).to_not include(primary_file)
94
- expect(subject).to eq([a_file, replacement_file])
94
+ expect(subject).to contain_exactly(a_file, replacement_file)
95
95
  expect(reloaded_page_image.primary_file).to eq(replacement_file)
96
96
  end
97
97
  end
@@ -19,7 +19,7 @@ describe ActiveFedora::Base do
19
19
  end
20
20
  context "in a typical sitation" do
21
21
  specify "it cannot be reused" do
22
- expect { described_class.create(id: ghost) }.to raise_error(Ldp::Gone)
22
+ expect { described_class.create(ghost) }.to raise_error(Ldp::Gone)
23
23
  end
24
24
  end
25
25
  specify "remove its tombstone" do
@@ -9,14 +9,17 @@ describe ActiveFedora::Config::SolrGenerator do
9
9
  '.solr_wrapper'
10
10
  ]}
11
11
 
12
+ before do
13
+ generator.solr_wrapper_config
14
+ end
15
+
16
+ after do
17
+ files_to_test.each { |file| File.delete(file) if File.exist?(file) }
18
+ end
19
+
12
20
  it "creates config files" do
13
- Dir.mktmpdir do |dir|
14
- Dir.chdir(dir) do
15
- generator.solr_wrapper_config
16
- files_to_test.each do |file|
17
- expect(File).to exist(file), "Expected #{file} to exist"
18
- end
19
- end
21
+ files_to_test.each do |file|
22
+ expect(File).to exist(file), "Expected #{file} to exist"
20
23
  end
21
24
  end
22
25
  end
@@ -5,11 +5,11 @@ describe ActiveFedora::Base do
5
5
  context "that is also a HABTM" do
6
6
  before do
7
7
  class Book < ActiveFedora::Base
8
- has_and_belongs_to_many :topics, predicate: ::RDF::FOAF.primaryTopic, inverse_of: :books
8
+ has_and_belongs_to_many :topics, predicate: ::RDF::Vocab::FOAF.primaryTopic, inverse_of: :books
9
9
  end
10
10
 
11
11
  class Topic < ActiveFedora::Base
12
- has_and_belongs_to_many :books, predicate: ::RDF::FOAF.isPrimaryTopicOf
12
+ has_and_belongs_to_many :books, predicate: ::RDF::Vocab::FOAF.isPrimaryTopicOf
13
13
  end
14
14
  end
15
15
 
@@ -34,7 +34,7 @@ describe ActiveFedora::Base do
34
34
  end
35
35
 
36
36
  it "allows for more than 10 items" do
37
- (1..12).each do
37
+ 12.times do
38
38
  book.topics << Topic.create
39
39
  end
40
40
  book.save
@@ -208,7 +208,7 @@ describe ActiveFedora::Base do
208
208
  end
209
209
 
210
210
  it "delete should cause the entries to be removed from RELS-EXT, but not destroy the original record" do
211
- expect(book.collections).to eq [collection1, collection2]
211
+ expect(book.collections).to contain_exactly collection1, collection2
212
212
  book.collections.delete(collection1)
213
213
  expect(book.collections).to eq [collection2]
214
214
  book.save!
@@ -218,7 +218,7 @@ describe ActiveFedora::Base do
218
218
  end
219
219
 
220
220
  it "destroy should cause the entries to be removed from RELS-EXT, but not destroy the original record" do
221
- expect(book.collections).to eq [collection1, collection2]
221
+ expect(book.collections).to contain_exactly collection1, collection2
222
222
  book.collections.destroy(collection1)
223
223
  expect(book.collections).to eq [collection2]
224
224
  book.save!
@@ -161,7 +161,7 @@ describe ActiveFedora::Associations::HasManyAssociation do
161
161
 
162
162
  it "only returns relationships of the correct class" do
163
163
  @book.reload
164
- expect(@book.people).to eq [@person1, @person2]
164
+ expect(@book.people).to contain_exactly @person1, @person2
165
165
  expect(@book.collections).to eq []
166
166
  end
167
167
  end
@@ -222,7 +222,7 @@ describe ActiveFedora::Associations::HasManyAssociation do
222
222
  end
223
223
  it "does not restrict relationships" do
224
224
  @book.reload
225
- expect(@book.attachments).to eq [@image, @pdf]
225
+ expect(@book.attachments).to contain_exactly @image, @pdf
226
226
  end
227
227
  end
228
228
 
@@ -240,7 +240,7 @@ describe ActiveFedora::Associations::HasManyAssociation do
240
240
  it "does not restrict relationships" do
241
241
  email.attachment_ids = [image.id, pdf.id]
242
242
  email.reload
243
- expect(email.attachments).to eq [image, pdf]
243
+ expect(email.attachments).to contain_exactly image, pdf
244
244
  end
245
245
  end
246
246
  end
@@ -409,7 +409,7 @@ describe ActiveFedora::Associations::HasManyAssociation do
409
409
  subject { library.books(true) }
410
410
 
411
411
  it "saves the new title" do
412
- expect(subject.first.title).to eql ["Better book"]
412
+ expect(subject.first.title).to eq ["Better book"]
413
413
  end
414
414
  end
415
415
  end
@@ -62,7 +62,7 @@ describe ActiveFedora::Base do
62
62
  class GenericFile < ActiveFedora::Base
63
63
  has_many :permissions, predicate: ::RDF::Vocab::ACL.accessTo
64
64
  accepts_nested_attributes_for :permissions, allow_destroy: true
65
- property :title, predicate: ::RDF::DC.title
65
+ property :title, predicate: ::RDF::Vocab::DC.title
66
66
 
67
67
  def to_solr
68
68
  super.tap do |doc|
@@ -160,7 +160,7 @@ describe "Indirect containers" do
160
160
  describe "#append" do
161
161
  let(:file2) { o.related_objects.build }
162
162
  it "has two related_objects" do
163
- expect(o.related_objects).to eq [file, file2]
163
+ expect(o.related_objects).to contain_exactly file, file2
164
164
  end
165
165
 
166
166
  context "and then saved/reloaded" do
@@ -170,7 +170,7 @@ describe "Indirect containers" do
170
170
  end
171
171
 
172
172
  it "has two related_objects" do
173
- expect(reloaded.related_objects).to eq [file, file2]
173
+ expect(reloaded.related_objects).to contain_exactly file, file2
174
174
  end
175
175
  end
176
176
  end
@@ -196,7 +196,7 @@ describe "Indirect containers" do
196
196
  end
197
197
 
198
198
  it "returns the ids" do
199
- expect(reloaded.related_object_ids).to eq [file.id, file2.id]
199
+ expect(reloaded.related_object_ids).to contain_exactly file.id, file2.id
200
200
  end
201
201
  end
202
202
  end
@@ -6,13 +6,23 @@ describe ActiveFedora::NtriplesRDFDatastream do
6
6
  property :size
7
7
  end
8
8
 
9
- class MyDatastream < ActiveFedora::NtriplesRDFDatastream
10
- property :title, predicate: ::RDF::Vocab::DC.title
11
- property :date_uploaded, predicate: ::RDF::Vocab::DC.dateSubmitted
12
- property :filesize, predicate: FileVocabulary.size
13
- property :part, predicate: ::RDF::Vocab::DC.hasPart
14
- property :based_near, predicate: ::RDF::FOAF.based_near
15
- property :related_url, predicate: ::RDF::RDFS.seeAlso
9
+ Deprecation.silence(ActiveFedora::RDFDatastream) do
10
+ class MyDatastream < ActiveFedora::NtriplesRDFDatastream
11
+ property :title, predicate: ::RDF::Vocab::DC.title do |index|
12
+ index.as :stored_searchable, :facetable
13
+ end
14
+ property :date_uploaded, predicate: ::RDF::Vocab::DC.dateSubmitted do |index|
15
+ index.type :date
16
+ index.as :stored_searchable, :sortable
17
+ end
18
+ property :filesize, predicate: FileVocabulary.size do |index|
19
+ index.type :integer
20
+ index.as :stored_sortable
21
+ end
22
+ property :part, predicate: ::RDF::Vocab::DC.hasPart
23
+ property :based_near, predicate: ::RDF::Vocab::FOAF.based_near
24
+ property :related_url, predicate: ::RDF::RDFS.seeAlso
25
+ end
16
26
  end
17
27
 
18
28
  class RdfTest < ActiveFedora::Base
@@ -52,7 +62,7 @@ EOF
52
62
  end
53
63
  it "handles integers" do
54
64
  subject.filesize = 12_345
55
- expect(subject.filesize).to be_kind_of Array
65
+ expect(subject.filesize).to eq [12_345]
56
66
  expect(subject.filesize.first).to be_kind_of Fixnum
57
67
  end
58
68
  end
@@ -89,7 +99,7 @@ EOF
89
99
  subject.save
90
100
 
91
101
  loaded = MyDatastream.new(subject.uri)
92
- expect(loaded.part).to eq ['part 1', 'part 2']
102
+ expect(loaded.part).to contain_exactly 'part 1', 'part 2'
93
103
  end
94
104
 
95
105
  it "appends values" do
@@ -97,7 +107,12 @@ EOF
97
107
  subject.save
98
108
 
99
109
  subject.part << "thing 2"
100
- expect(subject.part).to eq ["thing 1", "thing 2"]
110
+ expect(subject.part).to contain_exactly "thing 1", "thing 2"
111
+ end
112
+
113
+ it "is able to save a blank document" do
114
+ subject.title = ""
115
+ subject.save
101
116
  end
102
117
 
103
118
  it "loads n-triples into the graph" do
@@ -105,7 +120,7 @@ EOF
105
120
  <http://oregondigital.org/ns/62> <http://purl.org/dc/terms/spatial> "Benton County (Ore.)" .
106
121
  '
107
122
  subject.content = ntrip
108
- expect(subject.graph.dump(:ntriples)).to eq ntrip
123
+ expect(subject.graph.statements.to_a).to contain_exactly(*RDF::NTriples::Reader.new(ntrip).statements.to_a)
109
124
  end
110
125
 
111
126
  describe "using rdf_subject" do
@@ -123,7 +138,7 @@ EOF
123
138
  subject.destroy
124
139
  end
125
140
 
126
- subject { RdfTest.new(id: '/test:99') }
141
+ subject { RdfTest.new('/test:99') }
127
142
 
128
143
  it "writes rdf with proper subjects" do
129
144
  subject.reload
@@ -155,15 +170,15 @@ EOF
155
170
  subject.part = ["MacBeth"]
156
171
  subject.part << "Hamlet"
157
172
  subject.part << "Romeo & Juliet"
158
- expect(subject.part.first).to eq "MacBeth"
159
- subject.part.delete("MacBeth", "Romeo & Juliet")
173
+ expect(subject.part).to include "MacBeth"
174
+ subject.part.subtract(["MacBeth", "Romeo & Juliet"])
160
175
  expect(subject.part).to eq ["Hamlet"]
161
176
  expect(subject.part.first).to eq "Hamlet"
162
177
  end
163
178
  it "ignores values to be deleted that do not exist" do
164
179
  subject.part = ["title1", "title2", "title3"]
165
- subject.part.delete("title2", "title4", "title6")
166
- expect(subject.part).to eq ["title1", "title3"]
180
+ subject.part.subtract(["title2", "title4", "title6"])
181
+ expect(subject.part).to contain_exactly "title1", "title3"
167
182
  end
168
183
 
169
184
  describe "term proxy methods" do
@@ -185,19 +200,16 @@ EOF
185
200
  it "iterates over multiple values" do
186
201
  expect(subject.title).to respond_to(:each)
187
202
  end
188
- it "gets the first value" do
189
- expect(subject.title.first).to eq "title1"
190
- end
191
203
  it "evaluates equality predictably" do
192
- expect(subject.title).to eq ["title1", "title2", "title3"]
204
+ expect(subject.title).to contain_exactly "title1", "title2", "title3"
193
205
  end
194
206
  it "supports the empty? method" do
195
207
  expect(subject.title).to_not be_empty
196
- subject.title.delete("title1", "title2", "title3")
208
+ subject.title.subtract(["title1", "title2", "title3"])
197
209
  expect(subject.title).to be_empty
198
210
  end
199
- it "supports the is_a? method" do
200
- expect(subject.title.is_a?(Array)).to eq true
211
+ it "supports the each method" do
212
+ expect(subject.title.respond_to?(:each)).to eq true
201
213
  end
202
214
  end
203
215
  end