active-fedora 6.7.8 → 6.8.0
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/.rspec +1 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +938 -0
- data/.travis.yml +5 -6
- data/Gemfile +3 -1
- data/Rakefile +7 -5
- data/active-fedora.gemspec +7 -8
- data/lib/active_fedora/om_datastream.rb +1 -0
- data/lib/active_fedora/rdf_xml_writer.rb +31 -62
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +14 -14
- data/spec/integration/associations_spec.rb +232 -232
- data/spec/integration/attributes_spec.rb +11 -12
- data/spec/integration/auditable_spec.rb +10 -10
- data/spec/integration/base_spec.rb +163 -163
- data/spec/integration/bug_spec.rb +7 -7
- data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
- data/spec/integration/datastream_collections_spec.rb +69 -69
- data/spec/integration/datastream_spec.rb +43 -43
- data/spec/integration/datastreams_spec.rb +63 -63
- data/spec/integration/delegating_spec.rb +14 -14
- data/spec/integration/delete_all_spec.rb +38 -42
- data/spec/integration/fedora_solr_sync_spec.rb +5 -5
- data/spec/integration/full_featured_model_spec.rb +101 -101
- data/spec/integration/has_many_associations_spec.rb +24 -24
- data/spec/integration/model_spec.rb +30 -30
- data/spec/integration/nested_attribute_spec.rb +41 -41
- data/spec/integration/ntriples_datastream_spec.rb +107 -107
- data/spec/integration/om_datastream_spec.rb +67 -67
- data/spec/integration/persistence_spec.rb +6 -6
- data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
- data/spec/integration/relation_delegation_spec.rb +24 -26
- data/spec/integration/rels_ext_datastream_spec.rb +20 -20
- data/spec/integration/scoped_query_spec.rb +40 -41
- data/spec/integration/solr_instance_loader_spec.rb +4 -4
- data/spec/integration/solr_service_spec.rb +46 -46
- data/spec/rails3_test_app/config/application.rb +1 -1
- data/spec/rails3_test_app/config/environments/development.rb +0 -1
- data/spec/rails3_test_app/config/environments/production.rb +1 -1
- data/spec/rails3_test_app/spec/spec_helper.rb +3 -3
- data/spec/rails3_test_app/spec/unit/rails_3_init.rb +4 -4
- data/spec/samples/hydra-mods_article_datastream.rb +334 -334
- data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
- data/spec/samples/marpa-dc_datastream.rb +17 -17
- data/spec/samples/models/audio_record.rb +16 -16
- data/spec/samples/models/image.rb +2 -2
- data/spec/samples/models/mods_article.rb +5 -5
- data/spec/samples/models/oral_history.rb +18 -18
- data/spec/samples/models/seminar.rb +24 -24
- data/spec/samples/models/seminar_audio_file.rb +17 -17
- data/spec/samples/oral_history_sample_model.rb +21 -21
- data/spec/samples/special_thing.rb +14 -14
- data/spec/spec_helper.rb +7 -11
- data/spec/support/an_active_model.rb +2 -2
- data/spec/support/mock_fedora.rb +16 -17
- data/spec/unit/active_fedora_spec.rb +58 -58
- data/spec/unit/association_proxy_spec.rb +5 -7
- data/spec/unit/base_active_model_spec.rb +25 -26
- data/spec/unit/base_cma_spec.rb +5 -5
- data/spec/unit/base_datastream_management_spec.rb +27 -27
- data/spec/unit/base_delegate_spec.rb +80 -82
- data/spec/unit/base_delegate_to_spec.rb +37 -39
- data/spec/unit/base_extra_spec.rb +48 -48
- data/spec/unit/base_spec.rb +300 -300
- data/spec/unit/callback_spec.rb +19 -19
- data/spec/unit/code_configurator_spec.rb +17 -17
- data/spec/unit/config_spec.rb +16 -8
- data/spec/unit/content_model_spec.rb +60 -60
- data/spec/unit/datastream_collections_spec.rb +229 -229
- data/spec/unit/datastream_spec.rb +57 -54
- data/spec/unit/datastreams_spec.rb +77 -77
- data/spec/unit/file_configurator_spec.rb +217 -217
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +26 -26
- data/spec/unit/has_many_collection_spec.rb +9 -9
- data/spec/unit/inheritance_spec.rb +12 -13
- data/spec/unit/model_spec.rb +41 -51
- data/spec/unit/nom_datastream_spec.rb +15 -15
- data/spec/unit/ntriples_datastream_spec.rb +112 -112
- data/spec/unit/om_datastream_spec.rb +233 -227
- data/spec/unit/persistence_spec.rb +6 -6
- data/spec/unit/predicates_spec.rb +73 -73
- data/spec/unit/property_spec.rb +9 -17
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
- data/spec/unit/query_spec.rb +188 -217
- data/spec/unit/rdf_datastream_spec.rb +28 -21
- data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
- data/spec/unit/rdf_list_spec.rb +80 -104
- data/spec/unit/rdf_node_spec.rb +7 -7
- data/spec/unit/rdf_xml_writer_spec.rb +10 -10
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
- data/spec/unit/relationship_graph_spec.rb +51 -51
- data/spec/unit/rels_ext_datastream_spec.rb +75 -69
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
- data/spec/unit/rubydora_connection_spec.rb +5 -5
- data/spec/unit/semantic_node_spec.rb +59 -59
- data/spec/unit/serializers_spec.rb +4 -4
- data/spec/unit/service_definitions_spec.rb +26 -26
- data/spec/unit/simple_datastream_spec.rb +17 -17
- data/spec/unit/solr_config_options_spec.rb +27 -28
- data/spec/unit/solr_digital_object_spec.rb +21 -21
- data/spec/unit/solr_service_spec.rb +81 -81
- data/spec/unit/unsaved_digital_object_spec.rb +20 -20
- data/spec/unit/validations_spec.rb +21 -21
- metadata +70 -58
- data/gemfiles/gemfile.rails3 +0 -11
- data/gemfiles/gemfile.rails4 +0 -10
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
4
|
-
it
|
|
5
|
-
subject = double(
|
|
6
|
-
predicate = double(:klass => double.class, :options=>{:property=>'predicate'}, :class_name=> nil)
|
|
7
|
-
ActiveFedora::SolrService.
|
|
4
|
+
it 'should call add_relationship' do
|
|
5
|
+
subject = double('subject', :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a', :ids_for_outbound => [])
|
|
6
|
+
predicate = double(:klass => double.class, :options => {:property => 'predicate'}, :class_name => nil)
|
|
7
|
+
allow(ActiveFedora::SolrService).to receive(:query).and_return([])
|
|
8
8
|
ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
|
|
9
|
-
object = double(
|
|
10
|
-
|
|
11
|
-
subject.
|
|
12
|
-
|
|
9
|
+
object = double('object', :new_record? => false, :pid => 'object:b', :save => nil)
|
|
10
|
+
|
|
11
|
+
expect(subject).to receive(:add_relationship).with('predicate', object)
|
|
12
|
+
|
|
13
13
|
ac << object
|
|
14
14
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
it
|
|
18
|
-
subject = double(
|
|
19
|
-
predicate = double(:klass => double.class, :options=>{:property=>'predicate', :inverse_of => 'inverse_predicate'}, :class_name=> nil)
|
|
20
|
-
ActiveFedora::SolrService.
|
|
17
|
+
it 'should call add_relationship on subject and object when inverse_of given' do
|
|
18
|
+
subject = double('subject', :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a', :ids_for_outbound => [])
|
|
19
|
+
predicate = double(:klass => double.class, :options => {:property => 'predicate', :inverse_of => 'inverse_predicate'}, :class_name => nil)
|
|
20
|
+
allow(ActiveFedora::SolrService).to receive(:query).and_return([])
|
|
21
21
|
ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
|
|
22
|
-
object = double(
|
|
23
|
-
|
|
24
|
-
subject.
|
|
25
|
-
|
|
26
|
-
object.
|
|
27
|
-
|
|
22
|
+
object = double('object', :new_record? => false, :pid => 'object:b', :save => nil)
|
|
23
|
+
|
|
24
|
+
expect(subject).to receive(:add_relationship).with('predicate', object)
|
|
25
|
+
|
|
26
|
+
expect(object).to receive(:add_relationship).with('inverse_predicate', subject)
|
|
27
|
+
|
|
28
28
|
ac << object
|
|
29
29
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
it
|
|
32
|
+
it 'should call solr query multiple times' do
|
|
33
33
|
|
|
34
|
-
subject = double(
|
|
35
|
-
predicate = double(:klass => double.class, :options=>{:property=>'predicate', solr_page_size:10}, :class_name=> nil)
|
|
34
|
+
subject = double('subject', :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a', :ids_for_outbound => [])
|
|
35
|
+
predicate = double(:klass => double.class, :options => {:property => 'predicate', solr_page_size: 10}, :class_name => nil)
|
|
36
36
|
ids = []
|
|
37
37
|
0.upto(15) {|i| ids << i.to_s}
|
|
38
|
-
query1 = ids.slice(0,10).map {|i| "_query_:\"{!raw f=id}#{i}\""}.join(
|
|
39
|
-
query2 = ids.slice(10,10).map {|i| "_query_:\"{!raw f=id}#{i}\""}.join(
|
|
40
|
-
subject.
|
|
41
|
-
ActiveFedora::SolrService.
|
|
42
|
-
ActiveFedora::SolrService.
|
|
38
|
+
query1 = ids.slice(0, 10).map {|i| "_query_:\"{!raw f=id}#{i}\""}.join(' OR ')
|
|
39
|
+
query2 = ids.slice(10, 10).map {|i| "_query_:\"{!raw f=id}#{i}\""}.join(' OR ')
|
|
40
|
+
expect(subject).to receive(:ids_for_outbound).and_return(ids)
|
|
41
|
+
expect(ActiveFedora::SolrService).to receive(:query).with(query1, {:rows => 10}).and_return([])
|
|
42
|
+
expect(ActiveFedora::SolrService).to receive(:query).with(query2, {:rows => 10}).and_return([])
|
|
43
43
|
|
|
44
44
|
ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
|
|
45
45
|
ac.find_target
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::Associations::HasManyAssociation do
|
|
4
|
-
it
|
|
5
|
-
subject = double(
|
|
6
|
-
predicate = double(:klass => double.class, :options=>{:property=>'predicate'}, :class_name=> nil)
|
|
7
|
-
ActiveFedora::SolrService.
|
|
4
|
+
it 'should call add_relationship' do
|
|
5
|
+
subject = double('subject', :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a')
|
|
6
|
+
predicate = double(:klass => double.class, :options => {:property => 'predicate'}, :class_name => nil)
|
|
7
|
+
allow(ActiveFedora::SolrService).to receive(:query).and_return([])
|
|
8
8
|
ac = ActiveFedora::Associations::HasManyAssociation.new(subject, predicate)
|
|
9
|
-
object = double(
|
|
10
|
-
|
|
11
|
-
object.
|
|
12
|
-
|
|
9
|
+
object = double('object', :new_record? => false, :pid => 'object:b', :save => nil)
|
|
10
|
+
|
|
11
|
+
expect(object).to receive(:add_relationship).with('predicate', subject)
|
|
12
|
+
|
|
13
13
|
ac << object
|
|
14
14
|
|
|
15
15
|
end
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
end
|
|
@@ -3,31 +3,31 @@ require 'spec_helper'
|
|
|
3
3
|
describe ActiveFedora::Base do
|
|
4
4
|
before(:each) do
|
|
5
5
|
class Foo < ActiveFedora::Base
|
|
6
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>
|
|
7
|
-
m.field
|
|
6
|
+
has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'foostream' do|m|
|
|
7
|
+
m.field 'foostream', :string
|
|
8
8
|
end
|
|
9
|
-
has_metadata :type=>ActiveFedora::QualifiedDublinCoreDatastream, :name=>
|
|
9
|
+
has_metadata :type => ActiveFedora::QualifiedDublinCoreDatastream, :name => 'dcstream'
|
|
10
10
|
end
|
|
11
|
-
class Bar
|
|
12
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>
|
|
13
|
-
m.field
|
|
11
|
+
class Bar < ActiveFedora::Base
|
|
12
|
+
has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'barstream' do |m|
|
|
13
|
+
m.field 'barfield', :string
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "doesn't overwrite stream specs" do
|
|
19
19
|
f = Foo.new
|
|
20
|
-
f.datastreams.size.
|
|
20
|
+
expect(f.datastreams.size).to eq(3)
|
|
21
21
|
streams = f.datastreams.values.map{|x| x.class.to_s}.sort
|
|
22
|
-
streams.pop.
|
|
23
|
-
streams.pop.
|
|
24
|
-
streams.pop.
|
|
22
|
+
expect(streams.pop).to eq('ActiveFedora::SimpleDatastream')
|
|
23
|
+
expect(streams.pop).to eq('ActiveFedora::RelsExtDatastream')
|
|
24
|
+
expect(streams.pop).to eq('ActiveFedora::QualifiedDublinCoreDatastream')
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
it
|
|
27
|
+
it 'should work for multiple types' do
|
|
28
28
|
b = Foo.new
|
|
29
29
|
f = Bar.new
|
|
30
|
-
b.class.ds_specs.
|
|
30
|
+
expect(b.class.ds_specs).not_to eq(f.class.ds_specs)
|
|
31
31
|
end
|
|
32
32
|
after do
|
|
33
33
|
Object.send(:remove_const, :Bar)
|
|
@@ -35,4 +35,3 @@ describe ActiveFedora::Base do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
end
|
|
38
|
-
|
data/spec/unit/model_spec.rb
CHANGED
|
@@ -1,74 +1,64 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
before(:all) do
|
|
6
|
-
module SpecModel
|
|
7
|
-
class Basic < ActiveFedora::Base
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
@model_query = "has_model_s:#{solr_uri("info:fedora/afmodel:SpecModel_Basic")}"
|
|
3
|
+
module SpecModelM
|
|
4
|
+
class Basic < ActiveFedora::Base
|
|
11
5
|
end
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
class CamelCased
|
|
7
|
+
include ActiveFedora::Model
|
|
8
|
+
def name
|
|
9
|
+
self.class.to_s
|
|
10
|
+
end
|
|
15
11
|
end
|
|
16
|
-
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe ActiveFedora::Model do
|
|
15
|
+
|
|
17
16
|
describe '.solr_query_handler' do
|
|
18
17
|
after do
|
|
19
|
-
# reset to default
|
|
20
|
-
SpecModel::Basic.solr_query_handler = 'standard'
|
|
18
|
+
SpecModelM::Basic.solr_query_handler = 'standard' # reset to default
|
|
21
19
|
end
|
|
22
|
-
it
|
|
23
|
-
|
|
20
|
+
it 'should have a default' do
|
|
21
|
+
expect(SpecModelM::Basic.solr_query_handler).to eq('standard')
|
|
24
22
|
end
|
|
25
|
-
it
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
it 'should be settable' do
|
|
24
|
+
SpecModelM::Basic.solr_query_handler = 'search'
|
|
25
|
+
expect(SpecModelM::Basic.solr_query_handler).to eq('search')
|
|
28
26
|
end
|
|
29
27
|
end
|
|
30
|
-
|
|
31
|
-
describe "URI translation" do
|
|
32
|
-
before :all do
|
|
33
|
-
module SpecModel
|
|
34
|
-
class CamelCased
|
|
35
|
-
include ActiveFedora::Model
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
28
|
|
|
29
|
+
describe 'URI translation' do
|
|
30
|
+
before :each do
|
|
31
|
+
@camel = SpecModelM::CamelCased.new
|
|
39
32
|
end
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
SpecModel.send(:remove_const, :CamelCased)
|
|
33
|
+
it '#to_class_uri' do
|
|
34
|
+
expect(@camel.to_class_uri).to eq 'info:fedora/afmodel:SpecModelM_CamelCased'
|
|
43
35
|
end
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
before do
|
|
50
|
-
subject.stub(:pid_namespace).and_return("test-cModel")
|
|
36
|
+
|
|
37
|
+
context 'with the namespace declared in the model' do
|
|
38
|
+
it '#to_class_uri' do
|
|
39
|
+
expect(@camel).to receive(:pid_namespace).and_return('test-cModel')
|
|
40
|
+
expect(@camel.to_class_uri).to eq 'info:fedora/test-cModel:SpecModelM_CamelCased'
|
|
51
41
|
end
|
|
52
|
-
its(:to_class_uri) {should == 'info:fedora/test-cModel:SpecModel_CamelCased' }
|
|
53
42
|
end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
|
|
44
|
+
context 'with the suffix declared in the model' do
|
|
45
|
+
it '#to_class_uri' do
|
|
46
|
+
expect(@camel).to receive(:pid_suffix).and_return('-TEST-SUFFIX')
|
|
47
|
+
expect(@camel.to_class_uri).to eq 'info:fedora/afmodel:SpecModelM_CamelCased-TEST-SUFFIX'
|
|
57
48
|
end
|
|
58
|
-
its(:to_class_uri) {should == 'info:fedora/afmodel:SpecModel_CamelCased-TEST-SUFFIX' }
|
|
59
49
|
end
|
|
60
|
-
|
|
61
|
-
describe
|
|
62
|
-
it
|
|
63
|
-
ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:
|
|
50
|
+
|
|
51
|
+
describe '.classname_from_uri' do
|
|
52
|
+
it 'should turn an afmodel URI into a Model class name' do
|
|
53
|
+
expect(ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:SpecModelM_CamelCased')).to eq(['SpecModelM::CamelCased', 'afmodel'])
|
|
64
54
|
end
|
|
65
|
-
it
|
|
66
|
-
ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:MyMetadata').
|
|
55
|
+
it 'should not change plurality' do
|
|
56
|
+
expect(ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:MyMetadata')).to eq(['MyMetadata', 'afmodel'])
|
|
67
57
|
end
|
|
68
|
-
it
|
|
69
|
-
ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:image').
|
|
58
|
+
it 'should capitalize the first letter' do
|
|
59
|
+
expect(ActiveFedora::Model.classname_from_uri('info:fedora/afmodel:image')).to eq(['Image', 'afmodel'])
|
|
70
60
|
end
|
|
71
61
|
end
|
|
72
62
|
end
|
|
73
|
-
|
|
63
|
+
|
|
74
64
|
end
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::NomDatastream do
|
|
4
|
-
describe
|
|
4
|
+
describe 'test' do
|
|
5
5
|
subject {
|
|
6
6
|
class MyNomDatastream < ActiveFedora::NomDatastream
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
set_terminology do |t|
|
|
9
9
|
t.a :path => '//a', :accessor => lambda { |x| x.text }, :index => 'a_s'
|
|
10
10
|
t.b :path => '//b', :index => 'b_s'
|
|
11
11
|
end
|
|
12
|
-
end
|
|
12
|
+
end
|
|
13
13
|
|
|
14
14
|
MyNomDatastream.from_xml '<root><a>123</a><b><c>asdf</c></b></root>'
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
it
|
|
18
|
-
subject.a.
|
|
17
|
+
it 'should work' do
|
|
18
|
+
expect(subject.a).to include('123')
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
it
|
|
22
|
-
subject.to_solr['a_s'].
|
|
23
|
-
subject.to_solr['b_s'].
|
|
21
|
+
it 'should to_solr' do
|
|
22
|
+
expect(subject.to_solr['a_s']).to include('123')
|
|
23
|
+
expect(subject.to_solr['b_s']).to include('asdf')
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
it
|
|
27
|
-
subject.controlGroup.
|
|
26
|
+
it 'should be a managed datastream' do
|
|
27
|
+
expect(subject.controlGroup).to eq('M')
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
describe
|
|
31
|
+
describe 'with options for .set_terminology' do
|
|
32
32
|
subject {
|
|
33
33
|
class TerminologyOptions < ActiveFedora::NomDatastream
|
|
34
34
|
set_terminology({
|
|
35
35
|
:namespaces => {
|
|
36
|
-
'dc' =>
|
|
37
|
-
'dcterms' =>
|
|
36
|
+
'dc' => 'http://purl.org/dc/elements/1.1/',
|
|
37
|
+
'dcterms' => 'http://purl.org/dc/terms/'
|
|
38
38
|
}
|
|
39
39
|
}) do |t|
|
|
40
40
|
t.a :path => 'a', :xmlns => 'dc', :accessor => lambda { |x| x.text }
|
|
@@ -53,8 +53,8 @@ describe ActiveFedora::NomDatastream do
|
|
|
53
53
|
)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
it
|
|
57
|
-
subject.a.
|
|
56
|
+
it 'should scope #a attribute to only the dc namespace' do
|
|
57
|
+
expect(subject.a).to eq(['123'])
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::NtriplesRDFDatastream do
|
|
4
|
-
describe
|
|
5
|
-
before do
|
|
4
|
+
describe 'an instance with content' do
|
|
5
|
+
before do
|
|
6
6
|
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
|
7
7
|
map_predicates do |map|
|
|
8
8
|
map.created(:in => RDF::DC)
|
|
@@ -11,84 +11,84 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
|
11
11
|
map.creator(:in => RDF::DC)
|
|
12
12
|
map.educationLevel(:in => RDF::DC)
|
|
13
13
|
map.based_near(:in => RDF::FOAF)
|
|
14
|
-
map.related_url(:to =>
|
|
14
|
+
map.related_url(:to => 'seeAlso', :in => RDF::RDFS)
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
|
-
@subject = MyDatastream.new(double('inner object', :pid=>'test:1', :new_record? =>true), 'descMetadata')
|
|
17
|
+
@subject = MyDatastream.new(double('inner object', :pid => 'test:1', :new_record? => true), 'descMetadata')
|
|
18
18
|
@subject.content = File.new('spec/fixtures/mixed_rdf_descMetadata.nt').read
|
|
19
19
|
end
|
|
20
20
|
after do
|
|
21
21
|
Object.send(:remove_const, :MyDatastream)
|
|
22
22
|
end
|
|
23
|
-
it
|
|
24
|
-
@subject.rdf_subject.
|
|
23
|
+
it 'should have a subject' do
|
|
24
|
+
expect(@subject.rdf_subject).to eq('info:fedora/test:1')
|
|
25
25
|
end
|
|
26
|
-
it
|
|
27
|
-
@subject.controlGroup.
|
|
26
|
+
it 'should have controlGroup' do
|
|
27
|
+
expect(@subject.controlGroup).to eq('M')
|
|
28
28
|
end
|
|
29
|
-
it
|
|
30
|
-
@subject.mimeType.
|
|
29
|
+
it 'should have mimeType' do
|
|
30
|
+
expect(@subject.mimeType).to eq('text/plain')
|
|
31
31
|
end
|
|
32
|
-
it
|
|
33
|
-
@subject.dsid.
|
|
32
|
+
it 'should have dsid' do
|
|
33
|
+
expect(@subject.dsid).to eq('descMetadata')
|
|
34
34
|
end
|
|
35
|
-
it
|
|
36
|
-
@subject.created.
|
|
37
|
-
@subject.title.
|
|
38
|
-
@subject.publisher.
|
|
39
|
-
@subject.based_near.
|
|
40
|
-
@subject.related_url.
|
|
35
|
+
it 'should have fields' do
|
|
36
|
+
expect(@subject.created).to eq(['2010-12-31'])
|
|
37
|
+
expect(@subject.title).to eq(['Title of work'])
|
|
38
|
+
expect(@subject.publisher).to eq(['Penn State'])
|
|
39
|
+
expect(@subject.based_near).to eq(['New York, NY, US'])
|
|
40
|
+
expect(@subject.related_url).to eq(['http://google.com/'])
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
it
|
|
44
|
-
@subject.title.join(', ').
|
|
45
|
-
@subject.title.count.
|
|
46
|
-
@subject.title.size.
|
|
47
|
-
@subject.title[0].
|
|
48
|
-
@subject.title.to_a.
|
|
43
|
+
it 'should be able to call enumerable methods on the fields' do
|
|
44
|
+
expect(@subject.title.join(', ')).to eq('Title of work')
|
|
45
|
+
expect(@subject.title.count).to eq(1)
|
|
46
|
+
expect(@subject.title.size).to eq(1)
|
|
47
|
+
expect(@subject.title[0]).to eq('Title of work')
|
|
48
|
+
expect(@subject.title.to_a).to eq(['Title of work'])
|
|
49
49
|
val = []
|
|
50
50
|
@subject.title.each_with_index {|v, i| val << "#{i}. #{v}"}
|
|
51
|
-
val.
|
|
51
|
+
expect(val).to eq(['0. Title of work'])
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
it
|
|
55
|
-
@subject.created.
|
|
54
|
+
it 'should return fields that are not TermProxies' do
|
|
55
|
+
expect(@subject.created).to be_kind_of Array
|
|
56
56
|
end
|
|
57
|
-
it
|
|
58
|
-
|
|
57
|
+
it 'should have method missing' do
|
|
58
|
+
expect{@subject.frank}.to raise_exception NoMethodError
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
it
|
|
61
|
+
it 'should set fields' do
|
|
62
62
|
@subject.publisher = "St. Martin's Press"
|
|
63
|
-
@subject.publisher.
|
|
63
|
+
expect(@subject.publisher).to eq(["St. Martin's Press"])
|
|
64
64
|
end
|
|
65
|
-
it
|
|
66
|
-
@subject.creator = RDF.Literal(
|
|
67
|
-
@subject.creator.
|
|
65
|
+
it 'should set rdf literal fields' do
|
|
66
|
+
@subject.creator = RDF.Literal('Geoff Ryman')
|
|
67
|
+
expect(@subject.creator).to eq(['Geoff Ryman'])
|
|
68
68
|
end
|
|
69
|
-
it
|
|
69
|
+
it 'should append fields' do
|
|
70
70
|
@subject.publisher << "St. Martin's Press"
|
|
71
|
-
@subject.publisher.
|
|
71
|
+
expect(@subject.publisher).to eq(['Penn State', "St. Martin's Press"])
|
|
72
72
|
end
|
|
73
|
-
it
|
|
74
|
-
@subject.related_url.delete(RDF::URI(
|
|
75
|
-
@subject.related_url.
|
|
73
|
+
it 'should delete fields' do
|
|
74
|
+
@subject.related_url.delete(RDF::URI('http://google.com/'))
|
|
75
|
+
expect(@subject.related_url).to eq([])
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
describe
|
|
79
|
+
describe 'some dummy instances' do
|
|
80
80
|
before do
|
|
81
81
|
@one = ActiveFedora::RDFDatastream.new('fakepid', 'myFoobar')
|
|
82
82
|
@two = ActiveFedora::RDFDatastream.new('fakepid', 'myQuix')
|
|
83
83
|
end
|
|
84
|
-
it
|
|
85
|
-
@one .prefix(
|
|
86
|
-
@two.prefix(
|
|
84
|
+
it 'should generate predictable prexies' do
|
|
85
|
+
expect(@one .prefix('baz')).to eq(:my_foobar__baz)
|
|
86
|
+
expect(@two.prefix('baz')).to eq(:my_quix__baz)
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
describe
|
|
91
|
-
before do
|
|
90
|
+
describe 'an instance with a custom subject' do
|
|
91
|
+
before do
|
|
92
92
|
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
|
93
93
|
rdf_subject { |ds| "info:fedora/#{ds.pid}/content" }
|
|
94
94
|
map_predicates do |map|
|
|
@@ -96,7 +96,7 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
|
96
96
|
map.title(:in => RDF::DC)
|
|
97
97
|
map.publisher(:in => RDF::DC)
|
|
98
98
|
map.based_near(:in => RDF::FOAF)
|
|
99
|
-
map.related_url(:to =>
|
|
99
|
+
map.related_url(:to => 'seeAlso', :in => RDF::RDFS)
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
@subject = MyDatastream.new(@inner_object, 'mixed_rdf')
|
|
@@ -109,16 +109,16 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
|
109
109
|
Object.send(:remove_const, :MyDatastream)
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
-
it
|
|
113
|
-
@subject.title.
|
|
112
|
+
it 'should have fields' do
|
|
113
|
+
expect(@subject.title).to eq(['Title of datastream'])
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
-
it
|
|
117
|
-
@subject.rdf_subject.
|
|
116
|
+
it 'should have a custom subject' do
|
|
117
|
+
expect(@subject.rdf_subject).to eq('info:fedora/test:1/content')
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
-
describe
|
|
121
|
+
describe 'a new instance' do
|
|
122
122
|
before(:each) do
|
|
123
123
|
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
|
124
124
|
map_predicates do |map|
|
|
@@ -131,35 +131,35 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
|
131
131
|
after(:each) do
|
|
132
132
|
Object.send(:remove_const, :MyDatastream)
|
|
133
133
|
end
|
|
134
|
-
it
|
|
135
|
-
@subject.publisher.to_s.
|
|
136
|
-
@subject.publisher =
|
|
137
|
-
@subject.publisher.to_s.
|
|
138
|
-
@subject.publisher <<
|
|
139
|
-
@subject.publisher.to_s.
|
|
134
|
+
it 'should support to_s method' do
|
|
135
|
+
expect(@subject.publisher.to_s).to eq([].to_s)
|
|
136
|
+
@subject.publisher = 'Bob'
|
|
137
|
+
expect(@subject.publisher.to_s).to eq(['Bob'].to_s)
|
|
138
|
+
@subject.publisher << 'Jim'
|
|
139
|
+
expect(@subject.publisher.to_s).to eq(['Bob', 'Jim'].to_s)
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
142
|
|
|
143
|
-
describe
|
|
143
|
+
describe 'solr integration' do
|
|
144
144
|
before(:all) do
|
|
145
145
|
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
|
146
146
|
map_predicates do |map|
|
|
147
|
-
map.created(:in => RDF::DC) do |index|
|
|
147
|
+
map.created(:in => RDF::DC) do |index|
|
|
148
148
|
index.as :sortable, :displayable
|
|
149
149
|
index.type :date
|
|
150
150
|
end
|
|
151
151
|
map.title(:in => RDF::DC) do |index|
|
|
152
152
|
index.as :stored_searchable, :sortable
|
|
153
|
-
index.type :text
|
|
153
|
+
index.type :text
|
|
154
154
|
end
|
|
155
|
-
map.publisher(:in => RDF::DC) do |index|
|
|
155
|
+
map.publisher(:in => RDF::DC) do |index|
|
|
156
156
|
index.as :facetable, :sortable, :stored_searchable
|
|
157
157
|
end
|
|
158
158
|
map.based_near(:in => RDF::FOAF) do |index|
|
|
159
|
-
index.as :facetable, :stored_searchable
|
|
159
|
+
index.as :facetable, :stored_searchable
|
|
160
160
|
index.type :text
|
|
161
161
|
end
|
|
162
|
-
map.related_url(:to =>
|
|
162
|
+
map.related_url(:to => 'seeAlso', :in => RDF::RDFS) do |index|
|
|
163
163
|
index.as :stored_searchable
|
|
164
164
|
end
|
|
165
165
|
map.rights(:in => RDF::DC)
|
|
@@ -171,35 +171,35 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
|
171
171
|
after(:all) do
|
|
172
172
|
Object.send(:remove_const, :MyDatastream)
|
|
173
173
|
end
|
|
174
|
-
before(:each) do
|
|
174
|
+
before(:each) do
|
|
175
175
|
@subject.stub(:pid => 'test:1')
|
|
176
176
|
end
|
|
177
|
-
it
|
|
178
|
-
@subject.
|
|
179
|
-
@subject.to_solr.
|
|
177
|
+
it 'should provide .to_solr and return a SolrDocument' do
|
|
178
|
+
expect(@subject).to respond_to(:to_solr)
|
|
179
|
+
expect(@subject.to_solr).to be_kind_of(Hash)
|
|
180
180
|
end
|
|
181
|
-
it
|
|
182
|
-
doc =
|
|
183
|
-
@subject.to_solr(doc).
|
|
181
|
+
it 'should optionally allow you to provide the Solr::Document to add fields to and return that document when done' do
|
|
182
|
+
doc = {}
|
|
183
|
+
expect(@subject.to_solr(doc)).to eq(doc)
|
|
184
184
|
end
|
|
185
|
-
it
|
|
185
|
+
it 'should iterate through @fields hash' do
|
|
186
186
|
solr_doc = @subject.to_solr
|
|
187
|
-
solr_doc[ActiveFedora::SolrService.solr_name(
|
|
188
|
-
solr_doc[ActiveFedora::SolrService.solr_name(
|
|
189
|
-
solr_doc[ActiveFedora::SolrService.solr_name(
|
|
190
|
-
solr_doc[ActiveFedora::SolrService.solr_name(
|
|
191
|
-
solr_doc[ActiveFedora::SolrService.solr_name(
|
|
192
|
-
solr_doc[ActiveFedora::SolrService.solr_name(
|
|
193
|
-
solr_doc[ActiveFedora::SolrService.solr_name(
|
|
194
|
-
solr_doc[ActiveFedora::SolrService.solr_name(
|
|
195
|
-
solr_doc[ActiveFedora::SolrService.solr_name(
|
|
196
|
-
solr_doc[ActiveFedora::SolrService.solr_name(
|
|
187
|
+
expect(solr_doc[ActiveFedora::SolrService.solr_name('solr_rdf__publisher', type: :string)]).to eq(['publisher1'])
|
|
188
|
+
expect(solr_doc[ActiveFedora::SolrService.solr_name('solr_rdf__publisher', :sortable)]).to eq('publisher1')
|
|
189
|
+
expect(solr_doc[ActiveFedora::SolrService.solr_name('solr_rdf__publisher', :facetable)]).to eq(['publisher1'])
|
|
190
|
+
expect(solr_doc[ActiveFedora::SolrService.solr_name('solr_rdf__based_near', type: :string)]).to eq(['coverage1', 'coverage2'])
|
|
191
|
+
expect(solr_doc[ActiveFedora::SolrService.solr_name('solr_rdf__based_near', :facetable)]).to eq(['coverage1', 'coverage2'])
|
|
192
|
+
expect(solr_doc[ActiveFedora::SolrService.solr_name('solr_rdf__created', :sortable, type: :date)]).to eq('2009-10-10T00:00:00Z')
|
|
193
|
+
expect(solr_doc[ActiveFedora::SolrService.solr_name('solr_rdf__created', :displayable)]).to eq(['2009-10-10'])
|
|
194
|
+
expect(solr_doc[ActiveFedora::SolrService.solr_name('solr_rdf__title', type: :string)]).to eq(['fake-title'])
|
|
195
|
+
expect(solr_doc[ActiveFedora::SolrService.solr_name('solr_rdf__title', :sortable)]).to eq('fake-title')
|
|
196
|
+
expect(solr_doc[ActiveFedora::SolrService.solr_name('solr_rdf__related_url', type: :string)]).to eq(['http://example.org/'])
|
|
197
197
|
end
|
|
198
198
|
|
|
199
|
-
describe
|
|
199
|
+
describe 'with an actual object' do
|
|
200
200
|
before(:each) do
|
|
201
201
|
class Foo < ActiveFedora::Base
|
|
202
|
-
has_metadata :name =>
|
|
202
|
+
has_metadata :name => 'descMetadata', :type => MyDatastream
|
|
203
203
|
delegate :created, :to => :descMetadata, multiple: true
|
|
204
204
|
delegate :title, :to => :descMetadata, multiple: true
|
|
205
205
|
delegate :publisher, :to => :descMetadata, multiple: true
|
|
@@ -210,49 +210,49 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
|
210
210
|
@obj = MyDatastream.new(@inner_object, 'solr_rdf')
|
|
211
211
|
repository = double()
|
|
212
212
|
@obj.stub(:repository => repository, :pid => 'test:1')
|
|
213
|
-
repository.
|
|
214
|
-
repository.
|
|
215
|
-
@obj.created =
|
|
216
|
-
@obj.title =
|
|
213
|
+
allow(repository).to receive(:modify_datastream)
|
|
214
|
+
allow(repository).to receive(:add_datastream)
|
|
215
|
+
@obj.created = '2012-03-04'
|
|
216
|
+
@obj.title = 'Of Mice and Men, The Sequel'
|
|
217
217
|
@obj.publisher = "Bob's Blogtastic Publishing"
|
|
218
|
-
@obj.based_near = [
|
|
219
|
-
@obj.related_url =
|
|
218
|
+
@obj.based_near = ['Tacoma, WA', 'Renton, WA']
|
|
219
|
+
@obj.related_url = 'http://example.org/blogtastic/'
|
|
220
220
|
@obj.rights = "Totally open, y'all"
|
|
221
221
|
@obj.save
|
|
222
222
|
end
|
|
223
223
|
|
|
224
|
-
describe
|
|
225
|
-
it
|
|
226
|
-
@obj.send(:fields).keys.
|
|
224
|
+
describe '.fields()' do
|
|
225
|
+
it 'should return the right fields' do
|
|
226
|
+
expect(@obj.send(:fields).keys).to eq(['created', 'title', 'publisher', 'based_near', 'related_url'])
|
|
227
227
|
end
|
|
228
|
-
it
|
|
228
|
+
it 'should return the right values' do
|
|
229
229
|
fields = @obj.send(:fields)
|
|
230
|
-
fields[:related_url][:values].
|
|
231
|
-
fields[:based_near][:values].
|
|
230
|
+
expect(fields[:related_url][:values]).to eq(['http://example.org/blogtastic/'])
|
|
231
|
+
expect(fields[:based_near][:values]).to eq(['Tacoma, WA', 'Renton, WA'])
|
|
232
232
|
end
|
|
233
|
-
it
|
|
233
|
+
it 'should return the right type information' do
|
|
234
234
|
fields = @obj.send(:fields)
|
|
235
|
-
fields[:created][:type].
|
|
235
|
+
expect(fields[:created][:type]).to eq(:date)
|
|
236
236
|
end
|
|
237
237
|
end
|
|
238
|
-
describe
|
|
239
|
-
it
|
|
240
|
-
@obj.to_solr.keys.
|
|
241
|
-
ActiveFedora::SolrService.solr_name(
|
|
242
|
-
ActiveFedora::SolrService.solr_name(
|
|
243
|
-
ActiveFedora::SolrService.solr_name(
|
|
244
|
-
ActiveFedora::SolrService.solr_name(
|
|
245
|
-
ActiveFedora::SolrService.solr_name(
|
|
246
|
-
ActiveFedora::SolrService.solr_name(
|
|
247
|
-
ActiveFedora::SolrService.solr_name(
|
|
248
|
-
ActiveFedora::SolrService.solr_name(
|
|
249
|
-
ActiveFedora::SolrService.solr_name(
|
|
238
|
+
describe '.to_solr()' do
|
|
239
|
+
it 'should return the right fields' do
|
|
240
|
+
expect(@obj.to_solr.keys).to include(ActiveFedora::SolrService.solr_name('solr_rdf__related_url', type: :string),
|
|
241
|
+
ActiveFedora::SolrService.solr_name('solr_rdf__publisher', type: :string),
|
|
242
|
+
ActiveFedora::SolrService.solr_name('solr_rdf__publisher', :sortable),
|
|
243
|
+
ActiveFedora::SolrService.solr_name('solr_rdf__publisher', :facetable),
|
|
244
|
+
ActiveFedora::SolrService.solr_name('solr_rdf__created', :sortable, type: :date),
|
|
245
|
+
ActiveFedora::SolrService.solr_name('solr_rdf__created', :displayable),
|
|
246
|
+
ActiveFedora::SolrService.solr_name('solr_rdf__title', type: :string),
|
|
247
|
+
ActiveFedora::SolrService.solr_name('solr_rdf__title', :sortable),
|
|
248
|
+
ActiveFedora::SolrService.solr_name('solr_rdf__based_near', type: :string),
|
|
249
|
+
ActiveFedora::SolrService.solr_name('solr_rdf__based_near', :facetable))
|
|
250
250
|
|
|
251
251
|
end
|
|
252
252
|
|
|
253
|
-
it
|
|
254
|
-
@obj.to_solr[ActiveFedora::SolrService.solr_name(
|
|
255
|
-
@obj.to_solr[ActiveFedora::SolrService.solr_name(
|
|
253
|
+
it 'should return the right values' do
|
|
254
|
+
expect(@obj.to_solr[ActiveFedora::SolrService.solr_name('solr_rdf__related_url', type: :string)]).to eq(['http://example.org/blogtastic/'])
|
|
255
|
+
expect(@obj.to_solr[ActiveFedora::SolrService.solr_name('solr_rdf__based_near', type: :string)]).to eq(['Tacoma, WA', 'Renton, WA'])
|
|
256
256
|
end
|
|
257
257
|
end
|
|
258
258
|
end
|