From c5152b928ea0289822b8e9d414ebd0d876e6199b Mon Sep 17 00:00:00 2001 From: Peter Mangiafico Date: Tue, 16 Mar 2021 09:18:44 -0700 Subject: [PATCH] remove map spec; add webarchive seed as an option --- app/lib/pre_assembly/digital_object.rb | 3 +- app/models/batch_context.rb | 3 +- app/views/batch_contexts/_new_bc_form.erb | 3 +- spec/features/map_spec.rb | 75 ----------------------- spec/models/batch_context_spec.rb | 3 +- 5 files changed, 8 insertions(+), 79 deletions(-) delete mode 100644 spec/features/map_spec.rb diff --git a/app/lib/pre_assembly/digital_object.rb b/app/lib/pre_assembly/digital_object.rb index 28470ae76..28b3b154b 100644 --- a/app/lib/pre_assembly/digital_object.rb +++ b/app/lib/pre_assembly/digital_object.rb @@ -49,7 +49,8 @@ def content_md_creation_style Cocina::Models::Vocab.manuscript => :simple_book, Cocina::Models::Vocab.document => :document, Cocina::Models::Vocab.map => :map, - Cocina::Models::Vocab.three_dimensional => :'3d' + Cocina::Models::Vocab.three_dimensional => :'3d', + Cocina::Models::Vocab.webarchive_seed => :webarchive_seed }.fetch(object_type, content_structure.to_sym) end diff --git a/app/models/batch_context.rb b/app/models/batch_context.rb index 865475be8..cc45e175e 100644 --- a/app/models/batch_context.rb +++ b/app/models/batch_context.rb @@ -24,7 +24,8 @@ class BatchContext < ApplicationRecord 'media' => 4, '3d' => 5, 'document' => 6, - 'maps' => 7 + 'maps' => 7, + 'webarchive_seed' => 8 } enum content_metadata_creation: { diff --git a/app/views/batch_contexts/_new_bc_form.erb b/app/views/batch_contexts/_new_bc_form.erb index 894c5b631..9d10519fe 100644 --- a/app/views/batch_contexts/_new_bc_form.erb +++ b/app/views/batch_contexts/_new_bc_form.erb @@ -20,7 +20,8 @@ ['File', 'file'], ['Media', 'media'], ['3D', '3d'], - ['Map', 'maps'] + ['Map', 'maps'], + ['Webarchive seed', 'webarchive_seed'] ] %> diff --git a/spec/features/map_spec.rb b/spec/features/map_spec.rb deleted file mode 100644 index 8f25ba5b4..000000000 --- a/spec/features/map_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe 'Create Map object', type: :feature do - let(:user) { create(:user) } - let(:user_id) { "#{user.sunet_id}@stanford.edu" } - let(:project_name) { "image-#{RandomWord.nouns.next}" } - let(:bundle_dir) { Rails.root.join('spec/test_data/image_jpg') } - let(:bare_druid) { 'pr666rr9999' } - let(:object_staging_dir) { Rails.root.join(Settings.assembly_staging_dir, 'pr', '666', 'rr', '9999', bare_druid) } - let(:cocina_model_world_access) { instance_double(Cocina::Models::Access, access: 'world') } - let(:item) { instance_double(Cocina::Models::DRO, type: Cocina::Models::Vocab.map, access: cocina_model_world_access) } - let(:dsc_object_version) { instance_double(Dor::Services::Client::ObjectVersion, openable?: true) } - let(:dsc_object) { instance_double(Dor::Services::Client::Object, version: dsc_object_version, find: item) } - let(:exp_content_md) do - <<~XML - - - - - 3e9498107f73ff827e718d5c743f8813 - - - - XML - end - - before do - FileUtils.remove_dir(object_staging_dir) if Dir.exist?(object_staging_dir) - - login_as(user, scope: :user) - - allow(Dor::Services::Client).to receive(:object).and_return(dsc_object) - allow(StartAccession).to receive(:run).with(druid: "druid:#{bare_druid}", user: user.sunet_id) - end - - # have background jobs run synchronously - include ActiveJob::TestHelper - around do |example| - perform_enqueued_jobs do - example.run - end - end - - it do - visit '/' - expect(page).to have_selector('h3', text: 'Complete the form below') - - fill_in 'Project name', with: project_name - select 'Pre Assembly Run', from: 'Job type' - select 'Map', from: 'Content structure' - fill_in 'Bundle dir', with: bundle_dir - - click_button 'Submit' - exp_str = 'Success! Your job is queued. A link to job output will be emailed to you upon completion.' - expect(page).to have_content exp_str - - # go to job details page, wait for preassembly to finish - first('td > a').click - expect(page).to have_content project_name - expect(page).to have_link('Download') - - result_file = Rails.root.join(Settings.job_output_parent_dir, user_id, project_name, "#{project_name}_progress.yml") - yaml = YAML.load_file(result_file) - expect(yaml[:status]).to eq 'success' - - # we got all the expected content files - expect(Dir.children(File.join(object_staging_dir, 'content')).size).to eq 1 - - metadata_dir = File.join(object_staging_dir, 'metadata') - expect(Dir.children(metadata_dir).size).to eq 1 - - content_md_xml = File.open(File.join(metadata_dir, 'contentMetadata.xml')).read - expect(noko_doc(content_md_xml)).to be_equivalent_to exp_content_md - end -end diff --git a/spec/models/batch_context_spec.rb b/spec/models/batch_context_spec.rb index d01d79394..a205f4db2 100644 --- a/spec/models/batch_context_spec.rb +++ b/spec/models/batch_context_spec.rb @@ -64,7 +64,8 @@ 'media' => 4, '3d' => 5, 'document' => 6, - 'maps' => 7 + 'maps' => 7, + 'webarchive_seed' => 8 ) end