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
|
@@ -36,15 +36,15 @@ describe ActiveFedora::Base do
|
|
|
36
36
|
primary_file.content = "I'm in a container all alone!"
|
|
37
37
|
page_image.save!
|
|
38
38
|
end
|
|
39
|
-
subject { reloaded_page_image.primary_file }
|
|
39
|
+
subject(:reloaded_file) { reloaded_page_image.primary_file }
|
|
40
40
|
it "initializes an object within the container" do
|
|
41
|
-
expect(
|
|
42
|
-
expect(
|
|
41
|
+
expect(reloaded_file.content).to eq("I'm in a container all alone!")
|
|
42
|
+
expect(reloaded_file.metadata_node.type).to include(::RDF::URI.new("http://example.com/primaryFile"))
|
|
43
43
|
end
|
|
44
44
|
it "relies on info from the :through association, including class_name" do
|
|
45
45
|
expect(page_image.files).to include(primary_file)
|
|
46
46
|
expect(primary_file.uri.to_s).to include("/files/")
|
|
47
|
-
expect(
|
|
47
|
+
expect(reloaded_file.class).to eq FileWithMetadata
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
@@ -61,9 +61,7 @@ describe ActiveFedora::Base do
|
|
|
61
61
|
primary_file.content = "I am too"
|
|
62
62
|
page_image.save!
|
|
63
63
|
end
|
|
64
|
-
it
|
|
65
|
-
expect(subject).to eq primary_file
|
|
66
|
-
end
|
|
64
|
+
it { is_expected.to eq primary_file }
|
|
67
65
|
end
|
|
68
66
|
context "if class_name is set" do
|
|
69
67
|
before do
|
|
@@ -71,10 +69,10 @@ describe ActiveFedora::Base do
|
|
|
71
69
|
alternative_file.content = "I am too"
|
|
72
70
|
page_image.save!
|
|
73
71
|
end
|
|
74
|
-
subject { reloaded_page_image.alternative_file }
|
|
72
|
+
subject(:reloaded_file) { reloaded_page_image.alternative_file }
|
|
75
73
|
it "uses the specified class to load objects" do
|
|
76
|
-
expect(
|
|
77
|
-
expect(
|
|
74
|
+
expect(reloaded_file).to eq alternative_file
|
|
75
|
+
expect(reloaded_file).to be_instance_of AlternativeFileWithMetadata
|
|
78
76
|
end
|
|
79
77
|
end
|
|
80
78
|
end
|
|
@@ -85,13 +83,13 @@ describe ActiveFedora::Base do
|
|
|
85
83
|
primary_file.content = "I am too"
|
|
86
84
|
page_image.save!
|
|
87
85
|
end
|
|
88
|
-
subject { reloaded_page_image.files }
|
|
86
|
+
subject(:reloaded_file) { reloaded_page_image.files }
|
|
89
87
|
it "replaces existing record without disturbing the other contents of the container" do
|
|
90
88
|
replacement_file = page_image.primary_file = FileWithMetadata.new
|
|
91
89
|
replacement_file.content = "I'm a replacement"
|
|
92
90
|
page_image.save
|
|
93
|
-
expect(
|
|
94
|
-
expect(
|
|
91
|
+
expect(reloaded_file).to_not include(primary_file)
|
|
92
|
+
expect(reloaded_file).to contain_exactly(a_file, replacement_file)
|
|
95
93
|
expect(reloaded_page_image.primary_file).to eq(replacement_file)
|
|
96
94
|
end
|
|
97
95
|
end
|
|
@@ -19,7 +19,7 @@ describe ActiveFedora::Base do
|
|
|
19
19
|
end
|
|
20
20
|
context "in a typical sitation" do
|
|
21
21
|
specify "it cannot be reused" do
|
|
22
|
-
expect { described_class.create(ghost) }.to raise_error(Ldp::Gone)
|
|
22
|
+
expect { described_class.create(id: ghost) }.to raise_error(Ldp::Gone)
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
specify "remove its tombstone" do
|
|
@@ -18,9 +18,9 @@ describe "fedora_solr_sync_issues" do
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
let(:parent) { ParentThing.create }
|
|
21
|
-
subject { ChildThing.create parent: parent }
|
|
21
|
+
subject(:child) { ChildThing.create parent: parent }
|
|
22
22
|
|
|
23
|
-
before { Ldp::Resource::RdfSource.new(ActiveFedora.fedora.connection,
|
|
23
|
+
before { Ldp::Resource::RdfSource.new(ActiveFedora.fedora.connection, child.uri).delete }
|
|
24
24
|
|
|
25
25
|
it "does not go into an infinite loop" do
|
|
26
26
|
parent.reload
|
|
@@ -15,24 +15,22 @@ describe "Checking fixity" do
|
|
|
15
15
|
obj = MockAFBase.create
|
|
16
16
|
obj.data.content = "some content"
|
|
17
17
|
obj.save
|
|
18
|
-
obj.data
|
|
18
|
+
obj.data.check_fixity
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
context "with a valid resource" do
|
|
22
|
-
it
|
|
23
|
-
expect(subject.check_fixity).to be true
|
|
24
|
-
end
|
|
22
|
+
it { is_expected.to be true }
|
|
25
23
|
end
|
|
26
24
|
context "when no uri has been set" do
|
|
27
|
-
subject { ActiveFedora::File.new }
|
|
25
|
+
subject(:file) { ActiveFedora::File.new }
|
|
28
26
|
it "raises an error" do
|
|
29
|
-
expect {
|
|
27
|
+
expect { file.check_fixity }.to raise_error(ArgumentError, "You must provide a uri")
|
|
30
28
|
end
|
|
31
29
|
end
|
|
32
30
|
context "with missing resource" do
|
|
33
|
-
subject { ActiveFedora::File.new(ActiveFedora::Base.id_to_uri('123')) }
|
|
31
|
+
subject(:file) { ActiveFedora::File.new(ActiveFedora::Base.id_to_uri('123')) }
|
|
34
32
|
it "raises an error" do
|
|
35
|
-
expect {
|
|
33
|
+
expect { file.check_fixity }.to raise_error(Ldp::NotFound)
|
|
36
34
|
end
|
|
37
35
|
end
|
|
38
36
|
end
|
|
@@ -4,19 +4,20 @@ require 'active_fedora'
|
|
|
4
4
|
require "rexml/document"
|
|
5
5
|
|
|
6
6
|
describe ActiveFedora::File do
|
|
7
|
+
let(:file) { described_class.new }
|
|
7
8
|
describe "#save" do
|
|
8
9
|
context "with new files" do
|
|
9
10
|
context "with a string" do
|
|
10
|
-
before {
|
|
11
|
+
before { file.content = "hello" }
|
|
11
12
|
it "saves" do
|
|
12
|
-
expect(
|
|
13
|
+
expect(file.save).to be true
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
context "with no content" do
|
|
17
|
-
before {
|
|
18
|
+
before { file.content = nil }
|
|
18
19
|
it "does not save" do
|
|
19
|
-
expect(
|
|
20
|
+
expect(file.save).to be false
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
23
|
end
|
|
@@ -43,9 +44,9 @@ describe ActiveFedora::File do
|
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
it "saves" do
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
expect(
|
|
47
|
+
file.content = ActionDispatch::Http::UploadedFile.new
|
|
48
|
+
file.save
|
|
49
|
+
expect(file).not_to be_new_record
|
|
49
50
|
end
|
|
50
51
|
end
|
|
51
52
|
end
|
|
@@ -53,53 +54,52 @@ describe ActiveFedora::File do
|
|
|
53
54
|
context "with a sub-resource that autocreates" do
|
|
54
55
|
before do
|
|
55
56
|
class MockAFBase < ActiveFedora::Base
|
|
56
|
-
has_subresource "descMetadata", class_name: '
|
|
57
|
+
has_subresource "descMetadata", class_name: 'SampleResource', autocreate: true
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class SampleResource < ActiveFedora::File
|
|
61
|
+
def content
|
|
62
|
+
'something to save'
|
|
63
|
+
end
|
|
57
64
|
end
|
|
58
65
|
end
|
|
59
66
|
|
|
60
67
|
after do
|
|
68
|
+
Object.send(:remove_const, :SampleResource)
|
|
61
69
|
Object.send(:remove_const, :MockAFBase)
|
|
62
70
|
end
|
|
63
71
|
|
|
64
72
|
let(:test_object) { MockAFBase.create }
|
|
65
73
|
let(:descMetadata) { test_object.descMetadata }
|
|
66
74
|
|
|
67
|
-
describe "
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
describe "#described_by" do
|
|
73
|
-
subject { descMetadata.described_by }
|
|
74
|
-
it { should eq descMetadata.uri + '/fcr:metadata' }
|
|
75
|
+
describe "changed attributes are set" do
|
|
76
|
+
it "marks profile as changed" do
|
|
77
|
+
expect_any_instance_of(SampleResource).to receive(:attribute_will_change!).with(:profile)
|
|
78
|
+
test_object
|
|
79
|
+
end
|
|
75
80
|
end
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
let(:xml_content) { Nokogiri::XML::Document.parse(descMetadata.content) }
|
|
79
|
-
let(:title) { Nokogiri::XML::Element.new "title", xml_content }
|
|
82
|
+
describe "content_changed? is called" do
|
|
80
83
|
before do
|
|
81
|
-
|
|
82
|
-
xml_content.root.add_child title
|
|
83
|
-
allow(descMetadata).to receive(:before_save)
|
|
84
|
-
descMetadata.content = xml_content.to_s
|
|
85
|
-
descMetadata.save
|
|
84
|
+
allow_any_instance_of(SampleResource).to receive(:content_changed?).and_return(true)
|
|
86
85
|
end
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
subject { found.xpath('//dc/title/text()').first.inner_text }
|
|
91
|
-
it { should eq title.content }
|
|
86
|
+
subject { descMetadata.described_by }
|
|
87
|
+
it { is_expected.to eq descMetadata.uri + '/fcr:metadata' }
|
|
92
88
|
end
|
|
93
89
|
end
|
|
94
90
|
|
|
95
91
|
context "with a sub-resource" do
|
|
96
92
|
before do
|
|
97
93
|
class MockAFBase < ActiveFedora::Base
|
|
98
|
-
has_subresource "descMetadata", class_name: '
|
|
94
|
+
has_subresource "descMetadata", class_name: 'SampleResource'
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
class SampleResource < ActiveFedora::File
|
|
99
98
|
end
|
|
100
99
|
end
|
|
101
100
|
|
|
102
101
|
after do
|
|
102
|
+
Object.send(:remove_const, :SampleResource)
|
|
103
103
|
Object.send(:remove_const, :MockAFBase)
|
|
104
104
|
end
|
|
105
105
|
|
|
@@ -108,7 +108,7 @@ describe ActiveFedora::File do
|
|
|
108
108
|
|
|
109
109
|
describe "the metadata file" do
|
|
110
110
|
subject { descMetadata }
|
|
111
|
-
it {
|
|
111
|
+
it { is_expected.to be_a_kind_of(described_class) }
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
context "a binary file" do
|
|
@@ -131,7 +131,7 @@ describe ActiveFedora::File do
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
describe "streaming the response" do
|
|
134
|
-
let(:stream_reader) {
|
|
134
|
+
let(:stream_reader) { instance_double(IO) }
|
|
135
135
|
it "streams the response" do
|
|
136
136
|
expect(stream_reader).to receive(:read).at_least(:once)
|
|
137
137
|
test_object.attached_files[path].stream.each { |buff| stream_reader.read(buff) }
|
|
@@ -145,21 +145,19 @@ describe ActiveFedora::File do
|
|
|
145
145
|
subject { str = ''; test_object.webm.stream(range).each { |chunk| str << chunk }; str }
|
|
146
146
|
context "whole thing" do
|
|
147
147
|
let(:range) { 'bytes=0-15' }
|
|
148
|
-
it {
|
|
148
|
+
it { is_expected.to eq 'one1two2threfour' }
|
|
149
149
|
end
|
|
150
150
|
context "open ended" do
|
|
151
151
|
let(:range) { 'bytes=0-' }
|
|
152
|
-
it
|
|
153
|
-
expect(subject).to eq 'one1two2threfour'
|
|
154
|
-
end
|
|
152
|
+
it { is_expected.to eq 'one1two2threfour' }
|
|
155
153
|
end
|
|
156
154
|
context "not starting at the beginning" do
|
|
157
155
|
let(:range) { 'bytes=3-15' }
|
|
158
|
-
it {
|
|
156
|
+
it { is_expected.to eq '1two2threfour' }
|
|
159
157
|
end
|
|
160
158
|
context "not ending at the end" do
|
|
161
159
|
let(:range) { 'bytes=4-11' }
|
|
162
|
-
it {
|
|
160
|
+
it { is_expected.to eq 'two2thre' }
|
|
163
161
|
end
|
|
164
162
|
end
|
|
165
163
|
|
|
@@ -170,7 +168,7 @@ describe ActiveFedora::File do
|
|
|
170
168
|
test_object.save!
|
|
171
169
|
end
|
|
172
170
|
subject { str = ''; test_object.redirector.stream.each { |chunk| str << chunk }; str }
|
|
173
|
-
it {
|
|
171
|
+
it { is_expected.to eq 'one1two2threfour' }
|
|
174
172
|
end
|
|
175
173
|
|
|
176
174
|
context "when there are more than 3 requests because of redirects" do
|
|
@@ -9,17 +9,14 @@ describe ActiveFedora::Config::SolrGenerator do
|
|
|
9
9
|
'.solr_wrapper'
|
|
10
10
|
]}
|
|
11
11
|
|
|
12
|
-
before do
|
|
13
|
-
generator.solr_wrapper_config
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
after do
|
|
17
|
-
files_to_test.each { |file| File.delete(file) if File.exist?(file) }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
12
|
it "creates config files" do
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
Dir.mktmpdir do |dir|
|
|
14
|
+
Dir.chdir(dir) do
|
|
15
|
+
generator.solr_wrapper_config
|
|
16
|
+
files_to_test.each do |file|
|
|
17
|
+
expect(File).to exist(file), "Expected #{file} to exist"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
23
20
|
end
|
|
24
21
|
end
|
|
25
22
|
end
|
|
@@ -5,11 +5,11 @@ describe ActiveFedora::Base do
|
|
|
5
5
|
context "that is also a HABTM" do
|
|
6
6
|
before do
|
|
7
7
|
class Book < ActiveFedora::Base
|
|
8
|
-
has_and_belongs_to_many :topics, predicate: ::RDF::FOAF.primaryTopic, inverse_of: :books
|
|
8
|
+
has_and_belongs_to_many :topics, predicate: ::RDF::Vocab::FOAF.primaryTopic, inverse_of: :books
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
class Topic < ActiveFedora::Base
|
|
12
|
-
has_and_belongs_to_many :books, predicate: ::RDF::FOAF.isPrimaryTopicOf
|
|
12
|
+
has_and_belongs_to_many :books, predicate: ::RDF::Vocab::FOAF.isPrimaryTopicOf
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
@@ -34,7 +34,7 @@ describe ActiveFedora::Base do
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it "allows for more than 10 items" do
|
|
37
|
-
|
|
37
|
+
12.times do
|
|
38
38
|
book.topics << Topic.create
|
|
39
39
|
end
|
|
40
40
|
book.save
|
|
@@ -171,14 +171,14 @@ describe ActiveFedora::Base do
|
|
|
171
171
|
|
|
172
172
|
describe "#empty?" do
|
|
173
173
|
subject { book.collections }
|
|
174
|
-
it {
|
|
174
|
+
it { is_expected.to_not be_empty }
|
|
175
175
|
end
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
context "when a book isn't in a collection" do
|
|
179
179
|
describe "#empty?" do
|
|
180
180
|
subject { book.collections }
|
|
181
|
-
it {
|
|
181
|
+
it { is_expected.to be_empty }
|
|
182
182
|
end
|
|
183
183
|
end
|
|
184
184
|
end
|
|
@@ -208,7 +208,7 @@ describe ActiveFedora::Base do
|
|
|
208
208
|
end
|
|
209
209
|
|
|
210
210
|
it "delete should cause the entries to be removed from RELS-EXT, but not destroy the original record" do
|
|
211
|
-
expect(book.collections).to
|
|
211
|
+
expect(book.collections).to contain_exactly collection1, collection2
|
|
212
212
|
book.collections.delete(collection1)
|
|
213
213
|
expect(book.collections).to eq [collection2]
|
|
214
214
|
book.save!
|
|
@@ -218,7 +218,7 @@ describe ActiveFedora::Base do
|
|
|
218
218
|
end
|
|
219
219
|
|
|
220
220
|
it "destroy should cause the entries to be removed from RELS-EXT, but not destroy the original record" do
|
|
221
|
-
expect(book.collections).to
|
|
221
|
+
expect(book.collections).to contain_exactly collection1, collection2
|
|
222
222
|
book.collections.destroy(collection1)
|
|
223
223
|
expect(book.collections).to eq [collection2]
|
|
224
224
|
book.save!
|
|
@@ -31,18 +31,16 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
|
31
31
|
let!(:book) { Book.create }
|
|
32
32
|
let(:library) { Library.new }
|
|
33
33
|
subject { library.books.count }
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
34
|
+
# it excludes the books that aren't associated
|
|
35
|
+
it { is_expected.to eq 0 }
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
context "when the owner is saved with associations" do
|
|
40
39
|
let(:book) { Book.create }
|
|
41
40
|
let!(:library) { Library.create(books: [book]) }
|
|
42
41
|
subject { library.reload; library.books.count }
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
end
|
|
42
|
+
# it excludes the books that are associated
|
|
43
|
+
it { is_expected.to eq 1 }
|
|
46
44
|
end
|
|
47
45
|
|
|
48
46
|
context "when the owner is not saved after checking the count" do
|
|
@@ -161,7 +159,7 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
|
161
159
|
|
|
162
160
|
it "only returns relationships of the correct class" do
|
|
163
161
|
@book.reload
|
|
164
|
-
expect(@book.people).to
|
|
162
|
+
expect(@book.people).to contain_exactly @person1, @person2
|
|
165
163
|
expect(@book.collections).to eq []
|
|
166
164
|
end
|
|
167
165
|
end
|
|
@@ -222,7 +220,7 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
|
222
220
|
end
|
|
223
221
|
it "does not restrict relationships" do
|
|
224
222
|
@book.reload
|
|
225
|
-
expect(@book.attachments).to
|
|
223
|
+
expect(@book.attachments).to contain_exactly @image, @pdf
|
|
226
224
|
end
|
|
227
225
|
end
|
|
228
226
|
|
|
@@ -240,7 +238,7 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
|
240
238
|
it "does not restrict relationships" do
|
|
241
239
|
email.attachment_ids = [image.id, pdf.id]
|
|
242
240
|
email.reload
|
|
243
|
-
expect(email.attachments).to
|
|
241
|
+
expect(email.attachments).to contain_exactly image, pdf
|
|
244
242
|
end
|
|
245
243
|
end
|
|
246
244
|
end
|
|
@@ -406,10 +404,10 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
|
406
404
|
library.save
|
|
407
405
|
end
|
|
408
406
|
|
|
409
|
-
subject { library.books(true) }
|
|
407
|
+
subject(:books) { library.books(true) }
|
|
410
408
|
|
|
411
409
|
it "saves the new title" do
|
|
412
|
-
expect(
|
|
410
|
+
expect(books.first.title).to eq ["Better book"]
|
|
413
411
|
end
|
|
414
412
|
end
|
|
415
413
|
end
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
|
3
3
|
|
|
4
4
|
describe ActiveFedora::Base do
|
|
5
5
|
describe "descendant_uris" do
|
|
6
|
-
before
|
|
6
|
+
before do
|
|
7
7
|
ids.each do |id|
|
|
8
8
|
described_class.create id: id
|
|
9
9
|
end
|
|
@@ -62,7 +62,7 @@ describe ActiveFedora::Base do
|
|
|
62
62
|
class GenericFile < ActiveFedora::Base
|
|
63
63
|
has_many :permissions, predicate: ::RDF::Vocab::ACL.accessTo
|
|
64
64
|
accepts_nested_attributes_for :permissions, allow_destroy: true
|
|
65
|
-
property :title, predicate: ::RDF::DC.title
|
|
65
|
+
property :title, predicate: ::RDF::Vocab::DC.title
|
|
66
66
|
|
|
67
67
|
def to_solr
|
|
68
68
|
super.tap do |doc|
|
|
@@ -130,18 +130,17 @@ describe "Indirect containers" do
|
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
describe "#first" do
|
|
133
|
-
subject { reloaded.related_objects.first }
|
|
133
|
+
subject(:first) { reloaded.related_objects.first }
|
|
134
134
|
it "has the content" do
|
|
135
|
-
expect(
|
|
135
|
+
expect(first.title).to eq 'HMMM'
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
describe "#==" do
|
|
140
140
|
subject { reloaded.related_objects }
|
|
141
141
|
|
|
142
|
-
it
|
|
143
|
-
|
|
144
|
-
end
|
|
142
|
+
# it delegates to to_a
|
|
143
|
+
it { is_expected.to eq [file] }
|
|
145
144
|
end
|
|
146
145
|
|
|
147
146
|
describe "#concat" do
|
|
@@ -160,7 +159,7 @@ describe "Indirect containers" do
|
|
|
160
159
|
describe "#append" do
|
|
161
160
|
let(:file2) { o.related_objects.build }
|
|
162
161
|
it "has two related_objects" do
|
|
163
|
-
expect(o.related_objects).to
|
|
162
|
+
expect(o.related_objects).to contain_exactly file, file2
|
|
164
163
|
end
|
|
165
164
|
|
|
166
165
|
context "and then saved/reloaded" do
|
|
@@ -170,7 +169,7 @@ describe "Indirect containers" do
|
|
|
170
169
|
end
|
|
171
170
|
|
|
172
171
|
it "has two related_objects" do
|
|
173
|
-
expect(reloaded.related_objects).to
|
|
172
|
+
expect(reloaded.related_objects).to contain_exactly file, file2
|
|
174
173
|
end
|
|
175
174
|
end
|
|
176
175
|
end
|
|
@@ -196,7 +195,7 @@ describe "Indirect containers" do
|
|
|
196
195
|
end
|
|
197
196
|
|
|
198
197
|
it "returns the ids" do
|
|
199
|
-
expect(reloaded.related_object_ids).to
|
|
198
|
+
expect(reloaded.related_object_ids).to contain_exactly file.id, file2.id
|
|
200
199
|
end
|
|
201
200
|
end
|
|
202
201
|
end
|
|
@@ -242,9 +241,9 @@ describe "Indirect containers" do
|
|
|
242
241
|
end
|
|
243
242
|
|
|
244
243
|
describe "#first" do
|
|
245
|
-
subject { reloaded.related_objects.first }
|
|
244
|
+
subject(:first) { reloaded.related_objects.first }
|
|
246
245
|
it "has the content" do
|
|
247
|
-
expect(
|
|
246
|
+
expect(first.title).to eq 'HMMM'
|
|
248
247
|
end
|
|
249
248
|
end
|
|
250
249
|
end
|
|
@@ -280,9 +279,9 @@ describe "Indirect containers" do
|
|
|
280
279
|
end
|
|
281
280
|
|
|
282
281
|
describe "#first" do
|
|
283
|
-
subject { reloaded.related_objects.first }
|
|
282
|
+
subject(:first) { reloaded.related_objects.first }
|
|
284
283
|
it "has the content" do
|
|
285
|
-
expect(
|
|
284
|
+
expect(first.title).to eq 'HMMM'
|
|
286
285
|
end
|
|
287
286
|
end
|
|
288
287
|
end
|
|
@@ -21,12 +21,12 @@ describe "Objects should be serialized to JSON" do
|
|
|
21
21
|
|
|
22
22
|
before { allow(obj).to receive(:id).and_return('test-123') }
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
let(:json) { JSON.parse(obj.to_json) }
|
|
25
25
|
|
|
26
26
|
it "has to_json" do
|
|
27
|
-
expect(
|
|
28
|
-
expect(
|
|
29
|
-
expect(
|
|
27
|
+
expect(json['id']).to eq "test-123"
|
|
28
|
+
expect(json['title']).to eq ["My Title"]
|
|
29
|
+
expect(json['description']).to eq "Wonderful stuff"
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -2,35 +2,23 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::QueryResultBuilder do
|
|
4
4
|
describe "#reify_solr_results" do
|
|
5
|
-
before
|
|
5
|
+
before do
|
|
6
6
|
class FooObject < ActiveFedora::Base
|
|
7
7
|
def self.id_namespace
|
|
8
8
|
"foo"
|
|
9
9
|
end
|
|
10
|
-
|
|
11
|
-
has_subresource :descMetadata, class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
|
|
12
10
|
end
|
|
13
|
-
@test_object = ActiveFedora::Base.new
|
|
14
|
-
@foo_object = FooObject.new
|
|
15
|
-
attributes = { "language" => { 0 => "Italian" },
|
|
16
|
-
"creator" => { 0 => "Linguist, A." },
|
|
17
|
-
"geography" => { 0 => "Italy" },
|
|
18
|
-
"title" => { 0 => "Italian and Spanish: A Comparison of Common Phrases" } }
|
|
19
|
-
@foo_object.descMetadata.update_indexed_attributes(attributes)
|
|
20
|
-
@test_object.save
|
|
21
|
-
@foo_object.save
|
|
22
|
-
@profiles = {
|
|
23
|
-
# 'test' => @test_object.profile,
|
|
24
|
-
# 'foo' => @foo_object.profile,
|
|
25
|
-
# 'foo_descMetadata' => @foo_object.datastreams['descMetadata'].profile
|
|
26
|
-
}
|
|
27
|
-
@foo_content = @foo_object.attached_files['descMetadata'].content
|
|
28
11
|
end
|
|
29
|
-
|
|
12
|
+
|
|
13
|
+
let(:test_object) { ActiveFedora::Base.create }
|
|
14
|
+
let(:foo_object) { FooObject.create }
|
|
15
|
+
|
|
16
|
+
after do
|
|
30
17
|
Object.send(:remove_const, :FooObject)
|
|
31
18
|
end
|
|
19
|
+
|
|
32
20
|
it "returns an array of objects that are of the class stored in active_fedora_model_s" do
|
|
33
|
-
query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([
|
|
21
|
+
query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([test_object.id, foo_object.id])
|
|
34
22
|
solr_result = ActiveFedora::SolrService.query(query)
|
|
35
23
|
result = described_class.reify_solr_results(solr_result)
|
|
36
24
|
expect(result.length).to eq 2
|
|
@@ -40,7 +28,7 @@ describe ActiveFedora::QueryResultBuilder do
|
|
|
40
28
|
end
|
|
41
29
|
|
|
42
30
|
it '#reifies a lightweight object as a new instance' do
|
|
43
|
-
query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([
|
|
31
|
+
query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([foo_object.id])
|
|
44
32
|
solr_result = ActiveFedora::SolrService.query(query)
|
|
45
33
|
result = described_class.reify_solr_results(solr_result, load_from_solr: true)
|
|
46
34
|
expect(result.first).to be_instance_of FooObject
|
|
@@ -9,7 +9,7 @@ describe "Nesting attribute behavior of RDF resources" do
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
class CustomName < ActiveFedora::Base
|
|
12
|
-
property :pref_label, predicate: ::RDF::SKOS.prefLabel, multiple: false
|
|
12
|
+
property :pref_label, predicate: ::RDF::Vocab::SKOS.prefLabel, multiple: false
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
class CustomSource < ActiveFedora::Base
|
|
@@ -38,25 +38,25 @@ describe "Nesting attribute behavior of RDF resources" do
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
context "with an AT resource as a property" do
|
|
41
|
-
subject { ComplexResource.new }
|
|
41
|
+
subject(:complex_resource) { ComplexResource.new }
|
|
42
42
|
|
|
43
43
|
let(:params) { [{ subject: 'Foo' }, { subject: 'Bar' }] }
|
|
44
44
|
|
|
45
45
|
before do
|
|
46
46
|
ComplexResource.accepts_nested_attributes_for(*args)
|
|
47
|
-
|
|
47
|
+
complex_resource.topic_attributes = params
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
context "when no options are set" do
|
|
51
51
|
let(:args) { [:topic] }
|
|
52
52
|
|
|
53
53
|
it "sets the attributes" do
|
|
54
|
-
expect(
|
|
55
|
-
expect(
|
|
54
|
+
expect(complex_resource.topic.size).to eq 2
|
|
55
|
+
expect(complex_resource.topic.map(&:subject)).to contain_exactly ['Foo'], ['Bar']
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it "marks the attributes as changed" do
|
|
59
|
-
expect(
|
|
59
|
+
expect(complex_resource.changed_attributes.keys).to eq ["topic"]
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -66,7 +66,7 @@ describe "Nesting attribute behavior of RDF resources" do
|
|
|
66
66
|
let(:params) { [{ subject: 'Foo' }, { subject: 'Bar' }] }
|
|
67
67
|
|
|
68
68
|
it "does not add terms for which the proc is true" do
|
|
69
|
-
expect(
|
|
69
|
+
expect(complex_resource.topic.map(&:subject)).to eq [['Foo']]
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
end
|