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
@@ -9,7 +9,7 @@ describe "Nesting attribute behavior of RDF resources" do
9
9
  end
10
10
 
11
11
  class CustomName < ActiveFedora::Base
12
- property :pref_label, predicate: ::RDF::SKOS.prefLabel, multiple: false
12
+ property :pref_label, predicate: ::RDF::Vocab::SKOS.prefLabel, multiple: false
13
13
  end
14
14
 
15
15
  class CustomSource < ActiveFedora::Base
@@ -52,11 +52,11 @@ describe "Nesting attribute behavior of RDF resources" do
52
52
 
53
53
  it "sets the attributes" do
54
54
  expect(subject.topic.size).to eq 2
55
- expect(subject.topic.map(&:subject)).to eq [['Foo'], ['Bar']]
55
+ expect(subject.topic.map(&:subject)).to contain_exactly ['Foo'], ['Bar']
56
56
  end
57
57
 
58
58
  it "marks the attributes as changed" do
59
- expect(subject.changed_attributes).to eq('topic' => [])
59
+ expect(subject.changed_attributes.keys).to eq ["topic"]
60
60
  end
61
61
  end
62
62
 
@@ -28,11 +28,11 @@ describe ActiveFedora::Base do
28
28
  subject { TestClass.where(bar: 'Peanuts') }
29
29
 
30
30
  it "maps" do
31
- expect(subject.map(&:id)).to eq [instance2.id, instance3.id]
31
+ expect(subject.map(&:id)).to contain_exactly instance2.id, instance3.id
32
32
  end
33
33
 
34
34
  it "collects" do
35
- expect(subject.collect(&:id)).to eq [instance2.id, instance3.id]
35
+ expect(subject.collect(&:id)).to contain_exactly instance2.id, instance3.id
36
36
  end
37
37
 
38
38
  it "has each" do
@@ -68,13 +68,13 @@ describe ActiveFedora::Querying do
68
68
  expect(ModelIntegrationSpec::Basic.where('foo' => ['Beta', 'Alpha'])).to eq [test_instance1, test_instance2]
69
69
  end
70
70
  it "orders" do
71
- expect(ModelIntegrationSpec::Basic.order(ActiveFedora.index_field_mapper.solr_name('foo', :sortable) + ' asc')).to eq [test_instance2, test_instance1, test_instance3]
71
+ expect(ModelIntegrationSpec::Basic.order(ActiveFedora.index_field_mapper.solr_name('foo', :sortable) + ' asc')).to contain_exactly test_instance2, test_instance1, test_instance3
72
72
  end
73
73
  it "limits" do
74
74
  expect(ModelIntegrationSpec::Basic.limit(1)).to eq [test_instance1]
75
75
  end
76
76
  it "offsets" do
77
- expect(ModelIntegrationSpec::Basic.offset(1)).to eq [test_instance2, test_instance3]
77
+ expect(ModelIntegrationSpec::Basic.offset(1)).to contain_exactly test_instance2, test_instance3
78
78
  end
79
79
 
80
80
  it "chains queries" do
@@ -127,7 +127,7 @@ describe ActiveFedora::Querying do
127
127
  end
128
128
  it "logs an error" do
129
129
  expect(ActiveFedora::Base.logger).to receive(:error).with("Although #{id} was found in Solr, it doesn't seem to exist in Fedora. The index is out of synch.")
130
- expect(ModelIntegrationSpec::Basic.all).to eq [test_instance1, test_instance3]
130
+ expect(ModelIntegrationSpec::Basic.all).to contain_exactly test_instance1, test_instance3
131
131
  end
132
132
  end
133
133
  end
@@ -29,15 +29,4 @@ describe ActiveFedora::SolrHit do
29
29
  expect(subject.title).to eq 'My Title'
30
30
  end
31
31
  end
