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
@@ -4,7 +4,7 @@ RSpec.describe ActiveFedora::Orders::ListNode do
4
4
  subject { described_class.new(node_cache, rdf_subject, graph) }
5
5
  let(:node_cache) { {} }
6
6
  let(:rdf_subject) { RDF::URI("#bla") }
7
- let(:graph) { RDF::Graph.new }
7
+ let(:graph) { ActiveTriples::Resource.new }
8
8
 
9
9
  describe "#target" do
10
10
  context "when a target is set" do
@@ -35,7 +35,7 @@ RSpec.describe ActiveFedora::Orders::ListNode do
35
35
  end
36
36
  context "and it doesn't exist" do
37
37
  it "returns an AT::Resource" do
38
- member = Member.new(id: "testing")
38
+ member = Member.new("testing")
39
39
  graph << [rdf_subject, RDF::Vocab::ORE.proxyFor, member.resource.rdf_subject]
40
40
  expect(subject.target.rdf_subject).to eq member.uri
41
41
  end
@@ -316,7 +316,7 @@ RSpec.describe ActiveFedora::Orders::OrderedList do
316
316
  graph = subject.to_graph
317
317
 
318
318
  expect(graph.statements.to_a.length).to eq 5
319
- expect(graph.subjects.to_a).to eq subject.to_a.map(&:rdf_subject)
319
+ expect(graph.subjects.to_a).to contain_exactly(*subject.to_a.map(&:rdf_subject))
320
320
  expect(graph.query([nil, RDF::Vocab::ORE.proxyFor, nil]).to_a.last.object).to be_kind_of RDF::URI
321
321
  end
322
322
  end
@@ -128,9 +128,9 @@ describe ActiveFedora::Base do
128
128
  .and_return('response' => { 'docs' => mock_docs })
129
129
 
130
130
  allow(relation).to receive(:load_from_fedora).with("changeme-30", nil)
131
- .and_return(SpecModel::Basic.new(id: 'changeme-30'))
131
+ .and_return(SpecModel::Basic.new('changeme-30'))
132
132
  allow(relation).to receive(:load_from_fedora).with("changeme-22", nil)
133
- .and_return(SpecModel::Basic.new(id: 'changeme-22'))
133
+ .and_return(SpecModel::Basic.new('changeme-22'))
134
134
  SpecModel::Basic.find_each { |obj| obj.class == SpecModel::Basic }
135
135
  end
136
136
 
@@ -144,8 +144,8 @@ describe ActiveFedora::Base do
144
144
  let(:mock_docs) { [{ "id" => "changeme-30" }, { "id" => "changeme-22" }] }
145
145
 
146
146
  it "filters by the provided fields" do
147
- expect(relation).to receive(:load_from_fedora).with("changeme-30", nil).and_return(SpecModel::Basic.new(id: 'changeme-30'))
148
- expect(relation).to receive(:load_from_fedora).with("changeme-22", nil).and_return(SpecModel::Basic.new(id: 'changeme-22'))
147
+ expect(relation).to receive(:load_from_fedora).with("changeme-30", nil).and_return(SpecModel::Basic.new('changeme-30'))
148
+ expect(relation).to receive(:load_from_fedora).with("changeme-22", nil).and_return(SpecModel::Basic.new('changeme-22'))
149
149
 
150
150
  expect(mock_docs).to receive(:has_next?).and_return(false)
151
151
  expect(solr).to receive(:paginate).with(1, 1000, 'select', expected_params).and_return('response' => { 'docs' => mock_docs })
@@ -6,8 +6,8 @@ describe ActiveFedora::RDF::IndexingService do
6
6
  property :created, predicate: ::RDF::Vocab::DC.created
7
7
  property :title, predicate: ::RDF::Vocab::DC.title
8
8
  property :publisher, predicate: ::RDF::Vocab::DC.publisher
