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
File without changes
|
File without changes
|
File without changes
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
2
|
-
|
3
|
-
# This model initially had no columns defined. If you add columns to the
|
4
|
-
# model remove the '{}' from the fixture names and add the columns immediately
|
5
|
-
# below each fixture, per the syntax in the comments below
|
6
|
-
#
|
7
|
-
one: {}
|
8
|
-
# column: value
|
9
|
-
#
|
10
|
-
two: {}
|
11
|
-
# column: value
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,10 +0,0 @@
|
|
1
|
-
ENV['RAILS_ENV'] ||= 'test'
|
2
|
-
require File.expand_path('../../config/environment', __FILE__)
|
3
|
-
require 'rails/test_help'
|
4
|
-
|
5
|
-
class ActiveSupport::TestCase
|
6
|
-
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
7
|
-
fixtures :all
|
8
|
-
|
9
|
-
# Add more helper methods to be used by all tests here...
|
10
|
-
end
|
data/spec/dummy/vendor/.keep
DELETED
File without changes
|
data/spec/fixtures/dog.jpg
DELETED
Binary file
|
data/spec/fixtures/example.csv
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
title,description
|
2
|
-
Fake Item,A description of a fake item.
|
3
|
-
Fake Item with Quoted Description,"Lorem ipsum dolor sit amet, cu mel habeo antiopam, id pri mucius oporteat. No graeco accumsan deterruisset est. Vix te sonet doctus perpetua, mei at odio eius nostrum. Ex postea quidam menandri duo. Rebum ullum cu mel.\nAperiam malorum indoctum ad nec.\nIn duo nonumes accusata, detraxit adipisci philosophia quo id. Ei usu volutpat vituperatoribus. Ut veniam dolorem qui. Ei legendos erroribus usu. Mentitum moderatius ei est, mei eius magna alterum no. Legere vivendum per ad, vim ei putent facilis."
|
4
|
-
Fake Item with Unicode Description,"Лорем ипсум долор сит амет, ех мовет толлит модератиус ест. Еу яуидам сенсерит цонсецтетуер про, при иисяуе ерудити цоррумпит ат. Ех усу нусяуам пхаедрум темпорибус, ест ат омнесяуе инструцтиор.\nЯуо ех мелиоре инсоленс праесент, иудицо тантас еурипидис хис ут. Аццусам урбанитас инструцтиор ан еам. Но хас вениам дицунт дебитис, нец ут суас аццусам перицула, нец риденс аетерно виртуте не.\nАт про еним вереар, ут солум юсто меи."
|
@@ -1,3 +0,0 @@
|
|
1
|
-
title,depositor,date_modified,label,relative_path,import_url,resource type,creator,contributor,abstract or summary,keyword,license,rights statement,publisher,date created,subject,language,identifier,location,related url,bibliographic_citation,source
|
2
|
-
Work 1 Title,user@example.com,2018-01-01,Work 1 Label,tmp/files,https://example.com,Work 1 Type,Work 1 creator,Work 1 contrib,Desc 1,Key 1,Lic 1,RS 1,Pub 1,2018-06-06,Subj 1,English|~|Japanese,Ident 1,Based 1,https://example.com/related,Bib 1,Source 1
|
3
|
-
Work 2 Title,1970-12-21,,Work 2 Label,,,Work 2 Type,,,Desc 2,,,,Pub 2,,Subj 2
|
Binary file
|
Binary file
|
data/spec/fixtures/zizia.png
DELETED
Binary file
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'Using the CsvImportDetail models' do
|
6
|
-
let(:user) { User.new }
|
7
|
-
let(:csv_import) { Zizia::CsvImport.new }
|
8
|
-
let(:csv_import_detail) { Zizia::CsvImportDetail.new }
|
9
|
-
let(:pre_ingest_work_one) { Zizia::PreIngestWork.new }
|
10
|
-
let(:pre_ingest_work_two) { Zizia::PreIngestWork.new }
|
11
|
-
let(:pre_ingest_file_one) do
|
12
|
-
Zizia::PreIngestFile.new(row: 'some,row',
|
13
|
-
row_number: 1,
|
14
|
-
size: 1000)
|
15
|
-
end
|
16
|
-
let(:pre_ingest_file_two) do
|
17
|
-
Zizia::PreIngestFile.new(row: 'another,row',
|
18
|
-
row_number: 2,
|
19
|
-
size: 2000)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'allows you to create PreIngestFiles that are associated with PreIngestWorks' do
|
23
|
-
pre_ingest_work_one.save
|
24
|
-
|
25
|
-
pre_ingest_work_one.pre_ingest_files << pre_ingest_file_one
|
26
|
-
pre_ingest_work_one.pre_ingest_files << pre_ingest_file_two
|
27
|
-
|
28
|
-
expect(pre_ingest_work_one.pre_ingest_files.length).to eq(2)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'allows you to associate PreIngestWorks & Files with a CsvImportDetail' do
|
32
|
-
user.save
|
33
|
-
csv_import.user = user
|
34
|
-
csv_import.save!
|
35
|
-
csv_import_detail.csv_import = csv_import
|
36
|
-
csv_import_detail.save!
|
37
|
-
|
38
|
-
pre_ingest_work_one.pre_ingest_files << pre_ingest_file_one
|
39
|
-
pre_ingest_work_one.pre_ingest_files << pre_ingest_file_two
|
40
|
-
csv_import_detail.pre_ingest_works << pre_ingest_work_one
|
41
|
-
csv_import_detail.pre_ingest_works << pre_ingest_work_two
|
42
|
-
|
43
|
-
expect(csv_import_detail.pre_ingest_files.length).to eq(2)
|
44
|
-
expect(csv_import_detail.pre_ingest_works.length).to eq(2)
|
45
|
-
|
46
|
-
expect(csv_import_detail.total_size).to eq(3000)
|
47
|
-
end
|
48
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'importing a csv batch', :clean do
|
6
|
-
subject(:importer) { Zizia::Importer.new(parser: parser) }
|
7
|
-
let(:parser) { Zizia::CsvParser.new(file: file) }
|
8
|
-
let(:file) { File.open('spec/fixtures/example.csv') }
|
9
|
-
|
10
|
-
load File.expand_path("../../support/shared_contexts/with_work_type.rb", __FILE__)
|
11
|
-
include_context 'with a work type'
|
12
|
-
|
13
|
-
it 'creates a record for each CSV line' do
|
14
|
-
expect { importer.import }.to change { Work.count }.to 3
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'validation' do
|
18
|
-
context 'with invalid CSV' do
|
19
|
-
let(:file) { File.open('spec/fixtures/bad_example.csv') }
|
20
|
-
|
21
|
-
it 'outputs invalid file notice to Rails.logger' do
|
22
|
-
expect(Rails.logger).to receive(:error).with("[zizia] CSV::MalformedCSVError: Illegal quoting in line 2. (Zizia::CsvFormatValidator)")
|
23
|
-
parser.validate
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe 'importing a CSV with Hyrax defaults', :clean do
|
5
|
-
subject(:importer) { Zizia::Importer.new(parser: parser, record_importer: record_importer) }
|
6
|
-
let(:parser) { Zizia::CsvParser.new(file: csv_file) }
|
7
|
-
let(:record_importer) { Zizia::HyraxRecordImporter.new }
|
8
|
-
|
9
|
-
let(:csv_file) { File.open('spec/fixtures/hyrax/example.csv') }
|
10
|
-
after { csv_file.close }
|
11
|
-
|
12
|
-
load File.expand_path("../../support/shared_contexts/with_work_type.rb", __FILE__)
|
13
|
-
include_context 'with a work type'
|
14
|
-
|
15
|
-
it 'creates the record(s)' do
|
16
|
-
expect { importer.import }.to change { Work.count }.to 2
|
17
|
-
|
18
|
-
works = Work.all
|
19
|
-
work1 = works.find { |w| w.title == ['Work 1 Title'] }
|
20
|
-
work2 = works.find { |w| w.title == ['Work 2 Title'] }
|
21
|
-
|
22
|
-
# First Record
|
23
|
-
expect(work1.depositor).to eq 'batchuser@example.com'
|
24
|
-
expect(work1.date_modified).to eq '2018-01-01'
|
25
|
-
expect(work1.label).to eq 'Work 1 Label'
|
26
|
-
expect(work1.relative_path).to eq 'tmp/files'
|
27
|
-
expect(work1.import_url).to eq 'https://example.com'
|
28
|
-
expect(work1.resource_type).to eq ['Work 1 Type']
|
29
|
-
expect(work1.creator).to eq ['Work 1 creator']
|
30
|
-
expect(work1.contributor).to eq ['Work 1 contrib']
|
31
|
-
expect(work1.description).to eq ['Desc 1']
|
32
|
-
expect(work1.keyword).to eq ['Key 1']
|
33
|
-
expect(work1.license).to eq ['Lic 1']
|
34
|
-
expect(work1.rights_statement).to eq ['RS 1']
|
35
|
-
expect(work1.publisher).to eq ['Pub 1']
|
36
|
-
expect(work1.date_created).to eq ['2018-06-06']
|
37
|
-
expect(work1.subject).to eq ['Subj 1']
|
38
|
-
|
39
|
-
# An example with 2 values
|
40
|
-
expect(work1.language).to contain_exactly('English', 'Japanese')
|
41
|
-
|
42
|
-
expect(work1.identifier).to eq ['Ident 1']
|
43
|
-
expect(work1.based_near).to eq ['Based 1']
|
44
|
-
expect(work1.related_url).to eq ['https://example.com/related']
|
45
|
-
expect(work1.bibliographic_citation).to eq ['Bib 1']
|
46
|
-
expect(work1.source).to eq ['Source 1']
|
47
|
-
|
48
|
-
# Second Record
|
49
|
-
expect(work2.depositor).to eq 'batchuser@example.com'
|
50
|
-
expect(work2.date_modified).to be_nil
|
51
|
-
expect(work2.label).to eq 'Work 2 Label'
|
52
|
-
expect(work2.relative_path).to be_nil
|
53
|
-
expect(work2.import_url).to be_nil
|
54
|
-
expect(work2.resource_type).to eq ['Work 2 Type']
|
55
|
-
expect(work2.creator).to eq []
|
56
|
-
expect(work2.contributor).to eq []
|
57
|
-
expect(work2.description).to eq ['Desc 2']
|
58
|
-
expect(work2.keyword).to eq []
|
59
|
-
expect(work2.license).to eq []
|
60
|
-
expect(work2.rights_statement).to eq []
|
61
|
-
expect(work2.publisher).to eq ['Pub 2']
|
62
|
-
expect(work2.date_created).to eq []
|
63
|
-
expect(work2.subject).to eq ['Subj 2']
|
64
|
-
expect(work2.language).to eq []
|
65
|
-
expect(work2.identifier).to eq []
|
66
|
-
expect(work2.based_near).to eq []
|
67
|
-
expect(work2.related_url).to eq []
|
68
|
-
expect(work2.bibliographic_citation).to eq []
|
69
|
-
expect(work2.source).to eq []
|
70
|
-
end
|
71
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe Zizia::CsvImport, type: :model do
|
5
|
-
subject(:csv_import) { described_class.new }
|
6
|
-
|
7
|
-
it 'has a CSV manifest' do
|
8
|
-
expect(csv_import.manifest).to be_a Zizia::CsvManifestUploader
|
9
|
-
end
|
10
|
-
|
11
|
-
context '#queue_start_job' do
|
12
|
-
it 'queues a job to start the import' do
|
13
|
-
expect do
|
14
|
-
csv_import.queue_start_job
|
15
|
-
end.to have_enqueued_job(Zizia::StartCsvImportJob)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'coveralls'
|
3
|
-
Coveralls.wear!('rails')
|
4
|
-
require 'pry' unless ENV['CI']
|
5
|
-
|
6
|
-
ENV['environment'] ||= 'test'
|
7
|
-
# Configure Rails Envinronment
|
8
|
-
ENV['RAILS_ENV'] = 'test'
|
9
|
-
|
10
|
-
require File.expand_path("../dummy/config/environment", __FILE__)
|
11
|
-
ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')
|
12
|
-
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each { |f| require f }
|
13
|
-
|
14
|
-
require 'rails/all'
|
15
|
-
require 'rspec/rails'
|
16
|
-
|
17
|
-
ActiveJob::Base.queue_adapter = :test
|
18
|
-
|
19
|
-
require 'bundler/setup'
|
20
|
-
require 'active_fedora'
|
21
|
-
require 'active_fedora/cleaner'
|
22
|
-
require 'zizia'
|
23
|
-
require 'zizia/spec'
|
24
|
-
require 'byebug'
|
25
|
-
|
26
|
-
RSpec.configure do |config|
|
27
|
-
config.filter_run focus: true
|
28
|
-
config.run_all_when_everything_filtered = true
|
29
|
-
|
30
|
-
config.before(:each, clean: true) { ActiveFedora::Cleaner.clean! }
|
31
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Hyrax
|
4
|
-
module BasicMetadata
|
5
|
-
def self.included(work)
|
6
|
-
work.property :label, predicate: ActiveFedora::RDF::Fcrepo::Model.downloadFilename, multiple: false
|
7
|
-
work.property :relative_path, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#relativePath'), multiple: false
|
8
|
-
work.property :import_url, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#importUrl'), multiple: false
|
9
|
-
work.property :resource_type, predicate: ::RDF::Vocab::DC.type
|
10
|
-
work.property :creator, predicate: ::RDF::Vocab::DC11.creator
|
11
|
-
work.property :contributor, predicate: ::RDF::Vocab::DC11.contributor
|
12
|
-
work.property :description, predicate: ::RDF::Vocab::DC11.description
|
13
|
-
work.property :keyword, predicate: ::RDF::Vocab::DC11.relation
|
14
|
-
work.property :license, predicate: ::RDF::Vocab::DC.rights
|
15
|
-
work.property :rights_statement, predicate: ::RDF::Vocab::EDM.rights
|
16
|
-
work.property :publisher, predicate: ::RDF::Vocab::DC11.publisher
|
17
|
-
work.property :date_created, predicate: ::RDF::Vocab::DC.created
|
18
|
-
work.property :subject, predicate: ::RDF::Vocab::DC11.subject
|
19
|
-
work.property :language, predicate: ::RDF::Vocab::DC11.language
|
20
|
-
work.property :identifier, predicate: ::RDF::Vocab::DC.identifier
|
21
|
-
|
22
|
-
# Note: based_near is defined differently here than in Hyrax.
|
23
|
-
work.property :based_near, predicate: ::RDF::Vocab::FOAF.based_near
|
24
|
-
|
25
|
-
work.property :related_url, predicate: ::RDF::RDFS.seeAlso
|
26
|
-
work.property :bibliographic_citation, predicate: ::RDF::Vocab::DC.bibliographicCitation
|
27
|
-
work.property :source, predicate: ::RDF::Vocab::DC.source
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Hyrax
|
4
|
-
module CoreMetadata
|
5
|
-
def self.included(work)
|
6
|
-
work.property :depositor, predicate: ::RDF::URI.new('http://id.loc.gov/vocabulary/relators/dpt'), multiple: false
|
7
|
-
|
8
|
-
work.property :title, predicate: ::RDF::Vocab::DC.title
|
9
|
-
|
10
|
-
work.property :date_uploaded, predicate: ::RDF::Vocab::DC.dateSubmitted, multiple: false
|
11
|
-
|
12
|
-
work.property :date_modified, predicate: ::RDF::Vocab::DC.modified, multiple: false
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
shared_context 'with a work type' do
|
4
|
-
# A work type must be defined for the default `RecordImporter` to save objects
|
5
|
-
before do
|
6
|
-
load './spec/support/hyrax/core_metadata.rb'
|
7
|
-
load './spec/support/hyrax/basic_metadata.rb'
|
8
|
-
|
9
|
-
class Work < ActiveFedora::Base
|
10
|
-
attr_accessor :visibility
|
11
|
-
attr_accessor :based_near_attributes
|
12
|
-
include ::Hyrax::CoreMetadata
|
13
|
-
include ::Hyrax::BasicMetadata
|
14
|
-
end
|
15
|
-
|
16
|
-
class User < Struct.new(:id, :user_key)
|
17
|
-
def initialize(inputs = {})
|
18
|
-
self.id = inputs[:id]
|
19
|
-
self.user_key = inputs[:user_key] || batch_user_key
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.find_by_user_key(email)
|
23
|
-
User.new(user_key: email)
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.find_or_create_system_user(_email)
|
27
|
-
User.new
|
28
|
-
end
|
29
|
-
|
30
|
-
def batch_user_key
|
31
|
-
'batchuser@example.com'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Ability
|
36
|
-
def initialize(user); end
|
37
|
-
end
|
38
|
-
|
39
|
-
module Hyrax
|
40
|
-
def self.config
|
41
|
-
Config.new
|
42
|
-
end
|
43
|
-
|
44
|
-
class Config
|
45
|
-
def curation_concerns
|
46
|
-
[Work]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class Institution
|
51
|
-
def self.name
|
52
|
-
'my_institution'
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.name_full
|
56
|
-
'my full institution name'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
class UploadedFile < ActiveFedora::Base
|
61
|
-
def self.create(*)
|
62
|
-
h = Hyrax::UploadedFile.new
|
63
|
-
h.save
|
64
|
-
h
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
module Actors
|
69
|
-
class Environment
|
70
|
-
attr_reader :new_object, :attributes
|
71
|
-
def initialize(new_object, _ability, attributes)
|
72
|
-
@new_object = new_object
|
73
|
-
@attributes = attributes
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
class Actor
|
79
|
-
def create(actor_env)
|
80
|
-
attrs = actor_env.attributes
|
81
|
-
attrs.delete(:uploaded_files)
|
82
|
-
actor_env.new_object.attributes = attrs
|
83
|
-
actor_env.new_object.save
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
class CurationConcern
|
88
|
-
def self.actor
|
89
|
-
Hyrax::Actor.new
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
after do
|
96
|
-
Object.send(:remove_const, :Hyrax) if defined?(Hyrax)
|
97
|
-
Object.send(:remove_const, :Work) if defined?(Work)
|
98
|
-
Object.send(:remove_const, :User) if defined?(User)
|
99
|
-
Object.send(:remove_const, :Ability) if defined?(Ability)
|
100
|
-
end
|
101
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe Zizia::CsvManifestUploader, type: :model do
|
5
|
-
subject(:csv_uploader) { described_class.new }
|
6
|
-
|
7
|
-
it 'has a a store dir' do
|
8
|
-
expect(csv_uploader.store_dir.to_s).to match(/uploads/)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'has a cache dir' do
|
12
|
-
expect(csv_uploader.cache_dir.to_s).to match(/cache/)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'has an extension whitelist' do
|
16
|
-
expect(csv_uploader.extension_whitelist).to eq(%w[csv])
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'returns an empty array if the validator has no errors' do
|
20
|
-
expect(csv_uploader.errors).to eq([])
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'has warnings' do
|
24
|
-
expect(csv_uploader.warnings).to eq([])
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'has records' do
|
28
|
-
expect(csv_uploader.records).to eq(0)
|
29
|
-
end
|
30
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe "zizia/importer_documentation/guide.html.erb", type: :view do
|
5
|
-
before do
|
6
|
-
view.stub(:render_guide).and_return('<h1 id="title">Title</h1>')
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'renders as html' do
|
10
|
-
render
|
11
|
-
expect(rendered).to match(/<h1 id="title">Title<\/h1>/)
|
12
|
-
end
|
13
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Zizia::CsvFormatValidator do
|
6
|
-
subject(:validator) { described_class.new }
|
7
|
-
let(:invalid_parser) { Zizia::CsvParser.new(file: invalid_file) }
|
8
|
-
let(:invalid_file) { File.open('spec/fixtures/bad_example.csv') }
|
9
|
-
|
10
|
-
it_behaves_like 'a Zizia::Validator' do
|
11
|
-
let(:valid_parser) { Zizia::CsvParser.new(file: valid_file) }
|
12
|
-
let(:valid_file) { File.open('spec/fixtures/example.csv') }
|
13
|
-
end
|
14
|
-
|
15
|
-
define :a_validator_error do
|
16
|
-
match do |error|
|
17
|
-
return false unless error.respond_to?(:validator)
|
18
|
-
|
19
|
-
if fields
|
20
|
-
return false if fields[:validator] && error.validator != fields[:validator]
|
21
|
-
return false if fields[:name] && error.name != fields[:name]
|
22
|
-
end
|
23
|
-
|
24
|
-
true
|
25
|
-
end
|
26
|
-
|
27
|
-
chain :with, :fields
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#validate' do
|
31
|
-
it 'returns a Validator::Error' do
|
32
|
-
expect(validator.validate(parser: invalid_parser))
|
33
|
-
.to contain_exactly a_validator_error
|
34
|
-
.with(validator: validator.class,
|
35
|
-
name: CSV::MalformedCSVError)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'spec_helper'
|
5
|
-
require 'tempfile'
|
6
|
-
|
7
|
-
describe Zizia::CsvParser do
|
8
|
-
subject(:parser) { described_class.new(file: file) }
|
9
|
-
let(:file) { Tempfile.new(['fake', '.csv']) }
|
10
|
-
|
11
|
-
shared_context 'with content' do
|
12
|
-
let(:csv_content) do
|
13
|
-
<<-EOS
|
14
|
-
title,description,date created
|
15
|
-
The Moomins and the Great Flood,"The Moomins and the Great Flood (Swedish: Småtrollen och den stora översvämningen, literally The Little Trolls and the Great Flood) is a book written by Finnish author Tove Jansson in 1945, during the end of World War II. It was the first book to star the Moomins, but is often seen as a prelude to the main Moomin books, as most of the main characters are introduced in the next book.",1945
|
16
|
-
Comet in Moominland,"Comet in Moominland is the second in Tove Jansson's series of Moomin books. Published in 1946, it marks the first appearance of several main characters, like Snufkin and the Snork Maiden.",1946
|
17
|
-
EOS
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:record_count) { 2 }
|
21
|
-
|
22
|
-
before do
|
23
|
-
file.write(csv_content)
|
24
|
-
file.rewind
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
it_behaves_like 'a Zizia::Parser' do
|
29
|
-
include_context 'with content'
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'matches .csv files' do
|
33
|
-
expect(Zizia::Parser.for(file: file)).to be_a described_class
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#records' do
|
37
|
-
context 'with valid content' do
|
38
|
-
include_context 'with content'
|
39
|
-
|
40
|
-
it 'has the correct titles' do
|
41
|
-
expect(parser.records.map(&:title))
|
42
|
-
.to contain_exactly(['The Moomins and the Great Flood'],
|
43
|
-
['Comet in Moominland'])
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'has correct other fields' do
|
47
|
-
expect(parser.records.map(&:date_created)).to contain_exactly(['1945'], ['1946'])
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'with invalid file' do
|
52
|
-
let(:file) { File.open('spec/fixtures/bad_example.csv') }
|
53
|
-
|
54
|
-
it 'is empty' do
|
55
|
-
expect(parser.records.to_a).to be_empty
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '#validate' do
|
61
|
-
it 'is valid' do
|
62
|
-
expect(parser.validate).to be_truthy
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'with invalid file' do
|
66
|
-
let(:file) { File.open('spec/fixtures/bad_example.csv') }
|
67
|
-
|
68
|
-
it 'is invalid' do
|
69
|
-
expect(parser.validate).to be_falsey
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe Zizia::CsvTemplate do
|
6
|
-
let(:csv_template) { described_class.new }
|
7
|
-
|
8
|
-
before do
|
9
|
-
Zizia.config.metadata_mapper_class = Zizia::HyraxBasicMetadataMapper
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'returns a CSV string based on the headers in the Hyrax mapper' do
|
13
|
-
expect(csv_template.to_s).to eq(Zizia::HyraxBasicMetadataMapper.new.fields.join(','))
|
14
|
-
end
|
15
|
-
end
|