active-fedora 13.1.2 → 13.1.3

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.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.github_changelog_generator +2 -0
  3. data/CHANGELOG.md +3362 -0
  4. data/CONTRIBUTING.md +23 -1
  5. data/README.md +4 -0
  6. data/active-fedora.gemspec +14 -13
  7. data/lib/active_fedora/version.rb +1 -1
  8. metadata +104 -206
  9. data/spec/config_helper.rb +0 -17
  10. data/spec/fixtures/dino.jpg +0 -0
  11. data/spec/fixtures/dino_jpg_no_file_ext +0 -0
  12. data/spec/fixtures/minivan.jpg +0 -0
  13. data/spec/fixtures/rails_root/config/fake_fedora.yml +0 -7
  14. data/spec/fixtures/rails_root/config/fedora.yml +0 -12
  15. data/spec/fixtures/rails_root/config/solr.yml +0 -15
  16. data/spec/fixtures/rails_root/config/solr_mappings.yml +0 -16
  17. data/spec/fixtures/rails_root/config/solr_mappings_af_0.1.yml +0 -9
  18. data/spec/fixtures/rails_root/config/solr_mappings_bl_2.4.yml +0 -17
  19. data/spec/integration/associations/rdf_spec.rb +0 -61
  20. data/spec/integration/associations_spec.rb +0 -680
  21. data/spec/integration/attached_files_spec.rb +0 -146
  22. data/spec/integration/attributes_spec.rb +0 -73
  23. data/spec/integration/autosave_association_spec.rb +0 -24
  24. data/spec/integration/base_spec.rb +0 -184
  25. data/spec/integration/basic_contains_association_spec.rb +0 -121
  26. data/spec/integration/belongs_to_association_spec.rb +0 -260
  27. data/spec/integration/caching_spec.rb +0 -59
  28. data/spec/integration/clean_connection_spec.rb +0 -21
  29. data/spec/integration/collection_association_spec.rb +0 -166
  30. data/spec/integration/date_time_properties_spec.rb +0 -41
  31. data/spec/integration/delete_all_spec.rb +0 -64
  32. data/spec/integration/direct_container_spec.rb +0 -250
  33. data/spec/integration/directly_contains_one_association_spec.rb +0 -96
  34. data/spec/integration/eradicate_spec.rb +0 -52
  35. data/spec/integration/fedora_solr_sync_spec.rb +0 -30
  36. data/spec/integration/file_fixity_spec.rb +0 -36
  37. data/spec/integration/file_spec.rb +0 -221
  38. data/spec/integration/generators/fedora_generator_spec.rb +0 -26
  39. data/spec/integration/generators/solr_generator_spec.rb +0 -23
  40. data/spec/integration/gone_spec.rb +0 -41
  41. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +0 -414
  42. data/spec/integration/has_many_associations_spec.rb +0 -436
  43. data/spec/integration/has_subresource_spec.rb +0 -34
  44. data/spec/integration/indexing/descendant_fetcher_spec.rb +0 -64
  45. data/spec/integration/indexing_spec.rb +0 -110
  46. data/spec/integration/indirect_container_spec.rb +0 -290
  47. data/spec/integration/json_serialization_spec.rb +0 -32
  48. data/spec/integration/marshal_spec.rb +0 -39
  49. data/spec/integration/nested_attribute_spec.rb +0 -177
  50. data/spec/integration/nested_hash_resources_spec.rb +0 -43
  51. data/spec/integration/persistence_spec.rb +0 -37
  52. data/spec/integration/query_result_builder_spec.rb +0 -37
  53. data/spec/integration/rdf_nested_attributes_spec.rb +0 -85
  54. data/spec/integration/relation_delegation_spec.rb +0 -52
  55. data/spec/integration/relation_spec.rb +0 -117
  56. data/spec/integration/scoped_query_spec.rb +0 -134
  57. data/spec/integration/scoping_spec.rb +0 -48
  58. data/spec/integration/solr_hit_spec.rb +0 -32
  59. data/spec/integration/versionable_spec.rb +0 -256
  60. data/spec/integration/with_metadata_spec.rb +0 -111
  61. data/spec/lib/active_fedora/null_logger_spec.rb +0 -10
  62. data/spec/rcov.opts +0 -2
  63. data/spec/spec.opts +0 -5
  64. data/spec/spec_helper.rb +0 -106
  65. data/spec/support/an_active_model.rb +0 -29
  66. data/spec/unit/active_fedora/indexing/inserter_spec.rb +0 -35
  67. data/spec/unit/active_fedora_spec.rb +0 -118
  68. data/spec/unit/aggregation/list_source_spec.rb +0 -134
  69. data/spec/unit/aggregation/ordered_reader_spec.rb +0 -43
  70. data/spec/unit/association_hash_spec.rb +0 -64
  71. data/spec/unit/attached_files_spec.rb +0 -218
  72. data/spec/unit/attributes_spec.rb +0 -146
  73. data/spec/unit/base_active_model_spec.rb +0 -28
  74. data/spec/unit/base_cma_spec.rb +0 -15
  75. data/spec/unit/base_extra_spec.rb +0 -33
  76. data/spec/unit/base_spec.rb +0 -328
  77. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +0 -8
  78. data/spec/unit/callback_spec.rb +0 -65
  79. data/spec/unit/change_set_spec.rb +0 -60
  80. data/spec/unit/checksum_spec.rb +0 -25
  81. data/spec/unit/code_configurator_spec.rb +0 -41
  82. data/spec/unit/collection_proxy_spec.rb +0 -25
  83. data/spec/unit/config_spec.rb +0 -18
  84. data/spec/unit/core/fedora_id_translator_spec.rb +0 -29
  85. data/spec/unit/core/fedora_uri_translator_spec.rb +0 -19
  86. data/spec/unit/core/logger_spec.rb +0 -18
  87. data/spec/unit/core_spec.rb +0 -242
  88. data/spec/unit/default_model_mapper_spec.rb +0 -39
  89. data/spec/unit/fedora_spec.rb +0 -31
  90. data/spec/unit/file/streaming_spec.rb +0 -33
  91. data/spec/unit/file_configurator_spec.rb +0 -295
  92. data/spec/unit/file_io_spec.rb +0 -137
  93. data/spec/unit/file_path_builder_spec.rb +0 -18
  94. data/spec/unit/file_spec.rb +0 -489
  95. data/spec/unit/files_hash_spec.rb +0 -52
  96. data/spec/unit/filter_spec.rb +0 -133
  97. data/spec/unit/finder_methods_spec.rb +0 -154
  98. data/spec/unit/fixity_service_spec.rb +0 -128
  99. data/spec/unit/forbidden_attributes_protection_spec.rb +0 -50
  100. data/spec/unit/has_and_belongs_to_many_association_spec.rb +0 -125
  101. data/spec/unit/has_many_association_spec.rb +0 -131
  102. data/spec/unit/indexers/global_indexer_spec.rb +0 -41
  103. data/spec/unit/indexing/map/index_object_spec.rb +0 -25
  104. data/spec/unit/indexing/map_spec.rb +0 -27
  105. data/spec/unit/indexing_service_spec.rb +0 -28
  106. data/spec/unit/indexing_spec.rb +0 -86
  107. data/spec/unit/inheritance_spec.rb +0 -60
  108. data/spec/unit/ldp_resource_spec.rb +0 -15
  109. data/spec/unit/loadable_from_json_spec.rb +0 -40
  110. data/spec/unit/logger_spec.rb +0 -19
  111. data/spec/unit/model_classifier_spec.rb +0 -49
  112. data/spec/unit/ordered_spec.rb +0 -367
  113. data/spec/unit/orders/list_node_spec.rb +0 -151
  114. data/spec/unit/orders/ordered_list_spec.rb +0 -335
  115. data/spec/unit/orders/reflection_spec.rb +0 -22
  116. data/spec/unit/pathing_spec.rb +0 -35
  117. data/spec/unit/persistence_spec.rb +0 -115
  118. data/spec/unit/property_predicate_spec.rb +0 -35
  119. data/spec/unit/property_spec.rb +0 -25
  120. data/spec/unit/query_result_builder_spec.rb +0 -31
  121. data/spec/unit/query_spec.rb +0 -307
  122. data/spec/unit/querying_spec.rb +0 -24
  123. data/spec/unit/rdf/indexing_service_spec.rb +0 -114
  124. data/spec/unit/rdf_vocab_spec.rb +0 -30
  125. data/spec/unit/readonly_spec.rb +0 -24
  126. data/spec/unit/reflection_spec.rb +0 -42
  127. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +0 -37
  128. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +0 -38
  129. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +0 -38
  130. data/spec/unit/schema_indexing_strategy_spec.rb +0 -68
  131. data/spec/unit/scoping_spec.rb +0 -67
  132. data/spec/unit/serializers_spec.rb +0 -19
  133. data/spec/unit/solr_config_options_spec.rb +0 -57
  134. data/spec/unit/solr_hit_spec.rb +0 -57
  135. data/spec/unit/solr_query_builder_spec.rb +0 -18
  136. data/spec/unit/solr_service_spec.rb +0 -165
  137. data/spec/unit/sparql_insert_spec.rb +0 -31
  138. data/spec/unit/validations_spec.rb +0 -92
  139. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +0 -29
  140. data/spec/unit/with_metadata/metadata_node_spec.rb +0 -69