9
- property :based_near, predicate: ::RDF::FOAF.based_near
10
- property :related_url, predicate: ::RDF::RDFS.seeAlso
9
+ property :based_near, predicate: ::RDF::Vocab::FOAF.based_near
10
+ property :related_url, predicate: ::RDF::Vocab::RDFS.seeAlso
11
11
  property :rights, predicate: ::RDF::Vocab::DC.rights
12
12
  end
13
13
  end
@@ -73,8 +73,8 @@ describe ActiveFedora::RDF::IndexingService do
73
73
 
74
74
  it "returns the right values" do
75
75
  expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__related_url", type: :string)]).to eq ["http://example.org/blogtastic/"]
76
- expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", type: :string)]).to eq ["Tacoma, WA", "Renton, WA"]
77
- expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", :facetable)]).to eq ["Tacoma, WA", "Renton, WA"]
76
+ expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", type: :string)]).to contain_exactly "Tacoma, WA", "Renton, WA"
77
+ expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", :facetable)]).to contain_exactly "Tacoma, WA", "Renton, WA"
78
78
  expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", type: :string)]).to eq ["Bob's Blogtastic Publishing"]
79
79
  expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :sortable)]).to eq "Bob's Blogtastic Publishing"
80
80
  expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :facetable)]).to eq ["Bob's Blogtastic Publishing"]
@@ -90,7 +90,7 @@ describe ActiveFedora::RDF::IndexingService do
90
90
 
91
91
  it "returns the right values" do
92
92
  expect(fields["related_url"].values).to eq ["http://example.org/blogtastic/"]
93
- expect(fields["based_near"].values).to eq ["Tacoma, WA", "Renton, WA"]
93
+ expect(fields["based_near"].values).to contain_exactly "Tacoma, WA", "Renton, WA"
94
94
  end
95
95
 
96
96
  it "returns the right type information" do
@@ -134,6 +134,10 @@ describe ActiveFedora::RDFDatastream do
134
134
  subject.creator = @new_object
135
135
  end
136
136
 
137
+ it "can set sub-properties to AF objects" do
138
+ expect(subject.creator).to eq [@new_object]
139
+ end
140
+
137
141
  it "has accessible relationship attributes" do
138
142
  expect(subject.creator.first.something).to eq ["subbla"]
139
143
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.3.0
4
+ version: 11.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-11-21 00:00:00.000000000 Z
13
+ date: 2016-07-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr
@@ -120,28 +120,42 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: 0.7.1
123
+ version: 0.10.0
124
124
  type: :runtime
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: 0.7.1
130
+ version: 0.10.0
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: rdf-rdfxml
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - "~>"
135
+ - - ">="
136
136
  - !ruby/object:Gem::Version
137
- version: '1.1'
137
+ version: '0'
138
138
  type: :runtime
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
- - - "~>"
142
+ - - ">="
143
143
  - !ruby/object:Gem::Version
144
- version: '1.1'
144
+ version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: linkeddata
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :runtime
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
145
159
  - !ruby/object:Gem::Dependency
146
160
  name: deprecation
147
161
  requirement: !ruby/object:Gem::Requirement
@@ -316,14 +330,14 @@ dependencies:
316
330
  requirements:
317
331
  - - "~>"
318
332
  - !ruby/object:Gem::Version
319
- version: 0.38.0
333
+ version: 0.42.0
320
334
  type: :development
321
335
  prerelease: false
322
336
  version_requirements: !ruby/object:Gem::Requirement
323
337
  requirements:
324
338
  - - "~>"
325
339
  - !ruby/object:Gem::Version
326
- version: 0.38.0
340
+ version: 0.42.0
327
341
  - !ruby/object:Gem::Dependency
328
342
  name: rubocop-rspec
329
343
  requirement: !ruby/object:Gem::Requirement
@@ -353,7 +367,7 @@ files:
353
367
  - ".mailmap"
354
368
  - ".rspec"
355
369
  - ".rubocop.yml"