32
-
33
- describe "#instantiate_with_json" do
34
- subject { solr_hit.instantiate_with_json }
35
-
36
- it { is_expected.to be_persisted }
37
-
38
- it "finds the document in solr" do
39
- expect(subject).to be_instance_of Foo
40
- expect(subject.title).to eq 'My Title'
41
- end
42
- end
43
32
  end
@@ -106,7 +106,7 @@ describe ActiveFedora::Versionable do
106
106
  end
107
107
 
108
108
  it "will return to the first version's values" do
109
- expect(subject.title).to eql(["Greetings Earthlings"])
109
+ expect(subject.title).to eq(["Greetings Earthlings"])
110
110
  end
111
111
 
112
112
  context "and creating additional versions" do
@@ -118,7 +118,7 @@ describe ActiveFedora::Versionable do
118
118
 
119
119
  it "has three versions" do
120
120
  expect(subject.versions.all.size).to eq 3
121
- expect(subject.title).to eql(["Now, surrender and prepare to be boarded"])
121
+ expect(subject.title).to eq(["Now, surrender and prepare to be boarded"])
122
122
  end
123
123
  end
124
124
  end
@@ -179,7 +179,7 @@ describe ActiveFedora::Versionable do
179
179
  end
180
180
 
181
181
  it "has a title" do
182
- expect(subject.title).to eql(["Greetings Earthlings"])
182
+ expect(subject.title).to eq(["Greetings Earthlings"])
183
183
  end
184
184
 
185
185
  it "has a size" do
@@ -202,7 +202,7 @@ describe ActiveFedora::Versionable do
202
202
  end
203
203
 
204
204
  it "has the new title" do
205
- expect(subject.title).to eql(["Surrender and prepare to be boarded"])
205
+ expect(subject.title).to eq(["Surrender and prepare to be boarded"])
206
206
  end
207
207
 
208
208
  it "has a new size" do
@@ -221,7 +221,7 @@ describe ActiveFedora::Versionable do
221
221
  end
222
222
 
223
223
  it "loads the restored file's content" do
224
- expect(subject.title).to eql(["Greetings Earthlings"])
224
+ expect(subject.title).to eq(["Greetings Earthlings"])
225
225
  end
226
226
 
227
227
  it "is the same size as the original file" do
@@ -240,7 +240,7 @@ describe ActiveFedora::Versionable do
240
240
  end
241
241
 
242
242
  it "has a new title" do
243
- expect(subject.title).to eql(["Now, surrender and prepare to be boarded"])
243
+ expect(subject.title).to eq(["Now, surrender and prepare to be boarded"])
244
244
  end
245
245
 
246
246
  it "has a new size" do
@@ -30,7 +30,7 @@ describe ActiveFedora::WithMetadata do
30
30
  file.title = ['one', 'two']
31
31
  end
32
32
  it "sets and retrieve properties" do
33
- expect(file.title).to eq ['one', 'two']
33
+ expect(file.title).to contain_exactly 'one', 'two'
34
34
  end
35
35
 
36
36
  it "tracks changes" do
@@ -253,8 +253,7 @@ module Hydra
253
253
  "edt" => "Editor",
254
254
  "ill" => "Illustrator",
255
255
  "oth" => "Other",
256
- "trl" => "Translator"
257
- }
256
+ "trl" => "Translator" }
258
257
  end
259
258
 
260
259
  def self.person_relator_terms
@@ -268,8 +267,7 @@ module Hydra
268
267
  "res" => "Researcher",
269
268
  "rth" => "Research team head",
270
269
  "rtm" => "Research team member",
271
- "trl" => "Translator"
272
- }
270
+ "trl" => "Translator" }
273
271
  end
274
272
 
275
273
  def self.conference_relator_terms
@@ -72,8 +72,8 @@ describe ActiveFedora::Base do
72
72
  context "on an inherited class" do
73
73
  before do
74
74
  class Agent < ActiveFedora::Base
