-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Green - refactor headers to be parsed along with the rest of the CSV
- Loading branch information
Showing
5 changed files
with
160 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
spec/dummy/spec/fixtures/csv_import/csv_files_with_problems/duplicate_headers.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
parent,parent,object type,identifier,license,deduplication_key,visibility,location,keyword,rights statement,creator,title,files | ||
,def/123,w,abc/123,https://creativecommons.org/licenses/by/4.0/,abc/123,PUBlic,http://www.geonames.org/5667009/montana.html|~|http://www.geonames.org/6252001/united-states.html,Clothing stores $z California $z Los Angeles|~|Interior design $z California $z Los Angeles,http://rightsstatements.org/vocab/InC/1.0/,"Connell, Will, $d 1898-1961","Interior view of The Bachelors haberdashery designed by Julius Ralph Davidson, Los Angeles, circa 1929",dog.jpg | ||
,,C,,,7,Public,,,,,Test collection, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
object type,title,creator,keyword,rights statement,visibility,files,identifier,deduplication_key,parent | ||
Collection,Collection of fruits,,,,public,,def/234,def/234, | ||
w,Work on tomatoes,"Tomato, Tommy",fruits|~|tomatoes,http://rightsstatements.org/vocab/InC/1.0/,public,,abc/123,abc/123,def/234 | ||
f,,,,,,dog.jpg,,,abc/123 | ||
f,,,,,,birds.jpg,,,abc/123 | ||
f,,,,,,cat.jpg,,,abc/123 | ||
f,,,,,,zizia.png,,,abc/123 |
78 changes: 78 additions & 0 deletions
78
spec/dummy/spec/system/import_from_csv_separate_files_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# frozen_string_literal: true | ||
require 'rails_helper' | ||
include Warden::Test::Helpers | ||
|
||
RSpec.describe 'Importing records from a CSV file', :perform_jobs, clean: true, type: :system, js: true do | ||
before do | ||
allow(CharacterizeJob).to receive(:perform_later) | ||
end | ||
|
||
around do |example| | ||
orig_import_path = ENV['IMPORT_PATH'] | ||
ENV['IMPORT_PATH'] = File.join(fixture_path, 'images') | ||
example.run | ||
ENV['IMPORT_PATH'] = orig_import_path | ||
end | ||
|
||
let(:csv_file) { File.join(fixture_path, 'csv_import', 'good', 'many_files.csv') } | ||
let(:test_strategy) { Flipflop::FeatureSet.current.test! } | ||
|
||
context 'logged in as an admin user' do | ||
let(:admin_user) { FactoryBot.create(:admin) } | ||
|
||
let(:admin_set_id) { AdminSet.find_or_create_default_admin_set_id } | ||
let(:permission_template) { Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set_id) } | ||
let(:default_collection_type) { Hyrax::CollectionType.find_or_create_default_collection_type } | ||
let(:workflow) { Sipity::Workflow.create!(active: true, name: 'test-workflow', permission_template: permission_template) } | ||
|
||
before do | ||
# Create the default collection type in order to create a new collection | ||
default_collection_type | ||
# Create a single action that can be taken | ||
Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow) | ||
|
||
# Grant the user access to deposit into the admin set. | ||
Hyrax::PermissionTemplateAccess.create!( | ||
permission_template_id: permission_template.id, | ||
agent_type: 'user', | ||
agent_id: admin_user.user_key, | ||
access: 'deposit' | ||
) | ||
|
||
login_as admin_user | ||
end | ||
|
||
context 'using the new UI' do | ||
before do | ||
test_strategy.switch!(:new_zizia_ui, true) | ||
end | ||
|
||
it 'creates a collection and a work via the UI' do | ||
pending('Not requiring a work to have info in the files row if it has files elsewhere on the sheet') | ||
visit '/csv_imports/new' | ||
# Fill in and submit the form | ||
expect do | ||
select 'Update Existing Metadata, create new works', from: "csv_import[update_actor_stack]" | ||
attach_file('csv_import[manifest]', csv_file, make_visible: true) | ||
expect(page).to have_content('You sucessfully uploaded this CSV: many_files.csv') | ||
|
||
click_on 'Preview Import' | ||
|
||
expect(page).to have_content 'This import will process 6 row(s).' | ||
|
||
click_on 'Start Import' | ||
end.to change { Work.count }.by(1) | ||
.and change { Collection.count }.by(1) | ||
.and change { FileSet.count }.by(4) | ||
|
||
# The show page for the CsvImport | ||
expect(page).to have_content 'many_files.csv' | ||
expect(page).to have_content 'Start time' | ||
|
||
# Ensure that all the fields got assigned as expected | ||
work_one = Work.where(title: "*tomatoes*").first | ||
expect(work_one.title.first).to match(/tomatoes/) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters