active-fedora 8.7.0 → 9.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +8 -15
- data/Gemfile +5 -5
- data/History.txt +0 -80
- data/README.md +1 -0
- data/Rakefile +0 -3
- data/active-fedora.gemspec +8 -7
- data/config/fedora.yml +5 -4
- data/config/predicate_mappings.yml +5 -5
- data/gemfiles/rails4.1.gemfile +10 -0
- data/gemfiles/rails4.2.beta.gemfile +10 -0
- data/lib/active_fedora.rb +151 -117
- data/lib/active_fedora/associations.rb +47 -15
- data/lib/active_fedora/associations/association.rb +29 -8
- data/lib/active_fedora/associations/association_scope.rb +5 -5
- data/lib/active_fedora/associations/belongs_to_association.rb +20 -63
- data/lib/active_fedora/associations/builder/association.rb +61 -25
- data/lib/active_fedora/associations/builder/belongs_to.rb +7 -94
- data/lib/active_fedora/associations/builder/collection_association.rb +11 -43
- data/lib/active_fedora/associations/builder/contains.rb +28 -0
- data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +13 -3
- data/lib/active_fedora/associations/builder/has_many.rb +16 -10
- data/lib/active_fedora/associations/builder/property.rb +14 -0
- data/lib/active_fedora/associations/builder/singular_association.rb +14 -18
- data/lib/active_fedora/associations/builder/singular_property.rb +12 -0
- data/lib/active_fedora/associations/collection_association.rb +57 -80
- data/lib/active_fedora/associations/contains_association.rb +50 -0
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +44 -24
- data/lib/active_fedora/associations/has_many_association.rb +46 -14
- data/lib/active_fedora/associations/rdf.rb +86 -0
- data/lib/active_fedora/associations/singular_association.rb +4 -8
- data/lib/active_fedora/associations/singular_rdf.rb +15 -0
- data/lib/active_fedora/attached_files.rb +195 -0
- data/lib/active_fedora/attribute_methods.rb +122 -0
- data/lib/active_fedora/attribute_methods/dirty.rb +16 -0
- data/lib/active_fedora/attribute_methods/read.rb +61 -0
- data/lib/active_fedora/attribute_methods/write.rb +47 -0
- data/lib/active_fedora/attributes.rb +93 -44
- data/lib/active_fedora/attributes/primary_key.rb +12 -0
- data/lib/active_fedora/autosave_association.rb +2 -2
- data/lib/active_fedora/base.rb +16 -15
- data/lib/active_fedora/callbacks.rb +7 -7
- data/lib/active_fedora/change_set.rb +34 -0
- data/lib/active_fedora/cleaner.rb +62 -0
- data/lib/active_fedora/config.rb +4 -22
- data/lib/active_fedora/core.rb +173 -99
- data/lib/active_fedora/datastream.rb +4 -117
- data/lib/active_fedora/datastreams.rb +2 -263
- data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +28 -51
- data/lib/active_fedora/{datastream_attribute.rb → delegated_attribute.rb} +57 -26
- data/lib/active_fedora/errors.rb +61 -0
- data/lib/active_fedora/fedora.rb +19 -0
- data/lib/active_fedora/fedora_attributes.rb +58 -26
- data/lib/active_fedora/file.rb +318 -0
- data/lib/active_fedora/file_configurator.rb +32 -32
- data/lib/active_fedora/file_path_builder.rb +24 -0
- data/lib/active_fedora/files_hash.rb +82 -0
- data/lib/active_fedora/fixity_service.rb +40 -0
- data/lib/active_fedora/indexing.rb +55 -82
- data/lib/active_fedora/indexing_service.rb +70 -0
- data/lib/active_fedora/ldp_resource.rb +26 -0
- data/lib/active_fedora/loadable_from_json.rb +112 -0
- data/lib/active_fedora/model.rb +5 -19
- data/lib/active_fedora/nested_attributes.rb +5 -6
- data/lib/active_fedora/nom_datastream.rb +15 -25
- data/lib/active_fedora/om_datastream.rb +26 -197
- data/lib/active_fedora/persistence.rb +95 -71
- data/lib/active_fedora/predicates.rb +4 -4
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +17 -18
- data/lib/active_fedora/querying.rb +3 -4
- data/lib/active_fedora/railtie.rb +3 -6
- data/lib/active_fedora/rdf.rb +3 -1
- data/lib/active_fedora/rdf/datastream_indexing.rb +11 -0
- data/lib/active_fedora/rdf/fcrepo.rb +10 -324
- data/lib/active_fedora/rdf/indexing.rb +20 -16
- data/lib/active_fedora/rdf/ldp.rb +6 -0
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +1 -1
- data/lib/active_fedora/rdf/persistence.rb +5 -6
- data/lib/active_fedora/rdf/rdf_datastream.rb +44 -37
- data/lib/active_fedora/rdf/rdfxml_datastream.rb +13 -0
- data/lib/active_fedora/rdf/rels_ext.rb +26 -0
- data/lib/active_fedora/reflection.rb +256 -199
- data/lib/active_fedora/relation.rb +18 -6
- data/lib/active_fedora/relation/finder_methods.rb +69 -38
- data/lib/active_fedora/relation/query_methods.rb +7 -3
- data/lib/active_fedora/rspec_matchers/belong_to_associated_active_fedora_object_matcher.rb +7 -7
- data/lib/active_fedora/rspec_matchers/have_many_associated_active_fedora_objects_matcher.rb +8 -8
- data/lib/active_fedora/rspec_matchers/have_predicate_matcher.rb +9 -11
- data/lib/active_fedora/simple_datastream.rb +18 -13
- data/lib/active_fedora/solr_instance_loader.rb +18 -38
- data/lib/active_fedora/solr_service.rb +37 -20
- data/lib/active_fedora/sparql_insert.rb +45 -0
- data/lib/active_fedora/test_support.rb +1 -22
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/versionable.rb +90 -0
- data/lib/active_fedora/with_metadata.rb +37 -0
- data/lib/active_fedora/with_metadata/metadata_node.rb +70 -0
- data/lib/generators/active_fedora/config/config_generator.rb +0 -1
- data/lib/generators/active_fedora/config/solr/solr_generator.rb +1 -1
- data/lib/generators/active_fedora/model/model_generator.rb +5 -5
- data/lib/generators/active_fedora/model/templates/datastream_spec.rb.erb +1 -1
- data/lib/generators/active_fedora/model/templates/model_spec.rb.erb +2 -2
- data/lib/tasks/active_fedora_dev.rake +21 -27
- data/spec/config_helper.rb +1 -1
- data/spec/fixtures/mixed_rdf_descMetadata.nt +6 -6
- data/spec/fixtures/rails_root/config/predicate_mappings.yml +3 -19
- data/spec/fixtures/solr_rdf_descMetadata.nt +6 -6
- data/spec/integration/associations_spec.rb +133 -153
- data/spec/integration/attached_files_spec.rb +164 -0
- data/spec/integration/attributes_spec.rb +73 -12
- data/spec/integration/autosave_association_spec.rb +3 -3
- data/spec/integration/base_spec.rb +57 -351
- data/spec/integration/belongs_to_association_spec.rb +86 -76
- data/spec/integration/bug_spec.rb +3 -3
- data/spec/integration/collection_association_spec.rb +4 -4
- data/spec/integration/complex_rdf_datastream_spec.rb +54 -56
- data/spec/integration/delete_all_spec.rb +18 -15
- data/spec/integration/eradicate_spec.rb +54 -0
- data/spec/integration/fedora_solr_sync_spec.rb +7 -5
- data/spec/integration/field_to_solr_name_spec.rb +5 -5
- data/spec/integration/file_fixity_spec.rb +40 -0
- data/spec/integration/file_spec.rb +122 -0
- data/spec/integration/full_featured_model_spec.rb +53 -63
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +141 -114
- data/spec/integration/has_many_associations_spec.rb +142 -64
- data/spec/integration/json_serialization_spec.rb +50 -8
- data/spec/integration/model_spec.rb +12 -29
- data/spec/integration/nested_attribute_spec.rb +28 -20
- data/spec/integration/ntriples_datastream_spec.rb +60 -57
- data/spec/integration/om_datastream_spec.rb +51 -140
- data/spec/integration/rdf_nested_attributes_spec.rb +16 -14
- data/spec/integration/relation_delegation_spec.rb +7 -9
- data/spec/integration/relation_spec.rb +9 -7
- data/spec/integration/scoped_query_spec.rb +26 -26
- data/spec/integration/solr_instance_loader_spec.rb +69 -53
- data/spec/integration/solr_service_spec.rb +12 -73
- data/spec/integration/versionable_spec.rb +477 -0
- data/spec/integration/with_metadata_spec.rb +52 -0
- data/spec/samples/hydra-mods_article_datastream.rb +10 -6
- data/spec/samples/models/mods_article.rb +6 -2
- data/spec/samples/oral_history_sample.xml +1 -1
- data/spec/samples/oral_history_xml.xml +1 -1
- data/spec/samples/special_thing.rb +3 -3
- data/spec/spec_helper.rb +22 -12
- data/spec/support/an_active_model.rb +3 -7
- data/spec/unit/active_fedora_spec.rb +20 -17
- data/spec/unit/attached_files_spec.rb +203 -0
- data/spec/unit/attributes_spec.rb +286 -207
- data/spec/unit/base_active_model_spec.rb +8 -8
- data/spec/unit/base_datastream_management_spec.rb +11 -24
- data/spec/unit/base_extra_spec.rb +17 -67
- data/spec/unit/base_spec.rb +163 -428
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +2 -2
- data/spec/unit/callback_spec.rb +38 -23
- data/spec/unit/change_set_spec.rb +46 -0
- data/spec/unit/code_configurator_spec.rb +5 -5
- data/spec/unit/config_spec.rb +9 -14
- data/spec/unit/core_spec.rb +59 -8
- data/spec/unit/file_configurator_spec.rb +55 -53
- data/spec/unit/file_path_builder_spec.rb +18 -0
- data/spec/unit/file_spec.rb +221 -0
- data/spec/unit/files_hash_spec.rb +53 -0
- data/spec/unit/fixity_service_spec.rb +34 -0
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +134 -0
- data/spec/unit/has_many_association_spec.rb +51 -0
- data/spec/unit/indexing_service_spec.rb +23 -0
- data/spec/unit/indexing_spec.rb +26 -0
- data/spec/unit/inheritance_spec.rb +9 -10
- data/spec/unit/model_spec.rb +15 -33
- data/spec/unit/nom_datastream_spec.rb +13 -10
- data/spec/unit/ntriples_datastream_spec.rb +81 -96
- data/spec/unit/om_datastream_spec.rb +137 -227
- data/spec/unit/persistence_spec.rb +28 -34
- data/spec/unit/predicates_spec.rb +29 -29
- data/spec/unit/property_spec.rb +1 -3
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +27 -32
- data/spec/unit/query_spec.rb +116 -149
- data/spec/unit/rdf_datastream_spec.rb +25 -43
- data/spec/unit/rdf_resource_datastream_spec.rb +24 -123
- data/spec/unit/{rdfxml_rdf_datastream_spec.rb → rdfxml_datastream_spec.rb} +21 -25
- data/spec/unit/readonly_spec.rb +23 -0
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +6 -6
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +6 -6
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +6 -6
- data/spec/unit/serializers_spec.rb +1 -1
- data/spec/unit/simple_datastream_spec.rb +12 -23
- data/spec/unit/solr_config_options_spec.rb +14 -17
- data/spec/unit/solr_service_spec.rb +38 -77
- data/spec/unit/sparql_insert_spec.rb +32 -0
- data/spec/unit/validations_spec.rb +8 -11
- metadata +96 -121
- data/lib/active_fedora/auditable.rb +0 -9
- data/lib/active_fedora/content_model.rb +0 -70
- data/lib/active_fedora/datastream_collections.rb +0 -302
- data/lib/active_fedora/datastream_hash.rb +0 -35
- data/lib/active_fedora/digital_object.rb +0 -55
- data/lib/active_fedora/fixture_exporter.rb +0 -33
- data/lib/active_fedora/fixture_loader.rb +0 -48
- data/lib/active_fedora/rdf/identifiable.rb +0 -66
- data/lib/active_fedora/rdf/project_hydra.rb +0 -12
- data/lib/active_fedora/rdf/rdfxml_rdf_datastream.rb +0 -13
- data/lib/active_fedora/rdf_xml_writer.rb +0 -49
- data/lib/active_fedora/relationship_graph.rb +0 -101
- data/lib/active_fedora/reload_on_save.rb +0 -16
- data/lib/active_fedora/rels_ext_datastream.rb +0 -100
- data/lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb +0 -41
- data/lib/active_fedora/rubydora_connection.rb +0 -35
- data/lib/active_fedora/semantic_node.rb +0 -164
- data/lib/active_fedora/service_definitions.rb +0 -88
- data/lib/active_fedora/sharding.rb +0 -58
- data/lib/active_fedora/solr_digital_object.rb +0 -68
- data/lib/active_fedora/unsaved_digital_object.rb +0 -58
- data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +0 -12
- data/lib/generators/active_fedora/config/fedora/templates/fedora.yml +0 -38
- data/lib/generators/active_fedora/config/fedora/templates/fedora_conf/conf/development/fedora.fcfg +0 -953
- data/lib/generators/active_fedora/config/fedora/templates/fedora_conf/conf/test/fedora.fcfg +0 -953
- data/lib/tasks/active_fedora.rake +0 -83
- data/spec/fixtures/sharded_fedora.yml +0 -11
- data/spec/integration/auditable_spec.rb +0 -29
- data/spec/integration/datastream_collections_spec.rb +0 -127
- data/spec/integration/datastream_spec.rb +0 -90
- data/spec/integration/datastreams_spec.rb +0 -173
- data/spec/integration/load_from_solr_spec.rb +0 -66
- data/spec/integration/rels_ext_datastream_spec.rb +0 -82
- data/spec/support/mock_fedora.rb +0 -44
- data/spec/unit/content_model_spec.rb +0 -86
- data/spec/unit/datastream_collections_spec.rb +0 -420
- data/spec/unit/datastream_spec.rb +0 -83
- data/spec/unit/datastreams_spec.rb +0 -243
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +0 -96
- data/spec/unit/has_many_collection_spec.rb +0 -35
- data/spec/unit/rdf_vocab_spec.rb +0 -30
- data/spec/unit/rdf_xml_writer_spec.rb +0 -63
- data/spec/unit/relationship_graph_spec.rb +0 -115
- data/spec/unit/reload_on_save_spec.rb +0 -24
- data/spec/unit/rels_ext_datastream_spec.rb +0 -170
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +0 -44
- data/spec/unit/rubydora_connection_spec.rb +0 -12
- data/spec/unit/semantic_node_spec.rb +0 -112
- data/spec/unit/service_definitions_spec.rb +0 -63
- data/spec/unit/solr_digital_object_spec.rb +0 -97
- data/spec/unit/unsaved_digital_object_spec.rb +0 -48
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'active_fedora/rubydora_connection'
|
3
|
-
|
4
|
-
describe ActiveFedora::RubydoraConnection do
|
5
|
-
describe 'initialize' do
|
6
|
-
it "should pass through options" do
|
7
|
-
@instance = ActiveFedora::RubydoraConnection.new :timeout => 3600, :force => true, :validateChecksum=>true
|
8
|
-
expect(@instance.connection.client.options[:timeout]).to eq(3600)
|
9
|
-
expect(@instance.connection.config[:validateChecksum]).to eq(true)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
@@last_pid = 0
|
4
|
-
describe ActiveFedora::SemanticNode do
|
5
|
-
|
6
|
-
describe "with a bunch of objects" do
|
7
|
-
def increment_pid
|
8
|
-
@@last_pid += 1
|
9
|
-
end
|
10
|
-
|
11
|
-
before(:each) do
|
12
|
-
class SpecNode
|
13
|
-
include ActiveFedora::SemanticNode
|
14
|
-
|
15
|
-
attr_accessor :pid
|
16
|
-
def initialize (params={})
|
17
|
-
self.pid = params[:pid]
|
18
|
-
end
|
19
|
-
def internal_uri
|
20
|
-
'info:fedora/' + pid.to_s
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
@node = SpecNode.new
|
25
|
-
allow(@node).to receive(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
|
26
|
-
@node.pid = increment_pid
|
27
|
-
end
|
28
|
-
|
29
|
-
after(:each) do
|
30
|
-
Object.send(:remove_const, :SpecNode)
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "pid_from_uri" do
|
34
|
-
it "should strip the info:fedora/ out of a given string" do
|
35
|
-
expect(SpecNode.pid_from_uri("info:fedora/FOO:BAR")).to eq("FOO:BAR")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe ".add_relationship" do
|
40
|
-
it "should add relationship to the relationships graph" do
|
41
|
-
@node.add_relationship("isMemberOf", 'demo:9')
|
42
|
-
expect(@node.ids_for_outbound("isMemberOf")).to eq(['demo:9'])
|
43
|
-
end
|
44
|
-
it "should not be written into the graph until it is saved" do
|
45
|
-
@n1 = ActiveFedora::Base.new
|
46
|
-
@node.add_relationship(:has_part, @n1)
|
47
|
-
expect(@node.relationships.statements.to_a.first.object.to_s).to eq('info:fedora/')
|
48
|
-
@n1.save
|
49
|
-
expect(@node.relationships.statements.to_a.first.object.to_s).to eq(@n1.internal_uri)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should add a literal relationship to the relationships graph" do
|
53
|
-
@node.add_relationship("isMemberOf", 'demo:9', true)
|
54
|
-
expect(@node.relationships("isMemberOf")).to eq(['demo:9'])
|
55
|
-
end
|
56
|
-
|
57
|
-
it "adding relationship to an instance should not affect class-level relationships hash" do
|
58
|
-
local_test_node1 = SpecNode.new
|
59
|
-
local_test_node2 = SpecNode.new
|
60
|
-
allow(local_test_node1).to receive(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
|
61
|
-
local_test_node1.add_relationship(:is_member_of, 'demo:10')
|
62
|
-
allow(local_test_node2).to receive(:rels_ext).and_return(double('rels-ext', :content=>''))
|
63
|
-
|
64
|
-
expect(local_test_node1.relationships(:is_member_of)).to eq(["demo:10"])
|
65
|
-
expect(local_test_node2.relationships(:is_member_of)).to eq([])
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
describe ".clear_relationship" do
|
71
|
-
before do
|
72
|
-
@node.add_relationship(:is_member_of, 'demo:9')
|
73
|
-
@node.add_relationship(:is_member_of, 'demo:7')
|
74
|
-
@node.add_relationship(:has_description, 'demo:9')
|
75
|
-
end
|
76
|
-
it "should clear the specified relationship" do
|
77
|
-
@node.clear_relationship(:is_member_of)
|
78
|
-
expect(@node.relationships(:is_member_of)).to eq([])
|
79
|
-
expect(@node.relationships(:has_description)).to eq(['demo:9'])
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '#remove_relationship' do
|
84
|
-
it 'should remove a relationship from the relationships hash' do
|
85
|
-
allow(@node).to receive(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
|
86
|
-
@node.add_relationship(:has_part, "info:fedora/3")
|
87
|
-
@node.add_relationship(:has_part, "info:fedora/4")
|
88
|
-
#check both are there
|
89
|
-
expect(@node.ids_for_outbound(:has_part)).to include "3", "4"
|
90
|
-
@node.remove_relationship(:has_part, "info:fedora/3")
|
91
|
-
#check returns false if relationship does not exist and does nothing with different predicate
|
92
|
-
@node.remove_relationship(:has_member,"info:fedora/4")
|
93
|
-
#check only one item removed
|
94
|
-
expect(@node.ids_for_outbound(:has_part)).to eq(['4'])
|
95
|
-
@node.remove_relationship(:has_part,"info:fedora/4")
|
96
|
-
#check last item removed and predicate removed since now emtpy
|
97
|
-
expect(@node.ids_for_outbound(:has_part)).to eq([])
|
98
|
-
|
99
|
-
expect(@node.relationships_are_dirty).to eq(true)
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe '#assert_kind_of' do
|
105
|
-
it 'should raise an exception if object supplied is not the correct type' do
|
106
|
-
expect {@node.assert_kind_of 'SpecNode', @node, ActiveFedora::Base}.to raise_error
|
107
|
-
#now should not throw any exception
|
108
|
-
@node.assert_kind_of 'SpecNode', @node, SpecNode
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class Test < ActiveFedora::Base
|
4
|
-
include ActiveFedora::ServiceDefinitions
|
5
|
-
#has_service_definition "monkey:100"
|
6
|
-
end
|
7
|
-
|
8
|
-
describe ActiveFedora::ServiceDefinitions do
|
9
|
-
before(:each) do
|
10
|
-
mmap = <<-MMAP
|
11
|
-
<fmm:MethodMap xmlns:fmm="http://fedora.comm.nsdlib.org/service/methodmap" name="Fedora MethodMap for listing collection members">
|
12
|
-
<fmm:Method operationName="getDocumentStyle1"/>
|
13
|
-
<fmm:Method operationName="getDocumentStyle2"/>
|
14
|
-
</fmm:MethodMap>
|
15
|
-
MMAP
|
16
|
-
@repository = ActiveFedora::Base.connection_for_pid(0)
|
17
|
-
allow(@repository).to receive(:datastream_dissemination).with({:pid=>'test:12',:dsid=>'METHODMAP'}).and_return mmap
|
18
|
-
Test.has_service_definition "test:12"
|
19
|
-
end
|
20
|
-
|
21
|
-
subject {
|
22
|
-
obj = Test.new()
|
23
|
-
allow(obj).to receive(:pid).and_return('monkey:99')
|
24
|
-
obj
|
25
|
-
}
|
26
|
-
describe "method lookup" do
|
27
|
-
it "should find method keys in the YAML config" do
|
28
|
-
expect(ActiveFedora::ServiceDefinitions.lookup_method("fedora-system:3", "viewObjectProfile")).to eq(:object_profile)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
describe "method creation" do
|
32
|
-
it "should create the system sdef methods" do
|
33
|
-
expect(subject).to respond_to(:object_profile)
|
34
|
-
end
|
35
|
-
it "should create the declared sdef methods" do
|
36
|
-
expect(subject).to respond_to(:document_style_1)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
describe "generated method" do
|
40
|
-
it "should call the appropriate rubydora rest api method" do
|
41
|
-
expect(@repository).to receive(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1'})
|
42
|
-
#@mock_client.stub(:[]).with('objects/monkey%3A99/methods/test%3A12/getDocumentStyle1')
|
43
|
-
|
44
|
-
subject.document_style_1
|
45
|
-
end
|
46
|
-
it "should call the appropriate rubydora rest api method with parameters" do
|
47
|
-
expect(@repository).to receive(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1', :format=>'xml'})
|
48
|
-
obj = Test.new()
|
49
|
-
allow(obj).to receive(:pid).and_return('monkey:99')
|
50
|
-
obj.document_style_1({:format=>'xml'})
|
51
|
-
end
|
52
|
-
it "should call the appropriate rubydora rest api method with a block" do
|
53
|
-
allow(@repository).to receive(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1'}).and_yield "ping!","pang!"
|
54
|
-
obj = Test.new()
|
55
|
-
allow(obj).to receive(:pid).and_return('monkey:99')
|
56
|
-
block_response = ""
|
57
|
-
obj.document_style_1 {|res,req|
|
58
|
-
block_response += 'pong!' if res == "ping!" and req == "pang!"
|
59
|
-
}
|
60
|
-
expect(block_response).to eq("pong!")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::SolrDigitalObject do
|
4
|
-
describe "repository" do
|
5
|
-
subject { ActiveFedora::SolrDigitalObject.new({},{'datastreams'=>{}}) }
|
6
|
-
describe "when not finished" do
|
7
|
-
it "should not respond_to? :repository" do
|
8
|
-
expect(subject).not_to respond_to :repository
|
9
|
-
end
|
10
|
-
end
|
11
|
-
describe "when finished" do
|
12
|
-
before do
|
13
|
-
subject.freeze
|
14
|
-
end
|
15
|
-
it "should respond_to? :repository" do
|
16
|
-
expect(subject).to respond_to :repository
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "fetch" do
|
22
|
-
before do
|
23
|
-
class MyDatastream
|
24
|
-
def initialize(_, _)
|
25
|
-
end
|
26
|
-
|
27
|
-
def primary_solr_name(field)
|
28
|
-
return if field == :publisher
|
29
|
-
"#{field}_tesim"
|
30
|
-
end
|
31
|
-
def self.type(field)
|
32
|
-
:string
|
33
|
-
end
|
34
|
-
end
|
35
|
-
class MyModel < ActiveFedora::Base
|
36
|
-
has_metadata 'descMetadata', type: MyDatastream
|
37
|
-
has_attributes :title, :author, :publisher, datastream: 'descMetadata'
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
after do
|
42
|
-
Object.send(:remove_const, :MyModel)
|
43
|
-
Object.send(:remove_const, :MyDatastream)
|
44
|
-
end
|
45
|
-
subject { ActiveFedora::SolrDigitalObject.new({'title_tesim' => 'foo'},{'datastreams'=>{}}, MyModel) }
|
46
|
-
it "the default should be nil" do
|
47
|
-
expect(subject.fetch('author')).to be_empty
|
48
|
-
end
|
49
|
-
it "should grab values" do
|
50
|
-
expect(subject.fetch('title')).to eq ['foo']
|
51
|
-
end
|
52
|
-
it "should grab values" do
|
53
|
-
expect(subject.fetch('title')).to eq ['foo']
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should raise an error if the field isn't indexed" do
|
57
|
-
expect{subject.fetch('publisher')}.to raise_error KeyError, "Tried to fetch `publisher' from solr, but it isn't indexed."
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "initializing" do
|
63
|
-
describe "without a datastream in the ds spec and an xml mime type in the solr doc" do
|
64
|
-
before do
|
65
|
-
class WithoutMetadataDs < ActiveFedora::Base
|
66
|
-
## No datastreams are defined in this class
|
67
|
-
end
|
68
|
-
end
|
69
|
-
after do
|
70
|
-
Object.send(:remove_const, :WithoutMetadataDs)
|
71
|
-
end
|
72
|
-
subject { ActiveFedora::SolrDigitalObject.new({}, {'datastreams'=>{'properties'=>{'dsMIME'=>'text/xml'}}},WithoutMetadataDs) }
|
73
|
-
it "should create an xml datastream" do
|
74
|
-
expect(subject.datastreams['properties']).to be_kind_of ActiveFedora::OmDatastream
|
75
|
-
end
|
76
|
-
|
77
|
-
its(:new_record?) { should be_falsey }
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "with a ds spec that's not part of the solrized object" do
|
81
|
-
before do
|
82
|
-
class MissingMetadataDs < ActiveFedora::Base
|
83
|
-
has_metadata :name => "foo", :type => ActiveFedora::OmDatastream, :label => 'Foo Data'
|
84
|
-
end
|
85
|
-
after do
|
86
|
-
Object.send(:remove_const, MissingMetadataDs)
|
87
|
-
end
|
88
|
-
subject { ActiveFedora::SolrDigitalObject.new({}, {'datastreams'=>{'properties'=>{'dsMIME'=>'text/xml'}}},MissingMetadataDs) }
|
89
|
-
it "should have a foo datastream" do
|
90
|
-
subject.datastreams['foo'].label.should == 'Foo Data'
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
|
97
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::UnsavedDigitalObject do
|
4
|
-
|
5
|
-
describe "an unsaved instance" do
|
6
|
-
subject { ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'bar') }
|
7
|
-
|
8
|
-
it { is_expected.to be_new_record}
|
9
|
-
|
10
|
-
it "should have ownerId property" do
|
11
|
-
subject.ownerId = 'fooo'
|
12
|
-
expect(subject.ownerId).to eq('fooo')
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should have state" do
|
16
|
-
subject.ownerId = 'D'
|
17
|
-
expect(subject.ownerId).to eq('D')
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should not have a default pid" do
|
21
|
-
expect(subject.pid).to be_nil
|
22
|
-
end
|
23
|
-
it "should be able to set the pid" do
|
24
|
-
subject.pid = "my:new_object"
|
25
|
-
expect(subject.pid).to eq("my:new_object")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
describe "#save" do
|
31
|
-
before :all do
|
32
|
-
obj = ActiveFedora::UnsavedDigitalObject.new(ActiveFedora::Base, 'bar')
|
33
|
-
obj.label = 'my label'
|
34
|
-
obj.ownerId = 'fooo'
|
35
|
-
@saved_obj = obj.save
|
36
|
-
end
|
37
|
-
it "should be a digital object" do
|
38
|
-
expect(@saved_obj).to be_kind_of ActiveFedora::DigitalObject
|
39
|
-
end
|
40
|
-
it "should set the ownerId property" do
|
41
|
-
expect(@saved_obj.ownerId).to eq('fooo')
|
42
|
-
end
|
43
|
-
it "should set the label property" do
|
44
|
-
expect(@saved_obj.label).to eq('my label')
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|