75
- rdf_label ::RDF::FOAF.name
76
- property :foaf_name, predicate: ::RDF::FOAF.name
75
+ rdf_label ::RDF::Vocab::FOAF.name
76
+ property :foaf_name, predicate: ::RDF::Vocab::FOAF.name
77
77
  end
78
78
  class Person < Agent
79
79
  rdf_label ::RDF::URI('http://example.com/foo')
@@ -141,7 +141,6 @@ describe ActiveFedora::Base do
141
141
 
142
142
  context "with an id argument" do
143
143
  it "is able to create with a custom id" do
144
- expect(Deprecation).to receive(:warn)
145
144
  expect(FooHistory).to receive(:id_to_uri).and_call_original
146
145
  f = FooHistory.new('baz_1')
147
146
  expect(f.id).to eq 'baz_1'
@@ -260,7 +259,7 @@ describe ActiveFedora::Base do
260
259
  end
261
260
 
262
261
  it "updates the resource" do
263
- expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.base_uri}/#{@this_id}")
262
+ expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/#{@this_id}")
264
263
  expect(test_object.title).to eq ['foo']
265
264
  end
266
265
  end
@@ -4,7 +4,7 @@ RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
4
4
  describe ".call" do
5
5
  let(:result) { described_class.call(id) }
6
6
  context "when given an id" do
7
- let(:good_uri) { ActiveFedora.fedora.base_uri + "/banana" }
7
+ let(:good_uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "/banana" }
8
8
  let(:id) { "banana" }
9
9
  it "returns a fedora URI" do
10
10
  expect(result).to eq good_uri
@@ -18,7 +18,7 @@ RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
18
18
  end
19
19
 
20
20
  context "with characters that need escaping" do
21
- let(:good_uri) { ActiveFedora.fedora.base_uri + "/%5Bfrob%5D" }
21
+ let(:good_uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "/%5Bfrob%5D" }
22
22
  let(:id) { "[frob]" }
23
23
  it "returns a good fedora URI" do
24
24
  expect(result).to eq good_uri
@@ -4,13 +4,13 @@ RSpec.describe ActiveFedora::Core::FedoraUriTranslator do
4
4
  describe ".call" do
5
5
  let(:result) { described_class.call(uri) }
6
6
  context "when given a Fedora URI" do
7
- let(:uri) { ActiveFedora.fedora.base_uri + "/6" }
7
+ let(:uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "/6" }
8
8
  it "returns the id" do
9
9
  expect(result).to eq '6'
10
10
  end
11
11
  end
12
12
  context "when given a URI missing a slash" do
13
- let(:uri) { ActiveFedora.fedora.base_uri + "602-a" }
13
+ let(:uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "602-a" }
14
14
  it "returns the id" do
15
15
  expect(result).to eq "602-a"
16
16
  end
@@ -109,7 +109,7 @@ describe ActiveFedora::Base do
109
109
  subject { described_class.id_to_uri(id) }
110
110
 
111
111
  context "with no custom proc is set" do
112
- it { is_expected.to eq "#{ActiveFedora.fedora.base_uri}/123456w" }
112
+ it { should eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/123456w" }
113
113
  it "justs call #translate_id_to_uri" do
114
114
  allow(described_class).to receive(:translate_id_to_uri).and_call_original
115
115
  allow(ActiveFedora::Core::FedoraIdTranslator).to receive(:call).and_call_original
@@ -122,11 +122,11 @@ describe ActiveFedora::Base do
122
122
 
123
123
  context "when custom proc is set" do
124
124
  before do
125
- described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.base_uri}/foo/#{id}" }
125
+ described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/#{id}" }
126
126
  end
127
127
  after { described_class.translate_id_to_uri = nil }
128
128
 
