active-fedora 9.9.1 → 9.10.0.pre1
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/.rubocop.yml +4 -2
- data/.travis.yml +2 -6
- data/active-fedora.gemspec +9 -6
- data/lib/active_fedora.rb +31 -15
- data/lib/active_fedora/associations.rb +1 -1
- data/lib/active_fedora/associations/association.rb +6 -2
- data/lib/active_fedora/associations/belongs_to_association.rb +0 -10
- data/lib/active_fedora/associations/builder/association.rb +85 -12
- data/lib/active_fedora/associations/builder/belongs_to.rb +3 -1
- data/lib/active_fedora/associations/builder/collection_association.rb +4 -3
- data/lib/active_fedora/associations/builder/contains.rb +7 -2
- data/lib/active_fedora/associations/builder/directly_contains.rb +7 -3
- data/lib/active_fedora/associations/builder/directly_contains_one.rb +8 -4
- data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +6 -2
- data/lib/active_fedora/associations/builder/has_many.rb +6 -2
- data/lib/active_fedora/associations/builder/indirectly_contains.rb +7 -3
- data/lib/active_fedora/associations/builder/property.rb +7 -2
- data/lib/active_fedora/associations/builder/singular_association.rb +3 -1
- data/lib/active_fedora/associations/builder/singular_property.rb +3 -1
- data/lib/active_fedora/associations/collection_association.rb +9 -5
- data/lib/active_fedora/associations/collection_proxy.rb +1 -1
- data/lib/active_fedora/associations/contained_finder.rb +1 -2
- data/lib/active_fedora/associations/directly_contains_one_association.rb +1 -1
- data/lib/active_fedora/associations/has_many_association.rb +1 -5
- data/lib/active_fedora/associations/rdf.rb +1 -20
- data/lib/active_fedora/attached_files.rb +1 -1
- data/lib/active_fedora/attribute_methods.rb +18 -0
- data/lib/active_fedora/attributes.rb +1 -1
- data/lib/active_fedora/autosave_association.rb +8 -12
- data/lib/active_fedora/base.rb +0 -2
- data/lib/active_fedora/caching_connection.rb +1 -1
- data/lib/active_fedora/default_model_mapper.rb +24 -0
- data/lib/active_fedora/fedora.rb +1 -1
- data/lib/active_fedora/file/attributes.rb +4 -5
- data/lib/active_fedora/identifiable.rb +5 -0
- data/lib/active_fedora/indexing.rb +13 -7
- data/lib/active_fedora/indexing_service.rb +4 -4
- data/lib/active_fedora/ldp_resource.rb +1 -0
- data/lib/active_fedora/model.rb +18 -16
- data/lib/active_fedora/model_classifier.rb +77 -0
- data/lib/active_fedora/nested_attributes.rb +145 -18
- data/lib/active_fedora/persistence.rb +1 -1
- data/lib/active_fedora/predicates.rb +3 -0
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
- data/lib/active_fedora/query_result_builder.rb +12 -28
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/rdf/datastream_indexing.rb +1 -1
- data/lib/active_fedora/reflection.rb +15 -7
- data/lib/active_fedora/relation.rb +17 -0
- data/lib/active_fedora/relation/calculations.rb +1 -5
- data/lib/active_fedora/relation/finder_methods.rb +39 -26
- data/lib/active_fedora/scoping.rb +5 -0
- data/lib/active_fedora/scoping/default.rb +113 -0
- data/lib/active_fedora/scoping/named.rb +11 -3
- data/lib/active_fedora/simple_datastream.rb +1 -1
- data/lib/active_fedora/solr_hit.rb +71 -0
- data/lib/active_fedora/solr_instance_loader.rb +12 -36
- data/lib/active_fedora/solr_query_builder.rb +20 -25
- data/lib/active_fedora/solr_service.rb +24 -13
- data/lib/active_fedora/type.rb +8 -0
- data/lib/active_fedora/type/boolean.rb +23 -0
- data/lib/active_fedora/type/value.rb +118 -0
- data/lib/active_fedora/validations.rb +14 -5
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/versionable.rb +8 -7
- data/spec/config_helper.rb +0 -5
- data/spec/integration/associations_spec.rb +5 -5
- data/spec/integration/base_spec.rb +4 -4
- data/spec/integration/bug_spec.rb +0 -1
- data/spec/integration/full_featured_model_spec.rb +4 -4
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +1 -1
- data/spec/integration/has_many_associations_spec.rb +30 -1
- data/spec/integration/indirect_container_spec.rb +1 -1
- data/spec/integration/nested_attribute_spec.rb +6 -0
- data/spec/integration/ntriples_datastream_spec.rb +4 -4
- data/spec/integration/om_datastream_spec.rb +1 -1
- data/spec/integration/relation_delegation_spec.rb +1 -1
- data/spec/integration/scoped_query_spec.rb +12 -12
- data/spec/integration/solr_hit_spec.rb +52 -0
- data/spec/samples/hydra-mods_article_datastream.rb +2 -2
- data/spec/spec_helper.rb +5 -9
- data/spec/unit/active_fedora_spec.rb +0 -26
- data/spec/unit/base_spec.rb +20 -0
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +2 -3
- data/spec/unit/callback_spec.rb +3 -8
- data/spec/unit/default_model_mapper_spec.rb +39 -0
- data/spec/unit/finder_methods_spec.rb +30 -6
- data/spec/unit/has_many_association_spec.rb +23 -1
- data/spec/unit/indexing_spec.rb +17 -3
- data/spec/unit/model_classifier_spec.rb +49 -0
- data/spec/unit/model_spec.rb +0 -9
- data/spec/unit/ntriples_datastream_spec.rb +16 -16
- data/spec/unit/om_datastream_spec.rb +7 -7
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
- data/spec/unit/query_result_builder_spec.rb +4 -10
- data/spec/unit/query_spec.rb +28 -28
- data/spec/unit/rdf/indexing_service_spec.rb +16 -16
- data/spec/unit/scoping_spec.rb +67 -0
- data/spec/unit/simple_datastream_spec.rb +2 -2
- data/spec/unit/solr_config_options_spec.rb +29 -32
- data/spec/unit/solr_hit_spec.rb +58 -0
- data/spec/unit/solr_query_builder_spec.rb +9 -1
- data/spec/unit/solr_service_spec.rb +19 -3
- metadata +73 -17
- data/spec/support/freeze_mocks.rb +0 -12
data/spec/spec_helper.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
ENV["environment"] ||= 'test'
|
2
2
|
require "bundler/setup"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
SimpleCov.start do
|
10
|
-
add_filter "/spec/"
|
11
|
-
add_filter "/gemfiles/"
|
12
|
-
end
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.start do
|
8
|
+
add_filter "/spec/"
|
13
9
|
end
|
14
10
|
|
15
11
|
require 'active-fedora'
|
@@ -115,30 +115,4 @@ describe ActiveFedora do
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
118
|
-
|
119
|
-
describe "#class_from_string" do
|
120
|
-
before do
|
121
|
-
module ParentClass
|
122
|
-
class SiblingClass
|
123
|
-
end
|
124
|
-
class OtherSiblingClass
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
it "returns class constants based on strings" do
|
129
|
-
expect(described_class.class_from_string("Om")).to eq Om
|
130
|
-
expect(described_class.class_from_string("ActiveFedora::RDF::IndexingService")).to eq ActiveFedora::RDF::IndexingService
|
131
|
-
expect(described_class.class_from_string("IndexingService", ActiveFedora::RDF)).to eq ActiveFedora::RDF::IndexingService
|
132
|
-
end
|
133
|
-
|
134
|
-
it "finds sibling classes" do
|
135
|
-
expect(described_class.class_from_string("SiblingClass", ParentClass::OtherSiblingClass)).to eq ParentClass::SiblingClass
|
136
|
-
end
|
137
|
-
|
138
|
-
it "raises a NameError if the class isn't found" do
|
139
|
-
expect {
|
140
|
-
described_class.class_from_string("FooClass", ParentClass::OtherSiblingClass)
|
141
|
-
}.to raise_error NameError, "uninitialized constant FooClass"
|
142
|
-
end
|
143
|
-
end
|
144
118
|
end
|
data/spec/unit/base_spec.rb
CHANGED
@@ -333,4 +333,24 @@ describe ActiveFedora::Base do
|
|
333
333
|
end
|
334
334
|
end
|
335
335
|
end
|
336
|
+
|
337
|
+
describe '.dangerous_attribute_method?' do
|
338
|
+
before do
|
339
|
+
class FooHistory < ActiveFedora::Base
|
340
|
+
type ::RDF::URI.new('http://example.com/foo')
|
341
|
+
property :title, predicate: ::RDF::Vocab::DC.title
|
342
|
+
end
|
343
|
+
end
|
344
|
+
after do
|
345
|
+
Object.send(:remove_const, :FooHistory)
|
346
|
+
end
|
347
|
+
|
348
|
+
it 'is dangerous if it is defined by the class' do
|
349
|
+
expect(FooHistory.dangerous_attribute_method?(:save)).to eq true
|
350
|
+
end
|
351
|
+
|
352
|
+
it 'is not dangerous if it is defined outside of ActiveFedora' do
|
353
|
+
expect(FooHistory.dangerous_attribute_method?(:puts)).to eq false
|
354
|
+
end
|
355
|
+
end
|
336
356
|
end
|
@@ -2,8 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Associations::Builder::HasAndBelongsToMany do
|
4
4
|
describe "valid_options" do
|
5
|
-
subject { described_class.valid_options }
|
6
|
-
it { should
|
7
|
-
:after_remove, :inverse_of, :solr_page_size, :autosave] }
|
5
|
+
subject { described_class.valid_options({}) }
|
6
|
+
it { should match_array [:class_name, :predicate, :type_validator, :before_add, :after_add, :before_remove, :after_remove, :inverse_of, :solr_page_size, :autosave] }
|
8
7
|
end
|
9
8
|
end
|
data/spec/unit/callback_spec.rb
CHANGED
@@ -2,11 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
4
|
before :each do
|
5
|
-
begin
|
6
|
-
described_class.find('test:123').delete
|
7
|
-
rescue
|
8
|
-
end
|
9
|
-
|
10
5
|
class CallbackStub < ActiveFedora::Base
|
11
6
|
has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m|
|
12
7
|
m.field "fubar", :string
|
@@ -43,7 +38,7 @@ describe ActiveFedora::Base do
|
|
43
38
|
allow_any_instance_of(CallbackStub).to receive :a_create
|
44
39
|
allow_any_instance_of(CallbackStub).to receive(:b_save)
|
45
40
|
allow_any_instance_of(CallbackStub).to receive(:a_save)
|
46
|
-
@cb = CallbackStub.new
|
41
|
+
@cb = CallbackStub.new
|
47
42
|
@cb.save
|
48
43
|
end
|
49
44
|
|
@@ -53,7 +48,7 @@ describe ActiveFedora::Base do
|
|
53
48
|
allow_any_instance_of(CallbackStub).to receive(:a_create)
|
54
49
|
allow_any_instance_of(CallbackStub).to receive(:b_save)
|
55
50
|
allow_any_instance_of(CallbackStub).to receive(:a_save)
|
56
|
-
@cb = CallbackStub.new
|
51
|
+
@cb = CallbackStub.new
|
57
52
|
@cb.save
|
58
53
|
allow_any_instance_of(CallbackStub).to receive(:a_init)
|
59
54
|
allow_any_instance_of(CallbackStub).to receive(:b_save)
|
@@ -63,7 +58,7 @@ describe ActiveFedora::Base do
|
|
63
58
|
allow_any_instance_of(CallbackStub).to receive(:a_update)
|
64
59
|
allow_any_instance_of(CallbackStub).to receive(:do_stuff)
|
65
60
|
|
66
|
-
@cb = CallbackStub.find(
|
61
|
+
@cb = CallbackStub.find(@cb.id)
|
67
62
|
@cb.save!
|
68
63
|
|
69
64
|
@cb.destroy
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::DefaultModelMapper do
|
4
|
+
let(:classifier) { double }
|
5
|
+
let(:classifier_instance) { double }
|
6
|
+
let(:solr_field) { 'solr_field' }
|
7
|
+
let(:predicate) { 'info:predicate' }
|
8
|
+
subject { described_class.new classifier_class: classifier, solr_field: solr_field, predicate: predicate }
|
9
|
+
|
10
|
+
describe '#classifier' do
|
11
|
+
context 'with a solr document' do
|
12
|
+
let(:solr_document) { { 'solr_field' => ['xyz'] } }
|
13
|
+
|
14
|
+
before do
|
15
|
+
expect(classifier).to receive(:new).with(['xyz']).and_return(classifier_instance)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'creates a classifier from the solr field data' do
|
19
|
+
expect(subject.classifier(solr_document)).to eq classifier_instance
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with a resource' do
|
24
|
+
let(:graph) do
|
25
|
+
RDF::Graph.new << [:hello, predicate, 'xyz']
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:resource) { double(graph: graph) }
|
29
|
+
|
30
|
+
before do
|
31
|
+
expect(classifier).to receive(:new).with(['xyz']).and_return(classifier_instance)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'creates a classifier from the resource model predicate' do
|
35
|
+
expect(subject.classifier(resource)).to eq classifier_instance
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -46,17 +46,17 @@ describe ActiveFedora::FinderMethods do
|
|
46
46
|
|
47
47
|
context "when value is an id" do
|
48
48
|
let(:value) { 'one/two/three' }
|
49
|
-
it { is_expected.to eq "_query_:\"{!
|
49
|
+
it { is_expected.to eq "_query_:\"{!field f=library_id}one/two/three\"" }
|
50
50
|
end
|
51
51
|
|
52
52
|
context "when value is an array" do
|
53
53
|
let(:value) { ['one', 'four'] }
|
54
|
-
it { is_expected.to eq "_query_:\"{!
|
55
|
-
"_query_:\"{!
|
54
|
+
it { is_expected.to eq "_query_:\"{!field f=library_id}one\" AND " \
|
55
|
+
"_query_:\"{!field f=library_id}four\"" }
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe "#
|
59
|
+
describe "#search_in_batches" do
|
60
60
|
let(:docs) { double('docs', has_next?: false) }
|
61
61
|
let(:select_handler) { 'select' }
|
62
62
|
let(:connection) { double('conn') }
|
@@ -70,14 +70,38 @@ describe ActiveFedora::FinderMethods do
|
|
70
70
|
end
|
71
71
|
it "yields the docs" do
|
72
72
|
expect { |b|
|
73
|
-
finder.
|
73
|
+
finder.search_in_batches({ 'age_t' => '21' }, { other_opt: 'test' }, &b)
|
74
74
|
}.to yield_with_args(docs)
|
75
75
|
end
|
76
76
|
|
77
77
|
context "with custom select handler" do
|
78
78
|
let(:select_handler) { 'select_test' }
|
79
79
|
it "uses the custom select handler" do
|
80
|
-
finder.
|
80
|
+
finder.search_in_batches({ 'age_t' => '21' }, other_opt: 'test') do end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#search_by_id' do
|
86
|
+
context 'with a document in solr' do
|
87
|
+
let(:doc) { double('Document') }
|
88
|
+
|
89
|
+
before do
|
90
|
+
expect(finder).to receive(:search_with_conditions).with({ id: 'x' }, hash_including(rows: 1)).and_return([doc])
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns the document" do
|
94
|
+
expect(finder.search_by_id('x')).to eq doc
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'without a document in solr' do
|
99
|
+
before do
|
100
|
+
expect(finder).to receive(:search_with_conditions).with({ id: 'x' }, hash_including(rows: 1)).and_return([])
|
101
|
+
end
|
102
|
+
|
103
|
+
it "returns the document" do
|
104
|
+
expect { finder.search_by_id('x') }.to raise_error ActiveFedora::ObjectNotFoundError
|
81
105
|
end
|
82
106
|
end
|
83
107
|
end
|
@@ -65,10 +65,32 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
let(:owner) { TimeSpan.new }
|
68
|
-
let(:reflection) { TimeSpan.
|
68
|
+
let(:reflection) { TimeSpan._reflect_on_association(:images) }
|
69
69
|
|
70
70
|
it "finds the predicate" do
|
71
71
|
expect { described_class.new(owner, reflection) }.not_to raise_error
|
72
72
|
end
|
73
73
|
end
|
74
|
+
|
75
|
+
describe "scope" do
|
76
|
+
before do
|
77
|
+
class Library < ActiveFedora::Base
|
78
|
+
has_many :images
|
79
|
+
end
|
80
|
+
|
81
|
+
class Image < ActiveFedora::Base
|
82
|
+
belongs_to :library, predicate: ::RDF::URI('http://example.com/library')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
after do
|
87
|
+
Object.send(:remove_const, :Library)
|
88
|
+
Object.send(:remove_const, :Image)
|
89
|
+
end
|
90
|
+
|
91
|
+
context "of an unsaved target" do
|
92
|
+
subject { Library.new.images.scope }
|
93
|
+
it { is_expected.to be_kind_of ActiveFedora::NullRelation }
|
94
|
+
end
|
95
|
+
end
|
74
96
|
end
|
data/spec/unit/indexing_spec.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Indexing do
|
4
|
+
describe '.indexer' do
|
5
|
+
let(:indexing_class) { Class.new }
|
6
|
+
let(:klass) { Class.new }
|
7
|
+
before do
|
8
|
+
klass.include described_class
|
9
|
+
end
|
10
|
+
|
11
|
+
it "is settable as a class attribute" do
|
12
|
+
expect(klass.indexer).to eq ActiveFedora::IndexingService
|
13
|
+
klass.indexer = indexing_class
|
14
|
+
expect(klass.indexer).to eq indexing_class
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
4
18
|
context "internal methods" do
|
5
19
|
before :all do
|
6
20
|
class SpecNode
|
@@ -52,13 +66,13 @@ describe ActiveFedora::Indexing do
|
|
52
66
|
expect(test_object).to receive(:modified_date).and_return(DateTime.parse("2012-03-07T03:12:02Z")).twice
|
53
67
|
allow(test_object).to receive(:id).and_return('changeme:123')
|
54
68
|
solr_doc = test_object.to_solr
|
55
|
-
expect(solr_doc[ActiveFedora
|
56
|
-
expect(solr_doc[ActiveFedora
|
69
|
+
expect(solr_doc[ActiveFedora.index_field_mapper.solr_name("system_create", :stored_sortable, type: :date)]).to eql("2012-03-04T03:12:02Z")
|
70
|
+
expect(solr_doc[ActiveFedora.index_field_mapper.solr_name("system_modified", :stored_sortable, type: :date)]).to eql("2012-03-07T03:12:02Z")
|
57
71
|
expect(solr_doc[:id]).to eql("changeme:123")
|
58
72
|
end
|
59
73
|
|
60
74
|
it "adds self.class as the :active_fedora_model" do
|
61
|
-
expect(subject[ActiveFedora
|
75
|
+
expect(subject[ActiveFedora.index_field_mapper.solr_name("active_fedora_model", :stored_sortable)]).to eql "SpecNode"
|
62
76
|
end
|
63
77
|
|
64
78
|
context "with attached files" do
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::ModelClassifier do
|
4
|
+
module ParentClass
|
5
|
+
class SiblingClass
|
6
|
+
end
|
7
|
+
class OtherSiblingClass
|
8
|
+
end
|
9
|
+
class SubclassClass < SiblingClass
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:class_names) { ["ParentClass::SiblingClass", "ParentClass::OtherSiblingClass", "ParentClass::SubclassClass", "ParentClass::NoSuchClass"] }
|
14
|
+
subject { described_class.new class_names }
|
15
|
+
|
16
|
+
describe ".class_from_string" do
|
17
|
+
it "returns class constants based on strings" do
|
18
|
+
expect(described_class.class_from_string("Om")).to eq Om
|
19
|
+
expect(described_class.class_from_string("ActiveFedora::RDF::IndexingService")).to eq ActiveFedora::RDF::IndexingService
|
20
|
+
expect(described_class.class_from_string("IndexingService", ActiveFedora::RDF)).to eq ActiveFedora::RDF::IndexingService
|
21
|
+
end
|
22
|
+
|
23
|
+
it "finds sibling classes" do
|
24
|
+
expect(described_class.class_from_string("SiblingClass", ParentClass::OtherSiblingClass)).to eq ParentClass::SiblingClass
|
25
|
+
end
|
26
|
+
|
27
|
+
it "raises a NameError if the class isn't found" do
|
28
|
+
expect {
|
29
|
+
described_class.class_from_string("FooClass", ParentClass::OtherSiblingClass)
|
30
|
+
}.to raise_error NameError, /uninitialized constant (Object::)?FooClass/
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#models' do
|
35
|
+
it 'converts class names to classes' do
|
36
|
+
expect(subject.models).to match_array [ParentClass::SiblingClass, ParentClass::OtherSiblingClass, ParentClass::SubclassClass]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#best_model' do
|
41
|
+
it 'selects the most specific matching model' do
|
42
|
+
expect(subject.best_model(default: nil)).to eq ParentClass::SubclassClass
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'filters models to subclasses of the default' do
|
46
|
+
expect(subject.best_model(default: ActiveFedora::Base)).to eq ActiveFedora::Base
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/unit/model_spec.rb
CHANGED
@@ -27,13 +27,4 @@ describe ActiveFedora::Model do
|
|
27
27
|
it { should eq 'search' }
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
|
-
describe ".from_class_uri" do
|
32
|
-
subject { described_class.from_class_uri(uri) }
|
33
|
-
context "a blank string" do
|
34
|
-
before { expect(ActiveFedora::Base.logger).to receive(:warn) }
|
35
|
-
let(:uri) { '' }
|
36
|
-
it { should be_nil }
|
37
|
-
end
|
38
|
-
end
|
39
30
|
end
|
@@ -216,25 +216,25 @@ EOF
|
|
216
216
|
describe ".to_solr()" do
|
217
217
|
subject { @obj.to_solr({}, name: 'solrRdf') }
|
218
218
|
it "returns the right fields" do
|
219
|
-
expect(subject.keys).to include(ActiveFedora
|
220
|
-
ActiveFedora
|
221
|
-
ActiveFedora
|
222
|
-
ActiveFedora
|
223
|
-
ActiveFedora
|
224
|
-
ActiveFedora
|
225
|
-
ActiveFedora
|
226
|
-
ActiveFedora
|
227
|
-
ActiveFedora
|
228
|
-
ActiveFedora
|
219
|
+
expect(subject.keys).to include(ActiveFedora.index_field_mapper.solr_name("solr_rdf__related_url", type: :string),
|
220
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", type: :string),
|
221
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :sortable),
|
222
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :facetable),
|
223
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__created", :sortable, type: :date),
|
224
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__created", :displayable),
|
225
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__title", type: :string),
|
226
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__title", :sortable),
|
227
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", type: :string),
|
228
|
+
ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", :facetable))
|
229
229
|
end
|
230
230
|
|
231
231
|
it "returns the right values" do
|
232
|
-
expect(subject[ActiveFedora
|
233
|
-
expect(subject[ActiveFedora
|
234
|
-
expect(subject[ActiveFedora
|
235
|
-
expect(subject[ActiveFedora
|
236
|
-
expect(subject[ActiveFedora
|
237
|
-
expect(subject[ActiveFedora
|
232
|
+
expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__related_url", type: :string)]).to eq ["http://example.org/blogtastic/"]
|
233
|
+
expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", type: :string)]).to eq ["Tacoma, WA", "Renton, WA"]
|
234
|
+
expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", :facetable)]).to eq ["Tacoma, WA", "Renton, WA"]
|
235
|
+
expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", type: :string)]).to eq ["Bob's Blogtastic Publishing"]
|
236
|
+
expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :sortable)]).to eq "Bob's Blogtastic Publishing"
|
237
|
+
expect(subject[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :facetable)]).to eq ["Bob's Blogtastic Publishing"]
|
238
238
|
end
|
239
239
|
end
|
240
240
|
end
|
@@ -257,16 +257,16 @@ describe ActiveFedora::OmDatastream do
|
|
257
257
|
end
|
258
258
|
|
259
259
|
describe '.has_solr_name?' do
|
260
|
-
let(:name0_role0) { ActiveFedora
|
261
|
-
let(:name1_role1) { ActiveFedora
|
260
|
+
let(:name0_role0) { ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_0_role_0_roleTerm", type: :string) }
|
261
|
+
let(:name1_role1) { ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_1_role_1_roleTerm", type: :string) }
|
262
262
|
let(:solr_doc) do
|
263
263
|
{ "id" => "mods_article1",
|
264
|
-
ActiveFedora
|
265
|
-
ActiveFedora
|
266
|
-
ActiveFedora
|
264
|
+
ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_role_roleTerm", type: :string) => ["creator", "submitter", "teacher"],
|
265
|
+
ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_0_role", type: :string) => "\r\ncreator\r\nsubmitter\r\n",
|
266
|
+
ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_1_role", type: :string) => "\r\n teacher \r\n",
|
267
267
|
name0_role0 => "creator",
|
268
|
-
ActiveFedora
|
269
|
-
ActiveFedora
|
268
|
+
ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_0_role_1_roleTerm", type: :string) => "submitter",
|
269
|
+
ActiveFedora.index_field_mapper.solr_name("desc_metadata__name_1_role_0_roleTerm", type: :string) => ["teacher"] }
|
270
270
|
end
|
271
271
|
|
272
272
|
it "returns true if the given key exists in the solr document passed in" do
|
@@ -94,7 +94,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
|
|
94
94
|
@test_ds = described_class.new
|
95
95
|
@test_ds.title = "War and Peace"
|
96
96
|
solr = @test_ds.to_solr
|
97
|
-
expect(solr[ActiveFedora
|
97
|
+
expect(solr[ActiveFedora.index_field_mapper.solr_name('title', type: :string)]).to eq "War and Peace"
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -3,20 +3,14 @@ require 'spec_helper'
|
|
3
3
|
describe ActiveFedora::QueryResultBuilder do
|
4
4
|
describe "reify solr results" do
|
5
5
|
before(:all) do
|
6
|
-
class AudioRecord
|
6
|
+
class AudioRecord < ActiveFedora::Base
|
7
7
|
attr_accessor :id
|
8
8
|
def self.connection_for_id(_id)
|
9
9
|
end
|
10
10
|
end
|
11
|
-
@sample_solr_hits = [{ "id" => "my:_ID1_", ActiveFedora
|
12
|
-
{ "id" => "my:_ID2_", ActiveFedora
|
13
|
-
{ "id" => "my:_ID3_", ActiveFedora
|
14
|
-
end
|
15
|
-
describe ".reify_solr_result" do
|
16
|
-
it "uses .find to instantiate objects" do
|
17
|
-
expect(AudioRecord).to receive(:find).with("my:_ID1_", cast: true)
|
18
|
-
described_class.reify_solr_result(@sample_solr_hits.first)
|
19
|
-
end
|
11
|
+
@sample_solr_hits = [{ "id" => "my:_ID1_", ActiveFedora.index_field_mapper.solr_name("has_model", :symbol) => ["AudioRecord"] },
|
12
|
+
{ "id" => "my:_ID2_", ActiveFedora.index_field_mapper.solr_name("has_model", :symbol) => ["AudioRecord"] },
|
13
|
+
{ "id" => "my:_ID3_", ActiveFedora.index_field_mapper.solr_name("has_model", :symbol) => ["AudioRecord"] }]
|
20
14
|
end
|
21
15
|
describe ".reify_solr_results" do
|
22
16
|
it "uses AudioRecord.find to instantiate objects" do
|