curation_concerns 1.0.0.beta5 → 1.0.0.beta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/actors/curation_concerns/actors/file_actor.rb +2 -34
- data/app/assets/stylesheets/curation_concerns.scss +1 -0
- data/app/assets/stylesheets/curation_concerns/_colors.scss +16 -0
- data/app/forms/curation_concerns/forms/work_form.rb +4 -11
- data/app/jobs/characterize_job.rb +5 -3
- data/app/jobs/create_derivatives_job.rb +4 -3
- data/app/jobs/ingest_file_job.rb +16 -8
- data/app/models/concerns/curation_concerns/solr_document_behavior.rb +14 -10
- data/app/presenters/curation_concerns/model_proxy.rb +1 -1
- data/app/presenters/curation_concerns/work_show_presenter.rb +1 -1
- data/app/services/curation_concerns/working_directory.rb +54 -0
- data/app/views/curation_concerns/base/_attribute_rows.html.erb +1 -1
- data/lib/curation_concerns/version.rb +1 -1
- data/spec/actors/curation_concerns/file_actor_spec.rb +3 -1
- data/spec/features/create_work_spec.rb +8 -0
- data/spec/forms/work_form_spec.rb +3 -1
- data/spec/jobs/characterize_job_spec.rb +13 -6
- data/spec/jobs/create_derivatives_job_spec.rb +12 -4
- data/spec/jobs/ingest_file_job_spec.rb +4 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36e9a2f37af838e6dd164d0a8e6e8b77bf82f1aa
|
4
|
+
data.tar.gz: e34ea9149f44ab96758c4a7d0bbef7e1ef6dbae2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e085e78c5b3d079635159e39198be326573a045fb9609eddd9d2c4bd7fbfaf57cef8b8666686fda4ce08581f990166eb6d43cea9c416adf599c8550d725d1bb0
|
7
|
+
data.tar.gz: ad13311d91b04790c04a3fe7b6db9f8383ace5228547170722f9bd9204b3297d9303b0dfc9ac3d894eed5ec8c97fd19715204106d9e95a2949556aa5b1688463
|
@@ -20,7 +20,7 @@ module CurationConcerns
|
|
20
20
|
# have made it to the repo
|
21
21
|
# @param [File, ActionDigest::HTTP::UploadedFile, Tempfile] file the file to save in the repository
|
22
22
|
def ingest_file(file)
|
23
|
-
working_file = copy_file_to_working_directory(file, file_set.id)
|
23
|
+
working_file = WorkingDirectory.copy_file_to_working_directory(file, file_set.id)
|
24
24
|
mime_type = file.respond_to?(:content_type) ? file.content_type : nil
|
25
25
|
IngestFileJob.perform_later(file_set, working_file, mime_type, user, relation)
|
26
26
|
true
|
@@ -35,42 +35,10 @@ module CurationConcerns
|
|
35
35
|
CurationConcerns::VersioningService.create(repository_file, user)
|
36
36
|
|
37
37
|
# Retrieve a copy of the original file from the repository
|
38
|
-
working_file = copy_repository_resource_to_working_directory(repository_file)
|
38
|
+
working_file = WorkingDirectory.copy_repository_resource_to_working_directory(repository_file, file_set.id)
|
39
39
|
CharacterizeJob.perform_later(file_set, working_file)
|
40
40
|
true
|
41
41
|
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
# @param [File, ActionDispatch::Http::UploadedFile] file
|
46
|
-
# @param [String] id the identifier of the FileSet
|
47
|
-
# @return [String] path of the working file
|
48
|
-
def copy_file_to_working_directory(file, id)
|
49
|
-
file_name = file.respond_to?(:original_filename) ? file.original_filename : ::File.basename(file)
|
50
|
-
copy_stream_to_working_directory(id, file_name, file)
|
51
|
-
end
|
52
|
-
|
53
|
-
# @param [ActiveFedora::File] file the resource in the repo
|
54
|
-
# @return [String] path of the working file
|
55
|
-
def copy_repository_resource_to_working_directory(file)
|
56
|
-
copy_stream_to_working_directory(file_set.id, file.original_name, StringIO.new(file.content))
|
57
|
-
end
|
58
|
-
|
59
|
-
# @param [String] id the identifier
|
60
|
-
# @param [String] name the file name
|
61
|
-
# @param [#read] stream the stream to copy to the working directory
|
62
|
-
# @return [String] path of the working file
|
63
|
-
def copy_stream_to_working_directory(id, name, stream)
|
64
|
-
working_path = full_filename(id, name)
|
65
|
-
FileUtils.mkdir_p(File.dirname(working_path))
|
66
|
-
IO.copy_stream(stream, working_path)
|
67
|
-
working_path
|
68
|
-
end
|
69
|
-
|
70
|
-
def full_filename(id, original_name)
|
71
|
-
pair = id.scan(/..?/).first(4)
|
72
|
-
File.join(CurationConcerns.config.working_path, *pair, original_name)
|
73
|
-
end
|
74
42
|
end
|
75
43
|
end
|
76
44
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
//
|
2
|
+
// Colors
|
3
|
+
//
|
4
|
+
// Many of the default Bootstrap theme colors
|
5
|
+
// fail to meet WCAG AA color contrast standards.
|
6
|
+
// These new variables at a minimum meet a 3:1
|
7
|
+
// contrast ratio (which is ideal for large text).
|
8
|
+
//
|
9
|
+
// Contrast ratio as
|
10
|
+
// foreground to #fff
|
11
|
+
|
12
|
+
$brand-primary: #0275d8; // 4.63:1
|
13
|
+
$brand-success: #00ac07; // 3.04:1
|
14
|
+
$brand-info: #17a0d3; // 3:1
|
15
|
+
$brand-warning: #d58000; // 3.04:1
|
16
|
+
$brand-danger: #d9534f; // 3.96:1
|
@@ -15,7 +15,7 @@ module CurationConcerns
|
|
15
15
|
:representative_id, :thumbnail_id, :files,
|
16
16
|
:visibility_during_embargo, :embargo_release_date, :visibility_after_embargo,
|
17
17
|
:visibility_during_lease, :lease_expiration_date, :visibility_after_lease,
|
18
|
-
:visibility, :ordered_member_ids]
|
18
|
+
:visibility, :ordered_member_ids, :source]
|
19
19
|
|
20
20
|
self.required_fields = [:title]
|
21
21
|
|
@@ -40,17 +40,10 @@ module CurationConcerns
|
|
40
40
|
|
41
41
|
class << self
|
42
42
|
# This determines whether the allowed parameters are single or multiple.
|
43
|
-
# By default it delegates to the model
|
44
|
-
# 'rights' which only has a single value on the form.
|
43
|
+
# By default it delegates to the model.
|
45
44
|
def multiple?(term)
|
46
|
-
|
47
|
-
|
48
|
-
false
|
49
|
-
when 'ordered_member_ids'
|
50
|
-
true
|
51
|
-
else
|
52
|
-
super
|
53
|
-
end
|
45
|
+
return true if term.to_s == 'ordered_member_ids'
|
46
|
+
super
|
54
47
|
end
|
55
48
|
|
56
49
|
# Overriden to cast 'rights' to an array
|
@@ -2,12 +2,14 @@ class CharacterizeJob < ActiveJob::Base
|
|
2
2
|
queue_as CurationConcerns.config.ingest_queue_name
|
3
3
|
|
4
4
|
# @param [FileSet] file_set
|
5
|
-
# @param [String]
|
6
|
-
def perform(file_set,
|
5
|
+
# @param [String] file_id identifier for a Hydra::PCDM::File
|
6
|
+
def perform(file_set, file_id)
|
7
|
+
filename = CurationConcerns::WorkingDirectory.find_or_retrieve(file_id, file_set.id)
|
7
8
|
raise LoadError, "#{file_set.class.characterization_proxy} was not found" unless file_set.characterization_proxy?
|
8
9
|
Hydra::Works::CharacterizationService.run(file_set.characterization_proxy, filename)
|
10
|
+
Rails.logger.debug "Ran characterization on #{file_set.characterization_proxy.id} (#{file_set.characterization_proxy.mime_type})"
|
9
11
|
file_set.characterization_proxy.save!
|
10
12
|
file_set.update_index
|
11
|
-
CreateDerivativesJob.perform_later(file_set,
|
13
|
+
CreateDerivativesJob.perform_later(file_set, file_id)
|
12
14
|
end
|
13
15
|
end
|
@@ -2,11 +2,12 @@ class CreateDerivativesJob < ActiveJob::Base
|
|
2
2
|
queue_as CurationConcerns.config.ingest_queue_name
|
3
3
|
|
4
4
|
# @param [FileSet] file_set
|
5
|
-
# @param [String]
|
6
|
-
def perform(file_set,
|
5
|
+
# @param [String] file_id identifier for a Hydra::PCDM::File
|
6
|
+
def perform(file_set, file_id)
|
7
7
|
return if file_set.video? && !CurationConcerns.config.enable_ffmpeg
|
8
|
+
filename = CurationConcerns::WorkingDirectory.find_or_retrieve(file_id, file_set.id)
|
8
9
|
|
9
|
-
file_set.create_derivatives(
|
10
|
+
file_set.create_derivatives(filename)
|
10
11
|
# The thumbnail is indexed in the solr document, so reindex
|
11
12
|
file_set.update_index
|
12
13
|
file_set.parent.update_index if parent_needs_reindex?(file_set)
|
data/app/jobs/ingest_file_job.rb
CHANGED
@@ -2,28 +2,36 @@ class IngestFileJob < ActiveJob::Base
|
|
2
2
|
queue_as CurationConcerns.config.ingest_queue_name
|
3
3
|
|
4
4
|
# @param [FileSet] file_set
|
5
|
-
# @param [String] filename
|
5
|
+
# @param [String] filename the cached file within the CurationConcerns.config.working_path
|
6
6
|
# @param [String,NilClass] mime_type
|
7
7
|
# @param [User] user
|
8
8
|
# @param [String] relation ('original_file')
|
9
9
|
def perform(file_set, filename, mime_type, user, relation = 'original_file')
|
10
|
-
|
10
|
+
local_file = File.open(filename, "rb")
|
11
11
|
# If mime-type is known, wrap in an IO decorator
|
12
12
|
# Otherwise allow Hydra::Works service to determine mime_type
|
13
13
|
if mime_type
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
local_file = Hydra::Derivatives::IoDecorator.new(local_file)
|
15
|
+
local_file.mime_type = mime_type
|
16
|
+
local_file.original_name = File.basename(filename)
|
17
17
|
end
|
18
18
|
|
19
19
|
# Tell AddFileToFileSet service to skip versioning because versions will be minted by VersionCommitter (called by save_characterize_and_record_committer) when necessary
|
20
|
-
Hydra::Works::AddFileToFileSet.call(file_set,
|
20
|
+
Hydra::Works::AddFileToFileSet.call(file_set,
|
21
|
+
local_file,
|
22
|
+
relation.to_sym,
|
23
|
+
versioning: false)
|
21
24
|
|
22
25
|
# Persist changes to the file_set
|
23
26
|
file_set.save!
|
24
27
|
|
28
|
+
repository_file = file_set.send(relation.to_sym)
|
29
|
+
|
25
30
|
# Do post file ingest actions
|
26
|
-
CurationConcerns::VersioningService.create(
|
27
|
-
|
31
|
+
CurationConcerns::VersioningService.create(repository_file, user)
|
32
|
+
|
33
|
+
# TODO: this is a problem, the file may not be available at this path on another machine.
|
34
|
+
# It may be local, or it may be in s3
|
35
|
+
CharacterizeJob.perform_later(file_set, repository_file.id)
|
28
36
|
end
|
29
37
|
end
|
@@ -29,25 +29,25 @@ module CurationConcerns
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def collection?
|
32
|
-
hydra_model ==
|
32
|
+
hydra_model == ::Collection
|
33
33
|
end
|
34
34
|
|
35
35
|
# Method to return the ActiveFedora model
|
36
36
|
def hydra_model
|
37
|
-
|
37
|
+
first(Solrizer.solr_name('has_model', :symbol)).constantize
|
38
38
|
end
|
39
39
|
|
40
40
|
def human_readable_type
|
41
|
-
|
41
|
+
first(Solrizer.solr_name('human_readable_type', :stored_searchable))
|
42
42
|
end
|
43
43
|
|
44
44
|
def representative_id
|
45
|
-
|
45
|
+
first(Solrizer.solr_name('hasRelatedMediaFragment', :symbol))
|
46
46
|
end
|
47
47
|
|
48
48
|
# Date created is indexed as a string. This allows users to enter values like: 'Circa 1840-1844'
|
49
49
|
def date_created
|
50
|
-
|
50
|
+
first(Solrizer.solr_name("date_created"))
|
51
51
|
end
|
52
52
|
|
53
53
|
def date_modified
|
@@ -59,7 +59,7 @@ module CurationConcerns
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def depositor(default = '')
|
62
|
-
val =
|
62
|
+
val = first(Solrizer.solr_name('depositor'))
|
63
63
|
val.present? ? val : default
|
64
64
|
end
|
65
65
|
|
@@ -72,11 +72,11 @@ module CurationConcerns
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def label
|
75
|
-
|
75
|
+
first(Solrizer.solr_name('label'))
|
76
76
|
end
|
77
77
|
|
78
78
|
def file_format
|
79
|
-
|
79
|
+
first(Solrizer.solr_name('file_format'))
|
80
80
|
end
|
81
81
|
|
82
82
|
def creator
|
@@ -112,7 +112,7 @@ module CurationConcerns
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def rights
|
115
|
-
|
115
|
+
fetch(Solrizer.solr_name('rights'), [])
|
116
116
|
end
|
117
117
|
|
118
118
|
def mime_type
|
@@ -123,6 +123,10 @@ module CurationConcerns
|
|
123
123
|
fetch(Hydra.config.permissions.read.group, [])
|
124
124
|
end
|
125
125
|
|
126
|
+
def source
|
127
|
+
fetch(Solrizer.solr_name('source'), [])
|
128
|
+
end
|
129
|
+
|
126
130
|
def visibility
|
127
131
|
@visibility ||= if read_groups.include? Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC
|
128
132
|
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
@@ -136,7 +140,7 @@ module CurationConcerns
|
|
136
140
|
private
|
137
141
|
|
138
142
|
def date_field(field_name)
|
139
|
-
field =
|
143
|
+
field = first(Solrizer.solr_name(field_name, :stored_sortable, type: :date))
|
140
144
|
return unless field.present?
|
141
145
|
begin
|
142
146
|
Date.parse(field).to_formatted_s(:standard)
|
@@ -35,7 +35,7 @@ module CurationConcerns
|
|
35
35
|
# Metadata Methods
|
36
36
|
delegate :title, :date_created, :date_modified, :date_uploaded, :description,
|
37
37
|
:creator, :contributor, :subject, :publisher, :language, :embargo_release_date,
|
38
|
-
:lease_expiration_date, :rights, to: :solr_document
|
38
|
+
:lease_expiration_date, :rights, :source, to: :solr_document
|
39
39
|
|
40
40
|
# @return [Array<FileSetPresenter>] presenters for the orderd_members that are FileSets
|
41
41
|
def file_set_presenters
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module CurationConcerns
|
2
|
+
module WorkingDirectory
|
3
|
+
class << self
|
4
|
+
# @param [String] repository_file_id identifier for Hydra::PCDM::File
|
5
|
+
# @param [String] id the identifier of the FileSet
|
6
|
+
# @return [String] path of the working file
|
7
|
+
def find_or_retrieve(repository_file_id, id)
|
8
|
+
repository_file = Hydra::PCDM::File.find(repository_file_id)
|
9
|
+
working_path = full_filename(id, repository_file.original_name)
|
10
|
+
if File.exist?(working_path)
|
11
|
+
Rails.logger.debug "#{repository_file.original_name} already exists in the working directory at #{working_path}"
|
12
|
+
return working_path
|
13
|
+
end
|
14
|
+
copy_repository_resource_to_working_directory(repository_file, id)
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param [File, ActionDispatch::Http::UploadedFile] file
|
18
|
+
# @param [String] id the identifier of the FileSet
|
19
|
+
# @return [String] path of the working file
|
20
|
+
def copy_file_to_working_directory(file, id)
|
21
|
+
file_name = file.respond_to?(:original_filename) ? file.original_filename : ::File.basename(file)
|
22
|
+
copy_stream_to_working_directory(id, file_name, file)
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param [ActiveFedora::File] file the resource in the repo
|
26
|
+
# @param [String] id the identifier of the FileSet
|
27
|
+
# @return [String] path of the working file
|
28
|
+
def copy_repository_resource_to_working_directory(file, id)
|
29
|
+
Rails.logger.debug "Loading #{file.original_name} (#{file.id}) from the repository to the working directory"
|
30
|
+
# TODO: this causes a load into memory, which we'd like to avoid
|
31
|
+
copy_stream_to_working_directory(id, file.original_name, StringIO.new(file.content))
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# @param [String] id the identifier
|
37
|
+
# @param [String] name the file name
|
38
|
+
# @param [#read] stream the stream to copy to the working directory
|
39
|
+
# @return [String] path of the working file
|
40
|
+
def copy_stream_to_working_directory(id, name, stream)
|
41
|
+
working_path = full_filename(id, name)
|
42
|
+
Rails.logger.debug "Writing #{name} to the working directory at #{working_path}"
|
43
|
+
FileUtils.mkdir_p(File.dirname(working_path))
|
44
|
+
IO.copy_stream(stream, working_path)
|
45
|
+
working_path
|
46
|
+
end
|
47
|
+
|
48
|
+
def full_filename(id, original_name)
|
49
|
+
pair = id.scan(/..?/).first(4)
|
50
|
+
File.join(CurationConcerns.config.working_path, *pair, original_name)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -21,14 +21,16 @@ describe CurationConcerns::Actors::FileActor do
|
|
21
21
|
let(:revision_id) { 'asdf1234' }
|
22
22
|
let(:previous_version) { mock_file_factory }
|
23
23
|
let(:file_path) { 'path/to/working_file' }
|
24
|
+
|
24
25
|
before do
|
25
26
|
allow(file_set).to receive(:remastered).and_return(previous_version)
|
26
27
|
allow(previous_version).to receive(:restore_version).with(revision_id)
|
27
28
|
allow(previous_version).to receive(:original_name).and_return('original_name')
|
28
29
|
end
|
30
|
+
|
29
31
|
it 'reverts to a previous version of a file' do
|
30
32
|
expect(CurationConcerns::VersioningService).to receive(:create).with(previous_version, user)
|
31
|
-
expect(
|
33
|
+
expect(CurationConcerns::WorkingDirectory).to receive(:copy_repository_resource_to_working_directory).with(previous_version, file_set.id).and_return(file_path)
|
32
34
|
expect(CharacterizeJob).to receive(:perform_later).with(file_set, file_path)
|
33
35
|
actor.revert_to(revision_id)
|
34
36
|
end
|
@@ -22,12 +22,20 @@ feature 'Creating a new Work' do
|
|
22
22
|
it 'creates the work and allow you to attach a file' do
|
23
23
|
visit '/concern/generic_works/new'
|
24
24
|
work_title = 'My Test Work'
|
25
|
+
source = 'related resource'
|
25
26
|
within('form.new_generic_work') do
|
26
27
|
fill_in('Title', with: work_title)
|
28
|
+
fill_in('Source', with: source)
|
29
|
+
select 'Attribution 3.0 United States', from: 'generic_work[rights][]'
|
27
30
|
attach_file('Upload a file', fixture_file_path('files/image.png'))
|
28
31
|
choose('generic_work_visibility_open')
|
29
32
|
click_on('Create Generic work')
|
30
33
|
end
|
34
|
+
|
35
|
+
expect(page).to have_content(source)
|
36
|
+
expect(page).to have_link 'Attribution 3.0 United States',
|
37
|
+
href: 'http://creativecommons.org/licenses/by/3.0/us/'
|
38
|
+
|
31
39
|
within '.related_files' do
|
32
40
|
expect(page).to have_link 'image.png'
|
33
41
|
end
|
@@ -46,7 +46,8 @@ describe CurationConcerns::Forms::WorkForm do
|
|
46
46
|
representative_id: '456',
|
47
47
|
thumbnail_id: '789',
|
48
48
|
keyword: ['derp'],
|
49
|
-
|
49
|
+
source: ['related'],
|
50
|
+
rights: ['http://creativecommons.org/licenses/by/3.0/us/'])
|
50
51
|
}
|
51
52
|
subject { PirateShipForm.model_attributes(params) }
|
52
53
|
|
@@ -56,6 +57,7 @@ describe CurationConcerns::Forms::WorkForm do
|
|
56
57
|
expect(subject['visibility']).to eq 'open'
|
57
58
|
expect(subject['rights']).to eq ['http://creativecommons.org/licenses/by/3.0/us/']
|
58
59
|
expect(subject['keyword']).to eq ['derp']
|
60
|
+
expect(subject['source']).to eq ['related']
|
59
61
|
end
|
60
62
|
|
61
63
|
it 'excludes non-permitted params' do
|
@@ -4,9 +4,16 @@ describe CharacterizeJob do
|
|
4
4
|
include CurationConcerns::FactoryHelpers
|
5
5
|
|
6
6
|
let(:file_set) { FileSet.new(id: file_set_id) }
|
7
|
-
let(:file_set_id) { '
|
8
|
-
let(:
|
9
|
-
let(:
|
7
|
+
let(:file_set_id) { 'abc12345678' }
|
8
|
+
let(:file_path) { Rails.root + 'tmp' + 'uploads' + 'ab' + 'c1' + '23' + '45' + 'picture.png' }
|
9
|
+
let(:filename) { file_path.to_s }
|
10
|
+
let(:file) do
|
11
|
+
Hydra::PCDM::File.new.tap do |f|
|
12
|
+
f.content = 'foo'
|
13
|
+
f.original_name = 'picture.png'
|
14
|
+
f.save!
|
15
|
+
end
|
16
|
+
end
|
10
17
|
|
11
18
|
before do
|
12
19
|
allow(FileSet).to receive(:find).with(file_set_id).and_return(file_set)
|
@@ -18,15 +25,15 @@ describe CharacterizeJob do
|
|
18
25
|
expect(Hydra::Works::CharacterizationService).to receive(:run).with(file, filename)
|
19
26
|
expect(file).to receive(:save!)
|
20
27
|
expect(file_set).to receive(:update_index)
|
21
|
-
expect(CreateDerivativesJob).to receive(:perform_later).with(file_set,
|
22
|
-
described_class.perform_now(file_set,
|
28
|
+
expect(CreateDerivativesJob).to receive(:perform_later).with(file_set, file.id)
|
29
|
+
described_class.perform_now(file_set, file.id)
|
23
30
|
end
|
24
31
|
end
|
25
32
|
|
26
33
|
context 'when the characterization proxy content is absent' do
|
27
34
|
before { allow(file_set).to receive(:characterization_proxy?).and_return(false) }
|
28
35
|
it 'raises an error' do
|
29
|
-
expect { described_class.perform_now(file_set,
|
36
|
+
expect { described_class.perform_now(file_set, file.id) }.to raise_error(LoadError, 'original_file was not found')
|
30
37
|
end
|
31
38
|
end
|
32
39
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe CreateDerivativesJob do
|
4
4
|
let(:id) { '123' }
|
5
5
|
|
6
6
|
before do
|
@@ -11,6 +11,14 @@ describe CurationConcerns::CreateDerivativesJob do
|
|
11
11
|
allow(file_set).to receive(:id).and_return(id)
|
12
12
|
end
|
13
13
|
|
14
|
+
let(:file) do
|
15
|
+
Hydra::PCDM::File.new.tap do |f|
|
16
|
+
f.content = 'foo'
|
17
|
+
f.original_name = 'picture.png'
|
18
|
+
f.save!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
14
22
|
let(:file_set) { FileSet.new }
|
15
23
|
|
16
24
|
after do
|
@@ -21,7 +29,7 @@ describe CurationConcerns::CreateDerivativesJob do
|
|
21
29
|
it 'calls create_derivatives and save on a file set' do
|
22
30
|
expect(Hydra::Derivatives::AudioDerivatives).to receive(:create)
|
23
31
|
expect(file_set).to receive(:update_index)
|
24
|
-
|
32
|
+
described_class.perform_now(file_set, file.id)
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
@@ -37,7 +45,7 @@ describe CurationConcerns::CreateDerivativesJob do
|
|
37
45
|
|
38
46
|
it 'updates the index of the parent object' do
|
39
47
|
expect(parent).to receive(:update_index)
|
40
|
-
|
48
|
+
described_class.perform_now(file_set, file.id)
|
41
49
|
end
|
42
50
|
end
|
43
51
|
|
@@ -46,7 +54,7 @@ describe CurationConcerns::CreateDerivativesJob do
|
|
46
54
|
|
47
55
|
it "doesn't update the parent's index" do
|
48
56
|
expect(parent).to_not receive(:update_index)
|
49
|
-
|
57
|
+
described_class.perform_now(file_set, file.id)
|
50
58
|
end
|
51
59
|
end
|
52
60
|
end
|
@@ -20,7 +20,7 @@ describe IngestFileJob do
|
|
20
20
|
Object.send(:remove_const, :FileSetWithExtras)
|
21
21
|
end
|
22
22
|
it 'uses the provided relationship' do
|
23
|
-
expect(CharacterizeJob).to receive(:perform_later).with(file_set,
|
23
|
+
expect(CharacterizeJob).to receive(:perform_later).with(file_set, String)
|
24
24
|
described_class.perform_now(file_set, filename, 'image/png', 'bob', 'remastered')
|
25
25
|
expect(file_set.reload.remastered.mime_type).to eq 'image/png'
|
26
26
|
end
|
@@ -28,7 +28,7 @@ describe IngestFileJob do
|
|
28
28
|
|
29
29
|
context 'when given a mime_type' do
|
30
30
|
it 'uses the provided mime_type' do
|
31
|
-
expect(CharacterizeJob).to receive(:perform_later).with(file_set,
|
31
|
+
expect(CharacterizeJob).to receive(:perform_later).with(file_set, String)
|
32
32
|
described_class.perform_now(file_set, filename, 'image/png', 'bob')
|
33
33
|
expect(file_set.reload.original_file.mime_type).to eq 'image/png'
|
34
34
|
end
|
@@ -39,8 +39,8 @@ describe IngestFileJob do
|
|
39
39
|
# Mocking CC Versioning here as it will be the versioning machinery called by the job.
|
40
40
|
# The parameter versioning: false instructs the machinery in Hydra::Works NOT to do versioning. So it can be handled later on.
|
41
41
|
allow(CurationConcerns::VersioningService).to receive(:create)
|
42
|
-
expect(Hydra::Works::AddFileToFileSet).to receive(:call).with(file_set, instance_of(::File), :original_file, versioning: false)
|
43
|
-
expect(CharacterizeJob).to receive(:perform_later).with(file_set,
|
42
|
+
expect(Hydra::Works::AddFileToFileSet).to receive(:call).with(file_set, instance_of(::File), :original_file, versioning: false).and_call_original
|
43
|
+
expect(CharacterizeJob).to receive(:perform_later).with(file_set, String)
|
44
44
|
described_class.perform_now(file_set, filename, nil, 'bob')
|
45
45
|
end
|
46
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curation_concerns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-06-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hydra-head
|
@@ -649,6 +649,7 @@ files:
|
|
649
649
|
- app/assets/javascripts/curation_concerns/uploader.js
|
650
650
|
- app/assets/javascripts/modernizr.js
|
651
651
|
- app/assets/stylesheets/curation_concerns.scss
|
652
|
+
- app/assets/stylesheets/curation_concerns/_colors.scss
|
652
653
|
- app/assets/stylesheets/curation_concerns/_curation_concerns.scss
|
653
654
|
- app/assets/stylesheets/curation_concerns/_modules.scss
|
654
655
|
- app/assets/stylesheets/curation_concerns/_positioning.scss
|
@@ -809,6 +810,7 @@ files:
|
|
809
810
|
- app/services/curation_concerns/thumbnail_path_service.rb
|
810
811
|
- app/services/curation_concerns/time_service.rb
|
811
812
|
- app/services/curation_concerns/versioning_service.rb
|
813
|
+
- app/services/curation_concerns/working_directory.rb
|
812
814
|
- app/services/resource_types_service.rb
|
813
815
|
- app/services/rights_service.rb
|
814
816
|
- app/validators/has_one_title_validator.rb
|