129
- it { is_expected.to eq "#{ActiveFedora.fedora.base_uri}/foo/123456w" }
129
+ it { should eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/123456w" }
130
130
  end
131
131
 
132
132
  context "with an empty base path" do
@@ -145,8 +145,8 @@ describe ActiveFedora::Base do
145
145
  end
146
146
 
147
147
  describe "uri_to_id" do
148
- let(:uri) { "#{ActiveFedora.fedora.base_uri}/foo/123456w" }
149
- subject(:uri_id) { described_class.uri_to_id(uri) }
148
+ let(:uri) { "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/123456w" }
149
+ subject { described_class.uri_to_id(uri) }
150
150
 
151
151
  context "with no custom proc is set" do
152
152
  it { should eq 'foo/123456w' }
@@ -8,8 +8,7 @@ describe ActiveFedora::Fedora do
8
8
  { url: "https://example.com",
9
9
  user: "fedoraAdmin",
10
10
  password: "fedoraAdmin",
11
- ssl: { ca_path: '/path/to/certs' }
12
- }
11
+ ssl: { ca_path: '/path/to/certs' } }
13
12
  }
14
13
  specify {
15
14
  expect(Faraday).to receive(:new).with("https://example.com", ssl: { ca_path: '/path/to/certs' }).and_call_original
@@ -51,14 +51,14 @@ describe ActiveFedora::File do
51
51
  context "and it's initialized with the URI" do
52
52
  let(:file) { described_class.new(parent.uri + "/FOO1") }
53
53
  it "works" do
54
- expect(subject.to_s).to eq "#{ActiveFedora.fedora.base_uri}/1234/FOO1"
54
+ expect(subject.to_s).to eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/1234/FOO1"
55
55
  end
56
56
  end
57
57
 
58
58
  context "and it's initialized with an ID" do
59
59
  let(:file) { described_class.new(parent.id + "/FOO1") }
60
60
  it "works" do
61
- expect(subject.to_s).to eq "#{ActiveFedora.fedora.base_uri}/1234/FOO1"
61
+ expect(subject.to_s).to eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/1234/FOO1"
62
62
  end
63
63
  end
64
64
  end
@@ -55,7 +55,7 @@ describe ActiveFedora::Associations::FilterAssociation do
55
55
  image.child_collections = [another_collection]
56
56
  end
57
57
  it "overwrites existing matches" do
58
- expect(image.members).to eq [test_object, another_collection]
58
+ expect(image.members).to contain_exactly test_object, another_collection
59
59
  end
60
60
  end
61
61
  end
@@ -75,7 +75,7 @@ describe ActiveFedora::Associations::FilterAssociation do
75
75
  end
76
76
 
77
77
  it "updates the parent" do
78
- expect(image.members).to eq [test_object, test_collection, another_collection]
78
+ expect(image.members).to contain_exactly test_object, test_collection, another_collection
79
79
  end
80
80
  end
81
81
  end
@@ -128,6 +128,6 @@ describe ActiveFedora::Associations::FilterAssociation do
128
128
 
129
129
  subject { image.members }
130
130
 
131
- it { is_expected.to eq [test_collection, another_object] }
131
+ it { is_expected.to contain_exactly test_collection, another_object }
132
132
  end
133
133
  end
@@ -24,8 +24,8 @@ describe ActiveFedora::Attributes, ".new" do
24
24
  end
25
25
 
26
26
  class Person < ActiveFedora::Base
27
- property :first_name, predicate: ::RDF::FOAF.firstName, multiple: false
28
- property :gender, predicate: ::RDF::FOAF.gender, multiple: false
27
+ property :first_name, predicate: ::RDF::Vocab::FOAF.firstName, multiple: false
28
+ property :gender, predicate: ::RDF::Vocab::FOAF.gender, multiple: false
29
29
  end
30
30
  end
31
31
 
@@ -18,7 +18,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
18
18
  Object.send(:remove_const, :Book)
19
19
  Object.send(:remove_const, :Page)
20
20
  end
21
- subject { Book.new(id: 'subject-a') }
21
+ subject { Book.new('subject-a') }
22
22
 
23
23
  context "a one way relationship " do
24
24
  describe "adding memeber" do
@@ -114,7 +114,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
114
114
  it "clears the object set" do
115
115
  expect(collection.members).to eq [thing]
116
116
  collection.member_ids = [thing2.id, thing3.id]
117
- expect(collection.members).to eq [thing2, thing3]
117
+ expect(collection.members).to contain_exactly thing2, thing3
118
118
  end
119
119
  end
120
120
 
@@ -12,8 +12,8 @@ describe ActiveFedora::Associations::HasManyAssociation do
12
12
  Object.send(:remove_const, :Book)
13
13
  Object.send(:remove_const, :Page)
14
14
  end
15
- let(:book) { Book.new(id: 'subject-a') }
16
- let(:page) { Page.new(id: 'object-b') }
15
+ let(:book) { Book.new('subject-a') }
16
+ let(:page) { Page.new('object-b') }
17
17
 
18
18
  describe "setting the foreign key" do
19
19
  before do
@@ -32,34 +32,19 @@ describe ActiveFedora::Associations::HasManyAssociation do
32
32
  end
33
33
  end
34
34
 
35
- describe "#find_polymorphic_inverse" do
35
+ describe "Finding a polymorphic inverse relation" do
36
+ before do
37
+ # :books must come first, so that we can test that is being passed over in favor of :contents
38
+ Page.has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
39
+ Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
40
+ end
36
41
  let(:book_reflection) { ActiveFedora::Reflection.create(:has_many, 'pages', nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
37
42
  let(:association) { described_class.new(book, book_reflection) }
38
43
 
39
- subject(:inverse) { association.send(:find_polymorphic_inverse, page) }
40
-
41
- context "when a has_many is present" do
42
- before do
43
- # :books must come first, so that we can test that is being passed over in favor of :contents
44
- Page.has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
45
- Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
46
- end
47
-
48
- it "finds the HABTM reflection" do
49
- expect(inverse.name).to eq :contents
50
- end
51
- end
52
-
53
- context "when multiple belongs_to are present" do
54
- before do
55
- # :foo must come first, so that we can test that is being passed over in favor of :bar
56
- Page.belongs_to :foo, predicate: ::RDF::Vocab::DC.isPartOf, class_name: 'ActiveFedora::Base'
57
- Page.belongs_to :bar, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
58
- end
44
+ subject { association.send(:find_polymorphic_inverse, page) }
59
45
 
60
- it "finds the belongs_to reflection" do
61
- expect(inverse.name).to eq :bar
62
- end
46
+ it "finds the HABTM reflection" do
47
+ expect(subject.name).to eq :contents
63
48
  end
64
49
  end
65
50
 
@@ -20,8 +20,8 @@ EOF
20
20
  property :publisher, predicate: ::RDF::Vocab::DC.publisher
21
21
  property :creator, predicate: ::RDF::Vocab::DC.creator
22
22
  property :educationLevel, predicate: ::RDF::Vocab::DC.educationLevel
23
- property :based_near, predicate: ::RDF::FOAF.based_near
24
- property :related_url, predicate: ::RDF::RDFS.seeAlso
23
+ property :based_near, predicate: ::RDF::Vocab::FOAF.based_near
24
+ property :related_url, predicate: ::RDF::Vocab::RDFS.seeAlso
25
25
  end
26
26
  @subject = MyDatastream.new(ActiveFedora::Base.id_to_uri('/test:1/descMetadata'))
27
27
  @subject.content = remote_content
@@ -55,9 +55,6 @@ EOF
55
55
  expect(val).to eq ["0. Title of work"]
56
56
  end
57
57
 
58
- it "returns fields that are not TermProxies" do
59
- expect(@subject.created).to be_kind_of Array
60
- end
61
58
  it "has method missing" do
62
59
  expect(lambda { @subject.frank }).to raise_exception NoMethodError
63
60
  end
@@ -72,7 +69,7 @@ EOF
72
69
  end
73
70
  it "appends fields" do
74
71
  @subject.publisher << "St. Martin's Press"
75
- expect(@subject.publisher).to eq ["Penn State", "St. Martin's Press"]
72
+ expect(@subject.publisher).to contain_exactly "Penn State", "St. Martin's Press"
76
73
  end
77
74
  it "deletes fields" do
78
75
  @subject.related_url.delete(RDF::URI("http://google.com/"))
@@ -98,8 +95,8 @@ EOF
98
95
  property :created, predicate: ::RDF::Vocab::DC.created
99
96
  property :title, predicate: ::RDF::Vocab::DC.title
100
97
  property :publisher, predicate: ::RDF::Vocab::DC.publisher
101
- property :based_near, predicate: ::RDF::FOAF.based_near
102
- property :related_url, predicate: ::RDF::RDFS.seeAlso
98
+ property :based_near, predicate: ::RDF::Vocab::FOAF.based_near
99
+ property :related_url, predicate: ::RDF::Vocab::RDFS.seeAlso
103
100
  end
104
101
  @subject = MyDatastream.new
105
102
  allow(@subject).to receive(:id).and_return 'test:1'
@@ -132,7 +129,7 @@ EOF
132
129
  Object.send(:remove_const, :MyDatastream)
133
130
  end
134
131
 
135
- it "supports to_s method" do
132
+ xit "supports to_s method" do
136
133
  expect(@subject.publisher.to_s).to eq [].to_s
137
134
  @subject.publisher = "Bob"
138
135
  expect(@subject.publisher.to_s).to eq ["Bob"].to_s
@@ -58,16 +58,6 @@ describe ActiveFedora::Orders do
58
58
  end
59
59
  end
60
60
 
61
- it "can load from solr" do
62
- member = Member.new
63
- subject.ordered_members << member
64
- subject.save!
65
- solr_doc = ActiveFedora::SolrService.query("id:#{subject.id}").first
66
-
67
- allow(Deprecation).to receive(:warn)
68
- expect { ActiveFedora::Base.load_instance_from_solr(subject.id, solr_doc) }.not_to raise_error
69
- end
70
-
71
61
  describe "#ordered_members" do
72
62
  describe "<<" do
73
63
  it "appends" do
@@ -98,7 +88,7 @@ describe ActiveFedora::Orders do
98
88
  subject.ordered_members = [member_2, member_2]
99
89
  expect(subject.ordered_members).to eq [member_2, member_2]
100
90
  # Removing from ordering is not the same as removing from aggregation.
101
- expect(subject.members).to eq [member, member_2]
91
+ expect(subject.members).to contain_exactly member, member_2
102
92
  end
103
93
  end
104
94
  describe "+=" do
@@ -135,6 +125,12 @@ describe ActiveFedora::Orders do
135
125
  expect(subject.ordered_members.delete(member)).to eq member
136
126
  expect(subject.ordered_members.to_a).to eq [member_2]
137
127
  end
128
+ it "can delete all" do
129
+ expect(subject.ordered_members.delete(member)).to eq member
130
+ expect(subject.ordered_members.delete(member_2)).to eq member_2
131
+ subject.save!
132
+ expect(subject.reload.ordered_members.to_a).to eq []
133
+ end
138
134
  end
139
135
 
140
136
  context "with an object not found in the list" do
@@ -227,6 +223,7 @@ describe ActiveFedora::Orders do
227
223
  subject.save
228
224
  subject.reload
229
225
  expect(subject.ordered_members).to eq [member, member]
226
+ expect(subject.ordered_member_ids).to eq [member.id, member.id]
230
227
  expect(subject.list_source.resource.query([nil, ::RDF::Vocab::ORE.proxyIn, subject.resource.rdf_subject]).to_a.length).to eq 2
231
228
  expect(subject.head_ids).to eq subject.list_source.head_id
232
229
  expect(subject.tail_ids).to eq subject.list_source.tail_id