active-fedora 9.13.0 → 10.0.0.beta1
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/README.md +0 -19
- data/lib/active_fedora.rb +0 -17
- data/lib/active_fedora/associations.rb +0 -16
- data/lib/active_fedora/associations/builder/association.rb +3 -19
- data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +1 -3
- data/lib/active_fedora/attached_files.rb +2 -108
- data/lib/active_fedora/attributes.rb +4 -100
- data/lib/active_fedora/core.rb +0 -6
- data/lib/active_fedora/datastreams.rb +0 -2
- data/lib/active_fedora/errors.rb +0 -9
- data/lib/active_fedora/file.rb +9 -22
- data/lib/active_fedora/file_configurator.rb +1 -32
- data/lib/active_fedora/identifiable.rb +0 -6
- data/lib/active_fedora/ldp_resource.rb +0 -12
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
- data/lib/active_fedora/query_result_builder.rb +0 -17
- data/lib/active_fedora/rdf/datastream_indexing.rb +0 -11
- data/lib/active_fedora/rdf/indexing_service.rb +1 -1
- data/lib/active_fedora/rdf/rdf_datastream.rb +0 -10
- data/lib/active_fedora/relation/finder_methods.rb +2 -21
- data/lib/active_fedora/solr_query_builder.rb +0 -16
- data/lib/active_fedora/solr_service.rb +2 -89
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/versionable.rb +0 -8
- data/spec/config_helper.rb +0 -4
- data/spec/integration/attached_files_spec.rb +1 -108
- data/spec/integration/attributes_spec.rb +14 -94
- data/spec/integration/direct_container_spec.rb +2 -2
- data/spec/integration/file_spec.rb +23 -13
- data/spec/integration/indexing_spec.rb +4 -4
- data/spec/integration/json_serialization_spec.rb +4 -57
- data/spec/integration/ntriples_datastream_spec.rb +77 -139
- data/spec/integration/relation_delegation_spec.rb +16 -18
- data/spec/integration/{model_spec.rb → scoping_spec.rb} +10 -14
- data/spec/integration/solr_hit_spec.rb +4 -20
- data/spec/integration/solr_instance_loader_spec.rb +1 -13
- data/spec/integration/versionable_spec.rb +0 -9
- data/spec/samples/models/mods_article.rb +1 -6
- data/spec/spec_helper.rb +0 -3
- data/spec/unit/attached_files_spec.rb +29 -127
- data/spec/unit/attributes_spec.rb +51 -475
- data/spec/unit/base_active_model_spec.rb +12 -47
- data/spec/unit/base_extra_spec.rb +1 -1
- data/spec/unit/code_configurator_spec.rb +2 -10
- data/spec/unit/core_spec.rb +3 -18
- data/spec/unit/file_configurator_spec.rb +0 -80
- data/spec/unit/file_spec.rb +0 -6
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +0 -7
- data/spec/unit/inheritance_spec.rb +0 -12
- data/spec/unit/ntriples_datastream_spec.rb +2 -74
- data/spec/unit/property_spec.rb +0 -3
- data/spec/unit/query_spec.rb +0 -7
- data/spec/unit/querying_spec.rb +24 -0
- data/spec/unit/rdf/indexing_service_spec.rb +32 -20
- data/spec/unit/rdf_resource_datastream_spec.rb +37 -97
- data/spec/unit/solr_query_builder_spec.rb +0 -8
- data/spec/unit/solr_service_spec.rb +0 -13
- metadata +6 -19
- data/config/predicate_mappings.yml +0 -51
- data/lib/active_fedora/attributes/om_attribute.rb +0 -26
- data/lib/active_fedora/attributes/rdf_datastream_attribute.rb +0 -44
- data/lib/active_fedora/attributes/stream_attribute.rb +0 -43
- data/lib/active_fedora/datastream.rb +0 -9
- data/lib/active_fedora/model.rb +0 -31
- data/lib/active_fedora/predicates.rb +0 -122
- data/lib/active_fedora/simple_datastream.rb +0 -92
- data/spec/fixtures/rails_root/config/predicate_mappings.yml +0 -31
- data/spec/integration/field_to_solr_name_spec.rb +0 -36
- data/spec/unit/base_datastream_management_spec.rb +0 -19
- data/spec/unit/model_spec.rb +0 -30
- data/spec/unit/predicates_spec.rb +0 -126
- data/spec/unit/simple_datastream_spec.rb +0 -101
@@ -2,61 +2,26 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
4
|
describe "active model methods" do
|
5
|
-
class BarStream < ActiveFedora::OmDatastream
|
6
|
-
set_terminology do |t|
|
7
|
-
t.root(path: "first", xmlns: "urn:foobar")
|
8
|
-
t.duck
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.xml_template
|
12
|
-
Nokogiri::XML::Document.parse '<first xmlns="urn:foobar">
|
13
|
-
<duck></duck>
|
14
|
-
</first>'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class BazStream < ActiveFedora::OmDatastream
|
19
|
-
set_terminology do |t|
|
20
|
-
t.root(path: "first", xmlns: "urn:foobar")
|
21
|
-
t.fubar
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.xml_template
|
25
|
-
Nokogiri::XML::Document.parse '<first xmlns="urn:foobar">
|
26
|
-
<fubar></fubar>
|
27
|
-
</first>'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
5
|
class BarHistory < ActiveFedora::Base
|
32
|
-
|
33
|
-
|
34
|
-
Deprecation.silence(ActiveFedora::Attributes) do
|
35
|
-
has_attributes :fubar, datastream: 'withText', multiple: false
|
36
|
-
has_attributes :duck, datastream: 'xmlish', multiple: false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
before :each do
|
40
|
-
@n = BarHistory.new
|
6
|
+
property :fubar, predicate: ::RDF::URI('http://example.com/fubar'), multiple: false
|
7
|
+
property :duck, predicate: ::RDF::URI('http://example.com/duck'), multiple: false
|
41
8
|
end
|
9
|
+
subject { BarHistory.new }
|
10
|
+
|
42
11
|
describe "attributes=" do
|
43
12
|
it "sets attributes" do
|
44
|
-
|
45
|
-
expect(
|
46
|
-
expect(
|
47
|
-
expect(@n.duck).to eq "Quack"
|
48
|
-
expect(@n.xmlish.term_values(:duck).first).to eq 'Quack'
|
13
|
+
subject.attributes = { fubar: "baz", duck: "Quack" }
|
14
|
+
expect(subject.fubar).to eq "baz"
|
15
|
+
expect(subject.duck).to eq "Quack"
|
49
16
|
end
|
50
17
|
end
|
18
|
+
|
51
19
|
describe "update_attributes" do
|
52
20
|
it "sets attributes and save" do
|
53
|
-
|
54
|
-
|
55
|
-
expect(
|
56
|
-
expect(
|
57
|
-
end
|
58
|
-
after do
|
59
|
-
@n.delete
|
21
|
+
subject.update_attributes(fubar: "baz", duck: "Quack")
|
22
|
+
subject.reload
|
23
|
+
expect(subject.fubar).to eq "baz"
|
24
|
+
expect(subject.duck).to eq "Quack"
|
60
25
|
end
|
61
26
|
end
|
62
27
|
end
|
@@ -4,24 +4,17 @@ require 'config_helper'
|
|
4
4
|
describe ActiveFedora::FileConfigurator do
|
5
5
|
before :all do
|
6
6
|
class TestConfigurator
|
7
|
-
attr_reader :fedora_config, :solr_config
|
7
|
+
attr_reader :fedora_config, :solr_config
|
8
8
|
|
9
9
|
def init(options = {})
|
10
10
|
@fedora_config = options[:fedora_config]
|
11
11
|
@solr_config = options[:solr_config]
|
12
|
-
@predicate_config = options[:predicate_config]
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
15
|
@config_params = {
|
17
16
|
fedora_config: { url: 'http://codeconfig.example.edu/fedora/', user: 'fedoraAdmin', password: 'configurator', cert_file: '/path/to/cert/file' },
|
18
|
-
solr_config: { url: 'http://codeconfig.example.edu/solr/' }
|
19
|
-
predicate_config: {
|
20
|
-
default_namespace: 'info:fedora/fedora-system:def/relations-external#',
|
21
|
-
predicate_mapping: {
|
22
|
-
'info:fedora/fedora-system:def/relations-external#' => { has_part: 'hasPart' }
|
23
|
-
}
|
24
|
-
}
|
17
|
+
solr_config: { url: 'http://codeconfig.example.edu/solr/' }
|
25
18
|
}
|
26
19
|
end
|
27
20
|
|
@@ -44,6 +37,5 @@ describe ActiveFedora::FileConfigurator do
|
|
44
37
|
ActiveFedora.init(@config_params)
|
45
38
|
expect(ActiveFedora.fedora_config.credentials).to eq @config_params[:fedora_config]
|
46
39
|
expect(ActiveFedora.solr_config).to eq @config_params[:solr_config]
|
47
|
-
expect(ActiveFedora::Predicates.predicate_mappings['info:fedora/fedora-system:def/relations-external#'].length).to eq 1
|
48
40
|
end
|
49
41
|
end
|
data/spec/unit/core_spec.rb
CHANGED
@@ -2,19 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
4
|
before do
|
5
|
-
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
6
|
-
property :publisher, predicate: ::RDF::Vocab::DC.publisher
|
7
|
-
end
|
8
5
|
class Library < ActiveFedora::Base
|
9
6
|
end
|
10
7
|
class Book < ActiveFedora::Base
|
11
8
|
belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent
|
12
|
-
|
13
|
-
|
14
|
-
Deprecation.silence(ActiveFedora::Attributes) do
|
15
|
-
has_attributes :title, datastream: 'foo' # Om backed property
|
16
|
-
has_attributes :publisher, datastream: 'bar' # RDF backed property
|
17
|
-
end
|
9
|
+
property :title, predicate: ::RDF::Vocab::DC.title, multiple: false
|
10
|
+
property :publisher, predicate: ::RDF::Vocab::DC.publisher, multiple: false
|
18
11
|
end
|
19
12
|
end
|
20
13
|
|
@@ -24,7 +17,6 @@ describe ActiveFedora::Base do
|
|
24
17
|
after do
|
25
18
|
Object.send(:remove_const, :Book)
|
26
19
|
Object.send(:remove_const, :Library)
|
27
|
-
Object.send(:remove_const, :MyDatastream)
|
28
20
|
end
|
29
21
|
|
30
22
|
it "asserts a content model" do
|
@@ -60,14 +52,7 @@ describe ActiveFedora::Base do
|
|
60
52
|
end
|
61
53
|
end
|
62
54
|
|
63
|
-
it "makes the
|
64
|
-
expect {
|
65
|
-
subject.title = "HEY"
|
66
|
-
}.to raise_error RuntimeError, "can't modify frozen ActiveFedora::QualifiedDublinCoreDatastream"
|
67
|
-
expect(subject.title).to eq "War and Peace"
|
68
|
-
end
|
69
|
-
|
70
|
-
it "makes the RDF properties immutable" do
|
55
|
+
it "makes the properties immutable" do
|
71
56
|
expect {
|
72
57
|
subject.publisher = "HEY"
|
73
58
|
}.to raise_error TypeError
|
@@ -58,15 +58,6 @@ describe ActiveFedora::FileConfigurator do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
describe "#get_config_path" do
|
62
|
-
it "calls #config_path" do
|
63
|
-
expect(subject).to receive(:config_path)
|
64
|
-
Deprecation.silence(described_class) do
|
65
|
-
subject.get_config_path(:fedora)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
61
|
describe "initialization methods" do
|
71
62
|
describe "config_path(:fedora)" do
|
72
63
|
it "uses the config_options[:config_path] if it exists" do
|
@@ -100,38 +91,6 @@ describe ActiveFedora::FileConfigurator do
|
|
100
91
|
end
|
101
92
|
end
|
102
93
|
|
103
|
-
describe "config_path(:predicate_mappings)" do
|
104
|
-
it "uses the config_options[:config_path] if it exists" do
|
105
|
-
expect(subject).to receive(:config_options).and_return(predicate_mappings_config_path: "/path/to/predicate_mappings.yml")
|
106
|
-
expect(File).to receive(:file?).with("/path/to/predicate_mappings.yml").and_return(true)
|
107
|
-
expect(subject.config_path(:predicate_mappings)).to eql("/path/to/predicate_mappings.yml")
|
108
|
-
end
|
109
|
-
|
110
|
-
it "looks in Rails.root/config/predicate_mappings.yml if it exists and no predicate_mappings_config_path passed in" do
|
111
|
-
expect(subject).to receive(:config_options).and_return({})
|
112
|
-
stub_rails(root: "/rails/root")
|
113
|
-
expect(File).to receive(:file?).with("/rails/root/config/predicate_mappings.yml").and_return(true)
|
114
|
-
expect(subject.config_path(:predicate_mappings)).to eql("/rails/root/config/predicate_mappings.yml")
|
115
|
-
unstub_rails
|
116
|
-
end
|
117
|
-
|
118
|
-
it "looks in ./config/predicate_mappings.yml if neither rails.root nor :predicate_mappings_config_path are set" do
|
119
|
-
expect(subject).to receive(:config_options).and_return({})
|
120
|
-
allow(Dir).to receive(:getwd).and_return("/current/working/directory")
|
121
|
-
expect(File).to receive(:file?).with("/current/working/directory/config/predicate_mappings.yml").and_return(true)
|
122
|
-
expect(subject.config_path(:predicate_mappings)).to eql("/current/working/directory/config/predicate_mappings.yml")
|
123
|
-
end
|
124
|
-
|
125
|
-
it "returns default predicate_mappings.yml that ships with active-fedora if none of the above" do
|
126
|
-
expect(subject).to receive(:config_options).and_return({})
|
127
|
-
expect(Dir).to receive(:getwd).and_return("/current/working/directory")
|
128
|
-
expect(File).to receive(:file?).with("/current/working/directory/config/predicate_mappings.yml").and_return(false)
|
129
|
-
expect(File).to receive(:file?).with(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'predicate_mappings.yml'))).and_return(true)
|
130
|
-
expect(ActiveFedora::Base.logger).to receive(:warn).with("Using the default predicate_mappings.yml that comes with active-fedora. If you want to override this, pass the path to predicate_mappings.yml to ActiveFedora - ie. ActiveFedora.init(:predicate_mappings_config_path => '/path/to/predicate_mappings.yml') - or set Rails.root and put predicate_mappings.yml into \#{Rails.root}/config.")
|
131
|
-
expect(subject.config_path(:predicate_mappings)).to eql(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'predicate_mappings.yml')))
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
94
|
describe "config_path(:solr)" do
|
136
95
|
it "returns the solr_config_path if set in config_options hash" do
|
137
96
|
allow(subject).to receive(:config_options).and_return(solr_config_path: "/path/to/solr.yml")
|
@@ -342,43 +301,4 @@ describe ActiveFedora::FileConfigurator do
|
|
342
301
|
end
|
343
302
|
end
|
344
303
|
end
|
345
|
-
|
346
|
-
##########################
|
347
|
-
|
348
|
-
describe ".build_predicate_config_path" do
|
349
|
-
it "returns the path to the default config/predicate_mappings.yml if no valid path is given" do
|
350
|
-
expect(subject.send(:build_predicate_config_path)).to eq default_predicate_mapping_file
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
describe ".predicate_config" do
|
355
|
-
before do
|
356
|
-
subject.instance_variable_set :@config_loaded, nil
|
357
|
-
end
|
358
|
-
it "returns the default mapping if it has not been initialized" do
|
359
|
-
expect(subject.predicate_config).to eq Psych.load(File.read(default_predicate_mapping_file))
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
describe ".valid_predicate_mapping" do
|
364
|
-
it "returns true if the predicate mapping has the appropriate keys and value types" do
|
365
|
-
expect(subject.send(:valid_predicate_mapping?, default_predicate_mapping_file)).to be true
|
366
|
-
end
|
367
|
-
it "returns false if the mapping is missing the :default_namespace" do
|
368
|
-
mock_yaml({ default_namespace0: "my_namespace", predicate_mapping: { key0: "value0", key1: "value1" } }, "/path/to/predicate_mappings.yml")
|
369
|
-
expect(subject.send(:valid_predicate_mapping?, "/path/to/predicate_mappings.yml")).to be false
|
370
|
-
end
|
371
|
-
it "returns false if the :default_namespace is not a string" do
|
372
|
-
mock_yaml({ default_namespace: { foo: "bar" }, predicate_mapping: { key0: "value0", key1: "value1" } }, "/path/to/predicate_mappings.yml")
|
373
|
-
expect(subject.send(:valid_predicate_mapping?, "/path/to/predicate_mappings.yml")).to be false
|
374
|
-
end
|
375
|
-
it "returns false if the :predicate_mappings key is missing" do
|
376
|
-
mock_yaml({ default_namespace: "a string" }, "/path/to/predicate_mappings.yml")
|
377
|
-
expect(subject.send(:valid_predicate_mapping?, "/path/to/predicate_mappings.yml")).to be false
|
378
|
-
end
|
379
|
-
it "returns false if the :predicate_mappings key is not a hash" do
|
380
|
-
mock_yaml({ default_namespace: "a string", predicate_mapping: "another string" }, "/path/to/predicate_mappings.yml")
|
381
|
-
expect(subject.send(:valid_predicate_mapping?, "/path/to/predicate_mappings.yml")).to be false
|
382
|
-
end
|
383
|
-
end
|
384
304
|
end
|
data/spec/unit/file_spec.rb
CHANGED
@@ -32,12 +32,6 @@ describe ActiveFedora::File do
|
|
32
32
|
|
33
33
|
context "when the file is in an ldp:BasicContainer" do
|
34
34
|
let(:parent) { ActiveFedora::Base.new(id: '1234') }
|
35
|
-
before { allow(Deprecation).to receive(:warn) }
|
36
|
-
let(:file) { described_class.new(parent, 'FOO1') }
|
37
|
-
|
38
|
-
it "sets the uri using the parent as the base" do
|
39
|
-
expect(subject).to eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/1234/FOO1"
|
40
|
-
end
|
41
35
|
|
42
36
|
context "and it's initialized with the URI" do
|
43
37
|
let(:file) { described_class.new(parent.uri + "/FOO1") }
|
@@ -49,13 +49,6 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
49
49
|
association.send(:find_target)
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
53
|
-
describe "solr page size option" do
|
54
|
-
it "sends a deprecation warning" do
|
55
|
-
expect(Deprecation).to receive(:warn)
|
56
|
-
Book.has_and_belongs_to_many(:pages, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection, solr_page_size: 123)
|
57
|
-
end
|
58
|
-
end
|
59
52
|
end
|
60
53
|
|
61
54
|
context "with an inverse reflection" do
|
@@ -5,12 +5,10 @@ describe ActiveFedora::Base do
|
|
5
5
|
class MyDS < ActiveFedora::OmDatastream
|
6
6
|
end
|
7
7
|
class Foo < ActiveFedora::Base
|
8
|
-
extend Deprecation
|
9
8
|
has_subresource 'foostream', class_name: 'MyDS'
|
10
9
|
has_subresource 'dcstream', class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
|
11
10
|
end
|
12
11
|
class Bar < ActiveFedora::Base
|
13
|
-
extend Deprecation
|
14
12
|
has_subresource 'barstream', class_name: 'MyDS'
|
15
13
|
end
|
16
14
|
end
|
@@ -23,16 +21,6 @@ describe ActiveFedora::Base do
|
|
23
21
|
expect(streams.pop).to eq "ActiveFedora::QualifiedDublinCoreDatastream"
|
24
22
|
end
|
25
23
|
|
26
|
-
it "works for multiple types" do
|
27
|
-
b = Foo.new
|
28
|
-
f = Bar.new
|
29
|
-
Deprecation.silence(Foo) do
|
30
|
-
Deprecation.silence(Bar) do
|
31
|
-
expect(b.class.ds_specs).to_not eq f.class.ds_specs
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
24
|
after do
|
37
25
|
Object.send(:remove_const, :Bar)
|
38
26
|
Object.send(:remove_const, :Foo)
|
@@ -143,28 +143,7 @@ EOF
|
|
143
143
|
|
144
144
|
describe "solr integration" do
|
145
145
|
before(:all) do
|
146
|
-
|
147
|
-
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
148
|
-
property :created, predicate: ::RDF::Vocab::DC.created do |index|
|
149
|
-
index.as :sortable, :displayable
|
150
|
-
index.type :date
|
151
|
-
end
|
152
|
-
property :title, predicate: ::RDF::Vocab::DC.title do |index|
|
153
|
-
index.as :stored_searchable, :sortable
|
154
|
-
index.type :text
|
155
|
-
end
|
156
|
-
property :publisher, predicate: ::RDF::Vocab::DC.publisher do |index|
|
157
|
-
index.as :facetable, :sortable, :stored_searchable
|
158
|
-
end
|
159
|
-
property :based_near, predicate: ::RDF::FOAF.based_near do |index|
|
160
|
-
index.as :facetable, :stored_searchable
|
161
|
-
index.type :text
|
162
|
-
end
|
163
|
-
property :related_url, predicate: ::RDF::RDFS.seeAlso do |index|
|
164
|
-
index.as :stored_searchable
|
165
|
-
end
|
166
|
-
property :rights, predicate: ::RDF::Vocab::DC.rights
|
167
|
-
end
|
146
|
+
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
168
147
|
end
|
169
148
|
end
|
170
149
|
|
@@ -183,60 +162,9 @@ EOF
|
|
183
162
|
expect(@subject.to_solr).to be_kind_of(Hash)
|
184
163
|
end
|
185
164
|
|
186
|
-
it "
|
187
|
-
expect(MyDatastream.new.primary_solr_name(:based_near, 'descMetadata')).to eq 'desc_metadata__based_near_tesim'
|
188
|
-
expect(MyDatastream.new.primary_solr_name(:title, 'props')).to eq 'props__title_tesim'
|
189
|
-
end
|
190
|
-
|
191
|
-
it "optionallies allow you to provide the Solr::Document to add fields to and return that document when done" do
|
165
|
+
it "optionally allows you to provide the Solr::Document to add fields to and return that document when done" do
|
192
166
|
doc = {}
|
193
167
|
expect(@subject.to_solr(doc)).to eq doc
|
194
168
|
end
|
195
|
-
|
196
|
-
describe "with an actual object" do
|
197
|
-
before(:each) do
|
198
|
-
class Foo < ActiveFedora::Base
|
199
|
-
has_subresource "descMetadata", class_name: 'MyDatastream'
|
200
|
-
Deprecation.silence(ActiveFedora::Attributes) do
|
201
|
-
has_attributes :created, :title, :publisher, :based_near, :related_url, :rights, datastream: :descMetadata, multiple: true
|
202
|
-
end
|
203
|
-
end
|
204
|
-
@obj = MyDatastream.new
|
205
|
-
@obj.created = Date.parse("2012-03-04")
|
206
|
-
@obj.title = "Of Mice and Men, The Sequel"
|
207
|
-
@obj.publisher = "Bob's Blogtastic Publishing"
|
208
|
-
@obj.based_near = ["Tacoma, WA", "Renton, WA"]
|
209
|
-
@obj.related_url = "http://example.org/blogtastic/"
|
210
|
-
@obj.rights = "Totally open, y'all"
|
211
|
-
end
|
212
|
-
after do
|
213
|
-
Object.send(:remove_const, :Foo)
|
214
|
-
end
|
215
|
-
|
216
|
-
describe ".to_solr()" do
|
217
|
-
subject { @obj.to_solr({}, name: 'solrRdf') }
|
218
|
-
it "returns the right fields" do
|
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
|
-
end
|
230
|
-
|
231
|
-
it "returns the right values" do
|
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
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
169
|
end
|
242
170
|
end
|
data/spec/unit/property_spec.rb
CHANGED
data/spec/unit/query_spec.rb
CHANGED
@@ -61,13 +61,6 @@ describe ActiveFedora::Base do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
describe "using an options hash" do
|
65
|
-
it "is deprecated" do
|
66
|
-
expect(Deprecation).to receive(:warn)
|
67
|
-
SpecModel::Basic.find(id: "_ID_")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
64
|
context "with a blank string" do
|
72
65
|
it 'raises ActiveFedora::ObjectNotFoundError' do
|
73
66
|
expect {
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::Querying do
|
4
|
+
before do
|
5
|
+
class SpecModel < ActiveFedora::Base
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
Object.send(:remove_const, :SpecModel)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.solr_query_handler' do
|
14
|
+
subject { SpecModel.solr_query_handler }
|
15
|
+
|
16
|
+
it { is_expected.to eq 'standard' }
|
17
|
+
|
18
|
+
context "when setting to something besides the default" do
|
19
|
+
before { SpecModel.solr_query_handler = 'search' }
|
20
|
+
|
21
|
+
it { is_expected.to eq 'search' }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|