@@ -1,52 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::FilesHash do
4
- before do
5
- class FilesContainer; end
6
- allow(FilesContainer).to receive(:child_resource_reflections).and_return(file: reflection)
7
- allow(container).to receive(:association).with(:file).and_return(association)
8
- allow(container).to receive(:undeclared_files).and_return([])
9
- end
10
-
11
- after { Object.send(:remove_const, :FilesContainer) }
12
-
13
- subject(:file_hash) { described_class.new(container) }
14
- let(:reflection) { instance_double(ActiveFedora::Reflection::MacroReflection) }
15
- let(:association) { instance_double(ActiveFedora::Associations::SingularAssociation, reader: object) }
16
- let(:object) { double('object') }
17
- let(:container) { FilesContainer.new }
18
-
19
- describe "#key?" do
20
- context 'when the key is present' do
21
- it "is true" do
22
- expect(file_hash.key?(:file)).to be true
23
- end
24
- it "returns true if a string is passed" do
25
- expect(file_hash.key?('file')).to be true
26
- end
27
- end
28
-
29
- context 'when the key is not present' do
30
- it "is false" do
31
- expect(file_hash.key?(:foo)).to be false
32
- end
33
- end
34
- end
35
-
36
- describe "#[]" do
37
- context 'when the key is present' do
38
- it "returns the object" do
39
- expect(file_hash[:file]).to eq object
40
- end
41
- it "returns the object if a string is passed" do
42
- expect(file_hash['file']).to eq object
43
- end
44
- end
45
-
46
- context 'when the key is not present' do
47
- it "is nil" do
48
- expect(file_hash[:foo]).to be_nil
49
- end
50
- end
51
- end
52
- end
@@ -1,133 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::Associations::FilterAssociation do
4
- before do
5
- class Image < ActiveFedora::Base
6
- ordered_aggregation :members, through: :list_source, class_name: 'ActiveFedora::Base'
7
-
8
- filters_association :members, as: :child_objects, condition: :pcdm_object?
9
- filters_association :members, as: :child_collections, condition: :pcdm_collection?
10
- end
11
-
12
- class TestObject < ActiveFedora::Base
13
- def pcdm_object?
14
- true
15
- end
16
-
17
- def pcdm_collection?
18
- false
19
- end
20
- end
21
-
22
- class TestCollection < ActiveFedora::Base
23
- def pcdm_object?
24
- false
25
- end
26
-
27
- def pcdm_collection?
28
- true
29
- end
30
- end
31
- end
32
-
33
- after do
34
- Object.send(:remove_const, :Image)
35
- Object.send(:remove_const, :TestObject)
36
- Object.send(:remove_const, :TestCollection)
37
- end
38
-
39
- let(:image) { Image.new }
40
- let(:test_object) { TestObject.new }
41
- let(:test_collection) { TestCollection.new }
42
-
43
- describe "setting" do
44
- context "when an incorrect object type is sent" do
45
- it "raises an error" do
46
- image.child_collections
47
- expect { image.child_collections = [test_object] }.to raise_error ArgumentError
48
- end
49
- end
50
-
51
- context "when the parent is already loaded" do
52
- let(:another_collection) { TestCollection.new }
53
- before do
54
- image.members = [test_object, test_collection]
55
- image.child_collections = [another_collection]
56
- end
57
- it "overwrites existing matches" do
58
- expect(image.members).to contain_exactly test_object, another_collection
59
- end
60
- end
61
- end
62
-
63
- describe "appending" do
64
- context "when an incorrect object type is sent" do
65
- it "raises an error" do
66
- expect { image.child_collections << test_object }.to raise_error ArgumentError
67
- end
68
- end
69
-
70
- context "when the parent is already loaded" do
71
- let(:another_collection) { TestCollection.new }
72
- before do
73
- image.members = [test_object, test_collection]
74
- image.child_collections << [another_collection]
75
- end
76
-
77
- it "updates the parent" do
78
- expect(image.members).to contain_exactly test_object, test_collection, another_collection
79
- end
80
- end
81
- end
82
-
83
- describe "#size" do
84
- it "returns the size" do
85
- # Need to persist so that count_records will be called.
86
- image.save
87
- test_object.save
88
- image.members = [test_object]
89
-
90
- expect(image.reload.child_objects.size).to eq 1
91
- end
92
- end
93
-
94
- describe "reading" do
95
- before do
96
- image.members = [test_object, test_collection]
97
- end
98
-
99
- it "returns the objects of the correct type" do
100
- expect(image.child_objects).to eq [test_object]
101
- end
102
-
103
- describe "when the parent association is changed" do
104
- before do
105
- image.child_objects = [test_object]
106
- image.child_objects.to_a # this would cause the @target of the association to be populated
107
- image.members = [test_collection]
108
- end
109
-
110
- it "updates the filtered relation" do
111
- expect(image.child_objects).to eq []
112
- end
113
- end
114
-
115
- describe "#_ids" do
116
- it "returns just the ids" do
117
- expect(image.child_object_ids).to eq [test_object.id]
118
- end
119
- end
120
- end
121
-
122
- describe "#delete" do
123
- subject { image.members }
124
-
125
- let(:another_object) { TestObject.new }
126
- before do
127
- image.members = [test_object, test_collection, another_object]
128
- image.child_objects.delete(test_object)
129
- end
130
-
131
- it { is_expected.to contain_exactly test_collection, another_object }
132
- end
133
- end
@@ -1,154 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveFedora::FinderMethods do
4
- let(:object_class) do
5
- Class.new do
6
- def self.delegated_attributes
7
- {}
8
- end
9
-
10
- def self.solr_query_handler
11
- 'standard'
12
- end
13
-
14
- def self.default_sort_params
15
- ["system_create_dtsi asc"]
16
- end
17
- end
18
- end
19
-
20
- let(:finder_class) do
21
- this = self
22
- Class.new do
23
- include ActiveFedora::FinderMethods
24
- @@klass = this.object_class
25
- def initialize
26
- @klass = @@klass
27
- end
28
- end
29
- end
30
-
31
- let(:finder) { finder_class.new }
32
-
33
- describe '#equivalent_class?' do
34
- let(:child_class) { Class.new(object_class) }
35
- let(:object_class) { Class.new }
36
- it 'is true for the exact class' do
37
- expect(finder.send(:equivalent_class?, object_class)).to be true
38
- end
39
-
40
- it 'is true for child classes' do
41
- expect(finder.send(:equivalent_class?, child_class)).to be true
42
- end
43
-
44
- it 'is falsey for non-decendants' do
45
- expect(finder.send(:equivalent_class?, Class.new)).to be_nil
46
- end
47
- end
48
-
49
- describe '#class_to_load' do
50
- subject(:class_to_load) { finder.send(:class_to_load, resource, true) }
51
-
52
- let(:best_model) { Class.new }
53
- let(:mapper) { instance_double(ActiveFedora::DefaultModelMapper, classifier: classifier) }
54
- let(:classifier) { instance_double(ActiveFedora::ModelClassifier, best_model: best_model) }
55
- let(:resource) { instance_double(Hash) }
56
-
57
- before do
58
- allow(ActiveFedora).to receive(:model_mapper).and_return(mapper)
59
- end
60
-
61
- context 'when using the default implementation' do
62
- it 'raises an error' do
63
- expect { class_to_load }.to raise_error ActiveFedora::ModelMismatch
64
- end
65
- end
66
-
67
- context 'when a custom finder overrides equivalent_class?' do
68
- before do
69
- allow(finder).to receive(:equivalent_class?).and_return(true)
70
- end
71
-
72
- it 'calls the overridden implementation' do
73
- expect(class_to_load).to eq best_model
74
- expect(finder).to have_received(:equivalent_class?).with(best_model)
75
- end
76
- end
77
- end
78
-
79
- describe "#condition_to_clauses" do
80
- subject { finder.send(:condition_to_clauses, key, value) }
81
- let(:key) { 'library_id' }
82
-
83
- context "when value is nil" do
84
- let(:value) { nil }
85
- it { is_expected.to eq "-library_id:[* TO *]" }
86
- end
87
-
88
- context "when value is empty string" do
89
- let(:value) { '' }
90
- it { is_expected.to eq "-library_id:[* TO *]" }
91
- end
92
-
93
- context "when value is an id" do
94
- let(:value) { 'one/two/three' }
95
- it { is_expected.to eq "_query_:\"{!field f=library_id}one/two/three\"" }
96
- end
97
-
98
- context "when value is an array" do
99
- let(:value) { ['one', 'four'] }
100
- it { is_expected.to eq "(_query_:\"{!field f=library_id}one\" AND " \
101
- "_query_:\"{!field f=library_id}four\")" }
102
- end
103
- end
104
-
105
- describe "#search_in_batches" do
106
- let(:docs) { instance_double(RSolr::Response::PaginatedDocSet, has_next?: false) }
107
- let(:select_handler) { 'select' }
108
- let(:connection) { instance_double(RSolr::Client) }
109
- before do
110
- expect(finder).to receive(:create_query).with('age_t' => '21').and_return('dummy query')
111
- allow(ActiveFedora::SolrService.instance).to receive(:conn).and_return(connection)
112
- allow(ActiveFedora::SolrService).to receive(:select_path).and_return(select_handler)
113
- expect(connection).to receive(:paginate) \
114
- .with(1, 1000, select_handler, params: hash_including(other_opt: 'test')) \
115
- .and_return('response' => { 'docs' => docs })
116
- end
117
- it "yields the docs" do
118
- expect { |b|
119
- finder.search_in_batches({ 'age_t' => '21' }, { other_opt: 'test' }, &b)
120
- }.to yield_with_args(docs)
121
- end
122
-
123
- context "with custom select handler" do
124
- let(:select_handler) { 'select_test' }
125
- it "uses the custom select handler" do
126
- finder.search_in_batches({ 'age_t' => '21' }, other_opt: 'test') do end
127
- end
128
- end
129
- end
130
-
131
- describe '#search_by_id' do
132
- context 'with a document in solr' do
133
- let(:doc) { instance_double(Hash) }
134
-
135
- before do
136
- expect(finder).to receive(:search_with_conditions).with({ id: 'x' }, hash_including(rows: 1)).and_return([doc])
137
- end
138
-
139
- it "returns the document" do
140
- expect(finder.search_by_id('x')).to eq doc
141
- end
142
- end
143
-
144
- context 'without a document in solr' do
145
- before do
146
- expect(finder).to receive(:search_with_conditions).with({ id: 'x' }, hash_including(rows: 1)).and_return([])
147
- end
148
-
149
- it "returns the document" do
150
- expect { finder.search_by_id('x') }.to raise_error ActiveFedora::ObjectNotFoundError, "Object 'x' not found in solr"
151
- end
152
- end
153
- end
154
- end
@@ -1,128 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::FixityService do
4
- let(:service) { described_class.new(uri) }
5
- let(:uri) { RDF::URI("http://path/to/resource") }
6
-
7
- let(:passing_fedora44_response_body) {
8
- <<-EOF
9
- @prefix premis: <http://www.loc.gov/premis/rdf/v1#> .
10
-
11
- <http://127.0.0.1:8080/rest/dev/0k/22/5b/04/0k225b04p/files/9f296a1f-10e7-44a3-83eb-4811d611edc6/fcr:versions/version1> premis:hasFixity <http://127.0.0.1:8080/rest/dev/0k/22/5b/04/0k225b04p/files/9f296a1f-10e7-44a3-83eb-4811d611edc6/fcr:versions/version1#fixity/1493843767961> .
12
-
13
- <http://127.0.0.1:8080/rest/dev/0k/22/5b/04/0k225b04p/files/9f296a1f-10e7-44a3-83eb-4811d611edc6/fcr:versions/version1#fixity/1493843767961> a premis:Fixity , premis:EventOutcomeDetail ;
14
- premis:hasEventOutcome "SUCCESS"^^<http://www.w3.org/2001/XMLSchema#string> ;
15
- premis:hasMessageDigest <urn:sha1:b995eef5262dd1c74f0ed9c96be1f404394d45dc> ;
16
- premis:hasSize "103945"^^<http://www.w3.org/2001/XMLSchema#long> .
17
- EOF
18
- }
19
-
20
- let(:failing_fedora44_response_body) {
21
- <<-EOF
22
- @prefix premis: <http://www.loc.gov/premis/rdf/v1#> .
23
-
24
- <http://127.0.0.1:8080/rest/dev/ks/65/hc/20/ks65hc20t/files/e316b4b5-4627-44f8-9fdb-d2016e0e7380/fcr:versions/version3> premis:hasFixity <http://127.0.0.1:8080/rest/dev/ks/65/hc/20/ks65hc20t/files/e316b4b5-4627-44f8-9fdb-d2016e0e7380/fcr:versions/version3#fixity/1493844791463> .
25
-
26
- <http://127.0.0.1:8080/rest/dev/ks/65/hc/20/ks65hc20t/files/e316b4b5-4627-44f8-9fdb-d2016e0e7380/fcr:versions/version3#fixity/1493844791463> a premis:Fixity , premis:EventOutcomeDetail ;
27
- premis:hasEventOutcome "BAD_CHECKSUM"^^<http://www.w3.org/2001/XMLSchema#string> , "BAD_SIZE"^^<http://www.w3.org/2001/XMLSchema#string> ;
28
- premis:hasMessageDigest <urn:sha1:1a89571e25dd372563a10740a883e93f8af2d146> ;
29
- premis:hasSize "1878582"^^<http://www.w3.org/2001/XMLSchema#long> .
30
- EOF
31
- }
32
-
33
- describe "the instance" do
34
- subject { described_class.new(uri) }
35
- it { is_expected.to respond_to(:response) }
36
- end
37
-
38
- describe "initialize" do
39
- context "with a string" do
40
- subject { service.target }
41
- let(:uri) { 'http://path/to/resource' }
42
- it { is_expected.to eq 'http://path/to/resource' }
43
- end
44
-
45
- context "with an RDF::URI" do
46
- subject { service.target }
47
- it { is_expected.to eq 'http://path/to/resource' }
48
- end
49
- end
50
-
51
- describe "#verified?" do
52
- before { allow(service).to receive(:fixity_response_from_fedora).and_return(response) }
53
- subject { service.verified? }
54
-
55
- context "with Fedora version >= 4.4.0" do
56
- context "with a passing result" do
57
- let(:response) do
58
- instance_double("Response", body: passing_fedora44_response_body)
59
- end
60
- it { is_expected.to be true }
61
- end
62
-
63
- context "with a failing result" do
64
- let(:response) do
65
- instance_double("Response", body: failing_fedora44_response_body)
66
- end
67
- it { is_expected.to be false }
68
- end
69
- end
70
-
71
- context "with Fedora version < 4.4.0" do
72
- context "with a passing result" do
73
- let(:response) do
74
- instance_double("Response", body: '<subject> <http://fedora.info/definitions/v4/repository#status> "SUCCESS"^^<http://www.w3.org/2001/XMLSchema#string> .')
75
- end
76
- it { is_expected.to be true }
77
- end
78
-
79
- context "with a failing result" do
80
- let(:response) do
81
- instance_double("Response", body: '<subject> <http://fedora.info/definitions/v4/repository#status> "BAD_CHECKSUM"^^<http://www.w3.org/2001/XMLSchema#string> .')
82
- end
83
- it { is_expected.to be false }
84
- end
85
- end
86
-
87
- context "with a non-existent predicate" do
88
- let(:response) do
89
- instance_double("Response", body: '<subject> <http://bogus.com/definitions/v1/bogusTerm#foo> "SUCCESS"^^<http://www.w3.org/2001/XMLSchema#string> .')
90
- end
91
- it { is_expected.to be false }
92
- end
93
- end
94
-
95
- describe "expected_message_digest" do
96
- before { allow(service).to receive(:fixity_response_from_fedora).and_return(response) }
97
- subject { service.expected_message_digest }
98
- context "with success response" do
99
- let(:response) do
100
- instance_double("Response", body: passing_fedora44_response_body)
101
- end
102
- it { is_expected.to match(/urn:sha1:[a-f0-9]+/) }
103
- end
104
- context "with failure response" do
105
- let(:response) do
106
- instance_double("Response", body: failing_fedora44_response_body)
107
- end
108
- it { is_expected.to match(/urn:sha1:[a-f0-9]+/) }
109
- end
110
- end
111
-
112
- describe "expected_size" do
113
- before { allow(service).to receive(:fixity_response_from_fedora).and_return(response) }
114
- subject { service.expected_size }
115
- context "with success response" do
116
- let(:response) do
117
- instance_double("Response", body: passing_fedora44_response_body)
118
- end
119
- it { is_expected.to be_kind_of Numeric }
120
- end
121
- context "with failure response" do
122
- let(:response) do
123
- instance_double("Response", body: failing_fedora44_response_body)
124
- end
125
- it { is_expected.to be_kind_of Numeric }
126
- end
127
- end
128
- end