curation_concerns 1.0.0.beta2 → 1.0.0.beta3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/actors/curation_concerns/actors/file_actor.rb +6 -11
  4. data/app/assets/javascripts/curation_concerns/file_manager/affix.es6 +1 -1
  5. data/app/assets/stylesheets/curation_concerns/modules/file_manager.scss +1 -1
  6. data/app/helpers/curation_concerns/file_set_helper.rb +6 -3
  7. data/app/jobs/characterize_job.rb +3 -2
  8. data/app/jobs/ingest_file_job.rb +1 -0
  9. data/app/models/concerns/curation_concerns/file_set/characterization.rb +47 -0
  10. data/app/models/concerns/curation_concerns/file_set_behavior.rb +2 -6
  11. data/app/presenters/curation_concerns/collection_presenter.rb +1 -1
  12. data/app/presenters/curation_concerns/work_show_presenter.rb +6 -0
  13. data/app/views/curation_concerns/base/_representative_media.html.erb +2 -2
  14. data/curation_concerns.gemspec +1 -1
  15. data/lib/curation_concerns/version.rb +1 -1
  16. data/lib/generators/curation_concerns/work/templates/actor.rb.erb +4 -2
  17. data/lib/generators/curation_concerns/work/templates/controller.rb.erb +5 -3
  18. data/spec/actors/curation_concerns/file_actor_spec.rb +19 -1
  19. data/spec/actors/curation_concerns/file_set_actor_spec.rb +0 -6
  20. data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +0 -1
  21. data/spec/factories/generic_works.rb +7 -0
  22. data/spec/jobs/characterize_job_spec.rb +20 -7
  23. data/spec/jobs/ingest_file_job_spec.rb +4 -0
  24. data/spec/models/curation_concerns/file_set/characterization_spec.rb +53 -0
  25. data/spec/presenters/curation_concerns/collection_presenter_spec.rb +6 -0
  26. data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +14 -0
  27. metadata +8 -6
  28. data/app/models/concerns/curation_concerns/characterization.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96756d166c6631a6999f710b4d914c1633bf87b6
4
- data.tar.gz: 3a0dee7f354c71afc0b72844e3eb6a37cbc48b3e
3
+ metadata.gz: 479354206a40bb627e8757bf979959e1334a9d36
4
+ data.tar.gz: ba279782938b4e3a7e66bb03b9f932855f0afddd
5
5
  SHA512:
6
- metadata.gz: 616e0cec3bf1225238270505c6966c83639857dd54b5fbcb500c9b677341d6e775ea6abec678dfe2a8e113644c51379fca9f9fc5df0bf61716c46a707df0b67a
7
- data.tar.gz: 09ca08d9a68ef729446a05e92f4e604ce8b2b764e35a73dcb0b12c8876fc2c68b2cb2711a3c7580d6e2fdc6730f85c150bc49ad4b20a32a6f9438bb6f069a4cf
6
+ metadata.gz: 4e741f7d4aa0ecb1ecdcd5bf0e1d82788409196b74b37c94a22bba836eb85f4d74aa8add3d3c3a2f5b3a332dbec5009a1aee63deb7fc8527cf555320628c1900
7
+ data.tar.gz: 9a89a75c1178e14d566e980a39d1e7ef363a1ccc1e96a18f5e5bef8b2f53d4b44777a8ddcbb9c53e61f1ba1740a85ed4e50d502cf3ff9aa6157bd5e3fbf2d0af
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # CurationConcerns
2
2
 