356
- - ".solr_wrapper"
370
+ - ".rubocop_todo.yml"
357
371
  - ".travis.yml"
358
372
  - CONTRIBUTING.md
359
373
  - CONTRIBUTORS.md
@@ -489,7 +503,6 @@ files:
489
503
  - lib/active_fedora/orders/target_proxy.rb
490
504
  - lib/active_fedora/pathing.rb
491
505
  - lib/active_fedora/persistence.rb
492
- - lib/active_fedora/profile_indexing_service.rb
493
506
  - lib/active_fedora/property.rb
494
507
  - lib/active_fedora/qualified_dublin_core_datastream.rb
495
508
  - lib/active_fedora/query_result_builder.rb
@@ -527,7 +540,6 @@ files:
527
540
  - lib/active_fedora/scoping/named.rb
528
541
  - lib/active_fedora/serialization.rb
529
542
  - lib/active_fedora/solr_hit.rb
530
- - lib/active_fedora/solr_instance_loader.rb
531
543
  - lib/active_fedora/solr_query_builder.rb
532
544
  - lib/active_fedora/solr_service.rb
533
545
  - lib/active_fedora/sparql_insert.rb
@@ -581,6 +593,22 @@ files:
581
593
  - script/console
582
594
  - script/destroy
583
595
  - script/generate
596
+ - solr/config/_rest_managed.json
597
+ - solr/config/admin-extra.html
598
+ - solr/config/elevate.xml
599
+ - solr/config/mapping-ISOLatin1Accent.txt
600
+ - solr/config/protwords.txt
601
+ - solr/config/schema.xml
602
+ - solr/config/scripts.conf
603
+ - solr/config/solrconfig.xml
604
+ - solr/config/spellings.txt
605
+ - solr/config/stopwords.txt
606
+ - solr/config/stopwords_en.txt
607
+ - solr/config/synonyms.txt
608
+ - solr/config/xslt/example.xsl
609
+ - solr/config/xslt/example_atom.xsl
610
+ - solr/config/xslt/example_rss.xsl
611
+ - solr/config/xslt/luke.xsl
584
612
  - spec/config_helper.rb
585
613
  - spec/fixtures/damsObjectModel.xml
586
614
  - spec/fixtures/dino.jpg
@@ -639,7 +667,6 @@ files:
639
667
  - spec/integration/scoped_query_spec.rb
640
668
  - spec/integration/scoping_spec.rb
641
669
  - spec/integration/solr_hit_spec.rb
642
- - spec/integration/solr_instance_loader_spec.rb
643
670
  - spec/integration/versionable_spec.rb
644
671
  - spec/integration/with_metadata_spec.rb
645
672
  - spec/rcov.opts
@@ -743,12 +770,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
743
770
  version: '2.0'
744
771
  required_rubygems_version: !ruby/object:Gem::Requirement
745
772
  requirements:
746
- - - ">="
773
+ - - ">"
747
774
  - !ruby/object:Gem::Version
748
- version: '0'
775
+ version: 1.3.1
749
776
  requirements: []
750
777
  rubyforge_project:
751
- rubygems_version: 2.4.5.1
778
+ rubygems_version: 2.5.1
752
779
  signing_key:
753
780
  specification_version: 4
754
781
  summary: A convenience libary for manipulating documents in the Fedora Repository.
