active-fedora 10.1.0 → 11.1.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/.gitignore +1 -0
- data/.rubocop.yml +6 -7
- data/.rubocop_todo.yml +55 -0
- data/.solr_wrapper +6 -0
- data/.travis.yml +6 -9
- data/Gemfile +1 -0
- data/History.txt +34 -0
- data/README.md +1 -3
- data/active-fedora.gemspec +7 -13
- data/lib/active_fedora/aggregation/list_source.rb +2 -0
- data/lib/active_fedora/associations/association_scope.rb +1 -1
- data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
- data/lib/active_fedora/associations/builder/association.rb +1 -1
- data/lib/active_fedora/associations/builder/orders.rb +11 -3
- data/lib/active_fedora/associations/collection_association.rb +5 -5
- data/lib/active_fedora/associations/collection_proxy.rb +10 -10
- data/lib/active_fedora/associations/contained_finder.rb +2 -2
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +1 -1
- data/lib/active_fedora/associations/has_many_association.rb +2 -2
- data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
- data/lib/active_fedora/associations/orders_association.rb +4 -0
- data/lib/active_fedora/associations/rdf.rb +2 -0
- data/lib/active_fedora/attribute_assignment.rb +0 -1
- data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
- data/lib/active_fedora/attribute_methods.rb +1 -1
- data/lib/active_fedora/attributes.rb +1 -1
- data/lib/active_fedora/base.rb +4 -8
- data/lib/active_fedora/change_set.rb +6 -2
- data/lib/active_fedora/cleaner.rb +1 -1
- data/lib/active_fedora/containers/container.rb +1 -1
- data/lib/active_fedora/core.rb +33 -30
- data/lib/active_fedora/fedora.rb +6 -2
- data/lib/active_fedora/fedora_attributes.rb +1 -1
- data/lib/active_fedora/file/streaming.rb +1 -1
- data/lib/active_fedora/file.rb +2 -1
- data/lib/active_fedora/file_configurator.rb +3 -3
- data/lib/active_fedora/indexing.rb +1 -18
- data/lib/active_fedora/indexing_service.rb +0 -9
- data/lib/active_fedora/initializing_connection.rb +1 -1
- data/lib/active_fedora/loadable_from_json.rb +12 -1
- data/lib/active_fedora/model_classifier.rb +1 -1
- data/lib/active_fedora/nested_attributes.rb +2 -2
- data/lib/active_fedora/null_logger.rb +10 -0
- data/lib/active_fedora/orders/list_node.rb +2 -2
- data/lib/active_fedora/orders/ordered_list.rb +8 -4
- data/lib/active_fedora/orders/target_proxy.rb +4 -0
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/railtie.rb +2 -2
- data/lib/active_fedora/rake_support.rb +1 -1
- data/lib/active_fedora/rdf/field_map_entry.rb +6 -0
- data/lib/active_fedora/rdf/persistence.rb +1 -0
- data/lib/active_fedora/rdf/value_caster.rb +15 -0
- data/lib/active_fedora/rdf.rb +1 -1
- data/lib/active_fedora/relation/delegation.rb +4 -0
- data/lib/active_fedora/relation/finder_methods.rb +3 -1
- data/lib/active_fedora/solr_hit.rb +1 -14
- data/lib/active_fedora/solr_query_builder.rb +17 -13
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/with_metadata/metadata_node.rb +2 -1
- data/lib/active_fedora.rb +1 -12
- data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +11 -0
- data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +1 -1
- data/lib/generators/active_fedora/model/model_generator.rb +1 -1
- data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
- data/lib/tasks/active_fedora_dev.rake +1 -1
- data/spec/config_helper.rb +1 -1
- data/spec/integration/associations_spec.rb +23 -24
- data/spec/integration/attached_files_spec.rb +19 -9
- data/spec/integration/attributes_spec.rb +12 -16
- data/spec/integration/autosave_association_spec.rb +6 -6
- data/spec/integration/base_spec.rb +8 -8
- data/spec/integration/basic_contains_association_spec.rb +1 -1
- data/spec/integration/clean_connection_spec.rb +1 -1
- data/spec/integration/collection_association_spec.rb +2 -5
- data/spec/integration/date_time_properties_spec.rb +1 -17
- data/spec/integration/direct_container_spec.rb +12 -12
- data/spec/integration/directly_contains_one_association_spec.rb +11 -13
- data/spec/integration/eradicate_spec.rb +1 -1
- data/spec/integration/fedora_solr_sync_spec.rb +2 -2
- data/spec/integration/file_fixity_spec.rb +6 -8
- data/spec/integration/file_spec.rb +37 -39
- data/spec/integration/generators/solr_generator_spec.rb +7 -10
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +7 -7
- data/spec/integration/has_many_associations_spec.rb +9 -11
- data/spec/integration/indexing_spec.rb +2 -2
- data/spec/integration/indirect_container_spec.rb +11 -12
- data/spec/integration/json_serialization_spec.rb +4 -4
- data/spec/integration/query_result_builder_spec.rb +9 -21
- data/spec/integration/rdf_nested_attributes_spec.rb +7 -7
- data/spec/integration/relation_delegation_spec.rb +8 -10
- data/spec/integration/relation_spec.rb +13 -16
- data/spec/integration/scoped_query_spec.rb +3 -3
- data/spec/integration/scoping_spec.rb +3 -3
- data/spec/integration/solr_hit_spec.rb +4 -15
- data/spec/integration/versionable_spec.rb +73 -327
- data/spec/integration/with_metadata_spec.rb +1 -1
- data/spec/spec_helper.rb +52 -10
- data/spec/unit/active_fedora_spec.rb +1 -1
- data/spec/unit/aggregation/list_source_spec.rb +37 -37
- data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
- data/spec/unit/association_hash_spec.rb +17 -31
- data/spec/unit/attached_files_spec.rb +35 -32
- data/spec/unit/attributes_spec.rb +25 -25
- data/spec/unit/base_active_model_spec.rb +8 -8
- data/spec/unit/base_cma_spec.rb +1 -1
- data/spec/unit/base_extra_spec.rb +7 -22
- data/spec/unit/base_spec.rb +21 -27
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
- data/spec/unit/callback_spec.rb +2 -2
- data/spec/unit/change_set_spec.rb +5 -5
- data/spec/unit/checksum_spec.rb +2 -2
- data/spec/unit/code_configurator_spec.rb +1 -1
- data/spec/unit/core/fedora_id_translator_spec.rb +2 -2
- data/spec/unit/core/fedora_uri_translator_spec.rb +2 -2
- data/spec/unit/core/logger_spec.rb +18 -0
- data/spec/unit/core_spec.rb +68 -32
- data/spec/unit/default_model_mapper_spec.rb +6 -6
- data/spec/unit/fedora_spec.rb +3 -4
- data/spec/unit/file_configurator_spec.rb +96 -96
- data/spec/unit/file_path_builder_spec.rb +3 -3
- data/spec/unit/file_spec.rb +93 -61
- data/spec/unit/files_hash_spec.rb +9 -9
- data/spec/unit/filter_spec.rb +3 -3
- data/spec/unit/finder_methods_spec.rb +3 -3
- data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +14 -15
- data/spec/unit/has_many_association_spec.rb +28 -13
- data/spec/unit/indexers/global_indexer_spec.rb +6 -6
- data/spec/unit/indexing_service_spec.rb +5 -5
- data/spec/unit/indexing_spec.rb +8 -8
- data/spec/unit/inheritance_spec.rb +11 -7
- data/spec/unit/loadable_from_json_spec.rb +4 -4
- data/spec/unit/logger_spec.rb +1 -1
- data/spec/unit/model_classifier_spec.rb +5 -5
- data/spec/unit/ordered_spec.rb +144 -147
- data/spec/unit/orders/list_node_spec.rb +22 -22
- data/spec/unit/orders/ordered_list_spec.rb +96 -96
- data/spec/unit/orders/reflection_spec.rb +4 -4
- data/spec/unit/pathing_spec.rb +4 -4
- data/spec/unit/persistence_spec.rb +28 -28
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/query_spec.rb +12 -12
- data/spec/unit/rdf/indexing_service_spec.rb +29 -29
- data/spec/unit/readonly_spec.rb +5 -4
- data/spec/unit/reflection_spec.rb +3 -3
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
- data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
- data/spec/unit/serializers_spec.rb +3 -4
- data/spec/unit/solr_config_options_spec.rb +13 -16
- data/spec/unit/solr_hit_spec.rb +9 -9
- data/spec/unit/solr_service_spec.rb +4 -10
- data/spec/unit/sparql_insert_spec.rb +2 -2
- data/spec/unit/validations_spec.rb +12 -12
- data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
- data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
- metadata +30 -130
- data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
- data/lib/active_fedora/datastreams.rb +0 -6
- data/lib/active_fedora/nom_datastream.rb +0 -73
- data/lib/active_fedora/om_datastream.rb +0 -118
- data/lib/active_fedora/profile_indexing_service.rb +0 -11
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
- data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
- data/lib/active_fedora/rdf/rdf_datastream.rb +0 -167
- data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
- data/lib/active_fedora/solr_instance_loader.rb +0 -47
- data/solr/config/_rest_managed.json +0 -3
- data/solr/config/admin-extra.html +0 -31
- data/solr/config/elevate.xml +0 -36
- data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
- data/solr/config/protwords.txt +0 -21
- data/solr/config/schema.xml +0 -372
- data/solr/config/scripts.conf +0 -24
- data/solr/config/solrconfig.xml +0 -311
- data/solr/config/spellings.txt +0 -2
- data/solr/config/stopwords.txt +0 -58
- data/solr/config/stopwords_en.txt +0 -58
- data/solr/config/synonyms.txt +0 -31
- data/solr/config/xslt/example.xsl +0 -132
- data/solr/config/xslt/example_atom.xsl +0 -67
- data/solr/config/xslt/example_rss.xsl +0 -66
- data/solr/config/xslt/luke.xsl +0 -337
- data/spec/fixtures/damsObjectModel.xml +0 -38
- data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
- data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
- data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
- data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
- data/spec/integration/complex_rdf_datastream_spec.rb +0 -228
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -179
- data/spec/integration/ntriples_datastream_spec.rb +0 -203
- data/spec/integration/om_datastream_spec.rb +0 -78
- data/spec/integration/solr_instance_loader_spec.rb +0 -156
- data/spec/samples/hydra-mods_article_datastream.rb +0 -517
- data/spec/samples/models/mods_article.rb +0 -9
- data/spec/samples/oral_history_sample.xml +0 -38
- data/spec/samples/oral_history_xml.xml +0 -35
- data/spec/samples/samples.rb +0 -2
- data/spec/unit/nom_datastream_spec.rb +0 -60
- data/spec/unit/ntriples_datastream_spec.rb +0 -170
- data/spec/unit/om_datastream_spec.rb +0 -294
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
- data/spec/unit/rdf_datastream_spec.rb +0 -84
- data/spec/unit/rdf_resource_datastream_spec.rb +0 -204
- data/spec/unit/rdfxml_datastream_spec.rb +0 -106
|
@@ -1,48 +1,33 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::Base do
|
|
4
|
+
subject(:object) { described_class.new }
|
|
4
5
|
describe ".update_index" do
|
|
5
6
|
before do
|
|
6
|
-
mock_conn =
|
|
7
|
+
mock_conn = instance_double(RSolr::Client)
|
|
7
8
|
expect(mock_conn).to receive(:add) do |_, opts|
|
|
8
9
|
expect(opts).to eq(params: { softCommit: true })
|
|
9
10
|
end
|
|
10
|
-
mock_ss =
|
|
11
|
+
mock_ss = instance_double(ActiveFedora::SolrService)
|
|
11
12
|
allow(mock_ss).to receive(:conn).and_return(mock_conn)
|
|
12
13
|
allow(ActiveFedora::SolrService).to receive(:instance).and_return(mock_ss)
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
it "makes the solr_document with to_solr and add it" do
|
|
16
|
-
expect(
|
|
17
|
-
|
|
17
|
+
expect(object).to receive(:to_solr)
|
|
18
|
+
object.update_index
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
describe ".delete" do
|
|
22
23
|
before do
|
|
23
|
-
allow(
|
|
24
|
+
allow(object).to receive(:new_record?).and_return(false)
|
|
24
25
|
allow(ActiveFedora.fedora.connection).to receive(:delete)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
it "deletes object from repository and index" do
|
|
28
29
|
expect(ActiveFedora::SolrService).to receive(:delete).with(nil)
|
|
29
|
-
|
|
30
|
+
object.delete
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
|
-
|
|
33
|
-
describe "to_class_uri" do
|
|
34
|
-
before :all do
|
|
35
|
-
module SpecModel
|
|
36
|
-
class CamelCased < ActiveFedora::Base
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
after :all do
|
|
42
|
-
Object.send(:remove_const, :SpecModel)
|
|
43
|
-
end
|
|
44
|
-
subject { SpecModel::CamelCased.to_class_uri }
|
|
45
|
-
|
|
46
|
-
it { should == 'SpecModel::CamelCased' }
|
|
47
|
-
end
|
|
48
33
|
end
|
data/spec/unit/base_spec.rb
CHANGED
|
@@ -14,17 +14,17 @@ describe ActiveFedora::Base do
|
|
|
14
14
|
Object.send(:remove_const, :FooHistory)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
subject { FooHistory.new(title: ["A good title"]) }
|
|
18
|
-
before {
|
|
17
|
+
subject(:history) { FooHistory.new(title: ["A good title"]) }
|
|
18
|
+
before { history.id = 9 }
|
|
19
19
|
|
|
20
20
|
it "is settable" do
|
|
21
|
-
expect(
|
|
22
|
-
expect(
|
|
21
|
+
expect(history.id).to eq '9'
|
|
22
|
+
expect(history.title).to eq ["A good title"]
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "is only settable once" do
|
|
26
|
-
expect {
|
|
27
|
-
expect(
|
|
26
|
+
expect { history.id = 10 }.to raise_error "ID has already been set to 9"
|
|
27
|
+
expect(history.id).to eq '9'
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -39,14 +39,14 @@ describe ActiveFedora::Base do
|
|
|
39
39
|
Object.send(:remove_const, :FooHistory)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
subject { FooHistory.new.type }
|
|
42
|
+
subject(:history) { FooHistory.new.type }
|
|
43
43
|
|
|
44
44
|
it { is_expected.to eq [RDF::URI('http://example.com/foo')] }
|
|
45
45
|
|
|
46
46
|
context "when type is called before propertes" do
|
|
47
|
-
subject { FooHistory.resource_class.reflect_on_property(:title) }
|
|
47
|
+
subject(:history) { FooHistory.resource_class.reflect_on_property(:title) }
|
|
48
48
|
it "does not wipe out the properties" do
|
|
49
|
-
expect(
|
|
49
|
+
expect(history).to be_kind_of ActiveTriples::NodeConfig
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -72,8 +72,8 @@ describe ActiveFedora::Base do
|
|
|
72
72
|
context "on an inherited class" do
|
|
73
73
|
before do
|
|
74
74
|
class Agent < ActiveFedora::Base
|
|
75
|
-
rdf_label ::RDF::FOAF.name
|
|
76
|
-
property :foaf_name, predicate: ::RDF::FOAF.name
|
|
75
|
+
rdf_label ::RDF::Vocab::FOAF.name
|
|
76
|
+
property :foaf_name, predicate: ::RDF::Vocab::FOAF.name
|
|
77
77
|
end
|
|
78
78
|
class Person < Agent
|
|
79
79
|
rdf_label ::RDF::URI('http://example.com/foo')
|
|
@@ -100,11 +100,13 @@ describe ActiveFedora::Base do
|
|
|
100
100
|
class SpecialThing < ActiveFedora::Base
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
|
+
|
|
103
104
|
after do
|
|
104
105
|
Object.send(:remove_const, :SpecialThing)
|
|
105
106
|
end
|
|
107
|
+
|
|
106
108
|
it "records the decendants" do
|
|
107
|
-
expect(described_class.descendants).to include(
|
|
109
|
+
expect(described_class.descendants).to include(SpecialThing)
|
|
108
110
|
end
|
|
109
111
|
end
|
|
110
112
|
|
|
@@ -133,21 +135,13 @@ describe ActiveFedora::Base do
|
|
|
133
135
|
before do
|
|
134
136
|
allow_any_instance_of(FooHistory).to receive(:assign_id).and_return(@this_id)
|
|
135
137
|
end
|
|
138
|
+
|
|
136
139
|
context "with no arguments" do
|
|
137
140
|
it "does not get an id on init" do
|
|
138
141
|
expect(FooHistory.new.id).to be_nil
|
|
139
142
|
end
|
|
140
143
|
end
|
|
141
144
|
|
|
142
|
-
context "with an id argument" do
|
|
143
|
-
it "is able to create with a custom id" do
|
|
144
|
-
expect(FooHistory).to receive(:id_to_uri).and_call_original
|
|
145
|
-
f = FooHistory.new('baz_1')
|
|
146
|
-
expect(f.id).to eq 'baz_1'
|
|
147
|
-
expect(f.id).to eq 'baz_1'
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
145
|
context "with a hash argument" do
|
|
152
146
|
context "that has an id" do
|
|
153
147
|
it "is able to create with a custom id" do
|
|
@@ -171,11 +165,11 @@ describe ActiveFedora::Base do
|
|
|
171
165
|
context "before saving" do
|
|
172
166
|
context "#to_param" do
|
|
173
167
|
subject { @test_object.to_param }
|
|
174
|
-
it {
|
|
168
|
+
it { is_expected.to be_nil }
|
|
175
169
|
end
|
|
176
170
|
context "#to_key" do
|
|
177
171
|
subject { @test_object.to_key }
|
|
178
|
-
it {
|
|
172
|
+
it { is_expected.to be_nil }
|
|
179
173
|
end
|
|
180
174
|
end
|
|
181
175
|
|
|
@@ -187,12 +181,12 @@ describe ActiveFedora::Base do
|
|
|
187
181
|
|
|
188
182
|
context "#to_param" do
|
|
189
183
|
subject { @test_object.to_param }
|
|
190
|
-
it {
|
|
184
|
+
it { is_expected.to eq 'one/two/three' }
|
|
191
185
|
end
|
|
192
186
|
|
|
193
187
|
context "#to_key" do
|
|
194
188
|
subject { @test_object.to_key }
|
|
195
|
-
it {
|
|
189
|
+
it { is_expected.to eq ['one/two/three'] }
|
|
196
190
|
end
|
|
197
191
|
end
|
|
198
192
|
### end ActiveModel::Conversions
|
|
@@ -259,7 +253,7 @@ describe ActiveFedora::Base do
|
|
|
259
253
|
end
|
|
260
254
|
|
|
261
255
|
it "updates the resource" do
|
|
262
|
-
expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.
|
|
256
|
+
expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.base_uri}/#{@this_id}")
|
|
263
257
|
expect(test_object.title).to eq ['foo']
|
|
264
258
|
end
|
|
265
259
|
end
|
|
@@ -280,7 +274,7 @@ describe ActiveFedora::Base do
|
|
|
280
274
|
|
|
281
275
|
describe "#create" do
|
|
282
276
|
it "builds a new record and save it" do
|
|
283
|
-
obj =
|
|
277
|
+
obj = instance_double(FooHistory)
|
|
284
278
|
expect(obj).to receive(:save)
|
|
285
279
|
expect(FooHistory).to receive(:new).and_return(obj)
|
|
286
280
|
FooHistory.create(fubar: 'ta')
|
|
@@ -3,6 +3,6 @@ require 'spec_helper'
|
|
|
3
3
|
describe ActiveFedora::Associations::Builder::HasAndBelongsToMany do
|
|
4
4
|
describe "valid_options" do
|
|
5
5
|
subject { described_class.valid_options({}) }
|
|
6
|
-
it {
|
|
6
|
+
it { is_expected.to match_array [:class_name, :predicate, :type_validator, :before_add, :after_add, :before_remove, :after_remove, :inverse_of, :solr_page_size, :autosave] }
|
|
7
7
|
end
|
|
8
8
|
end
|
data/spec/unit/callback_spec.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::Base do
|
|
4
|
-
before
|
|
4
|
+
before do
|
|
5
5
|
class CallbackStub < ActiveFedora::Base
|
|
6
6
|
after_initialize :a_init
|
|
7
7
|
before_save :b_save
|
|
@@ -19,7 +19,7 @@ describe ActiveFedora::Base do
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
-
after
|
|
22
|
+
after do
|
|
23
23
|
@cb.destroy if @cb && @cb.persisted? # this only is called if the test failed to run all the way through.
|
|
24
24
|
Object.send(:remove_const, :CallbackStub)
|
|
25
25
|
end
|
|
@@ -33,26 +33,26 @@ describe ActiveFedora::ChangeSet do
|
|
|
33
33
|
let(:base) { Book.create }
|
|
34
34
|
|
|
35
35
|
describe "#changes" do
|
|
36
|
-
subject { change_set.changes }
|
|
36
|
+
subject(:changes) { change_set.changes }
|
|
37
37
|
|
|
38
38
|
it { is_expected.to be_kind_of Hash }
|
|
39
39
|
|
|
40
40
|
it "has three elements" do
|
|
41
|
-
expect(
|
|
41
|
+
expect(changes.size).to eq 3
|
|
42
42
|
end
|
|
43
43
|
it "does not include URIs from other objects" do
|
|
44
44
|
base.resource << RDF::Statement.new(RDF::URI("http://wrong.com"), RDF::Vocab::DC.title, "bad")
|
|
45
45
|
base.title = nil
|
|
46
|
-
expect(
|
|
46
|
+
expect(changes[RDF::Vocab::DC.title].to_a).to eq []
|
|
47
47
|
end
|
|
48
48
|
it "includes hash URIs" do
|
|
49
49
|
# This is useful as an alternative to blank nodes.
|
|
50
50
|
hash_uri = RDF::URI(base.uri.to_s + "#test")
|
|
51
51
|
base.resource << RDF::Statement.new(hash_uri, RDF::Vocab::DC.title, "good")
|
|
52
52
|
base.title = [RDF::URI(hash_uri)]
|
|
53
|
-
expect(
|
|
53
|
+
expect(changes[RDF::Vocab::DC.title].to_a).not_to eq []
|
|
54
54
|
# Include the title reference and the title for the hash URI
|
|
55
|
-
expect(
|
|
55
|
+
expect(changes[RDF::Vocab::DC.title].to_a.length).to eq 2
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
data/spec/unit/checksum_spec.rb
CHANGED
|
@@ -7,7 +7,7 @@ module ActiveFedora
|
|
|
7
7
|
let(:uri) { ::RDF::URI("urn:sha1:bb3200c2ddaee4bd7b9a4dc1ad3e10ed886eaef1") }
|
|
8
8
|
|
|
9
9
|
describe "when initialized with a file having a digest" do
|
|
10
|
-
let(:file) {
|
|
10
|
+
let(:file) { instance_double(ActiveFedora::File, digest: [uri]) }
|
|
11
11
|
|
|
12
12
|
its(:uri) { is_expected.to eq(uri) }
|
|
13
13
|
its(:value) { is_expected.to eq("bb3200c2ddaee4bd7b9a4dc1ad3e10ed886eaef1") }
|
|
@@ -15,7 +15,7 @@ module ActiveFedora
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
describe "when initialized with a file not having a digest" do
|
|
18
|
-
let(:file) {
|
|
18
|
+
let(:file) { instance_double(ActiveFedora::File, digest: []) }
|
|
19
19
|
|
|
20
20
|
its(:uri) { is_expected.to be_nil }
|
|
21
21
|
its(:value) { is_expected.to be_nil }
|
|
@@ -4,7 +4,7 @@ RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
|
|
|
4
4
|
describe ".call" do
|
|
5
5
|
let(:result) { described_class.call(id) }
|
|
6
6
|
context "when given an id" do
|
|
7
|
-
let(:good_uri) { ActiveFedora.fedora.
|
|
7
|
+
let(:good_uri) { ActiveFedora.fedora.base_uri + "/banana" }
|
|
8
8
|
let(:id) { "banana" }
|
|
9
9
|
it "returns a fedora URI" do
|
|
10
10
|
expect(result).to eq good_uri
|
|
@@ -18,7 +18,7 @@ RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
context "with characters that need escaping" do
|
|
21
|
-
let(:good_uri) { ActiveFedora.fedora.
|
|
21
|
+
let(:good_uri) { ActiveFedora.fedora.base_uri + "/%5Bfrob%5D" }
|
|
22
22
|
let(:id) { "[frob]" }
|
|
23
23
|
it "returns a good fedora URI" do
|
|
24
24
|
expect(result).to eq good_uri
|
|
@@ -4,13 +4,13 @@ RSpec.describe ActiveFedora::Core::FedoraUriTranslator do
|
|
|
4
4
|
describe ".call" do
|
|
5
5
|
let(:result) { described_class.call(uri) }
|
|
6
6
|
context "when given a Fedora URI" do
|
|
7
|
-
let(:uri) { ActiveFedora.fedora.
|
|
7
|
+
let(:uri) { ActiveFedora.fedora.base_uri + "/6" }
|
|
8
8
|
it "returns the id" do
|
|
9
9
|
expect(result).to eq '6'
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
context "when given a URI missing a slash" do
|
|
13
|
-
let(:uri) { ActiveFedora.fedora.
|
|
13
|
+
let(:uri) { ActiveFedora.fedora.base_uri + "602-a" }
|
|
14
14
|
it "returns the id" do
|
|
15
15
|
expect(result).to eq "602-a"
|
|
16
16
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe ActiveFedora::NullLogger do
|
|
4
|
+
before { ActiveFedora::Base.logger = described_class.new }
|
|
5
|
+
describe "::logger" do
|
|
6
|
+
let(:logger) { ActiveFedora::Base.logger }
|
|
7
|
+
it "when calling the logger" do
|
|
8
|
+
expect(logger.warn("warning!")).to be_nil
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "#logger" do
|
|
13
|
+
let(:logger) { ActiveFedora::Base.new.logger }
|
|
14
|
+
it "when calling the logger" do
|
|
15
|
+
expect(logger.warn("warning!")).to be_nil
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/spec/unit/core_spec.rb
CHANGED
|
@@ -12,7 +12,7 @@ describe ActiveFedora::Base do
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
let(:library) { Library.create }
|
|
15
|
-
subject { Book.new(library: library, title: "War and Peace", publisher: "Random House") }
|
|
15
|
+
subject(:book) { Book.new(library: library, title: "War and Peace", publisher: "Random House") }
|
|
16
16
|
|
|
17
17
|
after do
|
|
18
18
|
Object.send(:remove_const, :Book)
|
|
@@ -20,61 +20,61 @@ describe ActiveFedora::Base do
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "asserts a content model" do
|
|
23
|
-
expect(
|
|
23
|
+
expect(book.has_model).to eq ['Book']
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
describe "initialize with a block" do
|
|
27
|
-
subject { Book.new { |b| b.title = "The Sun also Rises" } }
|
|
27
|
+
subject(:book) { Book.new { |b| b.title = "The Sun also Rises" } }
|
|
28
28
|
|
|
29
29
|
it "has set the title" do
|
|
30
|
-
expect(
|
|
30
|
+
expect(book.title).to eq "The Sun also Rises"
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
describe "#freeze" do
|
|
35
|
-
before {
|
|
35
|
+
before { book.freeze }
|
|
36
36
|
|
|
37
37
|
it "is frozen" do
|
|
38
|
-
expect(
|
|
38
|
+
expect(book).to be_frozen
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "makes the associations immutable" do
|
|
42
42
|
expect {
|
|
43
|
-
|
|
43
|
+
book.library_id = Library.create!.id
|
|
44
44
|
}.to raise_error RuntimeError, "can't modify frozen Book"
|
|
45
|
-
expect(
|
|
45
|
+
expect(book.library_id).to eq library.id
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
describe "when the association is set via an id" do
|
|
49
|
-
subject { Book.new(library_id: library.id) }
|
|
49
|
+
subject(:book) { Book.new(library_id: library.id) }
|
|
50
50
|
it "is able to load the association" do
|
|
51
|
-
expect(
|
|
51
|
+
expect(book.library).to eq library
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it "makes the properties immutable" do
|
|
56
56
|
expect {
|
|
57
|
-
|
|
57
|
+
book.publisher = "HEY"
|
|
58
58
|
}.to raise_error TypeError
|
|
59
|
-
expect(
|
|
59
|
+
expect(book.publisher).to eq "Random House"
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
describe "an object that hasn't loaded the associations" do
|
|
64
|
-
before {
|
|
64
|
+
before { book.save! }
|
|
65
65
|
|
|
66
66
|
it "accesses associations" do
|
|
67
|
-
f = Book.find(
|
|
67
|
+
f = Book.find(book.id)
|
|
68
68
|
f.freeze
|
|
69
69
|
expect(f.library_id).to_not be_nil
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
describe "#translate_id_to_uri" do
|
|
74
|
-
subject { described_class.translate_id_to_uri }
|
|
74
|
+
subject(:uri) { described_class.translate_id_to_uri }
|
|
75
75
|
context "when it's not set" do
|
|
76
76
|
it "is a FedoraIdTranslator" do
|
|
77
|
-
expect(
|
|
77
|
+
expect(uri).to eq ActiveFedora::Core::FedoraIdTranslator
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
context "when it's set to nil" do
|
|
@@ -82,16 +82,16 @@ describe ActiveFedora::Base do
|
|
|
82
82
|
described_class.translate_id_to_uri = nil
|
|
83
83
|
end
|
|
84
84
|
it "is a FedoraIdTranslator" do
|
|
85
|
-
expect(
|
|
85
|
+
expect(uri).to eq ActiveFedora::Core::FedoraIdTranslator
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
describe "#translate_uri_to_id" do
|
|
91
|
-
subject { described_class.translate_uri_to_id }
|
|
91
|
+
subject(:uri) { described_class.translate_uri_to_id }
|
|
92
92
|
context "when it's not set" do
|
|
93
93
|
it "is a FedoraUriTranslator" do
|
|
94
|
-
expect(
|
|
94
|
+
expect(uri).to eq ActiveFedora::Core::FedoraUriTranslator
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
context "when it's set to nil" do
|
|
@@ -99,22 +99,22 @@ describe ActiveFedora::Base do
|
|
|
99
99
|
described_class.translate_uri_to_id = nil
|
|
100
100
|
end
|
|
101
101
|
it "is a FedoraIdTranslator" do
|
|
102
|
-
expect(
|
|
102
|
+
expect(uri).to eq ActiveFedora::Core::FedoraUriTranslator
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
describe "id_to_uri" do
|
|
108
108
|
let(:id) { '123456w' }
|
|
109
|
-
subject { described_class.id_to_uri(id) }
|
|
109
|
+
subject(:uri) { described_class.id_to_uri(id) }
|
|
110
110
|
|
|
111
111
|
context "with no custom proc is set" do
|
|
112
|
-
it {
|
|
112
|
+
it { is_expected.to eq "#{ActiveFedora.fedora.base_uri}/123456w" }
|
|
113
113
|
it "justs call #translate_id_to_uri" do
|
|
114
114
|
allow(described_class).to receive(:translate_id_to_uri).and_call_original
|
|
115
115
|
allow(ActiveFedora::Core::FedoraIdTranslator).to receive(:call).and_call_original
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
uri
|
|
118
118
|
|
|
119
119
|
expect(ActiveFedora::Core::FedoraIdTranslator).to have_received(:call).with(id)
|
|
120
120
|
end
|
|
@@ -122,39 +122,39 @@ describe ActiveFedora::Base do
|
|
|
122
122
|
|
|
123
123
|
context "when custom proc is set" do
|
|
124
124
|
before do
|
|
125
|
-
described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.
|
|
125
|
+
described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.base_uri}/foo/#{id}" }
|
|
126
126
|
end
|
|
127
127
|
after { described_class.translate_id_to_uri = nil }
|
|
128
128
|
|
|
129
|
-
it {
|
|
129
|
+
it { is_expected.to eq "#{ActiveFedora.fedora.base_uri}/foo/123456w" }
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
context "with an empty base path" do
|
|
133
133
|
it "produces a valid URI" do
|
|
134
134
|
allow(ActiveFedora.fedora).to receive(:base_path).and_return("/")
|
|
135
|
-
expect(
|
|
135
|
+
expect(uri).to eq("#{ActiveFedora.fedora.host}/#{id}")
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
context "with a really empty base path" do
|
|
140
140
|
it "produces a valid URI" do
|
|
141
141
|
allow(ActiveFedora.fedora).to receive(:base_path).and_return("")
|
|
142
|
-
expect(
|
|
142
|
+
expect(uri).to eq("#{ActiveFedora.fedora.host}/#{id}")
|
|
143
143
|
end
|
|
144
144
|
end
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
describe "uri_to_id" do
|
|
148
|
-
let(:uri) { "#{ActiveFedora.fedora.
|
|
149
|
-
subject { described_class.uri_to_id(uri) }
|
|
148
|
+
let(:uri) { "#{ActiveFedora.fedora.base_uri}/foo/123456w" }
|
|
149
|
+
subject(:uri_id) { described_class.uri_to_id(uri) }
|
|
150
150
|
|
|
151
151
|
context "with no custom proc is set" do
|
|
152
|
-
it {
|
|
152
|
+
it { is_expected.to eq 'foo/123456w' }
|
|
153
153
|
it "justs call #translate_uri_to_id" do
|
|
154
154
|
allow(described_class).to receive(:translate_uri_to_id).and_call_original
|
|
155
155
|
allow(ActiveFedora::Core::FedoraUriTranslator).to receive(:call).and_call_original
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
uri_id
|
|
158
158
|
|
|
159
159
|
expect(ActiveFedora::Core::FedoraUriTranslator).to have_received(:call).with(uri)
|
|
160
160
|
end
|
|
@@ -166,7 +166,43 @@ describe ActiveFedora::Base do
|
|
|
166
166
|
end
|
|
167
167
|
after { described_class.translate_uri_to_id = nil }
|
|
168
168
|
|
|
169
|
-
it {
|
|
169
|
+
it { is_expected.to eq '123456w' }
|
|
170
170
|
end
|
|
171
171
|
end
|
|
172
|
+
|
|
173
|
+
describe "to_class_uri" do
|
|
174
|
+
before do
|
|
175
|
+
module SpecModel
|
|
176
|
+
class CamelCased < ActiveFedora::Base
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
after do
|
|
182
|
+
Object.send(:remove_const, :SpecModel)
|
|
183
|
+
end
|
|
184
|
+
subject do
|
|
185
|
+
Deprecation.silence(ActiveFedora::Core::ClassMethods) do
|
|
186
|
+
SpecModel::CamelCased.to_class_uri
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it { is_expected.to eq 'SpecModel::CamelCased' }
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
describe "to_rdf_representation" do
|
|
194
|
+
before do
|
|
195
|
+
module SpecModel
|
|
196
|
+
class CamelCased < ActiveFedora::Base
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
after do
|
|
202
|
+
Object.send(:remove_const, :SpecModel)
|
|
203
|
+
end
|
|
204
|
+
subject { SpecModel::CamelCased.to_rdf_representation }
|
|
205
|
+
|
|
206
|
+
it { is_expected.to eq 'SpecModel::CamelCased' }
|
|
207
|
+
end
|
|
172
208
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::DefaultModelMapper do
|
|
4
|
-
let(:classifier) {
|
|
5
|
-
let(:classifier_instance) {
|
|
4
|
+
let(:classifier) { class_double(ActiveFedora::ModelClassifier) }
|
|
5
|
+
let(:classifier_instance) { instance_double(ActiveFedora::ModelClassifier) }
|
|
6
6
|
let(:solr_field) { 'solr_field' }
|
|
7
7
|
let(:predicate) { 'info:predicate' }
|
|
8
|
-
subject { described_class.new classifier_class: classifier, solr_field: solr_field, predicate: predicate }
|
|
8
|
+
subject(:mapper) { described_class.new classifier_class: classifier, solr_field: solr_field, predicate: predicate }
|
|
9
9
|
|
|
10
10
|
describe '#classifier' do
|
|
11
11
|
context 'with a solr document' do
|
|
@@ -16,7 +16,7 @@ describe ActiveFedora::DefaultModelMapper do
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it 'creates a classifier from the solr field data' do
|
|
19
|
-
expect(
|
|
19
|
+
expect(mapper.classifier(solr_document)).to eq classifier_instance
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -25,14 +25,14 @@ describe ActiveFedora::DefaultModelMapper do
|
|
|
25
25
|
RDF::Graph.new << [:hello, predicate, 'xyz']
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
let(:resource) {
|
|
28
|
+
let(:resource) { instance_double(ActiveFedora::LdpResource, graph: graph) }
|
|
29
29
|
|
|
30
30
|
before do
|
|
31
31
|
expect(classifier).to receive(:new).with(['xyz']).and_return(classifier_instance)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it 'creates a classifier from the resource model predicate' do
|
|
35
|
-
expect(
|
|
35
|
+
expect(mapper.classifier(resource)).to eq classifier_instance
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
end
|
data/spec/unit/fedora_spec.rb
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::Fedora do
|
|
4
|
-
subject { described_class.new(config) }
|
|
4
|
+
subject(:fedora) { described_class.new(config) }
|
|
5
5
|
describe "#authorized_connection" do
|
|
6
6
|
describe "with SSL options" do
|
|
7
7
|
let(:config) {
|
|
8
8
|
{ url: "https://example.com",
|
|
9
9
|
user: "fedoraAdmin",
|
|
10
10
|
password: "fedoraAdmin",
|
|
11
|
-
ssl: { ca_path: '/path/to/certs' }
|
|
12
|
-
}
|
|
11
|
+
ssl: { ca_path: '/path/to/certs' } }
|
|
13
12
|
}
|
|
14
13
|
specify {
|
|
15
14
|
expect(Faraday).to receive(:new).with("https://example.com", ssl: { ca_path: '/path/to/certs' }).and_call_original
|
|
16
|
-
|
|
15
|
+
fedora.authorized_connection
|
|
17
16
|
}
|
|
18
17
|
end
|
|
19
18
|
end
|