active-fedora 11.0.0.rc1 → 11.0.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 +2 -7
- data/.rubocop_todo.yml +40 -9
- data/.solr_wrapper +6 -0
- data/README.md +1 -3
- data/active-fedora.gemspec +5 -9
- data/lib/active_fedora/associations/collection_association.rb +1 -1
- data/lib/active_fedora/associations/contained_finder.rb +2 -2
- data/lib/active_fedora/associations/has_many_association.rb +1 -1
- data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
- data/lib/active_fedora/attribute_assignment.rb +0 -1
- data/lib/active_fedora/attributes.rb +1 -1
- data/lib/active_fedora/base.rb +3 -7
- data/lib/active_fedora/change_set.rb +6 -2
- data/lib/active_fedora/containers/container.rb +1 -1
- data/lib/active_fedora/core.rb +22 -25
- data/lib/active_fedora/fedora_attributes.rb +1 -1
- data/lib/active_fedora/file.rb +1 -1
- data/lib/active_fedora/indexing_service.rb +0 -4
- data/lib/active_fedora/orders/ordered_list.rb +2 -2
- 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.rb +0 -1
- data/lib/active_fedora/relation/delegation.rb +4 -0
- data/lib/active_fedora/solr_hit.rb +0 -4
- data/lib/active_fedora/solr_query_builder.rb +16 -12
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora.rb +0 -10
- 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/spec/config_helper.rb +1 -1
- data/spec/integration/associations_spec.rb +17 -18
- data/spec/integration/attached_files_spec.rb +18 -8
- data/spec/integration/attributes_spec.rb +12 -16
- data/spec/integration/autosave_association_spec.rb +6 -6
- data/spec/integration/base_spec.rb +3 -3
- data/spec/integration/collection_association_spec.rb +2 -5
- data/spec/integration/date_time_properties_spec.rb +1 -2
- data/spec/integration/direct_container_spec.rb +8 -8
- 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 +32 -34
- data/spec/integration/generators/solr_generator_spec.rb +7 -10
- data/spec/integration/has_many_associations_spec.rb +6 -8
- data/spec/integration/indexing_spec.rb +1 -1
- data/spec/integration/indirect_container_spec.rb +8 -9
- 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 +6 -6
- data/spec/integration/relation_delegation_spec.rb +8 -10
- data/spec/integration/relation_spec.rb +13 -16
- data/spec/integration/solr_hit_spec.rb +4 -4
- data/spec/integration/versionable_spec.rb +73 -327
- 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 +14 -20
- 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_spec.rb +62 -26
- data/spec/unit/default_model_mapper_spec.rb +6 -6
- data/spec/unit/fedora_spec.rb +2 -2
- data/spec/unit/file_configurator_spec.rb +96 -96
- data/spec/unit/file_path_builder_spec.rb +1 -1
- data/spec/unit/file_spec.rb +61 -61
- data/spec/unit/files_hash_spec.rb +9 -9
- data/spec/unit/finder_methods_spec.rb +3 -3
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +13 -14
- 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 +6 -6
- 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 +142 -142
- data/spec/unit/orders/list_node_spec.rb +21 -21
- 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 +10 -10
- data/spec/unit/rdf/indexing_service_spec.rb +26 -26
- 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 +9 -9
- 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 +17 -118
- 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/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 -173
- data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
- 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 -227
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -180
- data/spec/integration/ntriples_datastream_spec.rb +0 -215
- data/spec/integration/om_datastream_spec.rb +0 -78
- data/spec/samples/hydra-mods_article_datastream.rb +0 -515
- 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 -167
- 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 -208
- data/spec/unit/rdfxml_datastream_spec.rb +0 -106
|
@@ -12,45 +12,45 @@ describe ActiveFedora::Versionable do
|
|
|
12
12
|
Object.send(:remove_const, :WithVersions)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
subject { WithVersions.new }
|
|
15
|
+
subject(:object) { WithVersions.new }
|
|
16
16
|
|
|
17
17
|
let(:current_year) { DateTime.now.year.to_s }
|
|
18
18
|
|
|
19
19
|
context "saved with no versions" do
|
|
20
20
|
it "does not have versions" do
|
|
21
|
-
|
|
22
|
-
expect(
|
|
21
|
+
object.update(title: ["Greetings Earthlings"])
|
|
22
|
+
expect(object).not_to have_versions
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
context "saved with versions" do
|
|
27
27
|
it "has versions" do
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
expect(
|
|
28
|
+
object.update(title: ["Greetings Earthlings"])
|
|
29
|
+
object.create_version
|
|
30
|
+
expect(object).to have_versions
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
describe 'sorting versions' do
|
|
35
35
|
before do
|
|
36
|
-
allow(
|
|
36
|
+
allow(graph).to receive(:fedora_versions) { versions }
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
let(:version1) {
|
|
40
|
-
let(:version2) {
|
|
39
|
+
let(:version1) { instance_double(ActiveFedora::VersionsGraph::ResourceVersion, uri: 'http://localhost:8983/fedora/rest/test/84/61/63/98/84616398-f63a-4572-ba01-0689339e4fcb/fcr:versions/87a0a8c317f1e711aa993d-e1d2-4a65-93ee-3a12fc9541ab', label: 'version1', created: '2015-04-02T19:54:45.962Z') }
|
|
40
|
+
let(:version2) { instance_double(ActiveFedora::VersionsGraph::ResourceVersion, uri: 'http://localhost:8983/fedora/rest/test/84/61/63/98/84616398-f63a-4572-ba01-0689339e4fcb/fcr:versions/87a0a8c317f1e790373a67-c9ee-447d-b740-4faa882b1a1f', label: 'version2', created: '2015-04-02T19:54:45.96Z') }
|
|
41
41
|
let(:versions) { [version1, version2] }
|
|
42
42
|
|
|
43
|
-
subject { ActiveFedora::VersionsGraph.new }
|
|
43
|
+
subject(:graph) { ActiveFedora::VersionsGraph.new }
|
|
44
44
|
|
|
45
45
|
it 'sorts by DateTime' do
|
|
46
|
-
expect(
|
|
46
|
+
expect(graph.first).to eq version2
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
context 'with an unparseable created date' do
|
|
50
|
-
let(:version2) {
|
|
50
|
+
let(:version2) { instance_double(ActiveFedora::VersionsGraph::ResourceVersion, uri: 'http://localhost:8983/fedora/rest/test/84/61/63/98/84616398-f63a-4572-ba01-0689339e4fcb/fcr:versions/87a0a8c317f1e790373a67-c9ee-447d-b740-4faa882b1a1f', label: 'version2', created: '') }
|
|
51
51
|
|
|
52
52
|
it 'raises an exception' do
|
|
53
|
-
expect {
|
|
53
|
+
expect { graph.first }.to raise_error(ActiveFedora::VersionLacksCreateDate)
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -60,319 +60,65 @@ describe ActiveFedora::Versionable do
|
|
|
60
60
|
allow(version2).to receive(:created) { raise NoMethodError }
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
let(:version2) {
|
|
63
|
+
let(:version2) { instance_double(ActiveFedora::VersionsGraph::ResourceVersion, uri: 'http://localhost:8983/fedora/rest/test/84/61/63/98/84616398-f63a-4572-ba01-0689339e4fcb/fcr:versions/87a0a8c317f1e790373a67-c9ee-447d-b740-4faa882b1a1f', label: 'version2') }
|
|
64
64
|
|
|
65
65
|
it 'raises an exception' do
|
|
66
|
-
expect {
|
|
66
|
+
expect { graph.first }.to raise_error(ActiveFedora::VersionLacksCreateDate)
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
context "after saving" do
|
|
72
72
|
before do
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
object.title = ["Greetings Earthlings"]
|
|
74
|
+
object.save
|
|
75
|
+
object.create_version
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
it { is_expected.to have_versions }
|
|
79
79
|
|
|
80
80
|
it "has one version" do
|
|
81
|
-
expect(
|
|
82
|
-
expect(
|
|
83
|
-
expect(
|
|
84
|
-
expect(
|
|
81
|
+
expect(object.versions).to be_kind_of ActiveFedora::VersionsGraph
|
|
82
|
+
expect(object.versions.all.first).to be_kind_of ActiveFedora::VersionsGraph::ResourceVersion
|
|
83
|
+
expect(object.versions.all.first.label).to eql "version1"
|
|
84
|
+
expect(object.versions.all.first.created).to start_with current_year
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
context "two times" do
|
|
88
88
|
before do
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
object.title = ["Surrender and prepare to be boarded"]
|
|
90
|
+
object.save
|
|
91
|
+
object.create_version
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
it "has two versions" do
|
|
95
|
-
expect(
|
|
96
|
-
|
|
97
|
-
expect(
|
|
98
|
-
expect(
|
|
95
|
+
expect(object.versions.all.size).to eq 2
|
|
96
|
+
object.versions.all.each_index do |index|
|
|
97
|
+
expect(object.versions.all[index].label).to end_with "version" + (index + 1).to_s
|
|
98
|
+
expect(object.versions.all[index].created).to start_with current_year
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
context "then restoring" do
|
|
103
103
|
let(:first_version) { "version1" }
|
|
104
104
|
before do
|
|
105
|
-
|
|
105
|
+
object.restore_version(first_version)
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
it "will return to the first version's values" do
|
|
109
|
-
expect(
|
|
109
|
+
expect(object.title).to eq(["Greetings Earthlings"])
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
context "and creating additional versions" do
|
|
113
113
|
before do
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
object.title = ["Now, surrender and prepare to be boarded"]
|
|
115
|
+
object.save!
|
|
116
|
+
object.create_version
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
it "has three versions" do
|
|
120
|
-
expect(
|
|
121
|
-
expect(
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
describe ActiveFedora::NtriplesRDFDatastream do
|
|
130
|
-
before(:all) do
|
|
131
|
-
class VersionableDatastream < ActiveFedora::NtriplesRDFDatastream
|
|
132
|
-
property :title, predicate: ::RDF::Vocab::DC.title
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
class MockAFBase < ActiveFedora::Base
|
|
136
|
-
has_subresource "descMetadata", class_name: 'VersionableDatastream', autocreate: true
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
after(:all) do
|
|
141
|
-
Object.send(:remove_const, :MockAFBase)
|
|
142
|
-
Object.send(:remove_const, :VersionableDatastream)
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
it "creates the object" do
|
|
146
|
-
MockAFBase.create
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
subject { test_object.descMetadata }
|
|
150
|
-
|
|
151
|
-
let(:current_year) { DateTime.now.year.to_s }
|
|
152
|
-
|
|
153
|
-
context "that exists in the repository" do
|
|
154
|
-
let(:test_object) { MockAFBase.create }
|
|
155
|
-
|
|
156
|
-
context "before creating the file" do
|
|
157
|
-
it "does not have versions" do
|
|
158
|
-
expect(subject.versions).to be_empty
|
|
159
|
-
end
|
|
160
|
-
it "does not have a title" do
|
|
161
|
-
expect(subject.title).to be_empty
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
context "after creating the file" do
|
|
166
|
-
before do
|
|
167
|
-
subject.title = "Greetings Earthlings"
|
|
168
|
-
subject.save
|
|
169
|
-
subject.create_version
|
|
170
|
-
@original_size = subject.size
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
it "links to versions endpoint" do
|
|
174
|
-
expect(subject.metadata.ldp_source.graph.query(predicate: ::RDF::Vocab::Fcrepo4.hasVersions).objects).to_not be_empty
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
it "has one version" do
|
|
178
|
-
expect(subject.versions.first.label).to eql "version1"
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
it "has a title" do
|
|
182
|
-
expect(subject.title).to eq(["Greetings Earthlings"])
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
it "has a size" do
|
|
186
|
-
expect(subject.size).to_not be_nil
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
context "two times" do
|
|
190
|
-
before do
|
|
191
|
-
subject.title = "Surrender and prepare to be boarded"
|
|
192
|
-
subject.save
|
|
193
|
-
subject.create_version
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
it "has two versions" do
|
|
197
|
-
expect(subject.versions.all.size).to eq 2
|
|
198
|
-
subject.versions.all.each_index do |index|
|
|
199
|
-
expect(subject.versions.all[index].label).to end_with "version" + (index + 1).to_s
|
|
200
|
-
expect(subject.versions.all[index].created).to start_with current_year
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
it "has the new title" do
|
|
205
|
-
expect(subject.title).to eq(["Surrender and prepare to be boarded"])
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
it "has a new size" do
|
|
209
|
-
expect(subject.size).to_not be_nil
|
|
210
|
-
expect(subject.size).to_not eq(@original_size)
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
context "then restoring" do
|
|
214
|
-
let(:first_version) { "version1" }
|
|
215
|
-
before do
|
|
216
|
-
subject.restore_version(first_version)
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
it "has two unique versions" do
|
|
220
|
-
expect(subject.versions.all.size).to eq 2
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
it "loads the restored file's content" do
|
|
224
|
-
expect(subject.title).to eq(["Greetings Earthlings"])
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
it "is the same size as the original file" do
|
|
228
|
-
expect(subject.size).to eq @original_size
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
context "and creating additional versions" do
|
|
232
|
-
before do
|
|
233
|
-
subject.title = "Now, surrender and prepare to be boarded"
|
|
234
|
-
subject.save
|
|
235
|
-
subject.create_version
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
it "has three unique versions" do
|
|
239
|
-
expect(subject.versions.all.size).to eq 3
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
it "has a new title" do
|
|
243
|
-
expect(subject.title).to eq(["Now, surrender and prepare to be boarded"])
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
it "has a new size" do
|
|
247
|
-
expect(subject.size).to_not eq @original_size
|
|
248
|
-
end
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
end
|
|
253
|
-
end
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
describe ActiveFedora::OmDatastream do
|
|
257
|
-
before(:all) do
|
|
258
|
-
class VersionableDatastream < ActiveFedora::OmDatastream
|
|
259
|
-
set_terminology do |t|
|
|
260
|
-
t.root(path: "foo")
|
|
261
|
-
t.title
|
|
262
|
-
end
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
class MockAFBase < ActiveFedora::Base
|
|
266
|
-
has_subresource "descMetadata", class_name: 'VersionableDatastream', autocreate: true
|
|
267
|
-
end
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
after(:all) do
|
|
271
|
-
Object.send(:remove_const, :MockAFBase)
|
|
272
|
-
Object.send(:remove_const, :VersionableDatastream)
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
subject { test_object.descMetadata }
|
|
276
|
-
|
|
277
|
-
let(:current_year) { DateTime.now.year.to_s }
|
|
278
|
-
|
|
279
|
-
context "that exists in the repository" do
|
|
280
|
-
let(:test_object) { MockAFBase.create }
|
|
281
|
-
|
|
282
|
-
context "before creating the file" do
|
|
283
|
-
it "does not have versions" do
|
|
284
|
-
expect(subject.versions).to be_empty
|
|
285
|
-
end
|
|
286
|
-
it "does not have a title" do
|
|
287
|
-
expect(subject.title).to be_empty
|
|
288
|
-
end
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
context "after creating the file" do
|
|
292
|
-
before do
|
|
293
|
-
subject.title = "Greetings Earthlings"
|
|
294
|
-
subject.save
|
|
295
|
-
subject.create_version
|
|
296
|
-
@original_size = subject.size
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
it "links to versions endpoint" do
|
|
300
|
-
expect(subject.metadata.ldp_source.graph.query(predicate: ::RDF::Vocab::Fcrepo4.hasVersions).objects).to_not be_empty
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
it "has one version" do
|
|
304
|
-
expect(subject.versions.first.label).to eql "version1"
|
|
305
|
-
expect(subject.versions.first.created).to start_with current_year
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
it "has a title" do
|
|
309
|
-
expect(subject.title).to eql(["Greetings Earthlings"])
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
it "has a size" do
|
|
313
|
-
expect(subject.size).to_not be_nil
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
context "two times" do
|
|
317
|
-
before do
|
|
318
|
-
subject.title = "Surrender and prepare to be boarded"
|
|
319
|
-
subject.save
|
|
320
|
-
subject.create_version
|
|
321
|
-
end
|
|
322
|
-
|
|
323
|
-
it "has two unique versions" do
|
|
324
|
-
expect(subject.versions.all.size).to eq 2
|
|
325
|
-
subject.versions.all.each_index do |index|
|
|
326
|
-
expect(subject.versions.all[index].label).to end_with "version" + (index + 1).to_s
|
|
327
|
-
expect(subject.versions.all[index].created).to start_with current_year
|
|
328
|
-
end
|
|
329
|
-
end
|
|
330
|
-
|
|
331
|
-
it "has the new title" do
|
|
332
|
-
expect(subject.title).to eql(["Surrender and prepare to be boarded"])
|
|
333
|
-
end
|
|
334
|
-
|
|
335
|
-
it "has a new size" do
|
|
336
|
-
expect(subject.size).to_not be_nil
|
|
337
|
-
expect(subject.size).to_not eq(@original_size)
|
|
338
|
-
end
|
|
339
|
-
|
|
340
|
-
context "then restoring" do
|
|
341
|
-
let(:first_version) { "version1" }
|
|
342
|
-
before do
|
|
343
|
-
subject.restore_version(first_version)
|
|
344
|
-
end
|
|
345
|
-
|
|
346
|
-
it "stills have two unique versions" do
|
|
347
|
-
expect(subject.versions.all.size).to eq 2
|
|
348
|
-
end
|
|
349
|
-
|
|
350
|
-
it "loads the restored file's content" do
|
|
351
|
-
expect(subject.title).to eql(["Greetings Earthlings"])
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
it "is the same size as the original file" do
|
|
355
|
-
expect(subject.size).to eq @original_size
|
|
356
|
-
end
|
|
357
|
-
|
|
358
|
-
context "and creating additional versions" do
|
|
359
|
-
before do
|
|
360
|
-
subject.title = "Now, surrender and prepare to be boarded"
|
|
361
|
-
subject.save
|
|
362
|
-
subject.create_version
|
|
363
|
-
end
|
|
364
|
-
|
|
365
|
-
it "has three unique versions" do
|
|
366
|
-
expect(subject.versions.all.size).to eq 3
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
it "has a new title" do
|
|
370
|
-
expect(subject.title).to eql(["Now, surrender and prepare to be boarded"])
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
it "has a new size" do
|
|
374
|
-
expect(subject.size).to_not eq @original_size
|
|
375
|
-
end
|
|
120
|
+
expect(object.versions.all.size).to eq 3
|
|
121
|
+
expect(object.title).to eq(["Now, surrender and prepare to be boarded"])
|
|
376
122
|
end
|
|
377
123
|
end
|
|
378
124
|
end
|
|
@@ -395,7 +141,7 @@ describe ActiveFedora::Versionable do
|
|
|
395
141
|
Object.send(:remove_const, :BinaryDatastream)
|
|
396
142
|
end
|
|
397
143
|
|
|
398
|
-
|
|
144
|
+
let(:content) { test_object.content }
|
|
399
145
|
|
|
400
146
|
let(:current_year) { DateTime.now.year.to_s }
|
|
401
147
|
|
|
@@ -404,7 +150,7 @@ describe ActiveFedora::Versionable do
|
|
|
404
150
|
|
|
405
151
|
context "before creating the file" do
|
|
406
152
|
it "does not have versions" do
|
|
407
|
-
expect(
|
|
153
|
+
expect(content.versions).to be_empty
|
|
408
154
|
end
|
|
409
155
|
end
|
|
410
156
|
|
|
@@ -412,48 +158,48 @@ describe ActiveFedora::Versionable do
|
|
|
412
158
|
let(:first_file) { File.new(File.join(File.dirname(__FILE__), "../fixtures/dino.jpg")) }
|
|
413
159
|
let(:first_name) { "dino.jpg" }
|
|
414
160
|
before do
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
161
|
+
content.content = first_file
|
|
162
|
+
content.original_name = first_name
|
|
163
|
+
content.save
|
|
164
|
+
content.create_version
|
|
419
165
|
end
|
|
420
166
|
|
|
421
167
|
it "links to versions endpoint" do
|
|
422
|
-
expect(
|
|
168
|
+
expect(content.metadata.ldp_source.graph.query(predicate: ::RDF::Vocab::Fcrepo4.hasVersions).objects).to_not be_empty
|
|
423
169
|
end
|
|
424
170
|
|
|
425
171
|
it "has one version" do
|
|
426
|
-
expect(
|
|
427
|
-
expect(
|
|
428
|
-
expect(
|
|
429
|
-
expect(
|
|
430
|
-
expect(
|
|
172
|
+
expect(content.versions.all.size).to eq 1
|
|
173
|
+
expect(content.original_name).to eql(first_name)
|
|
174
|
+
expect(content.content.size).to eq first_file.size
|
|
175
|
+
expect(content.versions.first.label).to eql "version1"
|
|
176
|
+
expect(content.versions.first.created).to start_with current_year
|
|
431
177
|
end
|
|
432
178
|
|
|
433
179
|
context "two times" do
|
|
434
180
|
let(:second_file) { File.new(File.join(File.dirname(__FILE__), "../fixtures/minivan.jpg")) }
|
|
435
181
|
let(:second_name) { "minivan.jpg" }
|
|
436
182
|
before do
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
183
|
+
content.content = second_file
|
|
184
|
+
content.original_name = second_name
|
|
185
|
+
content.save
|
|
186
|
+
content.create_version
|
|
441
187
|
end
|
|
442
188
|
|
|
443
189
|
it "has two unique versions" do
|
|
444
|
-
expect(
|
|
445
|
-
expect(
|
|
446
|
-
expect(
|
|
447
|
-
|
|
448
|
-
expect(
|
|
449
|
-
expect(
|
|
190
|
+
expect(content.versions.all.size).to eq 2
|
|
191
|
+
expect(content.original_name).to eql(second_name)
|
|
192
|
+
expect(content.content.size).to eq second_file.size
|
|
193
|
+
content.versions.all.each_index do |index|
|
|
194
|
+
expect(content.versions.all[index].label).to end_with "version" + (index + 1).to_s
|
|
195
|
+
expect(content.versions.all[index].created).to start_with current_year
|
|
450
196
|
end
|
|
451
197
|
end
|
|
452
198
|
|
|
453
199
|
context "with fixity checking" do
|
|
454
200
|
let(:results) do
|
|
455
201
|
results = []
|
|
456
|
-
|
|
202
|
+
content.versions.all.each do |version|
|
|
457
203
|
results << ActiveFedora::FixityService.new(version.uri).check
|
|
458
204
|
end
|
|
459
205
|
return results
|
|
@@ -469,36 +215,36 @@ describe ActiveFedora::Versionable do
|
|
|
469
215
|
context "then restoring" do
|
|
470
216
|
let(:first_version) { "version1" }
|
|
471
217
|
before do
|
|
472
|
-
|
|
218
|
+
content.restore_version(first_version)
|
|
473
219
|
end
|
|
474
220
|
|
|
475
221
|
it "stills have two unique versions" do
|
|
476
|
-
expect(
|
|
222
|
+
expect(content.versions.all.size).to eq 2
|
|
477
223
|
end
|
|
478
224
|
|
|
479
225
|
it "loads the restored file's content" do
|
|
480
|
-
expect(
|
|
226
|
+
expect(content.content.size).to eq first_file.size
|
|
481
227
|
end
|
|
482
228
|
|
|
483
229
|
it "loads the restored file's original name" do
|
|
484
|
-
expect(
|
|
230
|
+
expect(content.original_name).to eql(first_name)
|
|
485
231
|
end
|
|
486
232
|
|
|
487
233
|
context "and creating additional versions" do
|
|
488
234
|
before do
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
235
|
+
content.content = first_file
|
|
236
|
+
content.original_name = first_name
|
|
237
|
+
content.save
|
|
238
|
+
content.create_version
|
|
493
239
|
end
|
|
494
240
|
|
|
495
241
|
it "has three unique versions" do
|
|
496
|
-
expect(
|
|
497
|
-
expect(
|
|
498
|
-
expect(
|
|
499
|
-
|
|
500
|
-
expect(
|
|
501
|
-
expect(
|
|
242
|
+
expect(content.versions.all.size).to eq 3
|
|
243
|
+
expect(content.original_name).to eql(first_name)
|
|
244
|
+
expect(content.content.size).to eq first_file.size
|
|
245
|
+
content.versions.all.each_index do |index|
|
|
246
|
+
expect(content.versions.all[index].label).to end_with "version" + (index + 1).to_s
|
|
247
|
+
expect(content.versions.all[index].created).to start_with current_year
|
|
502
248
|
end
|
|
503
249
|
end
|
|
504
250
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -24,7 +24,6 @@ ActiveFedora::Base.logger.level = Logger::WARN
|
|
|
24
24
|
# HttpLogger.log_headers = true
|
|
25
25
|
|
|
26
26
|
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each { |f| require f }
|
|
27
|
-
require 'samples/samples'
|
|
28
27
|
|
|
29
28
|
$VERBOSE = nil
|
|
30
29
|
|
|
@@ -37,12 +36,6 @@ restore_spec_configuration
|
|
|
37
36
|
|
|
38
37
|
require 'active_fedora/cleaner'
|
|
39
38
|
RSpec.configure do |config|
|
|
40
|
-
config.before(:suite) do
|
|
41
|
-
ActiveFedora::RDFDatastream.deprecation_behavior = :silence
|
|
42
|
-
ActiveFedora::NtriplesRDFDatastream.deprecation_behavior = :silence
|
|
43
|
-
ActiveFedora::OmDatastream.deprecation_behavior = :silence
|
|
44
|
-
ActiveFedora::NomDatastream.deprecation_behavior = :silence
|
|
45
|
-
end
|
|
46
39
|
# Stub out test stuff.
|
|
47
40
|
config.before(:each) do
|
|
48
41
|
begin
|
|
@@ -51,10 +44,59 @@ RSpec.configure do |config|
|
|
|
51
44
|
$stderr.puts e.message
|
|
52
45
|
end
|
|
53
46
|
end
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
|
|
48
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
49
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
50
|
+
# assertions if you prefer.
|
|
51
|
+
config.expect_with :rspec do |expectations|
|
|
52
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
53
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
54
|
+
# defined using `chain`, e.g.:
|
|
55
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
56
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
57
|
+
# ...rather than:
|
|
58
|
+
# # => "be bigger than 2"
|
|
59
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
|
63
|
+
|
|
64
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
65
|
+
|
|
66
|
+
# This allows you to limit a spec run to individual examples or groups
|
|
67
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
|
68
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
|
69
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
|
70
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
|
71
|
+
config.filter_run_when_matching :focus
|
|
72
|
+
|
|
73
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
|
74
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
75
|
+
# file, and it's useful to allow more verbose output when running an
|
|
76
|
+
# individual spec file.
|
|
77
|
+
if config.files_to_run.one?
|
|
78
|
+
# Use the documentation formatter for detailed output,
|
|
79
|
+
# unless a formatter has already been configured
|
|
80
|
+
# (e.g. via a command-line flag).
|
|
81
|
+
config.default_formatter = 'doc'
|
|
56
82
|
end
|
|
57
|
-
|
|
83
|
+
|
|
84
|
+
# Print the 10 slowest examples and example groups at the
|
|
85
|
+
# end of the spec run, to help surface which specs are running
|
|
86
|
+
# particularly slow.
|
|
87
|
+
config.profile_examples = 10
|
|
88
|
+
|
|
89
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
90
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
91
|
+
# the seed, which is printed after each run.
|
|
92
|
+
# --seed 1234
|
|
93
|
+
config.order = :random
|
|
94
|
+
|
|
95
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
96
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
97
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
98
|
+
# as the one that triggered the failure.
|
|
99
|
+
Kernel.srand config.seed
|
|
58
100
|
end
|
|
59
101
|
|
|
60
102
|
def fixture(file)
|