3
3
  [![Version](https://badge.fury.io/rb/curation_concerns.png)](http://badge.fury.io/rb/curation_concerns)
4
- [![Build Status](https://travis-ci.org/projecthydra-labs/curation_concerns.svg?branch=master)](https://travis-ci.org/projecthydra-labs/curation_concerns)
4
+ [![Build Status](https://travis-ci.org/projecthydra/curation_concerns.svg?branch=master)](https://travis-ci.org/projecthydra/curation_concerns)
5
5
  [![Coverage Status](https://coveralls.io/repos/projecthydra-labs/curation_concerns/badge.svg?branch=master)](https://coveralls.io/r/projecthydra-labs/curation_concerns?branch=master)
6
6
  [![Code Climate](https://codeclimate.com/github/projecthydra-labs/curation_concerns/badges/gpa.svg)](https://codeclimate.com/github/projecthydra-labs/curation_concerns)
7
7
  [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE.txt)
@@ -9,7 +9,7 @@
9
9
  [![API Docs](http://img.shields.io/badge/API-docs-blue.svg)](http://rubydoc.info/gems/curation_concerns)
10
10
  [![Stories in Ready](https://badge.waffle.io/projecthydra-labs/sufia-core.png?source=projecthydra-labs%2Fcuration_concerns&label=ready&title=Ready)](https://waffle.io/projecthydra-labs/sufia-core?source=projecthydra-labs%2Fcuration_concerns)
11
11
 
12
- A Hydra-based Rails Engine that extends an application, adding the ability to Create, Read, Update and Destroy (CRUD) objects (based on [Hydra::Works](http://github.com/projecthydra-labs/hydra-works)) and providing a generator for defining object types with custom workflows, views, access controls, etc.
12
+ A Hydra-based Rails Engine that extends an application, adding the ability to Create, Read, Update and Destroy (CRUD) objects (based on [Hydra::Works](http://github.com/projecthydra/hydra-works)) and providing a generator for defining object types with custom workflows, views, access controls, etc.
13
13
 
14
14
  ## Prerequisites
15
15
 
@@ -14,8 +14,8 @@ module CurationConcerns
14
14
  end
15
15
 
16
16
  # Puts the uploaded content into a staging directory. Then kicks off a
17
- # job to characterize and create derivatives with this on disk variant.
18
- # Simultaneously moving a preservation copy to the repostiory.
17
+ # job to ingest the file into the repository, then characterize and
18
+ # create derivatives with this on disk variant.
19
19
  # TODO: create a job to monitor this directory and prune old files that
20
20
  # have made it to the repo
21
21
  # @param [File, ActionDigest::HTTP::UploadedFile, Tempfile] file the file to save in the repository
@@ -23,7 +23,6 @@ module CurationConcerns
23
23
  working_file = 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
- make_derivative(file_set, working_file)
27
26
  true
28
27
  end
29
28
 
@@ -35,20 +34,16 @@ module CurationConcerns
35
34
 
36
35
  CurationConcerns::VersioningService.create(repository_file, user)
37
36
 
38
- # Retrieve a copy of the orginal file from the repository
37
+ # Retrieve a copy of the original file from the repository
39
38
  working_file = copy_repository_resource_to_working_directory(repository_file)
40
- make_derivative(file_set, working_file)
39
+ CharacterizeJob.perform_later(file_set, working_file)
41
40
  true
42
41
  end
43
42
 
44
43
  private
45
44
 
46
- def make_derivative(file_set, working_file)
47
- CharacterizeJob.perform_later(file_set, working_file)
48
- end
49
-
50
45
  # @param [File, ActionDispatch::Http::UploadedFile] file
51
- # @param [String] id the identifer of the FileSet
46
+ # @param [String] id the identifier of the FileSet
52
47
  # @return [String] path of the working file
53
48
  def copy_file_to_working_directory(file, id)
54
49
  file_name = file.respond_to?(:original_filename) ? file.original_filename : ::File.basename(file)
@@ -61,7 +56,7 @@ module CurationConcerns
61
56
  copy_stream_to_working_directory(file_set.id, file.original_name, StringIO.new(file.content))
62
57
  end
63
58
 
64
- # @param [String] id the identifer
59
+ # @param [String] id the identifier
65
60
  # @param [String] name the file name
66
61
  # @param [#read] stream the stream to copy to the working directory
67
62
  # @return [String] path of the working file
@@ -3,7 +3,7 @@ Blacklight.onLoad(function() {
3
3
  if(tools.length > 0) {
4
4
  tools.affix({
5
5
  offset: {
6
- top: $("#file-manager-tools").parent().offset().top,
6
+ top: $("#file-manager-tools .actions").offset().top,
7
7
  bottom: function() {
8
8
  return $("#file-manager-extra-tools").outerHeight(true) + $("footer").outerHeight(true)
9
9
  }
@@ -102,7 +102,7 @@
102
102
  }
103
103
  @media (min-width: $screen-md-min) {
104
104
  &.affix {
105
- top: 0;
105
+ top: -50px;
106
106
  width: 235px;
107
107
  }
108
108
  }
@@ -7,9 +7,12 @@ module CurationConcerns::FileSetHelper
7
7
  end
8
8
  end
9
9
 
10
- def media_display(file_set, locals = {})
11
- render media_display_partial(file_set),
12
- locals.merge(file_set: file_set)
10
+ # REVIEW: Since this media display could theoretically work for
11
+ # any object that inplements to_s and the Mime Type methos (image? audio? ...),
12
+ # Should this really be in file_set or could it be in it's own helper class like media_helper?
13
+ def media_display(presenter, locals = {})
14
+ render media_display_partial(presenter),
15
+ locals.merge(file_set: presenter)
13
16
  end
14
17
 
15
18
  def media_display_partial(file_set)
@@ -2,9 +2,10 @@ class CharacterizeJob < ActiveJob::Base
2
2
  queue_as CurationConcerns.config.ingest_queue_name
3
3
 
4
4
  # @param [FileSet] file_set
5
- # @param [String] filename a local path for the file to characterize. By using this, we don't have to pull a copy out of fedora.
5
+ # @param [String] filename a local path for the file to characterize so we don't have to pull a copy out of fedora.
6
6
  def perform(file_set, filename)
7
- Hydra::Works::CharacterizationService.run(file_set, filename)
7
+ raise LoadError, "#{file_set.class.characterization_proxy} was not found" unless file_set.characterization_proxy?
8
+ Hydra::Works::CharacterizationService.run(file_set.characterization_proxy, filename)
8
9
  file_set.save!
9
10
  CreateDerivativesJob.perform_later(file_set, filename)
10
11
  end
@@ -24,5 +24,6 @@ class IngestFileJob < ActiveJob::Base
24
24
 
25
25
  # Do post file ingest actions
26
26
  CurationConcerns::VersioningService.create(file_set.send(relation.to_sym), user)
27
+ CharacterizeJob.perform_later(file_set, filename)
27
28
  end
28
29
  end
@@ -0,0 +1,47 @@
1
+ # This module points the FileSet to the location of the technical metdata.
2
+ # By default, the file holding the metadata is :original_file and the terms
3
+ # are listed under ::characterization_terms.
4
+ # Implementations may define their own terms or use a different source file, but
5
+ # any terms must be set on the ::characterization_proxy by the Hydra::Works::CharacterizationService
6
+ #
7
+ # class MyFileSet
8
+ # include CurationConcerns::FileSetBehavior
9
+ # end
10
+ #
11
+ # MyFileSet.characterization_proxy = :master_file
12
+ # MyFileSet.characterization_terms = [:term1, :term2, :term3]
13
+ module CurationConcerns
14
+ module FileSet
15
+ module Characterization
16
+ extend ActiveSupport::Concern
17
+
18
+ included do
19
+ class_attribute :characterization_terms, :characterization_proxy
20
+ self.characterization_terms = [
21
+ :format_label, :file_size, :height, :width, :filename, :well_formed,
22
+ :page_count, :file_title, :last_modified, :original_checksum, :mime_type
23
+ ]
24
+ self.characterization_proxy = :original_file
25
+
26
+ delegate(*characterization_terms, to: :characterization_proxy)
27
+
28
+ def characterization_proxy
29
+ send(self.class.characterization_proxy) || NullCharacterizationProxy.new
30
+ end
31
+
32
+ def characterization_proxy?
33
+ !characterization_proxy.is_a?(NullCharacterizationProxy)
34
+ end
35
+ end
36
+
37
+ class NullCharacterizationProxy
38
+ def method_missing(*_args)
39
+ []
40
+ end
41
+
42
+ def mime_type
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,15 +1,11 @@
1
1
  module CurationConcerns
2
2
  module FileSetBehavior
3
3
  extend ActiveSupport::Concern
4
- # BasicMetadata needs to be included before Characterization since
5
- # both of them declare properties with the same predicate (dc:creator
6
- # and dc:language.) Loading BasicMetadata first allows Characterization
7
- # to detect the duplicate (via the AlreadyThereStrategy) and prevents
8
- # the warning.
4
+
9
5
  include CurationConcerns::BasicMetadata
10
6
  include Hydra::Works::FileSetBehavior
11
7
  include Hydra::Works::VirusCheck
12
- include CurationConcerns::Characterization
8
+ include CurationConcerns::FileSet::Characterization
13
9
  include Hydra::WithDepositor
14
10
  include CurationConcerns::Serializers
15
11
  include CurationConcerns::Noid
@@ -17,7 +17,7 @@ module CurationConcerns
17
17
  :to_s, to: :solr_document
18
18
 
19
19
  # Metadata Methods
20
- delegate :title, :description, :creator, :contributor, :subject, :publisher, :language,
20
+ delegate :title, :description, :creator, :contributor, :subject, :publisher, :keyword, :language,
21
21
  :embargo_release_date, :lease_expiration_date, :rights, :date_created, to: :solr_document
22
22
 
23
23
  def size
@@ -40,6 +40,12 @@ module CurationConcerns
40
40
  @file_set_presenters ||= member_presenters(ordered_ids & file_set_ids)
41
41
  end
42
42
 
43
+ # @return FileSetPresenter presenter for the representative FileSets
44
+ def representative_presenter
45
+ return nil if representative_id.blank?
46
+ @representative_presenter ||= member_presenters([representative_id]).first
47
+ end
48
+
43
49
  # @return [Array<WorkShowPresenter>] presenters for the ordered_members that are not FileSets
44
50
  def work_presenters
45
51
  @work_presenters ||= member_presenters(ordered_ids - file_set_ids, work_presenter_class)
@@ -1,5 +1,5 @@
1
- <% if presenter.representative_id.present? && (fs = ::FileSet.find(presenter.representative_id)) %>
2
- <%= media_display fs %>
1
+ <% if presenter.representative_id.present? %>
2
+ <%= media_display presenter.representative_presenter %>
3
3
  <% else %>
4
4
  <%= image_tag 'nope.png', class: "canonical-image" %>
5
5
  <% end %>
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'sprockets-es6'
30
30
  spec.add_dependency 'kaminari_route_prefix', '~> 0.0.1'
31
31
  spec.add_dependency 'active_attr'
32
- spec.add_dependency 'hydra-works', '>= 0.10.0'
32
+ spec.add_dependency 'hydra-works', '>= 0.11.0'
33
33
  spec.add_dependency 'active_fedora-noid', '~> 1.0'
34
34
  spec.add_dependency 'qa', '~> 0.5'
35
35
  spec.add_dependency 'redlock', '~> 0.1.2'
@@ -1,3 +1,3 @@
1
1
  module CurationConcerns
2
- VERSION = "1.0.0.beta2".freeze
2
+ VERSION = "1.0.0.beta3".freeze
3
3
  end
@@ -1,6 +1,8 @@
1
1
  # Generated via
2
2
  # `rails generate curation_concerns:work <%= class_name %>`
3
- module CurationConcerns::Actors
4
- class <%= class_name %>Actor < CurationConcerns::Actors::BaseActor
3
+ module CurationConcerns
4
+ module Actors
5
+ class <%= class_name %>Actor < CurationConcerns::Actors::BaseActor
6
+ end
5
7
  end
6
8
  end
@@ -1,7 +1,9 @@
1
1
  # Generated via
2
2
  # `rails generate curation_concerns:work <%= class_name %>`
3
3
 
4
- class CurationConcerns::<%= class_name.pluralize %>Controller < ApplicationController
5
- include CurationConcerns::CurationConcernController
6
- self.curation_concern_type = <%= class_name %>
4
+ module CurationConcerns
5
+ class <%= class_name.pluralize %>Controller < ApplicationController
6
+ include CurationConcerns::CurationConcernController
7
+ self.curation_concern_type = <%= class_name %>
8
+ end
7
9
  end
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe CurationConcerns::Actors::FileActor do
4
4
  include ActionDispatch::TestProcess
5
+ include CurationConcerns::FactoryHelpers
6
+
5
7
  let(:user) { create(:user) }
6
8
  let(:file_set) { create(:file_set) }
7
9
  let(:relation) { create(:file_set) }
@@ -10,9 +12,25 @@ describe CurationConcerns::Actors::FileActor do
10
12
 
11
13
  describe '#ingest_file' do
12
14
  it 'calls ingest file job' do
13
- expect(CharacterizeJob).to receive(:perform_later)
14
15
  expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user, 'remastered')
15
16
  actor.ingest_file(uploaded_file)
16
17
  end
17
18
  end
19
+
20
+ describe '#revert_to' do
21
+ let(:revision_id) { 'asdf1234' }
22
+ let(:previous_version) { mock_file_factory }
23
+ let(:file_path) { 'path/to/working_file' }
24
+ before do
25
+ allow(file_set).to receive(:remastered).and_return(previous_version)
26
+ allow(previous_version).to receive(:restore_version).with(revision_id)
27
+ allow(previous_version).to receive(:original_name).and_return('original_name')
28
+ end
29
+ it 'reverts to a previous version of a file' do
30
+ expect(CurationConcerns::VersioningService).to receive(:create).with(previous_version, user)
31
+ expect(actor).to receive(:copy_repository_resource_to_working_directory).with(previous_version).and_return(file_path)
32
+ expect(CharacterizeJob).to receive(:perform_later).with(file_set, file_path)
33
+ actor.revert_to(revision_id)
34
+ end
35
+ end
18
36
  end
@@ -21,7 +21,6 @@ describe CurationConcerns::Actors::FileSetActor do
21
21
  end
22
22
 
23
23
  before do
24
- expect(CharacterizeJob).to receive(:perform_later)
25
24
  expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user, 'original_file')
26
25
  allow(actor).to receive(:acquire_lock_for).and_yield
27
26
  actor.create_metadata(work)
@@ -67,14 +66,12 @@ describe CurationConcerns::Actors::FileSetActor do
67
66
 
68
67
  describe '#create_content' do
69
68
  it 'calls ingest file job' do
70
- expect(CharacterizeJob).to receive(:perform_later)
71
69
  expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user, 'original_file')
72
70
  actor.create_content(uploaded_file)
73
71
  end
74
72
 
75
73
  context 'when an alternative relationship is specified' do
76
74
  it 'calls ingest file job' do
77
- expect(CharacterizeJob).to receive(:perform_later)
78
75
  expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user, 'remastered')
79
76
  actor.create_content(uploaded_file, 'remastered')
80
77
  end
@@ -82,7 +79,6 @@ describe CurationConcerns::Actors::FileSetActor do
82
79
 
83
80
  context 'using ::File' do
84
81
  before do
85
- allow(CharacterizeJob).to receive(:perform_later)
86
82
  allow(IngestFileJob).to receive(:perform_later)
87
83
  actor.create_content(local_file)
88
84
  end
@@ -104,7 +100,6 @@ describe CurationConcerns::Actors::FileSetActor do
104
100
  let(:actor) { described_class.new(file_set, user) }
105
101
 
106
102
  before do
107
- allow(CharacterizeJob).to receive(:perform_later)
108
103
  allow(IngestFileJob).to receive(:perform_later)
109
104
  allow(file_set).to receive(:label).and_return(short_name)
110
105
  # TODO: we should allow/expect call to IngestJob
@@ -129,7 +124,6 @@ describe CurationConcerns::Actors::FileSetActor do
129
124
 
130
125
  before do
131
126
  allow(IngestFileJob).to receive(:perform_later)
132
- allow(CharacterizeJob).to receive(:perform_later)
133
127
  actor.create_content(fixture_file_upload(file))
134
128
  end
135
129
 
@@ -165,7 +165,6 @@ describe CurationConcerns::FileSetsController do
165
165
  context 'updating file content' do
166
166
  it 'is successful' do
167
167
  expect(IngestFileJob).to receive(:perform_later)
168
- expect(CharacterizeJob).to receive(:perform_later).with(file_set, kind_of(String))
169
168
  post :update, id: file_set, file_set: { files: [file] }
170
169
  expect(response).to redirect_to main_app.curation_concerns_file_set_path(file_set)
171
170
  end
@@ -23,6 +23,13 @@ FactoryGirl.define do
23
23
  end
24
24
  end
25
25
 
26
+ factory :work_with_representative_file do
27
+ before(:create) do |work, evaluator|
28
+ work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user, title: ['A Contained FileSet'])
29
+ work.representative_id = work.members[0].id
30
+ end
31
+ end
32
+
26
33
  factory :work_with_file_and_work do
27
34
  before(:create) do |work, evaluator|
28
35
  work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user)
@@ -1,18 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CharacterizeJob do
4
- let(:file_set) { FileSet.new(id: file_set_id) }
4
+ include CurationConcerns::FactoryHelpers
5
+
6
+ let(:file_set) { FileSet.new(id: file_set_id) }
5
7
  let(:file_set_id) { 'abc123' }
6
- let(:filename) { double }
8
+ let(:filename) { double }
9
+ let(:file) { mock_file_factory }
7
10
 
8
11
  before do
9
12
  allow(FileSet).to receive(:find).with(file_set_id).and_return(file_set)
13
+ allow(file_set).to receive(:original_file).and_return(file)
14
+ end
15
+
16
+ context 'when the characterization proxy content is present' do
17
+ it 'runs Hydra::Works::CharacterizationService and creates a CreateDerivativesJob' do
18
+ expect(Hydra::Works::CharacterizationService).to receive(:run).with(file, filename)
19
+ expect(file_set).to receive(:save!)
20
+ expect(CreateDerivativesJob).to receive(:perform_later).with(file_set, filename)
21
+ described_class.perform_now(file_set, filename)
22
+ end
10
23
  end
11
24
 
12
- it 'runs Hydra::Works::CharacterizationService and creates a CreateDerivativesJob' do
13
- expect(Hydra::Works::CharacterizationService).to receive(:run).with(file_set, filename)
14
- expect(file_set).to receive(:save!)
15
- expect(CreateDerivativesJob).to receive(:perform_later).with(file_set, filename)
16
- described_class.perform_now file_set, filename
25
+ context 'when the characterization proxy content is absent' do
26
+ before { allow(file_set).to receive(:characterization_proxy?).and_return(false) }
27
+ it 'raises an error' do
28
+ expect { described_class.perform_now(file_set, filename) }.to raise_error(LoadError, 'original_file was not found')
29
+ end
17
30
  end
18
31
  end
@@ -20,6 +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, filename)
23
24
  described_class.perform_now(file_set, filename, 'image/png', 'bob', 'remastered')
24
25
  expect(file_set.reload.remastered.mime_type).to eq 'image/png'
25
26
  end
@@ -27,6 +28,7 @@ describe IngestFileJob do
27
28
 
28
29
  context 'when given a mime_type' do
29
30
  it 'uses the provided mime_type' do
31
+ expect(CharacterizeJob).to receive(:perform_later).with(file_set, filename)
30
32
  described_class.perform_now(file_set, filename, 'image/png', 'bob')
31
33
  expect(file_set.reload.original_file.mime_type).to eq 'image/png'
32
34
  end
@@ -38,6 +40,7 @@ describe IngestFileJob do
38
40
  # The parameter versioning: false instructs the machinery in Hydra::Works NOT to do versioning. So it can be handled later on.
39
41
  allow(CurationConcerns::VersioningService).to receive(:create)
40
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, filename)
41
44
  described_class.perform_now(file_set, filename, nil, 'bob')
42
45
  end
43
46
  end
@@ -49,6 +52,7 @@ describe IngestFileJob do
49
52
  let(:user2) { create(:user) }
50
53
 
51
54
  before do
55
+ allow(Hydra::Works::CharacterizationService).to receive(:run).with(any_args)
52
56
  described_class.perform_now(file_set, file1, 'image/png', user.user_key)
53
57
  described_class.perform_now(file_set, file2, 'text/plain', user2.user_key)
54
58
  end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe CurationConcerns::FileSet do
4
+ include CurationConcerns::FactoryHelpers
5
+
6
+ let(:file_set) { create(:file_set) }
7
+ let(:file) { mock_file_factory }
8
+
9
+ subject { file_set }
10
+
11
+ describe '::characterization_proxy' do
12
+ subject { file_set.class.characterization_proxy }
13
+ it { is_expected.to eq(:original_file) }
14
+ end
15
+
16
+ describe '::characterization_terms' do
17
+ subject { file_set.class.characterization_terms }
18
+ it { is_expected.to contain_exactly(:format_label, :file_size, :height, :width, :filename, :well_formed,
19
+ :page_count, :file_title, :last_modified, :original_checksum, :mime_type) }
20
+ end
21
+
22
+ describe 'characterization_proxy' do
23
+ subject { file_set.characterization_proxy }
24
+ context 'when no proxy is present' do
25
+ it { is_expected.to be_kind_of(CurationConcerns::FileSet::Characterization::NullCharacterizationProxy) }
26
+ end
27
+
28
+ context 'with a proxy' do
29
+ before { allow(file_set).to receive(:original_file).and_return(file) }
30
+ it { is_expected.to eq(file) }
31
+ end
32
+ end
33
+
34
+ describe '#characterization_proxy?' do
35
+ subject { file_set.characterization_proxy? }
36
+ context 'when no proxy is present' do
37
+ it { is_expected.to be false }
38
+ end
39
+
40
+ context 'with a proxy' do
41
+ before { allow(file_set).to receive(:original_file).and_return(file) }
42
+ it { is_expected.to be true }
43
+ end
44
+ end
45
+
46
+ context 'with a custom proxy' do
47
+ let(:custom_file_set) { build(:file_set) }
48
+ before { FileSet.characterization_proxy = :custom_proxy }
49
+ after { FileSet.characterization_proxy = :original_file }
50
+ subject { custom_file_set.class.characterization_proxy }
51
+ it { is_expected.to eq(:custom_proxy) }
52
+ end
53
+ end
@@ -6,6 +6,7 @@ describe CurationConcerns::CollectionPresenter do
6
6
  id: 'adc12v',
7
7
  description: ['a nice collection'],
8
8
  title: ['A clever title'],
9
+ keyword: ['neologism'],
9
10
  date_created: ['some date'])
10
11
  end
11
12
  let(:work) { build(:work, title: ['unimaginitive title']) }
@@ -21,6 +22,11 @@ describe CurationConcerns::CollectionPresenter do
21
22
  it { is_expected.to eq ['A clever title'] }
22
23
  end
23
24
 
25
+ describe '#keyword' do
26
+ subject { presenter.keyword }
27
+ it { is_expected.to eq ['neologism'] }
28
+ end
29
+
24
30
  describe '#to_key' do
25
31
  subject { presenter.to_key }
26
32
  it { is_expected.to eq ['adc12v'] }
@@ -109,6 +109,20 @@ describe CurationConcerns::WorkShowPresenter do
109
109
  end
110
110
  end
111
111
 
112
+ describe "#representative_presenter" do
113
+ let(:obj) { create(:work_with_representative_file) }
114
+ let(:attributes) { obj.to_solr }
115
+ let(:presenter_class) { double }
116
+ before do
117
+ allow(presenter).to receive(:file_presenter_class).and_return(presenter_class)
118
+ end
119
+ it "has a representative" do
120
+ expect(CurationConcerns::PresenterFactory).to receive(:build_presenters)
121
+ .with([obj.members[0].id], presenter_class, ability).and_return ["abc"]
122
+ expect(presenter.representative_presenter).to eq("abc")
123
+ end
124
+ end
125
+
112
126
  describe "#collection_presenters" do
113
127
  let(:collection) { create(:collection) }
114
128
  let(:obj) { create(:work) }
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.beta2
4
+ version: 1.0.0.beta3
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-05-13 00:00:00.000000000 Z
13
+ date: 2016-05-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hydra-head
@@ -178,14 +178,14 @@ dependencies:
178
178
  requirements:
179
179
  - - ">="
180
180
  - !ruby/object:Gem::Version
181
- version: 0.10.0
181
+ version: 0.11.0
182
182
  type: :runtime
183
183
  prerelease: false
184
184
  version_requirements: !ruby/object:Gem::Requirement
185
185
  requirements:
186
186
  - - ">="
187
187
  - !ruby/object:Gem::Version
188
- version: 0.10.0
188
+ version: 0.11.0
189
189
  - !ruby/object:Gem::Dependency
190
190
  name: active_fedora-noid
191
191
  requirement: !ruby/object:Gem::Requirement
@@ -710,10 +710,10 @@ files:
710
710
  - app/models/collection.rb
711
711
  - app/models/concerns/curation_concerns/ability.rb
712
712
  - app/models/concerns/curation_concerns/basic_metadata.rb
713
- - app/models/concerns/curation_concerns/characterization.rb
714
713
  - app/models/concerns/curation_concerns/collection.rb
715
714
  - app/models/concerns/curation_concerns/collection_behavior.rb
716
715
  - app/models/concerns/curation_concerns/file_set/belongs_to_works.rb
716
+ - app/models/concerns/curation_concerns/file_set/characterization.rb
717
717
  - app/models/concerns/curation_concerns/file_set/derivatives.rb
718
718
  - app/models/concerns/curation_concerns/file_set/full_text_indexing.rb
719
719
  - app/models/concerns/curation_concerns/file_set/indexing.rb
@@ -1102,6 +1102,7 @@ files:
1102
1102
  - spec/models/checksum_audit_log_spec.rb
1103
1103
  - spec/models/collection_spec.rb
1104
1104
  - spec/models/curation_concerns/collection_behavior_spec.rb
1105
+ - spec/models/curation_concerns/file_set/characterization_spec.rb
1105
1106
  - spec/models/curation_concerns/file_set/derivatives_spec.rb
1106
1107
  - spec/models/curation_concerns/operation_spec.rb
1107
1108
  - spec/models/curation_concerns/work_behavior_spec.rb
@@ -1204,7 +1205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1204
1205
  version: 1.3.1
1205
1206
  requirements: []
1206
1207
  rubyforge_project:
1207
- rubygems_version: 2.5.1
1208
+ rubygems_version: 2.6.4
1208
1209
  signing_key:
1209
1210
  specification_version: 4
1210
1211
  summary: A Rails Engine that allows an application to CRUD CurationConcern objects
@@ -1303,6 +1304,7 @@ test_files:
1303
1304
  - spec/models/checksum_audit_log_spec.rb
1304
1305
  - spec/models/collection_spec.rb
1305
1306
  - spec/models/curation_concerns/collection_behavior_spec.rb
1307
+ - spec/models/curation_concerns/file_set/characterization_spec.rb
1306
1308
  - spec/models/curation_concerns/file_set/derivatives_spec.rb
1307
1309
  - spec/models/curation_concerns/operation_spec.rb
1308
1310
  - spec/models/curation_concerns/work_behavior_spec.rb
@@ -1,41 +0,0 @@
1
- # This module points the FileSet to the location of the technical metdata.
2
- # By default, the file holding the metadata is :original_file and the terms
3
- # are listed under ::characterization_terms.
4
- # Implementations may define their own terms or use a different source file, but
5
- # any terms must be set on the ::characterization_proxy by the Hydra::Works::CharacterizationService
6
- #
7
- # class MyFileSet
8
- # include CurationConcerns::FileSetBehavior
9
- # end
10
- #
11
- # MyFileSet.characterization_proxy = :master_file
12
- # MyFileSet.characterization_terms = [:term1, :term2, :term3]
13
- module CurationConcerns
14
- module Characterization
15
- extend ActiveSupport::Concern
16
-
17
- included do
18
- class_attribute :characterization_terms, :characterization_proxy
19
- self.characterization_terms = [
20
- :format_label, :file_size, :height, :width, :filename, :well_formed,
21
- :page_count, :file_title, :last_modified, :original_checksum, :mime_type
22
- ]
23
- self.characterization_proxy = :original_file
24
-
25
- delegate(*characterization_terms, to: :characterization_proxy)
26
-
27
- def characterization_proxy
28
- send(self.class.characterization_proxy) || NullCharacterizationProxy.new
29
- end
30
- end
31
-
32
- class NullCharacterizationProxy
33
- def method_missing(*_args)
34
- []
35
- end
36
-
37
- def mime_type
38
- end
39
- end
40
- end
41
- end