@@ -1,6 +0,0 @@
1
- # Place any default configuration for solr_wrapper here
2
- # version: 6.1.0
3
- port: 8985
4
- collection:
5
- dir: lib/generators/active_fedora/config/solr/templates/solr/config/
6
- name: hydra-test
@@ -1,11 +0,0 @@
1
- module ActiveFedora
2
- class ProfileIndexingService
3
- def initialize(object)
4
- @object = object
5
- end
6
-
7
- def export
8
- @object.serializable_hash.to_json
9
- end
10
- end
11
- end
@@ -1,47 +0,0 @@
1
- module ActiveFedora
2
- class FedoraSolrMismatchError < ActiveFedora::ObjectNotFoundError
3
- def initialize(fedora_id, solr_document_id)
4
- super("Solr ID and Fedora ID do not match; Solr ID=#{solr_document_id}, Fedora ID=#{fedora_id}")
5
- end
6
- end
7
-
8
- # Responsible for loading an ActiveFedora::Base proxy from a Solr document.
9
- class SolrInstanceLoader
10
- attr_reader :context, :id
11
- private :context, :id
12
- def initialize(context, id, solr_doc = nil)
13
- @context = context
14
- @id = id
15
- self.solr_doc = solr_doc
16
- end
17
-
18
- def object
19
- return @object if @object
20
- @object = solr_doc.instantiate_with_json
21
- @object.readonly!
22
- @object.freeze
23
- @object
24
- end
25
-
26
- private
27
-
28
- def solr_doc
29
- @solr_doc ||= begin
30
- self.solr_doc = context.search_by_id(id)
31
- end
32
- end
33
-
34
- def solr_doc=(solr_doc)
35
- unless solr_doc.nil?
36
- solr_doc = ActiveFedora::SolrHit.for(solr_doc)
37
- validate_solr_doc_and_id!(solr_doc)
38
- @solr_doc = solr_doc
39
- end
40
- end
41
-
42
- def validate_solr_doc_and_id!(document)
43
- return if id == document.id
44
- raise ActiveFedora::FedoraSolrMismatchError, id, document.id
45
- end
46
- end
47
- end
@@ -1,156 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::SolrInstanceLoader do
4
- before do
5
- class MyDS < ActiveFedora::OmDatastream
6
- set_terminology do |t|
7
- t.root(path: "durh")
8
- t.foo
9
- t.bar
10
- end
11
- end
12
-
13
- class Foo < ActiveFedora::Base
14
- has_subresource 'descMetadata', class_name: 'MyDS'
15
- property :title, predicate: ::RDF::Vocab::DC.title, multiple: false
16
- property :description, predicate: ::RDF::Vocab::DC.description
17
- belongs_to :another, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'Foo'
18
- has_and_belongs_to_many :dates, predicate: ::RDF::Vocab::DC.date, class_name: 'Bar'
19
- accepts_nested_attributes_for :dates, reject_if: :all_blank, allow_destroy: true
20
- end
21
- class Bar < ActiveFedora::Base
22
- property :start, predicate: ::RDF::Vocab::EDM.begin, multiple: false
23
- has_many :foos, inverse_of: :dates, class_name: 'Foo'
24
- end
25
- end
26
-
27
- let(:another) { Foo.create }
28
-
29
- let!(:obj) { Foo.create!(
30
- id: 'test-123',
31
- title: 'My Title',
32
- description: ['first desc', 'second desc'],
33
- another_id: another.id,
34
- dates_attributes: [{ start: "2003" }, { start: "1996" }]
35
- ) }
36
-
37
- after do
38
- Object.send(:remove_const, :Foo)
39
- Object.send(:remove_const, :Bar)
40
- Object.send(:remove_const, :MyDS)
41
- end
42
-
43
- context "without a solr doc" do
44
- subject { loader.object }
45
-
46
- context "with context" do
47
- let(:loader) { described_class.new(Foo, obj.id) }
48
-
49
- it "finds the document in solr" do
50
- expect(subject).to be_instance_of Foo
51
- expect(subject.title).to eq 'My Title'
52
- expect(subject.description).to match_array ['first desc', 'second desc']
53
- expect(subject.another_id).to eq another.id
54
- end
55
-
56
- it "does not be mutable" do
57
- expect { subject.title = 'Foo' }.to raise_error ActiveFedora::ReadOnlyRecord
58
- end
59
-
60
- it "loads the correct number of nested attributes" do
61
- expect(subject.date_ids.count).to eq 2
62
- end
63
-
64
- it "loads the correct number of regular attributes" do
65
- expect(subject.description.count).to eq 2
66
- end
67
- end
68
-
69
- context "without context" do
70
- let(:loader) { described_class.new(ActiveFedora::Base, obj.id) }
71
-
72
- it "finds the document in solr" do
73
- expect_any_instance_of(ActiveFedora::File).to_not receive(:retrieve_content)
74
- expect_any_instance_of(Ldp::Client).to_not receive(:get)
75
- object = loader.object
76
- expect(object).to be_instance_of Foo
77
- expect(object.title).to eq 'My Title' # object assertion
78
-
79
- # and it's frozen
80
- expect { object.title = 'changed' }.to raise_error ActiveFedora::ReadOnlyRecord
81
- expect(object.title).to eq 'My Title'
82
- end
83
- end
84
-
85
- context "with children" do
86
- let(:loader) { described_class.new(Foo, obj.id) }
87
-
88
- it "has stub implementation of the children" do
89
- expect(subject.descMetadata).to be_kind_of ActiveFedora::LoadableFromJson::SolrBackedMetadataFile
90
- end
91
- end
92
- end
93
-
94
- context "with a solr doc" do
95
- let(:profile) { { "foo" => ["baz"], "bar" => "quix", "title" => "My Title" }.to_json }
96
- let(:doc) { { 'id' => 'test-123', 'has_model_ssim' => ['Foo'], 'object_profile_ssm' => profile } }
97
- let(:loader) { described_class.new(Foo, obj.id, doc) }
98
-
99
- subject { loader.object }
100
-
101
- it "finds the document in solr" do
102
- expect(subject).to be_instance_of Foo
103
- expect(subject.title).to eq 'My Title'
104
- end
105
- end
106
-
107
- context "when the model has imperfect json" do
108
- let(:doc) { { 'id' => 'test-123', 'has_model_ssim' => ['Foo'], 'object_profile_ssm' => profile } }
109
- let(:loader) { described_class.new(Foo, obj.id, doc) }
110
- context "when the json has extra values in it" do
111
- let(:profile) { { "foo" => ["baz"], "bar" => "quix", "title" => "My Title", "extra_value" => "Bonus values!" }.to_json }
112
- it "loads the object without trouble" do
113
- expect(loader.object).to be_instance_of Foo
114
- end
115
- end
116
-
117
- context "when the json is missing values" do
118
- let(:profile) { { "foo" => ["baz"], "bar" => "quix" }.to_json }
119
- it "loads the object without trouble" do
120
- expect(loader.object).to be_instance_of Foo
121
- end
122
- it "missing scalar should be nil" do
123
- expect(loader.object.title).to be_nil
124
- end
125
- it "missing multi-value should be []" do
126
- expect(loader.object.description).to eql([])
127
- end
128
- end
129
-
130
- context "when the json has scalar where multi-value is expected" do
131
- let(:profile) { { "foo" => ["baz"], "bar" => "quix", "description" => "test description" }.to_json }
132
- it "loads the object without trouble" do
133
- expect(loader.object).to be_instance_of Foo
134
- end
135
- it "converts the scalar to an array" do
136
- expect(loader.object.description).to eql(["test description"])
137
- end
138
- end
139
- end
140
-
141
- describe "loading system properties" do
142
- before { allow(Deprecation).to receive(:warn) }
143
- let(:obj_solr) { Foo.load_instance_from_solr(obj.id) }
144
- it "loads create_date from solr" do
145
- expect(obj.create_date).to be_present
146
- expect(obj_solr).to be_present
147
- expect(obj_solr.create_date).to be_a DateTime
148
- end
149
-
150
- it "loads modified_date from solr" do
151
- expect(obj.modified_date).to be_present
152
- expect(obj_solr).to be_present
153
- expect(obj_solr.modified_date).to be_a DateTime
154
- end
155
- end
156
- end