zizia 3.1.0.alpha.01 → 4.0.0.alpha.01
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -3
- data/lib/zizia/engine.rb +8 -0
- data/lib/zizia/{hyrax_basic_metadata_mapper.rb → hyrax/hyrax_basic_metadata_mapper.rb} +0 -0
- data/lib/zizia/hyrax/hyrax_default_updater.rb +11 -0
- data/lib/zizia/hyrax/hyrax_delete_files_updater.rb +16 -0
- data/lib/zizia/hyrax/hyrax_metadata_only_updater.rb +58 -0
- data/lib/zizia/{hyrax_record_importer.rb → hyrax/hyrax_record_importer.rb} +45 -56
- data/lib/zizia/{metadata_only_stack.rb → hyrax/metadata_only_stack.rb} +0 -0
- data/lib/zizia/version.rb +1 -1
- data/lib/zizia.rb +6 -3
- metadata +371 -213
- data/.circleci/config.yml +0 -44
- data/.gitignore +0 -16
- data/.rubocop.yml +0 -81
- data/.rubocop_todo.yml +0 -21
- data/.solr_wrapper +0 -8
- data/.travis.yml +0 -12
- data/Gemfile +0 -14
- data/Rakefile +0 -38
- data/app/assets/config/zizia_manifest.js +0 -2
- data/app/assets/images/zizia/.keep +0 -0
- data/app/assets/javascripts/zizia/DisplayUploadedFile.es6 +0 -43
- data/app/assets/javascripts/zizia/application.js +0 -13
- data/app/assets/javascripts/zizia/zizia.js +0 -6
- data/app/assets/stylesheets/zizia/_file_upload.scss +0 -17
- data/app/assets/stylesheets/zizia/application.css +0 -15
- data/app/assets/stylesheets/zizia/zizia.scss +0 -1
- data/app/controllers/zizia/application_controller.rb +0 -6
- data/app/controllers/zizia/csv_imports_controller.rb +0 -53
- data/app/controllers/zizia/importer_documentation_controller.rb +0 -11
- data/app/helpers/importer_documentation_helper.rb +0 -13
- data/app/helpers/zizia/application_helper.rb +0 -14
- data/app/importers/modular_importer.rb +0 -31
- data/app/jobs/zizia/application_job.rb +0 -5
- data/app/jobs/zizia/start_csv_import_job.rb +0 -14
- data/app/models/zizia/application_record.rb +0 -6
- data/app/models/zizia/csv_import.rb +0 -21
- data/app/models/zizia/csv_import_detail.rb +0 -13
- data/app/models/zizia/pre_ingest_file.rb +0 -6
- data/app/models/zizia/pre_ingest_work.rb +0 -6
- data/app/uploaders/zizia/csv_manifest_uploader.rb +0 -62
- data/app/uploaders/zizia/csv_manifest_validator.rb +0 -163
- data/app/views/layouts/zizia/application.html.erb +0 -14
- data/app/views/zizia/csv_imports/_actions.html.erb +0 -3
- data/app/views/zizia/csv_imports/_collection_selection.html.erb +0 -3
- data/app/views/zizia/csv_imports/_error.html.erb +0 -10
- data/app/views/zizia/csv_imports/_file_upload.html.erb +0 -3
- data/app/views/zizia/csv_imports/_form.html.erb +0 -75
- data/app/views/zizia/csv_imports/_no_collection.html.erb +0 -7
- data/app/views/zizia/csv_imports/_record_count.html.erb +0 -7
- data/app/views/zizia/csv_imports/_start_import_form.html.erb +0 -9
- data/app/views/zizia/csv_imports/index.html.erb +0 -21
- data/app/views/zizia/csv_imports/new.html.erb +0 -2
- data/app/views/zizia/csv_imports/preview.html.erb +0 -76
- data/app/views/zizia/csv_imports/show.html.erb +0 -31
- data/app/views/zizia/importer_documentation/guide.html.erb +0 -1
- data/bin/rails +0 -15
- data/config/routes.rb +0 -9
- data/db/migrate/201901162141281_create_zizia_csv_imports.rb +0 -10
- data/db/migrate/201901162203121_add_manifest_to_zizia_csv_imports.rb +0 -6
- data/db/migrate/201901241536541_add_fedora_collection_id_to_zizia_csv_imports.rb +0 -5
- data/db/migrate/20190911133657_create_zizia_pre_ingest_files.rb +0 -12
- data/db/migrate/20190911134002_create_zizia_pre_ingest_works.rb +0 -9
- data/db/migrate/20190911142616_create_zizia_csv_import_details.rb +0 -8
- data/docs/_config.yml +0 -1
- data/docs/customizing_metadata.md +0 -41
- data/docs/index.md +0 -113
- data/log/.keep +0 -0
- 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/routes.rb +0 -9
- data/solr/config/schema.xml +0 -366
- data/solr/config/scripts.conf +0 -24
- data/solr/config/solrconfig.xml +0 -322
- 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/controllers/importer_documentation_controller_spec.rb +0 -14
- data/spec/dummy/.gitignore +0 -23
- data/spec/dummy/Gemfile +0 -57
- data/spec/dummy/README.md +0 -24
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/config/manifest.js +0 -3
- data/spec/dummy/app/assets/csv/import_manifest.csv +0 -1
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/javascripts/cable.js +0 -13
- data/spec/dummy/app/assets/javascripts/channels/.keep +0 -0
- data/spec/dummy/app/assets/markdown/importer_guide.md +0 -256
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
- data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/jobs/application_job.rb +0 -2
- data/spec/dummy/app/mailers/application_mailer.rb +0 -4
- data/spec/dummy/app/models/application_record.rb +0 -3
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/user.rb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -9
- data/spec/dummy/bin/rake +0 -9
- data/spec/dummy/bin/setup +0 -38
- data/spec/dummy/bin/spring +0 -17
- data/spec/dummy/bin/update +0 -29
- data/spec/dummy/bin/yarn +0 -11
- data/spec/dummy/config/application.rb +0 -18
- data/spec/dummy/config/boot.rb +0 -3
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -54
- data/spec/dummy/config/environments/production.rb +0 -91
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/spec/dummy/config/initializers/assets.rb +0 -14
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -33
- data/spec/dummy/config/puma.rb +0 -56
- data/spec/dummy/config/routes.rb +0 -4
- data/spec/dummy/config/secrets.yml +0 -32
- data/spec/dummy/config/spring.rb +0 -6
- data/spec/dummy/config.ru +0 -5
- data/spec/dummy/db/migrate/20190911165049_create_users.rb +0 -8
- data/spec/dummy/db/schema.rb +0 -55
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/package.json +0 -5
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +0 -1
- data/spec/dummy/test/application_system_test_case.rb +0 -5
- data/spec/dummy/test/controllers/.keep +0 -0
- data/spec/dummy/test/fixtures/.keep +0 -0
- data/spec/dummy/test/fixtures/files/.keep +0 -0
- data/spec/dummy/test/fixtures/users.yml +0 -11
- data/spec/dummy/test/helpers/.keep +0 -0
- data/spec/dummy/test/integration/.keep +0 -0
- data/spec/dummy/test/mailers/.keep +0 -0
- data/spec/dummy/test/models/.keep +0 -0
- data/spec/dummy/test/models/user_test.rb +0 -7
- data/spec/dummy/test/system/.keep +0 -0
- data/spec/dummy/test/test_helper.rb +0 -10
- data/spec/dummy/vendor/.keep +0 -0
- data/spec/fixtures/bad_example.csv +0 -2
- data/spec/fixtures/dog.jpg +0 -0
- data/spec/fixtures/example.csv +0 -4
- data/spec/fixtures/hyrax/example.csv +0 -3
- data/spec/fixtures/images/animals/cat.png +0 -0
- data/spec/fixtures/images/zizia.png +0 -0
- data/spec/fixtures/zizia.png +0 -0
- data/spec/integration/csv_import_detail_spec.rb +0 -48
- data/spec/integration/import_csv_spec.rb +0 -27
- data/spec/integration/import_hyrax_csv.rb +0 -71
- data/spec/models/csv_import_spec.rb +0 -18
- data/spec/spec_helper.rb +0 -31
- data/spec/support/hyrax/basic_metadata.rb +0 -30
- data/spec/support/hyrax/core_metadata.rb +0 -15
- data/spec/support/shared_contexts/with_work_type.rb +0 -101
- data/spec/uploaders/csv_manifest_uploader_spec.rb +0 -30
- data/spec/views/zizia/importer_documentation/guide.html.erb_spec.rb +0 -13
- data/spec/zizia/csv_format_validator_spec.rb +0 -38
- data/spec/zizia/csv_parser_spec.rb +0 -73
- data/spec/zizia/csv_template_spec.rb +0 -15
- data/spec/zizia/hash_mapper_spec.rb +0 -8
- data/spec/zizia/hyrax_basic_metadata_mapper_spec.rb +0 -190
- data/spec/zizia/hyrax_record_importer_spec.rb +0 -176
- data/spec/zizia/importer_spec.rb +0 -46
- data/spec/zizia/input_record_spec.rb +0 -71
- data/spec/zizia/record_importer_spec.rb +0 -53
- data/spec/zizia/title_validator_spec.rb +0 -23
- data/spec/zizia/validator_spec.rb +0 -9
- data/spec/zizia/version_spec.rb +0 -7
- data/spec/zizia_spec.rb +0 -20
- data/zizia.gemspec +0 -42
@@ -1,190 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Zizia::HyraxBasicMetadataMapper do
|
5
|
-
let(:mapper) { described_class.new }
|
6
|
-
|
7
|
-
# Properties defined in Hyrax::CoreMetadata
|
8
|
-
let(:core_fields) do
|
9
|
-
[:depositor, :title, :date_modified]
|
10
|
-
end
|
11
|
-
|
12
|
-
# Properties defined in Hyrax::BasicMetadata
|
13
|
-
let(:basic_fields) do
|
14
|
-
[:label, :relative_path, :import_url,
|
15
|
-
:resource_type, :creator, :contributor,
|
16
|
-
:description, :keyword, :license,
|
17
|
-
:rights_statement, :publisher, :date_created,
|
18
|
-
:subject, :language, :identifier, :based_near,
|
19
|
-
:related_url, :bibliographic_citation, :source]
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:tenejo_fields) do
|
23
|
-
[:visibility]
|
24
|
-
end
|
25
|
-
|
26
|
-
it_behaves_like 'a Zizia::Mapper' do
|
27
|
-
let(:metadata) do
|
28
|
-
{ title: ['A Title for a Record'],
|
29
|
-
my_custom_field: ['This gets ignored'] }
|
30
|
-
end
|
31
|
-
let(:expected_fields) { core_fields + basic_fields + tenejo_fields }
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'with metadata, but some missing fields' do
|
35
|
-
before { mapper.metadata = metadata }
|
36
|
-
let(:metadata) do
|
37
|
-
{ 'depositor' => 'someone@example.org',
|
38
|
-
'title' => 'A Title',
|
39
|
-
'language' => 'English' }
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'provides methods for the fields, even fields that aren\'t included in the metadata' do
|
43
|
-
expect(metadata).to include('title')
|
44
|
-
expect(mapper).to respond_to(:title)
|
45
|
-
|
46
|
-
expect(metadata).not_to include('label')
|
47
|
-
expect(mapper).to respond_to(:label)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'returns single values for single-value fields' do
|
51
|
-
expect(mapper.depositor).to eq 'someone@example.org'
|
52
|
-
expect(mapper.date_modified).to eq nil
|
53
|
-
expect(mapper.label).to eq nil
|
54
|
-
expect(mapper.relative_path).to eq nil
|
55
|
-
expect(mapper.import_url).to eq nil
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'returns array values for multi-value fields' do
|
59
|
-
expect(mapper.title).to eq ['A Title']
|
60
|
-
expect(mapper.language).to eq ['English']
|
61
|
-
expect(mapper.keyword).to eq []
|
62
|
-
expect(mapper.subject).to eq []
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'fields with multiple values' do
|
67
|
-
before { mapper.metadata = metadata }
|
68
|
-
let(:metadata) do
|
69
|
-
{ 'title' => 'A Title',
|
70
|
-
'language' => 'English|~|French|~|Japanese' }
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'splits the values using the delimiter' do
|
74
|
-
expect(mapper.title).to eq ['A Title']
|
75
|
-
expect(mapper.language).to eq ['English', 'French', 'Japanese']
|
76
|
-
expect(mapper.keyword).to eq []
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'can set a different delimiter' do
|
80
|
-
expect(mapper.delimiter).to eq '|~|'
|
81
|
-
mapper.delimiter = 'ಠ_ಠ'
|
82
|
-
expect(mapper.delimiter).to eq 'ಠ_ಠ'
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe 'lenient headers' do
|
87
|
-
context 'headers with capital letters' do
|
88
|
-
before { mapper.metadata = metadata }
|
89
|
-
let(:metadata) do
|
90
|
-
{ 'Title' => 'A Title',
|
91
|
-
'Related URL' => 'http://example.com',
|
92
|
-
'Abstract or Summary' => 'desc1|~|desc2',
|
93
|
-
'visiBILITY' => 'open',
|
94
|
-
'Depositor' => 'someone@example.org',
|
95
|
-
'DATE_modified' => 'mod date',
|
96
|
-
'laBel' => 'label',
|
97
|
-
'relative_PATH' => 'rel path',
|
98
|
-
'import_URL' => 'imp url' }
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'matches the correct fields' do
|
102
|
-
expect(mapper.title).to eq ['A Title']
|
103
|
-
expect(mapper.related_url).to eq ['http://example.com']
|
104
|
-
expect(mapper.description).to eq ['desc1', 'desc2']
|
105
|
-
expect(mapper.creator).to eq []
|
106
|
-
expect(mapper.visibility).to eq 'open'
|
107
|
-
expect(mapper.depositor).to eq 'someone@example.org'
|
108
|
-
expect(mapper.date_modified).to eq 'mod date'
|
109
|
-
expect(mapper.label).to eq 'label'
|
110
|
-
expect(mapper.relative_path).to eq 'rel path'
|
111
|
-
expect(mapper.import_url).to eq 'imp url'
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context 'headers with sloppy whitespace' do
|
116
|
-
before { mapper.metadata = metadata }
|
117
|
-
let(:metadata) do
|
118
|
-
{ ' Title ' => 'A Title',
|
119
|
-
" Related URL \n " => 'http://example.com',
|
120
|
-
' visiBILITY ' => 'open' }
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'matches the correct fields' do
|
124
|
-
expect(mapper.title).to eq ['A Title']
|
125
|
-
expect(mapper.related_url).to eq ['http://example.com']
|
126
|
-
expect(mapper.visibility).to eq 'open'
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context 'Visibility values in the CSV should match the Edit UI' do
|
131
|
-
load File.expand_path("../../support/shared_contexts/with_work_type.rb", __FILE__)
|
132
|
-
include_context 'with a work type'
|
133
|
-
context 'public is a synonym for open' do
|
134
|
-
before { mapper.metadata = metadata }
|
135
|
-
let(:metadata) do
|
136
|
-
{ ' Title ' => 'A Title',
|
137
|
-
" Related URL \n " => 'http://example.com',
|
138
|
-
' visiBILITY ' => 'PubLIC' }
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'transforms public to open regardless of capitalization' do
|
142
|
-
expect(mapper.title).to eq ['A Title']
|
143
|
-
expect(mapper.related_url).to eq ['http://example.com']
|
144
|
-
expect(mapper.visibility).to eq 'open'
|
145
|
-
end
|
146
|
-
end
|
147
|
-
context 'institution name is a synonym for authenticated' do
|
148
|
-
before { mapper.metadata = metadata }
|
149
|
-
let(:metadata) do
|
150
|
-
{ ' Title ' => 'A Title',
|
151
|
-
" Related URL \n " => 'http://example.com',
|
152
|
-
' visiBILITY ' => 'my_institution' }
|
153
|
-
end
|
154
|
-
|
155
|
-
it 'transforms institution name to authenticated regardless of capitalization' do
|
156
|
-
expect(mapper.title).to eq ['A Title']
|
157
|
-
expect(mapper.related_url).to eq ['http://example.com']
|
158
|
-
expect(mapper.visibility).to eq 'authenticated'
|
159
|
-
end
|
160
|
-
end
|
161
|
-
context 'full institution name is a synonym for authenticated' do
|
162
|
-
before { mapper.metadata = metadata }
|
163
|
-
let(:metadata) do
|
164
|
-
{ ' Title ' => 'A Title',
|
165
|
-
" Related URL \n " => 'http://example.com',
|
166
|
-
' visiBILITY ' => 'my full institution name' }
|
167
|
-
end
|
168
|
-
|
169
|
-
it 'transforms full institution name to authenticated regardless of capitalization' do
|
170
|
-
expect(mapper.title).to eq ['A Title']
|
171
|
-
expect(mapper.related_url).to eq ['http://example.com']
|
172
|
-
expect(mapper.visibility).to eq 'authenticated'
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
# When someone accidentally has too many commas in the CSV rows
|
178
|
-
context 'headers with a nil' do
|
179
|
-
before { mapper.metadata = metadata }
|
180
|
-
let(:metadata) do
|
181
|
-
{ ' Title ' => 'A Title',
|
182
|
-
nil => nil }
|
183
|
-
end
|
184
|
-
|
185
|
-
it 'doesn\'t raise an error for missing fields' do
|
186
|
-
expect(mapper.depositor).to eq nil
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
@@ -1,176 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Zizia::HyraxRecordImporter, :clean do
|
5
|
-
subject(:importer) do
|
6
|
-
described_class.new
|
7
|
-
end
|
8
|
-
|
9
|
-
load File.expand_path("../../support/shared_contexts/with_work_type.rb", __FILE__)
|
10
|
-
include_context 'with a work type'
|
11
|
-
|
12
|
-
let(:record) { Zizia::InputRecord.from(metadata: metadata) }
|
13
|
-
|
14
|
-
context 'collection id' do
|
15
|
-
subject(:importer) do
|
16
|
-
described_class.new(attributes: { collection_id: collection_id })
|
17
|
-
end
|
18
|
-
let(:collection_id) { '123' }
|
19
|
-
|
20
|
-
it 'can have a collection id' do
|
21
|
-
expect(importer.collection_id).to eq collection_id
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'with no attached files' do
|
26
|
-
let(:metadata) do
|
27
|
-
{
|
28
|
-
'title' => 'A Title',
|
29
|
-
'language' => 'English',
|
30
|
-
'visibility' => 'open'
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'creates a work for record' do
|
35
|
-
expect { importer.import(record: record) }
|
36
|
-
.to change { Work.count }
|
37
|
-
.by 1
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Instead of having a files field in the mapper, which will create a
|
42
|
-
# Hyrax::UploadedFile for each file before attaching it, some importers will
|
43
|
-
# use a remote_files strategy and instead treat each file as a remote file and
|
44
|
-
# fetch it at object creation time. This might be faster, and we might eventually
|
45
|
-
# want to adopt it as our default. For now, do not raise an error if there is no
|
46
|
-
# `files` field in the mapper being used.
|
47
|
-
context 'with no files filed in the mapper' do
|
48
|
-
let(:metadata) do
|
49
|
-
{
|
50
|
-
'title' => 'A Title',
|
51
|
-
'language' => 'English',
|
52
|
-
'visibility' => 'open'
|
53
|
-
}
|
54
|
-
end
|
55
|
-
let(:record) { Zizia::InputRecord.from(metadata: metadata, mapper: Zizia::MetadataMapper.new) }
|
56
|
-
|
57
|
-
it 'creates a work for record' do
|
58
|
-
expect { importer.import(record: record) }
|
59
|
-
.to change { Work.count }
|
60
|
-
.by 1
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'with attached files' do
|
65
|
-
before do
|
66
|
-
ENV['IMPORT_PATH'] = File.expand_path('../fixtures/images', File.dirname(__FILE__))
|
67
|
-
end
|
68
|
-
let(:metadata) do
|
69
|
-
{
|
70
|
-
'title' => 'A Title',
|
71
|
-
'language' => 'English',
|
72
|
-
'visibility' => 'open',
|
73
|
-
'files' => 'zizia.png|~|cat.png'
|
74
|
-
}
|
75
|
-
end
|
76
|
-
it 'finds a file even if it is in a subdirectory' do
|
77
|
-
expect(importer.find_file_path('cat.png')).to eq "#{ENV['IMPORT_PATH']}/animals/cat.png"
|
78
|
-
end
|
79
|
-
it 'creates a work for record' do
|
80
|
-
expect { importer.import(record: record) }
|
81
|
-
.to change { Work.count }
|
82
|
-
.by 1
|
83
|
-
end
|
84
|
-
it 'makes an uploaded file object for each file attachment' do
|
85
|
-
expect { importer.import(record: record) }
|
86
|
-
.to change { Hyrax::UploadedFile.count }
|
87
|
-
.by 2
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'with attached files, alternate capitalization and whitespace in "files" header' do
|
92
|
-
before do
|
93
|
-
ENV['IMPORT_PATH'] = File.expand_path('../fixtures/images', File.dirname(__FILE__))
|
94
|
-
end
|
95
|
-
let(:metadata) do
|
96
|
-
{
|
97
|
-
'title' => 'A Title',
|
98
|
-
'visibility' => 'open',
|
99
|
-
' Files' => 'zizia.png|~|cat.png'
|
100
|
-
}
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'makes an uploaded file object for each file attachment' do
|
104
|
-
expect { importer.import(record: record) }
|
105
|
-
.to change { Hyrax::UploadedFile.count }
|
106
|
-
.by 2
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'with missing files' do
|
111
|
-
before do
|
112
|
-
ENV['IMPORT_PATH'] = File.expand_path('../fixtures/images', File.dirname(__FILE__))
|
113
|
-
end
|
114
|
-
it 'raises an exception' do
|
115
|
-
expect { importer.find_file_path('foo.png') }.to raise_exception(RuntimeError)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe '#set_depositor' do
|
120
|
-
let(:metadata) { { 'title' => 'A Title' } }
|
121
|
-
|
122
|
-
context 'when no depositor is set' do
|
123
|
-
it 'sets the Hyrax default batch user' do
|
124
|
-
expect(importer.depositor.user_key).to eq 'batchuser@example.com'
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
context 'when depositor is passed to initializer' do
|
129
|
-
subject(:importer) { described_class.new(attributes: { depositor_id: user.user_key }) }
|
130
|
-
|
131
|
-
let(:user) { ::User.new(id: '123', user_key: 'special_user@example.com') }
|
132
|
-
before { allow(::User).to receive(:find).and_return(user) }
|
133
|
-
|
134
|
-
it 'sets it to the passed-in depositor' do
|
135
|
-
expect(importer.depositor.user_key).to eq 'special_user@example.com'
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
context 'when depositor is set in metadata' do
|
140
|
-
let(:metadata) do
|
141
|
-
{ 'title' => 'A Title',
|
142
|
-
'Depositor' => 'metadata_user@example.com' }
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'sets the Hyrax default batch user' do
|
146
|
-
expect(importer.depositor.user_key).to eq 'batchuser@example.com'
|
147
|
-
# TODO: expect(importer.depositor.user_key).to eq 'metadata_user@example.com'
|
148
|
-
# The metadata depositor should probably override any passed-in or default depositor.
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
# When submitting location data (a.k.a., the "based near" attribute) via the UI,
|
153
|
-
# Hyrax expects to receive a `based_near_attributes` hash in a specific format.
|
154
|
-
# We need to take geonames urls as provided by the customer and transform them to
|
155
|
-
# mimic what the Hyrax UI would ordinarily produce. These will get turned into
|
156
|
-
# Hyrax::ControlledVocabularies::Location objects upon ingest.
|
157
|
-
context 'with location uris' do
|
158
|
-
let(:based_near) { ['http://www.geonames.org/5667009/montana.html', 'http://www.geonames.org/6252001/united-states.html'] }
|
159
|
-
let(:expected_bn_hash) do
|
160
|
-
{
|
161
|
-
"0" => {
|
162
|
-
"id" => "http://sws.geonames.org/5667009/", "_destroy" => ""
|
163
|
-
},
|
164
|
-
"1" => {
|
165
|
-
"id" => "http://sws.geonames.org/6252001/", "_destroy" => ""
|
166
|
-
}
|
167
|
-
}
|
168
|
-
end
|
169
|
-
it "gets a sws uri from a geonames uri" do
|
170
|
-
expect(importer.uri_to_sws("http://www.geonames.org/6252001/united-states.html")).to eq "http://sws.geonames.org/6252001/"
|
171
|
-
end
|
172
|
-
it 'transforms an array of geonames uris into the expected based_near_attributes hash' do
|
173
|
-
expect(importer.based_near_attributes(based_near)).to eq expected_bn_hash
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
data/spec/zizia/importer_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Zizia::Importer do
|
6
|
-
load File.expand_path("../../support/shared_contexts/with_work_type.rb", __FILE__)
|
7
|
-
include_context 'with a work type'
|
8
|
-
|
9
|
-
subject(:importer) { described_class.new(parser: parser) }
|
10
|
-
let(:parser) { FakeParser.new(file: input) }
|
11
|
-
let(:input) { [{ 'title' => '1' }, { 'title' => '2' }, { 'title' => '3' }] }
|
12
|
-
|
13
|
-
let(:fake_record_importer) do
|
14
|
-
Class.new do
|
15
|
-
attr_accessor :batch_id, :success_count, :failure_count
|
16
|
-
|
17
|
-
def import(record:)
|
18
|
-
records << record.attributes
|
19
|
-
end
|
20
|
-
|
21
|
-
def records
|
22
|
-
@records ||= []
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#records' do
|
28
|
-
it 'reflects the parsed records' do
|
29
|
-
expect(importer.records.map(&:attributes))
|
30
|
-
.to contain_exactly(*parser.records.map(&:attributes))
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#import' do
|
35
|
-
let(:record_importer) { fake_record_importer.new }
|
36
|
-
|
37
|
-
before { importer.record_importer = record_importer }
|
38
|
-
|
39
|
-
it 'sends records to the record importer' do
|
40
|
-
expect { importer.import }
|
41
|
-
.to change { record_importer.records }
|
42
|
-
.from(be_empty)
|
43
|
-
.to a_collection_containing_exactly(*importer.records.map(&:attributes))
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Zizia::InputRecord do
|
6
|
-
load File.expand_path("../../support/shared_contexts/with_work_type.rb", __FILE__)
|
7
|
-
include_context 'with a work type'
|
8
|
-
subject(:record) { described_class.from(metadata: metadata) }
|
9
|
-
|
10
|
-
let(:metadata) do
|
11
|
-
{ 'title' => 'Comet in Moominland',
|
12
|
-
'abstract or summary' => 'A book about moomins.' }
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'defaults to a Hyrax Mapper' do
|
16
|
-
expect(described_class.new).to have_attributes(mapper: an_instance_of(Zizia::HyraxBasicMetadataMapper))
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'has metadata and a mapper' do
|
20
|
-
is_expected
|
21
|
-
.to have_attributes(mapper: an_instance_of(Zizia::HyraxBasicMetadataMapper))
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#attributes' do
|
25
|
-
it 'handles basic text fields' do
|
26
|
-
expect(record.attributes).to include(:title, :description)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'does not include representative_file' do
|
30
|
-
expect(record.attributes).not_to include(:representative_file)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#representative_file' do
|
35
|
-
it 'is nil if mapper does not provide a representative file' do
|
36
|
-
expect(record.representative_file).to be_nil
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when mapper provides representative_file' do
|
40
|
-
let(:representative_file) { :A_DUMMY_FILE }
|
41
|
-
|
42
|
-
before do
|
43
|
-
allow(record.mapper)
|
44
|
-
.to receive(:representative_file)
|
45
|
-
.and_return(representative_file)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'is the file from the mapper' do
|
49
|
-
expect(record.representative_file).to eql representative_file
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe 'mapped fields' do
|
55
|
-
it 'has methods for metadata fields' do
|
56
|
-
expect(record.title).to contain_exactly metadata['title']
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'has methods for additional mapped metadata fields' do
|
60
|
-
expect(record.description).to contain_exactly metadata['abstract or summary']
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'knows it responds to methods for metadata fields' do
|
64
|
-
expect(record).to respond_to :title
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'knows it responds to methods for additional metadata fields' do
|
68
|
-
expect(record).to respond_to :description
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Zizia::RecordImporter, :clean do
|
6
|
-
subject(:importer) do
|
7
|
-
described_class.new
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:record) { Zizia::InputRecord.from(metadata: metadata) }
|
11
|
-
let(:metadata) do
|
12
|
-
{
|
13
|
-
'title' => 'A Title',
|
14
|
-
'language' => 'English',
|
15
|
-
'visibility' => 'open'
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'raises an error when no work type exists' do
|
20
|
-
expect { importer.import(record: record) }
|
21
|
-
.to raise_error 'No curation_concern found for import'
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'with a registered work type' do
|
25
|
-
load File.expand_path("../../support/shared_contexts/with_work_type.rb", __FILE__)
|
26
|
-
include_context 'with a work type'
|
27
|
-
|
28
|
-
it 'creates a work for record' do
|
29
|
-
expect { importer.import(record: record) }
|
30
|
-
.to change { Work.count }
|
31
|
-
.by 1
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when input record errors with LDP errors' do
|
35
|
-
let(:ldp_error) { Ldp::PreconditionFailed }
|
36
|
-
|
37
|
-
before { allow(record).to receive(:attributes).and_raise(ldp_error) }
|
38
|
-
it 'catches the error' do
|
39
|
-
expect { importer.import(record: record) }.not_to raise_error(ldp_error)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'when input record errors unexpectedly' do
|
44
|
-
let(:custom_error) { Class.new(RuntimeError) }
|
45
|
-
|
46
|
-
before { allow(record).to receive(:attributes).and_raise(custom_error) }
|
47
|
-
|
48
|
-
it 'reraises error' do
|
49
|
-
expect { importer.import(record: record) }.to raise_error(custom_error)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Zizia::TitleValidator do
|
6
|
-
subject(:validator) { described_class.new }
|
7
|
-
|
8
|
-
let(:invalid_parser) do
|
9
|
-
FakeParser.new(file: [{ 'title' => 'moomin' }, {}, {}])
|
10
|
-
end
|
11
|
-
|
12
|
-
it_behaves_like 'a Zizia::Validator' do
|
13
|
-
let(:valid_parser) { FakeParser.new(file: [{ 'title' => 'moomin' }]) }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#validate' do
|
17
|
-
it 'populates errors for records with missing titles' do
|
18
|
-
expect(validator.validate(parser: invalid_parser))
|
19
|
-
.to contain_exactly(an_instance_of(described_class::Error),
|
20
|
-
an_instance_of(described_class::Error))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/spec/zizia/version_spec.rb
DELETED
data/spec/zizia_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
class FakeMetadataMapper
|
6
|
-
end
|
7
|
-
|
8
|
-
describe Zizia do
|
9
|
-
describe '#config' do
|
10
|
-
it 'has a default metadata mapper' do
|
11
|
-
expect(described_class.config.metadata_mapper_class).to eq Zizia::HyraxBasicMetadataMapper
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'can set a default metadata mapper' do
|
15
|
-
expect { described_class.config { |c| c.metadata_mapper_class = FakeMetadataMapper } }
|
16
|
-
.to change { described_class.config.metadata_mapper_class }
|
17
|
-
.to(FakeMetadataMapper)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/zizia.gemspec
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
4
|
-
require 'zizia/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |gem|
|
7
|
-
gem.name = 'zizia'
|
8
|
-
gem.version = Zizia::VERSION
|
9
|
-
gem.platform = Gem::Platform::RUBY
|
10
|
-
gem.authors = ['Data Curation Experts']
|
11
|
-
gem.email = ['administrator@curationexperts.com']
|
12
|
-
gem.summary = 'Hyrax importers.'
|
13
|
-
gem.license = 'Apache-2.0'
|
14
|
-
gem.files = %w[AUTHORS CHANGELOG.md README.md LICENSE] +
|
15
|
-
Dir.glob('lib/**/*.rb')
|
16
|
-
gem.require_paths = %w[lib]
|
17
|
-
|
18
|
-
gem.required_ruby_version = '>= 2.3.4'
|
19
|
-
|
20
|
-
gem.add_dependency 'active-fedora'
|
21
|
-
gem.add_dependency 'rails', '~> 5.1.7'
|
22
|
-
gem.add_dependency 'carrierwave'
|
23
|
-
gem.add_dependency 'redcarpet'
|
24
|
-
gem.add_dependency 'sassc-rails'
|
25
|
-
|
26
|
-
gem.add_development_dependency 'yard'
|
27
|
-
gem.add_development_dependency 'bixby'
|
28
|
-
gem.add_development_dependency 'hyrax', '~> 2.5'
|
29
|
-
gem.add_development_dependency 'hyrax-spec'
|
30
|
-
gem.add_development_dependency 'rspec'
|
31
|
-
gem.add_development_dependency 'rspec-rails'
|
32
|
-
gem.add_development_dependency 'rspec_junit_formatter'
|
33
|
-
gem.add_development_dependency 'coveralls'
|
34
|
-
gem.add_development_dependency 'solr_wrapper', '~> 2.1'
|
35
|
-
gem.add_development_dependency 'fcrepo_wrapper', '~> 0.9'
|
36
|
-
gem.add_development_dependency 'byebug'
|
37
|
-
gem.add_development_dependency 'rake'
|
38
|
-
gem.add_development_dependency 'sqlite3'
|
39
|
-
|
40
|
-
gem.files = `git ls-files`.split("\n")
|
41
|
-
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
42
|
-
end
|