fedora-migrate 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/LICENSE +14 -0
- data/README.md +201 -6
- data/config/jetty.yml +2 -2
- data/fedora-migrate.gemspec +7 -6
- data/lib/fedora-migrate.rb +7 -24
- data/lib/fedora_migrate/content_mover.rb +49 -0
- data/lib/fedora_migrate/datastream_mover.rb +19 -34
- data/lib/fedora_migrate/datastream_verification.rb +36 -0
- data/lib/fedora_migrate/dates_mover.rb +14 -0
- data/lib/fedora_migrate/hooks.rb +23 -0
- data/lib/fedora_migrate/migration_options.rb +18 -0
- data/lib/fedora_migrate/mover.rb +12 -0
- data/lib/fedora_migrate/object_mover.rb +20 -9
- data/lib/fedora_migrate/rdf_datastream_mover.rb +31 -14
- data/lib/fedora_migrate/rels_ext_datastream_mover.rb +28 -62
- data/lib/fedora_migrate/repository_migrator.rb +30 -25
- data/lib/fedora_migrate/rubydora_connection.rb +0 -2
- data/lib/fedora_migrate/target_constructor.rb +39 -0
- data/lib/fedora_migrate/version.rb +1 -1
- data/spec/fixtures/objects/scholarsphere_5712mc568.xml +7284 -0
- data/spec/fixtures/objects/scholarsphere_7d279232g.xml +20120 -0
- data/spec/fixtures/objects/scholarsphere_sf2686078.xml +8823 -0
- data/spec/fixtures/objects/scholarsphere_x346dj04v.xml +188 -0
- data/spec/fixtures/objects/scholarsphere_x346dj06d.xml +255 -0
- data/spec/fixtures/objects/scholarsphere_x346dj08z.xml +1242 -0
- data/spec/fixtures/objects/sufia_5m60qr94g.xml +68 -0
- data/spec/fixtures/objects/sufia_5m60qr95r.xml +133 -0
- data/spec/fixtures/objects/sufia_5m60qr961.xml +133 -0
- data/spec/fixtures/objects/sufia_5m60qr979.xml +118 -0
- data/spec/integration/content_versions_spec.rb +24 -1
- data/spec/integration/missing_relationships_spec.rb +30 -0
- data/spec/integration/object_migration_spec.rb +49 -5
- data/spec/integration/rdf_migration_spec.rb +38 -13
- data/spec/integration/relationship_migration_spec.rb +10 -9
- data/spec/integration/repository_migration_spec.rb +46 -19
- data/spec/integration/versions_spec.rb +32 -0
- data/spec/spec_helper.rb +8 -1
- data/spec/support/example_model.rb +56 -0
- data/spec/unit/content_mover_spec.rb +78 -0
- data/spec/unit/datastream_verification_spec.rb +60 -0
- data/spec/unit/dates_mover_spec.rb +33 -0
- data/spec/unit/migration_options_spec.rb +61 -0
- data/spec/unit/mover_spec.rb +35 -1
- data/spec/unit/object_mover_spec.rb +1 -3
- data/spec/unit/rels_ext_datastream_mover_spec.rb +28 -18
- data/spec/unit/repository_migrator_spec.rb +16 -5
- data/spec/unit/target_constructor_spec.rb +34 -0
- data/tasks/dev.rake +1 -1
- metadata +80 -38
- data/LICENSE.txt +0 -22
- data/lib/fedora_migrate/rdf_datastream_parser.rb +0 -29
- data/lib/fedora_migrate/triple_converter.rb +0 -39
- data/spec/fixtures/datastreams/rdf_ntriples_datastream.txt +0 -2
- data/spec/unit/rdf_datastream_mover_spec.rb +0 -8
- data/spec/unit/rdf_datastream_parser_spec.rb +0 -38
- data/spec/unit/triple_converter_spec.rb +0 -35
@@ -9,6 +9,20 @@ describe "Versioned content" do
|
|
9
9
|
)
|
10
10
|
end
|
11
11
|
|
12
|
+
let(:application_mover) do
|
13
|
+
FedoraMigrate::DatastreamMover.new(
|
14
|
+
FedoraMigrate.source.connection.find("sufia:rb68xc089").datastreams["content"],
|
15
|
+
ExampleModel::VersionedContent.create.attached_files["content"],
|
16
|
+
{ application_creates_versions: true }
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "calls the before and after hooks when migrating" do
|
21
|
+
expect(mover).to receive(:before_datastream_migration)
|
22
|
+
expect(mover).to receive(:after_datastream_migration)
|
23
|
+
mover.migrate
|
24
|
+
end
|
25
|
+
|
12
26
|
context "with migrating versions" do
|
13
27
|
subject do
|
14
28
|
mover.migrate
|
@@ -21,7 +35,16 @@ describe "Versioned content" do
|
|
21
35
|
expect(subject.mime_type).to eql "image/png"
|
22
36
|
expect(subject.original_name).to eql "world.png"
|
23
37
|
end
|
24
|
-
|
38
|
+
context "and the application creates the versions" do
|
39
|
+
subject do
|
40
|
+
application_mover.migrate
|
41
|
+
application_mover.target
|
42
|
+
end
|
43
|
+
it "FedoraMigrate creates no versions" do
|
44
|
+
expect(subject.versions.count).to eql 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
25
48
|
|
26
49
|
context "without migrating versions" do
|
27
50
|
subject do
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Collections with missing files" do
|
4
|
+
|
5
|
+
let(:collection) { "x346dj04v" }
|
6
|
+
let(:files) { ["x346dj06d", "x346dj08z"] }
|
7
|
+
let(:missing_file) { "x346dj07p" }
|
8
|
+
|
9
|
+
before do
|
10
|
+
FedoraMigrate::ObjectMover.new(FedoraMigrate.find("scholarsphere:#{collection}"), ExampleModel::Collection.new(collection)).migrate
|
11
|
+
files.each { |f| FedoraMigrate::ObjectMover.new(FedoraMigrate.find("scholarsphere:#{f}"), ExampleModel::MigrationObject.new(f)).migrate }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when migrating relationships" do
|
15
|
+
|
16
|
+
let(:migrated_collection) { ExampleModel::Collection.first }
|
17
|
+
let(:error_message) do
|
18
|
+
"scholarsphere:#{collection} could not migrate relationship info:fedora/fedora-system:def/relations-external#hasCollectionMember because info:fedora/scholarsphere:#{missing_file} doesn't exist in Fedora 4"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should only migrate existing relationships and log failed ones" do
|
22
|
+
expect(FedoraMigrate::Logger).to receive(:warn).with(error_message)
|
23
|
+
FedoraMigrate::RelsExtDatastreamMover.new(FedoraMigrate.find("scholarsphere:#{collection}")).migrate
|
24
|
+
expect(migrated_collection.members.count).to eql 2
|
25
|
+
expect(migrated_collection.member_ids).to_not include(missing_file)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -8,7 +8,7 @@ describe "Migrating an object" do
|
|
8
8
|
context "when the target model is provided" do
|
9
9
|
|
10
10
|
let(:mover) { FedoraMigrate::ObjectMover.new source, ExampleModel::MigrationObject.new }
|
11
|
-
|
11
|
+
|
12
12
|
subject do
|
13
13
|
mover.migrate
|
14
14
|
mover.target
|
@@ -27,6 +27,18 @@ describe "Migrating an object" do
|
|
27
27
|
expect(subject.edit_users).to include("jilluser@example.com")
|
28
28
|
end
|
29
29
|
|
30
|
+
describe "objects with Om datastreams" do
|
31
|
+
let(:mover) { FedoraMigrate::ObjectMover.new(source, ExampleModel::OmDatastreamExample.new) }
|
32
|
+
subject do
|
33
|
+
mover.migrate
|
34
|
+
mover.target
|
35
|
+
end
|
36
|
+
it "should migrate the object without warnings" do
|
37
|
+
expect(FedoraMigrate::Logger).to_not receive(:warn)
|
38
|
+
expect(subject.characterization.ng_xml).to be_equivalent_to(fits_xml)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
30
42
|
end
|
31
43
|
|
32
44
|
context "when we have to determine the model" do
|
@@ -64,7 +76,7 @@ describe "Migrating an object" do
|
|
64
76
|
Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
|
65
77
|
end
|
66
78
|
it "should fail" do
|
67
|
-
expect{mover.migrate}.to raise_error(
|
79
|
+
expect{mover.migrate}.to raise_error(FedoraMigrate::Errors::MigrationError)
|
68
80
|
end
|
69
81
|
end
|
70
82
|
|
@@ -74,7 +86,7 @@ describe "Migrating an object" do
|
|
74
86
|
|
75
87
|
context "and we want to convert it to a provided model" do
|
76
88
|
let(:mover) { FedoraMigrate::ObjectMover.new(source, ExampleModel::RDFObject.new, {convert: "descMetadata"}) }
|
77
|
-
|
89
|
+
|
78
90
|
subject do
|
79
91
|
mover.migrate
|
80
92
|
mover.target
|
@@ -90,13 +102,32 @@ describe "Migrating an object" do
|
|
90
102
|
expect(subject.title).to eql(["world.png"])
|
91
103
|
end
|
92
104
|
|
105
|
+
it "should migrate the createdDate and lastModifiedDate" do
|
106
|
+
# The value of lastModifiedDate will depend on when you loaded your test fixtures
|
107
|
+
expect(subject.date_modified).to eq source.lastModifiedDate
|
108
|
+
expect(subject.date_uploaded).to eq '2014-10-15T03:50:37.063Z'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "with ISO-8859-1 characters" do
|
113
|
+
let(:problem_source) { FedoraMigrate.source.connection.find("scholarsphere:5712mc568") }
|
114
|
+
let(:mover) { FedoraMigrate::ObjectMover.new(problem_source, ExampleModel::RDFObject.new, {convert: "descMetadata"}) }
|
115
|
+
subject do
|
116
|
+
mover.migrate
|
117
|
+
mover.target
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should migrate the content" do
|
121
|
+
expect(subject.description.first).to match(/^The relationship between school administrators and music teachers/)
|
122
|
+
end
|
123
|
+
|
93
124
|
end
|
94
125
|
|
95
126
|
context "and we want to convert multiple datastreas" do
|
96
127
|
|
97
|
-
# Need a fixture with two different datastreams for this test to be more effective
|
128
|
+
# Need a fixture with two different datastreams for this test to be more effective
|
98
129
|
let(:mover) { FedoraMigrate::ObjectMover.new(source, ExampleModel::RDFObject.new, {convert: ["descMetadata", "descMetadata"]}) }
|
99
|
-
|
130
|
+
|
100
131
|
subject do
|
101
132
|
mover.migrate
|
102
133
|
mover.target
|
@@ -107,6 +138,19 @@ describe "Migrating an object" do
|
|
107
138
|
end
|
108
139
|
end
|
109
140
|
|
141
|
+
context "with RDF errors" do
|
142
|
+
let(:problem_source) { FedoraMigrate.source.connection.find("scholarsphere:sf2686078") }
|
143
|
+
let(:mover) { FedoraMigrate::ObjectMover.new(problem_source, ExampleModel::RDFObject.new, {convert: "descMetadata"}) }
|
144
|
+
subject do
|
145
|
+
mover.migrate
|
146
|
+
mover.target
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should migrate the content" do
|
150
|
+
expect(subject.title).to eql([" The \"Value Added\" in Editorial Acquisitions.pdf"])
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
110
154
|
end
|
111
155
|
|
112
156
|
end
|
@@ -1,22 +1,47 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Mirating RDF terms" do
|
4
|
+
let(:mover) { FedoraMigrate::RDFDatastreamMover.new(file, ExampleModel::RDFProperties.new) }
|
4
5
|
|
5
|
-
|
6
|
-
FedoraMigrate::RDFDatastreamMover.new(
|
7
|
-
FedoraMigrate.source.connection.find("sufia:xp68km39w").datastreams["descMetadata"],
|
8
|
-
ExampleModel::RDFProperties.new
|
9
|
-
)
|
10
|
-
end
|
6
|
+
context "normal record" do
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
let(:file) { FedoraMigrate.source.connection.find("sufia:xp68km39w").datastreams["descMetadata"] }
|
9
|
+
|
10
|
+
it "should call the before and after hooks when migrating" do
|
11
|
+
expect(mover).to receive(:before_rdf_datastream_migration)
|
12
|
+
expect(mover).to receive(:after_rdf_datastream_migration)
|
13
|
+
mover.migrate
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
describe "using triples" do
|
17
|
+
subject do
|
18
|
+
mover.migrate
|
19
|
+
mover.target
|
20
|
+
end
|
21
|
+
|
22
|
+
it "adds each triple to a new Fedora4 resource" do
|
23
|
+
expect(subject.title.first).to eql "Sample Migration Object A"
|
24
|
+
expect(subject.creator.first).to eql "Adam Wead"
|
25
|
+
end
|
26
|
+
end
|
20
27
|
end
|
21
28
|
|
29
|
+
context "record with UTF8 chracters" do
|
30
|
+
|
31
|
+
let(:file) { FedoraMigrate.source.connection.find("scholarsphere:7d279232g").datastreams["descMetadata"] }
|
32
|
+
|
33
|
+
describe "using triples" do
|
34
|
+
subject do
|
35
|
+
mover.migrate
|
36
|
+
mover.target
|
37
|
+
end
|
38
|
+
|
39
|
+
it "adds each triple to a new Fedora4 resource" do
|
40
|
+
expect(subject.title.first).to eql "Emerging Role of Genomic Profiling of Advanced Tumors to Aid in Treatment Selection: What Nurses Should Know"
|
41
|
+
expect(subject.creator.first).to eql "Eileen Bannon, RN, MSN, OCN, CBCN"
|
42
|
+
expect(subject.description.first). to eql "Objectives:\r\n• Explain the role of a new genomic assay (Target Now™) in guiding oncology treatment plans.\r\n• Describe the Target Now™ assay.\r\n• Present a case study where Target Now™ was instrumental in the patient’s treatment plan."
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
22
47
|
end
|
@@ -4,7 +4,7 @@ describe "Migrating objects with relationships" do
|
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
class GenericFile < ActiveFedora::Base
|
7
|
-
belongs_to :batch, predicate: ActiveFedora::RDF::RelsExt.isPartOf
|
7
|
+
belongs_to :batch, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
8
8
|
property :title, predicate: ::RDF::DC.title do |index|
|
9
9
|
index.as :stored_searchable, :facetable
|
10
10
|
end
|
@@ -14,14 +14,14 @@ describe "Migrating objects with relationships" do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class Batch < ActiveFedora::Base
|
17
|
-
has_many :generic_files, predicate: ActiveFedora::RDF::RelsExt.isPartOf
|
17
|
+
has_many :generic_files, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
after :all do
|
22
22
|
Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
let(:parent_source) { FedoraMigrate.source.connection.find("sufia:rb68xc09k") }
|
26
26
|
let(:child_source) { FedoraMigrate.source.connection.find("sufia:rb68xc11m") }
|
27
27
|
|
@@ -32,18 +32,19 @@ describe "Migrating objects with relationships" do
|
|
32
32
|
FedoraMigrate::ObjectMover.new(child_source).migrate
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
subject { Batch.find("rb68xc09k") }
|
36
36
|
|
37
|
+
describe "migrating the parent object's relationships" do
|
37
38
|
before do
|
38
39
|
FedoraMigrate::RelsExtDatastreamMover.new(child_source).migrate
|
39
40
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
specify "
|
41
|
+
specify "should connect the child to the parent" do
|
42
|
+
expect(subject.generic_files.count).to eql 1
|
43
|
+
end
|
44
|
+
specify "is repeatable" do
|
45
|
+
FedoraMigrate::RelsExtDatastreamMover.new(child_source).migrate
|
44
46
|
expect(subject.generic_files.count).to eql 1
|
45
47
|
end
|
46
|
-
|
47
48
|
end
|
48
49
|
|
49
50
|
end
|
@@ -7,23 +7,21 @@ describe "Migrating the repository" do
|
|
7
7
|
before do
|
8
8
|
Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
|
9
9
|
Object.send(:remove_const, :Batch) if defined?(Batch)
|
10
|
+
Object.send(:remove_const, :Collection) if defined?(Collection)
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
it "should log warnings" do
|
14
|
+
expect(FedoraMigrate::Logger).to receive(:warn).at_least(6).times
|
15
|
+
FedoraMigrate.migrate_repository(namespace: "sufia", options: {convert: "descMetadata"})
|
15
16
|
end
|
16
|
-
it { is_expected.to include("uninitialized constant GenericFile")}
|
17
|
-
it { is_expected.to include("uninitialized constant Batch")}
|
18
|
-
it { is_expected.to include("Source was not found in Fedora4. Did you migrated it?")}
|
19
17
|
end
|
20
18
|
|
21
|
-
context "
|
19
|
+
context "when all target objects are defined" do
|
22
20
|
|
23
21
|
before do
|
24
22
|
Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
|
25
23
|
class GenericFile < ExampleModel::MigrationObject
|
26
|
-
belongs_to :batch, predicate: ActiveFedora::RDF::RelsExt.isPartOf
|
24
|
+
belongs_to :batch, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
27
25
|
property :title, predicate: ::RDF::DC.title do |index|
|
28
26
|
index.as :stored_searchable, :facetable
|
29
27
|
end
|
@@ -32,28 +30,57 @@ describe "Migrating the repository" do
|
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
35
|
-
Object.send(:remove_const, :Batch) if defined?(Batch)
|
33
|
+
Object.send(:remove_const, :Batch) if defined?(Batch)
|
36
34
|
class Batch < ActiveFedora::Base
|
37
|
-
has_many :generic_files, predicate: ActiveFedora::RDF::RelsExt.isPartOf
|
35
|
+
has_many :generic_files, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
36
|
+
end
|
37
|
+
|
38
|
+
Object.send(:remove_const, :Collection) if defined?(Collection)
|
39
|
+
class Collection < ExampleModel::Collection
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
43
|
after do
|
42
44
|
Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
|
43
45
|
Object.send(:remove_const, :Batch) if defined?(Batch)
|
46
|
+
Object.send(:remove_const, :Collection) if defined?(Collection)
|
44
47
|
end
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
let(:file1) { GenericFile.find("rb68xc089") }
|
50
|
+
let(:file2) { GenericFile.find("xp68km39w") }
|
51
|
+
let(:versions_report) { GenericFile.all.map { |f| f.content.versions.count }.uniq }
|
52
|
+
|
53
|
+
context "by default" do
|
54
|
+
before do
|
55
|
+
FedoraMigrate.migrate_repository(namespace: "sufia", options: {convert: "descMetadata"})
|
56
|
+
end
|
57
|
+
it "should move every object and its versions" do
|
58
|
+
expect(file1.title).to eql ["world.png"]
|
59
|
+
expect(file2.title).to eql ["Sample Migration Object A"]
|
60
|
+
expect(file2.creator).to eql ["Adam Wead"]
|
61
|
+
expect(GenericFile.all.count).to eql 6
|
62
|
+
expect(Batch.all.count).to eql 2
|
63
|
+
expect(Batch.all.first.generic_files.count).to eql 2
|
64
|
+
expect(Batch.all.last.generic_files.count).to eql 2
|
65
|
+
expect(Collection.all.count).to eql 1
|
66
|
+
expect(Collection.first.members.count).to eql 2
|
67
|
+
expect(versions_report).to match_array [0,3,9]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "and the application will create versions" do
|
72
|
+
before do
|
73
|
+
FedoraMigrate.migrate_repository(namespace: "sufia",
|
74
|
+
options: {convert: "descMetadata", application_creates_versions: true}
|
75
|
+
)
|
76
|
+
end
|
77
|
+
it "should move every object but not its versions" do
|
78
|
+
expect(file1.title).to eql ["world.png"]
|
79
|
+
expect(versions_report).to eql [0]
|
80
|
+
end
|
55
81
|
end
|
56
82
|
|
57
83
|
end
|
58
84
|
|
59
85
|
end
|
86
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Versions" do
|
4
|
+
|
5
|
+
let(:source) { FedoraMigrate.source.connection.find("sufia:rb68xc089") }
|
6
|
+
let(:mover) { FedoraMigrate::ObjectMover.new source, ExampleModel::MigrationObject.new }
|
7
|
+
|
8
|
+
subject do
|
9
|
+
mover.migrate
|
10
|
+
mover.target
|
11
|
+
end
|
12
|
+
|
13
|
+
# Query the metadata node for a given version and return its hasDateCreatedByApplication expressed as an integer
|
14
|
+
def date_created_by_application version
|
15
|
+
uri = subject.content.versions.with_label(version).uri
|
16
|
+
response = ActiveFedora.fedora.connection.get(uri+"/fcr:metadata")
|
17
|
+
graph = ::RDF::Graph.new << ::RDF::Reader.for(:ttl).new(response.body)
|
18
|
+
value = graph.query(predicate: RDF::URI("http://www.loc.gov/premis/rdf/v1#hasDateCreatedByApplication")).first.object.to_s
|
19
|
+
DateTime.iso8601(value).to_i
|
20
|
+
end
|
21
|
+
|
22
|
+
def desc_metadata_source_versions
|
23
|
+
source.datastreams["descMetadata"].versions.sort { |a,b| a.createDate <=> b.createDate }
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be migrated in the order they were created with their original creation dates" do
|
27
|
+
expect(desc_metadata_source_versions[0].createDate.to_i).to eql date_created_by_application("version1")
|
28
|
+
expect(desc_metadata_source_versions[1].createDate.to_i).to eql date_created_by_application("version2")
|
29
|
+
expect(desc_metadata_source_versions[2].createDate.to_i).to eql date_created_by_application("version3")
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
require 'byebug' unless ENV['TRAVIS']
|
2
|
+
ENV['RAILS_ENV'] = "test"
|
3
|
+
|
2
4
|
require 'fedora-migrate'
|
3
5
|
require 'equivalent-xml/rspec_matchers'
|
4
6
|
require 'support/example_model'
|
5
7
|
require 'active_fedora/cleaner'
|
6
|
-
ENV['environment'] = "test"
|
7
8
|
|
9
|
+
require 'http_logger'
|
8
10
|
ActiveFedora::Base.logger = Logger.new(STDERR)
|
9
11
|
ActiveFedora::Base.logger.level = Logger::WARN
|
10
12
|
|
13
|
+
# HttpLogger.logger = Logger.new(STDOUT)
|
14
|
+
# HttpLogger.ignore = [/(127\.0\.0\.1|localhost):8983\/solr/]
|
15
|
+
# HttpLogger.colorize = false
|
16
|
+
# HttpLogger.log_headers = true
|
17
|
+
|
11
18
|
RSpec.configure do |config|
|
12
19
|
config.expect_with :rspec do |expectations|
|
13
20
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
@@ -1,3 +1,34 @@
|
|
1
|
+
# Shenanigans because we're not in a Rails environment and we need to load bits of
|
2
|
+
# code that depend on Rails in order to test migrating objects.
|
3
|
+
Hydra::Engine.config.autoload_paths.each { |path| $LOAD_PATH.unshift path }
|
4
|
+
# in gem version 2.4, .find_by_name isn't pulling up gems given in the Gemfile
|
5
|
+
# as opposed to those in the gemspec file.
|
6
|
+
# This is a workaround:
|
7
|
+
Gem::Specification.all.each do |g|
|
8
|
+
HAC_DIR = g.gem_dir if g.name.match("hydra-access-controls")
|
9
|
+
HCL_DIR = g.gem_dir if g.name.match("hydra-collections")
|
10
|
+
HCR_DIR = g.gem_dir if g.name.match("hydra-core")
|
11
|
+
end
|
12
|
+
|
13
|
+
# Load Rails-specific bits of hydra-access-controls
|
14
|
+
require HAC_DIR+'/app/vocabularies/acl'
|
15
|
+
require HAC_DIR+'/app/vocabularies/hydra/acl'
|
16
|
+
require HAC_DIR+'/app/models/role_mapper'
|
17
|
+
require HAC_DIR+'/app/models/ability'
|
18
|
+
require HAC_DIR+'/app/models/hydra/access_controls/access_control_list'
|
19
|
+
require HAC_DIR+'/app/models/hydra/access_controls/permission'
|
20
|
+
require HAC_DIR+'/app/models/hydra/access_controls/embargo'
|
21
|
+
require HAC_DIR+'/app/models/hydra/access_controls/lease'
|
22
|
+
require HAC_DIR+'/app/models/concerns/hydra/with_depositor'
|
23
|
+
require HAC_DIR+'/app/services/hydra/lease_service'
|
24
|
+
require HAC_DIR+'/app/services/hydra/embargo_service'
|
25
|
+
require HAC_DIR+'/app/validators/hydra/future_date_validator'
|
26
|
+
|
27
|
+
# Loading hydra-collections
|
28
|
+
require 'hydra-collections'
|
29
|
+
require HCR_DIR+'/app/models/concerns/hydra/model_methods'
|
30
|
+
require HCL_DIR+'/app/models/concerns/hydra/collection'
|
31
|
+
|
1
32
|
module ExampleModel
|
2
33
|
|
3
34
|
class RDFProperties < ActiveFedora::Base
|
@@ -7,6 +38,10 @@ module ExampleModel
|
|
7
38
|
property :creator, predicate: ::RDF::DC.creator do |index|
|
8
39
|
index.as :stored_searchable, :facetable
|
9
40
|
end
|
41
|
+
property :description, predicate: ::RDF::DC.description do |index|
|
42
|
+
index.type :text
|
43
|
+
index.as :stored_searchable
|
44
|
+
end
|
10
45
|
end
|
11
46
|
|
12
47
|
class VersionedDatastream < ActiveFedora::File
|
@@ -24,13 +59,34 @@ module ExampleModel
|
|
24
59
|
contains "characterization", class_name: "ActiveFedora::File"
|
25
60
|
end
|
26
61
|
|
62
|
+
class OmDatastreamExample < ActiveFedora::Base
|
63
|
+
contains "characterization", class_name: "ActiveFedora::OmDatastream"
|
64
|
+
end
|
65
|
+
|
27
66
|
class RDFObject < ActiveFedora::Base
|
28
67
|
property :title, predicate: ::RDF::DC.title do |index|
|
29
68
|
index.as :stored_searchable, :facetable
|
30
69
|
end
|
70
|
+
|
71
|
+
property :description, predicate: ::RDF::DC.description
|
72
|
+
|
73
|
+
property :date_uploaded, predicate: ::RDF::DC.dateSubmitted, multiple: false do |index|
|
74
|
+
index.type :date
|
75
|
+
index.as :stored_sortable
|
76
|
+
end
|
77
|
+
|
78
|
+
property :date_modified, predicate: ::RDF::DC.modified, multiple: false do |index|
|
79
|
+
index.type :date
|
80
|
+
index.as :stored_sortable
|
81
|
+
end
|
82
|
+
|
31
83
|
contains "content", class_name: "ExampleModel::VersionedDatastream"
|
32
84
|
contains "thumbnail", class_name: "ActiveFedora::File"
|
33
85
|
contains "characterization", class_name: "ActiveFedora::File"
|
34
86
|
end
|
35
87
|
|
88
|
+
class Collection < ActiveFedora::Base
|
89
|
+
include Hydra::Collection
|
90
|
+
end
|
91
|
+
|
36
92
|
end
|