curation_concerns 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +0 -4
- data/app/actors/curation_concerns/actors/file_actor.rb +19 -3
- data/app/assets/javascripts/curation_concerns/curation_concerns.js +1 -0
- data/app/assets/javascripts/curation_concerns/file_manager/sorting.es6 +44 -5
- data/app/assets/javascripts/curation_concerns/file_manager.es6 +9 -2
- data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +57 -18
- data/app/controllers/concerns/curation_concerns/permissions_controller_behavior.rb +23 -0
- data/app/controllers/concerns/curation_concerns/selects_collections.rb +2 -0
- data/app/controllers/curation_concerns/permissions_controller.rb +1 -16
- data/app/forms/curation_concerns/forms/work_form.rb +0 -7
- data/app/helpers/batch_select_helper.rb +0 -15
- data/app/helpers/curation_concerns/collections_helper.rb +40 -6
- data/app/helpers/curation_concerns/main_app_helpers.rb +0 -2
- data/app/jobs/characterize_job.rb +5 -3
- data/app/jobs/create_derivatives_job.rb +3 -2
- data/app/jobs/ingest_file_job.rb +16 -16
- data/app/models/concerns/curation_concerns/admin_set_behavior.rb +5 -0
- data/app/models/concerns/curation_concerns/basic_metadata.rb +8 -0
- data/app/models/concerns/curation_concerns/collection_behavior.rb +2 -3
- data/app/models/concerns/curation_concerns/serializers.rb +2 -2
- data/app/models/concerns/curation_concerns/solr_document_behavior.rb +3 -2
- data/app/models/concerns/curation_concerns/work_behavior.rb +1 -1
- data/app/presenters/curation_concerns/work_show_presenter.rb +2 -1
- data/app/renderers/curation_concerns/renderers/external_link_attribute_renderer.rb +13 -0
- data/app/renderers/{renderers.rb → curation_concerns/renderers.rb} +0 -0
- data/app/search_builders/curation_concerns/admin_set_search_builder.rb +3 -3
- data/app/search_builders/curation_concerns/collection_search_builder.rb +6 -4
- data/app/search_builders/curation_concerns/file_set_search_builder.rb +3 -3
- data/app/search_builders/curation_concerns/filter_by_type.rb +17 -5
- data/app/search_builders/curation_concerns/member_search_builder.rb +7 -3
- data/app/search_builders/curation_concerns/single_result.rb +1 -1
- data/app/services/curation_concerns/admin_set_service.rb +6 -8
- data/app/services/curation_concerns/indexes_thumbnails.rb +0 -1
- data/app/services/curation_concerns/license_service.rb +8 -0
- data/app/services/curation_concerns/working_directory.rb +4 -2
- data/app/views/collections/_search_form.html.erb +2 -2
- data/app/views/curation_concerns/base/_file_manager_actions.html.erb +1 -0
- data/app/views/curation_concerns/base/_file_manager_member_resource_options.html.erb +4 -0
- data/app/views/curation_concerns/base/_file_manager_resource_form.html.erb +1 -0
- data/app/views/curation_concerns/base/_form_rights.html.erb +3 -2
- data/config/locales/curation_concerns.en.yml +4 -0
- data/curation_concerns.gemspec +3 -3
- data/lib/curation_concerns/version.rb +1 -1
- data/lib/generators/curation_concerns/models_generator.rb +8 -0
- data/lib/generators/curation_concerns/templates/spec/models/collection_spec.rb +7 -0
- data/lib/generators/curation_concerns/templates/spec/models/file_set_spec.rb +7 -0
- data/spec/actors/curation_concerns/file_actor_spec.rb +17 -3
- data/spec/actors/curation_concerns/file_set_actor_spec.rb +34 -8
- data/spec/controllers/curation_concerns/collections_controller_spec.rb +3 -4
- data/spec/controllers/selects_collections_controller_spec.rb +7 -2
- data/spec/factories/generic_works.rb +3 -1
- data/spec/features/collection_spec.rb +2 -0
- data/spec/helpers/curation_concerns/collections_helper_spec.rb +87 -3
- data/spec/indexers/file_set_indexer_spec.rb +3 -0
- data/spec/indexers/work_indexer_spec.rb +2 -1
- data/spec/javascripts/file_manager_member_spec.coffee +2 -1
- data/spec/javascripts/file_manager_sorting_spec.coffee +23 -0
- data/spec/javascripts/fixtures/sortable.html +182 -0
- data/spec/javascripts/save_manager_spec.coffee +2 -1
- data/spec/jobs/characterize_job_spec.rb +18 -1
- data/spec/jobs/ingest_file_job_spec.rb +18 -13
- data/spec/models/admin_set_spec.rb +5 -3
- data/spec/models/file_set_spec.rb +2 -4
- data/spec/models/solr_document_spec.rb +17 -3
- data/spec/presenters/curation_concerns/collection_presenter_spec.rb +5 -0
- data/spec/renderers/curation_concerns/renderers/external_link_attribute_renderer_spec.rb +22 -0
- data/spec/search_builders/curation_concerns/admin_set_search_builder_spec.rb +8 -5
- data/spec/search_builders/curation_concerns/file_set_search_builder_spec.rb +2 -2
- data/spec/services/curation_concerns/admin_set_service_spec.rb +53 -22
- data/spec/spec_helper.rb +1 -2
- data/spec/test_app_templates/Gemfile.extra +4 -0
- data/spec/views/curation_concerns/base/_attributes.html.erb_spec.rb +10 -4
- data/spec/views/curation_concerns/base/file_manager.html.erb_spec.rb +8 -0
- data/spec/views/curation_concerns/base/show.json.jbuilder_spec.rb +1 -1
- data/spec/views/curation_concerns/file_sets/show.json.jbuilder_spec.rb +1 -1
- metadata +19 -22
- data/app/helpers/collections_helper.rb +0 -4
- data/app/helpers/curation_concerns/collections_helper_behavior.rb +0 -41
- data/app/helpers/curation_concerns/permissions_helper.rb +0 -19
- data/app/helpers/curation_concerns/rights_helper.rb +0 -9
- data/app/models/collection.rb +0 -6
- data/spec/helpers/collections_helper_spec.rb +0 -88
@@ -38,7 +38,8 @@ module CurationConcerns
|
|
38
38
|
# Metadata Methods
|
39
39
|
delegate :title, :date_created, :date_modified, :date_uploaded, :description,
|
40
40
|
:creator, :contributor, :subject, :publisher, :language, :embargo_release_date,
|
41
|
-
:lease_expiration_date, :rights, :source, :thumbnail_id,
|
41
|
+
:lease_expiration_date, :rights, :source, :thumbnail_id, :representative_id,
|
42
|
+
to: :solr_document
|
42
43
|
|
43
44
|
# @return [Array<FileSetPresenter>] presenters for the orderd_members that are FileSets
|
44
45
|
def file_set_presenters
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module CurationConcerns
|
2
|
+
module Renderers
|
3
|
+
class ExternalLinkAttributeRenderer < AttributeRenderer
|
4
|
+
private
|
5
|
+
|
6
|
+
def li_value(value)
|
7
|
+
auto_link(value) do |link|
|
8
|
+
"<span class='glyphicon glyphicon-new-window'></span> #{link}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
File without changes
|
@@ -5,9 +5,9 @@ module CurationConcerns
|
|
5
5
|
super(context)
|
6
6
|
end
|
7
7
|
|
8
|
-
# This overrides the
|
9
|
-
def
|
10
|
-
|
8
|
+
# This overrides the models in FilterByType
|
9
|
+
def models
|
10
|
+
[::AdminSet]
|
11
11
|
end
|
12
12
|
|
13
13
|
# Overrides Hydra::AccessControlsEnforcement
|
@@ -1,16 +1,18 @@
|
|
1
1
|
module CurationConcerns
|
2
2
|
class CollectionSearchBuilder < ::SearchBuilder
|
3
|
+
include FilterByType
|
3
4
|
# Defines which search_params_logic should be used when searching for Collections
|
4
5
|
self.default_processor_chain = [:default_solr_parameters, :add_query_to_solr,
|
5
|
-
:add_access_controls_to_solr_params, :
|
6
|
+
:add_access_controls_to_solr_params, :filter_models,
|
7
|
+
:some_rows, :sort_by_title]
|
6
8
|
|
7
9
|
def some_rows(solr_parameters)
|
8
10
|
solr_parameters[:rows] = '100'
|
9
11
|
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
# This overrides FilterByType and ensures we only match on collections.
|
14
|
+
def only_collections?
|
15
|
+
true
|
14
16
|
end
|
15
17
|
|
16
18
|
# Sort results by title if no query was supplied.
|
@@ -2,9 +2,9 @@ module CurationConcerns
|
|
2
2
|
class FileSetSearchBuilder < ::SearchBuilder
|
3
3
|
include CurationConcerns::SingleResult
|
4
4
|
|
5
|
-
# This overrides the
|
6
|
-
def
|
7
|
-
|
5
|
+
# This overrides the models in FilterByType
|
6
|
+
def models
|
7
|
+
[::FileSet]
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -9,7 +9,7 @@ module CurationConcerns
|
|
9
9
|
# Add queries that excludes everything except for works and collections
|
10
10
|
def filter_models(solr_parameters)
|
11
11
|
solr_parameters[:fq] ||= []
|
12
|
-
solr_parameters[:fq] <<
|
12
|
+
solr_parameters[:fq] << "{!terms f=has_model_ssim}#{models_to_solr_clause}"
|
13
13
|
end
|
14
14
|
|
15
15
|
protected
|
@@ -22,8 +22,19 @@ module CurationConcerns
|
|
22
22
|
generic_type_field.include?('Work')
|
23
23
|
end
|
24
24
|
|
25
|
+
# Override this method if you want to filter for a different set of models.
|
26
|
+
# @return [Array<Class>] a list of classes to include
|
27
|
+
def models
|
28
|
+
work_classes + collection_classes
|
29
|
+
end
|
30
|
+
|
25
31
|
private
|
26
32
|
|
33
|
+
def models_to_solr_clause
|
34
|
+
# to_class_uri is deprecated in AF 11
|
35
|
+
[ActiveFedora::Base.respond_to?(:to_rdf_representation) ? models.map(&:to_rdf_representation) : models.map(&:to_class_uri)].join(',')
|
36
|
+
end
|
37
|
+
|
27
38
|
def generic_type_field
|
28
39
|
Array.wrap(blacklight_params.fetch(:f, {}).fetch(:generic_type_sim, []))
|
29
40
|
end
|
@@ -35,14 +46,15 @@ module CurationConcerns
|
|
35
46
|
CurationConcerns.config.curation_concerns
|
36
47
|
end
|
37
48
|
|
38
|
-
def
|
49
|
+
def work_classes
|
39
50
|
return [] if only_collections?
|
40
|
-
work_types
|
51
|
+
work_types
|
41
52
|
end
|
42
53
|
|
43
|
-
def
|
54
|
+
def collection_classes
|
44
55
|
return [] if only_works?
|
45
|
-
|
56
|
+
# to_class_uri is deprecated in AF 11
|
57
|
+
[::Collection]
|
46
58
|
end
|
47
59
|
end
|
48
60
|
end
|
@@ -6,12 +6,16 @@ module CurationConcerns
|
|
6
6
|
# Defines which search_params_logic should be used when searching for Collection members
|
7
7
|
self.default_processor_chain += [:include_collection_ids]
|
8
8
|
|
9
|
-
delegate :collection, to: :scope
|
10
|
-
|
11
9
|
# include filters into the query to only include the collection memebers
|
12
10
|
def include_collection_ids(solr_parameters)
|
13
11
|
solr_parameters[:fq] ||= []
|
14
|
-
solr_parameters[:fq] << "{!join from=#{from_field} to=id}id:#{
|
12
|
+
solr_parameters[:fq] << "{!join from=#{from_field} to=id}id:#{collection_id}"
|
15
13
|
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def collection_id
|
18
|
+
blacklight_params.fetch('id')
|
19
|
+
end
|
16
20
|
end
|
17
21
|
end
|
@@ -14,13 +14,11 @@ module CurationConcerns
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
response.documents
|
24
|
-
end
|
17
|
+
# @param [Symbol] access :read or :edit
|
18
|
+
def search_results(access)
|
19
|
+
builder = AdminSetSearchBuilder.new(context, access)
|
20
|
+
response = context.repository.search(builder)
|
21
|
+
response.documents
|
22
|
+
end
|
25
23
|
end
|
26
24
|
end
|
@@ -20,7 +20,6 @@ module CurationConcerns
|
|
20
20
|
# @params [Hash] solr_document the solr document to add the field to
|
21
21
|
def index_thumbnails(solr_document)
|
22
22
|
solr_document[thumbnail_field] = thumbnail_path
|
23
|
-
solr_document[Solrizer.solr_name('thumbnail_id', :symbol)] = object.thumbnail_id
|
24
23
|
end
|
25
24
|
|
26
25
|
# Returns the value for the thumbnail path to put into the solr document
|
@@ -4,5 +4,13 @@ module CurationConcerns
|
|
4
4
|
def initialize
|
5
5
|
super('licenses')
|
6
6
|
end
|
7
|
+
|
8
|
+
def include_current_value(value, _index, render_options, html_options)
|
9
|
+
unless value.blank? || active?(value)
|
10
|
+
html_options[:class] << ' force-select'
|
11
|
+
render_options += [[label(value), value]]
|
12
|
+
end
|
13
|
+
[render_options, html_options]
|
14
|
+
end
|
7
15
|
end
|
8
16
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module CurationConcerns
|
2
|
-
|
2
|
+
class WorkingDirectory
|
3
3
|
class << self
|
4
4
|
# @param [String] repository_file_id identifier for Hydra::PCDM::File
|
5
5
|
# @param [String] id the identifier of the FileSet
|
6
|
+
# @param [String, NilClass] filepath path to existing cached copy of the file
|
6
7
|
# @return [String] path of the working file
|
7
|
-
def find_or_retrieve(repository_file_id, id)
|
8
|
+
def find_or_retrieve(repository_file_id, id, filepath = nil)
|
9
|
+
return filepath if filepath && File.exist?(filepath)
|
8
10
|
repository_file = Hydra::PCDM::File.find(repository_file_id)
|
9
11
|
working_path = full_filename(id, repository_file.original_name)
|
10
12
|
if File.exist?(working_path)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= form_for presenter, method: :get, class: "well form-search" do |f| %>
|
2
|
-
<label class="sr-only"
|
2
|
+
<label class="sr-only"><%= t('curation_concerns.collections.search_form.label', title: presenter.to_s) %></label>
|
3
3
|
<div class="input-group">
|
4
|
-
<%= text_field_tag :cq, params[:cq], class: "collection-query form-control", placeholder:
|
4
|
+
<%= text_field_tag :cq, params[:cq], class: "collection-query form-control", placeholder: t('curation_concerns.collections.search_form.placeholder'), size: '30', type: "search", id: "collection_search" %>
|
5
5
|
<div class="input-group-btn">
|
6
6
|
<button type="submit" class="btn btn-primary" id="collection_submit"><i class="glyphicon glyphicon-search"></i> Go</button>
|
7
7
|
</div>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
<div class="actions form-horizontal panel panel-default">
|
2
2
|
<%= button_tag "Save", class: "btn btn-primary disabled", data: { action: "save-actions" }%>
|
3
|
+
<%= button_tag "Sort alphabetically", class: "btn btn-primary", data: { action: "alpha-sort-action" }%>
|
3
4
|
</div>
|
4
5
|
<%= render "file_manager_resource_form" %>
|
@@ -3,4 +3,8 @@
|
|
3
3
|
<%= radio_button_tag "thumbnail_id", node.id, @presenter.thumbnail_id == node.id, id: "thumbnail_id_#{node.id}", class: "radio_buttons" %>
|
4
4
|
<%= label_tag "thumbnail_id_#{node.id}", "Thumbnail" %>
|
5
5
|
</span>
|
6
|
+
<span class="radio">
|
7
|
+
<%= radio_button_tag "representative_id", node.id, @presenter.representative_id == node.id, id: "representative_id_#{node.id}", class: "radio_buttons" %>
|
8
|
+
<%= label_tag "representative_id_#{node.id}", "Representative Media" %>
|
9
|
+
</span>
|
6
10
|
</div>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<div class="resource-form-container">
|
2
2
|
<%= simple_form_for [main_app, @presenter], remote: true, html: { id: 'resource-form', 'data-type': 'json' } do |f| %>
|
3
3
|
<%= f.input :thumbnail_id, as: :hidden, input_html: { data: {member_link: 'thumbnail_id'}} %>
|
4
|
+
<%= f.input :representative_id, as: :hidden, input_html: { data: {member_link: 'representative_id'}} %>
|
4
5
|
<% end %>
|
5
6
|
</div>
|
@@ -9,10 +9,11 @@
|
|
9
9
|
<a href="http://creativecommons.org/licenses/" target="_blank">Here's some help</a> if you don't know which license to choose.
|
10
10
|
</p>
|
11
11
|
|
12
|
+
<% license_service = CurationConcerns::LicenseService.new %>
|
12
13
|
<%= f.input :rights, as: :multi_value_select,
|
13
|
-
collection:
|
14
|
+
collection: license_service.select_active_options,
|
14
15
|
include_blank: true,
|
15
|
-
item_helper: method(:include_current_value),
|
16
|
+
item_helper: license_service.method(:include_current_value),
|
16
17
|
input_html: { class: 'form-control' } %>
|
17
18
|
</fieldset>
|
18
19
|
</div>
|
data/curation_concerns.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency 'sprockets-es6'
|
31
31
|
spec.add_dependency 'kaminari_route_prefix', '~> 0.0.1'
|
32
32
|
spec.add_dependency 'active_attr'
|
33
|
-
spec.add_dependency 'hydra-works', '>= 0.
|
33
|
+
spec.add_dependency 'hydra-works', '>= 0.14.0'
|
34
34
|
spec.add_dependency 'active_fedora-noid', '~> 2.0.0.beta1'
|
35
35
|
spec.add_dependency 'qa', '~> 0.5'
|
36
36
|
spec.add_dependency 'redlock', '~> 0.1.2'
|
@@ -41,12 +41,12 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_dependency 'browse-everything', '~> 0.10'
|
42
42
|
spec.add_dependency 'clipboard-rails', '~> 1.5'
|
43
43
|
|
44
|
-
spec.add_development_dependency 'solr_wrapper', '~> 0.
|
44
|
+
spec.add_development_dependency 'solr_wrapper', '~> 0.16'
|
45
45
|
spec.add_development_dependency 'fcrepo_wrapper', '~> 0.1'
|
46
46
|
spec.add_development_dependency 'devise', '>= 3.0', '< 5'
|
47
47
|
spec.add_development_dependency "bundler", "~> 1.6"
|
48
48
|
spec.add_development_dependency "rake"
|
49
|
-
spec.add_development_dependency "engine_cart", "~> 0
|
49
|
+
spec.add_development_dependency "engine_cart", "~> 1.0"
|
50
50
|
spec.add_development_dependency "sqlite3"
|
51
51
|
spec.add_development_dependency "rspec-its"
|
52
52
|
spec.add_development_dependency "rspec-rails"
|
@@ -38,14 +38,22 @@ This generator makes the following changes to your application:
|
|
38
38
|
|
39
39
|
def create_collection
|
40
40
|
copy_file 'app/models/collection.rb', 'app/models/collection.rb'
|
41
|
+
copy_file 'spec/models/collection_spec.rb', 'spec/models/collection_spec.rb' if rspec_installed?
|
41
42
|
end
|
42
43
|
|
43
44
|
def create_file_set
|
44
45
|
copy_file 'app/models/file_set.rb', 'app/models/file_set.rb'
|
46
|
+
copy_file 'spec/models/file_set_spec.rb', 'spec/models/file_set_spec.rb' if rspec_installed?
|
45
47
|
end
|
46
48
|
|
47
49
|
# Adds clamav initializtion
|
48
50
|
def clamav
|
49
51
|
generate 'curation_concerns:clamav'
|
50
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def rspec_installed?
|
57
|
+
defined?(RSpec) && defined?(RSpec::Rails)
|
58
|
+
end
|
51
59
|
end
|
@@ -9,11 +9,25 @@ describe CurationConcerns::Actors::FileActor do
|
|
9
9
|
let(:relation) { create(:file_set) }
|
10
10
|
let(:actor) { described_class.new(file_set, 'remastered', user) }
|
11
11
|
let(:uploaded_file) { fixture_file_upload('/world.png', 'image/png') }
|
12
|
+
let(:ingest_options) { { mime_type: 'image/png', relation: 'remastered', filename: 'world.png' } }
|
13
|
+
let(:working_file) { CurationConcerns::WorkingDirectory.copy_file_to_working_directory(uploaded_file, file_set.id) }
|
12
14
|
|
13
15
|
describe '#ingest_file' do
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
context "when the file is available locally" do
|
17
|
+
it 'calls ingest file job' do
|
18
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, uploaded_file.path, user, ingest_options)
|
19
|
+
expect(CurationConcerns::WorkingDirectory).not_to receive(:copy_file_to_working_directory)
|
20
|
+
actor.ingest_file(uploaded_file)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
context "when the file is not available locally" do
|
24
|
+
before do
|
25
|
+
allow(actor).to receive(:working_file).with(uploaded_file).and_return(working_file)
|
26
|
+
end
|
27
|
+
it 'calls ingest file job' do
|
28
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, user, ingest_options)
|
29
|
+
actor.ingest_file(uploaded_file)
|
30
|
+
end
|
17
31
|
end
|
18
32
|
end
|
19
33
|
|
@@ -4,11 +4,12 @@ require 'redlock'
|
|
4
4
|
describe CurationConcerns::Actors::FileSetActor do
|
5
5
|
include ActionDispatch::TestProcess
|
6
6
|
|
7
|
-
let(:user)
|
8
|
-
let(:uploaded_file)
|
9
|
-
let(:local_file)
|
10
|
-
let(:file_set)
|
11
|
-
let(:actor)
|
7
|
+
let(:user) { create(:user) }
|
8
|
+
let(:uploaded_file) { fixture_file_upload('/world.png', 'image/png') }
|
9
|
+
let(:local_file) { File.open(File.join(fixture_path, 'world.png')) }
|
10
|
+
let(:file_set) { create(:file_set, content: local_file) }
|
11
|
+
let(:actor) { described_class.new(file_set, user) }
|
12
|
+
let(:ingest_options) { { mime_type: 'image/png', relation: 'original_file', filename: 'world.png' } }
|
12
13
|
|
13
14
|
describe 'creating metadata and content' do
|
14
15
|
let(:upload_set_id) { nil }
|
@@ -21,7 +22,7 @@ describe CurationConcerns::Actors::FileSetActor do
|
|
21
22
|
end
|
22
23
|
|
23
24
|
before do
|
24
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png
|
25
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png/, user, ingest_options)
|
25
26
|
allow(actor).to receive(:acquire_lock_for).and_yield
|
26
27
|
actor.create_metadata(work)
|
27
28
|
actor.create_content(uploaded_file)
|
@@ -66,13 +67,14 @@ describe CurationConcerns::Actors::FileSetActor do
|
|
66
67
|
|
67
68
|
describe '#create_content' do
|
68
69
|
it 'calls ingest file job' do
|
69
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png
|
70
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png/, user, ingest_options)
|
70
71
|
actor.create_content(uploaded_file)
|
71
72
|
end
|
72
73
|
|
73
74
|
context 'when an alternative relationship is specified' do
|
75
|
+
let(:ingest_options) { { mime_type: 'image/png', relation: 'remastered', filename: 'world.png' } }
|
74
76
|
it 'calls ingest file job' do
|
75
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png
|
77
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png/, user, ingest_options)
|
76
78
|
actor.create_content(uploaded_file, 'remastered')
|
77
79
|
end
|
78
80
|
end
|
@@ -285,4 +287,28 @@ describe CurationConcerns::Actors::FileSetActor do
|
|
285
287
|
end
|
286
288
|
end
|
287
289
|
end
|
290
|
+
|
291
|
+
describe '#revert_content' do
|
292
|
+
let(:file_set) { create(:file_set, user: user) }
|
293
|
+
let(:file1) { "small_file.txt" }
|
294
|
+
let(:file2) { "curation_concerns_generic_stub.txt" }
|
295
|
+
let(:version1) { "version1" }
|
296
|
+
|
297
|
+
before do
|
298
|
+
original_adapter = ActiveJob::Base.queue_adapter
|
299
|
+
ActiveJob::Base.queue_adapter = :inline
|
300
|
+
allow(CharacterizeJob).to receive(:perform_later)
|
301
|
+
actor.create_content(fixture_file_upload(file1))
|
302
|
+
actor.create_content(fixture_file_upload(file2))
|
303
|
+
ActiveJob::Base.queue_adapter = original_adapter
|
304
|
+
actor.file_set.reload
|
305
|
+
end
|
306
|
+
|
307
|
+
let(:restored_content) { file_set.reload.original_file }
|
308
|
+
|
309
|
+
it "restores the first versions's content and metadata" do
|
310
|
+
actor.revert_content(version1)
|
311
|
+
expect(restored_content.original_name).to eq file1
|
312
|
+
end
|
313
|
+
end
|
288
314
|
end
|
@@ -76,10 +76,9 @@ describe CollectionsController do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
describe '#index' do
|
79
|
-
|
80
|
-
let!(:
|
81
|
-
let!(:
|
82
|
-
let!(:generic_work) { create(:generic_work, user: user) }
|
79
|
+
let!(:collection1) { create(:collection, :public, title: ['Beta']) }
|
80
|
+
let!(:collection2) { create(:collection, :public, title: ['Alpha']) }
|
81
|
+
let!(:generic_work) { create(:generic_work, :public) }
|
83
82
|
|
84
83
|
it 'shows a list of collections sorted alphabetically' do
|
85
84
|
get :index
|
@@ -3,13 +3,18 @@ require "spec_helper"
|
|
3
3
|
class SelectsCollectionsController < ApplicationController
|
4
4
|
include Blacklight::Catalog
|
5
5
|
include Hydra::Controller::ControllerBehavior
|
6
|
-
|
6
|
+
Deprecation.silence CurationConcerns::SelectsCollections do
|
7
|
+
include CurationConcerns::SelectsCollections
|
8
|
+
end
|
7
9
|
end
|
8
10
|
|
9
11
|
describe SelectsCollectionsController, type: :controller do
|
10
12
|
describe "#find_collections" do
|
11
13
|
it "uses the search builder" do
|
12
|
-
expect(subject.collections_search_builder_class.default_processor_chain).to eq [
|
14
|
+
expect(subject.collections_search_builder_class.default_processor_chain).to eq [
|
15
|
+
:default_solr_parameters, :add_query_to_solr,
|
16
|
+
:add_access_controls_to_solr_params, :filter_models,
|
17
|
+
:some_rows, :sort_by_title]
|
13
18
|
expect(CurationConcerns::CollectionSearchBuilder).to receive(:new).with(subject).and_call_original
|
14
19
|
subject.find_collections
|
15
20
|
end
|
@@ -13,7 +13,9 @@ FactoryGirl.define do
|
|
13
13
|
work.apply_depositor_metadata(evaluator.user.user_key)
|
14
14
|
end
|
15
15
|
|
16
|
-
factory :public_generic_work
|
16
|
+
factory :public_generic_work, traits: [:public]
|
17
|
+
|
18
|
+
trait :public do
|
17
19
|
visibility Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
18
20
|
end
|
19
21
|
|
@@ -86,6 +86,7 @@ feature 'collection' do
|
|
86
86
|
within('#document_' + collection.id) do
|
87
87
|
click_link('collection title')
|
88
88
|
end
|
89
|
+
expect(page).to have_selector '.sr-only', text: 'Search Collection Test collection title', visible: false
|
89
90
|
expect(page).to have_content 'Test collection title'
|
90
91
|
expect(page).to have_content 'collection description'
|
91
92
|
# Should have search results / contents listing
|
@@ -165,6 +166,7 @@ feature 'collection' do
|
|
165
166
|
within("#document_#{collection.id}") do
|
166
167
|
click_link('Edit Collection')
|
167
168
|
end
|
169
|
+
|
168
170
|
expect(page).to have_field 'collection_title', with: 'Test collection title'
|
169
171
|
expect(page).to have_field 'collection_description', with: 'collection description'
|
170
172
|
expect(page).to have_content(gw1.title.first)
|
@@ -40,9 +40,8 @@ describe CurationConcerns::CollectionsHelper do
|
|
40
40
|
|
41
41
|
before do
|
42
42
|
allow(helper).to receive(:current_user).and_return(user)
|
43
|
-
allow(
|
44
|
-
.with(
|
45
|
-
fl: 'title_tesim id', rows: 1000)
|
43
|
+
allow(Collection).to receive(:search_with_conditions)
|
44
|
+
.with({}, fl: 'title_tesim id', rows: 1000)
|
46
45
|
.and_return([doc1, doc2, doc3])
|
47
46
|
end
|
48
47
|
|
@@ -59,4 +58,89 @@ describe CurationConcerns::CollectionsHelper do
|
|
59
58
|
end
|
60
59
|
end
|
61
60
|
end
|
61
|
+
|
62
|
+
describe "has_collection_search_parameters?" do
|
63
|
+
subject { helper }
|
64
|
+
|
65
|
+
context "when cq is set" do
|
66
|
+
before { allow(helper).to receive(:params).and_return(cq: 'foo') }
|
67
|
+
it { is_expected.to have_collection_search_parameters }
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when cq is not set" do
|
71
|
+
before { allow(helper).to receive(:params).and_return(cq: '') }
|
72
|
+
it { is_expected.not_to have_collection_search_parameters }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "button_for_remove_from_collection" do
|
77
|
+
let(:item) { double(id: 'changeme:123') }
|
78
|
+
let(:collection) { FactoryGirl.create(:collection) }
|
79
|
+
|
80
|
+
it "generates a form that can remove the item" do
|
81
|
+
str = button_for_remove_from_collection collection, item
|
82
|
+
doc = Nokogiri::HTML(str)
|
83
|
+
form = doc.xpath('//form').first
|
84
|
+
expect(form.attr('action')).to eq collection_path(collection)
|
85
|
+
expect(form.css('input#collection_members[type="hidden"][value="remove"]')).not_to be_empty
|
86
|
+
expect(form.css('input[type="hidden"][name="batch_document_ids[]"][value="changeme:123"]')).not_to be_empty
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "for a collection of another name" do
|
90
|
+
before(:all) do
|
91
|
+
class OtherCollection < ActiveFedora::Base
|
92
|
+
include CurationConcerns::Collection
|
93
|
+
include Hydra::Works::WorkBehavior
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
let!(:collection) { OtherCollection.create! }
|
98
|
+
|
99
|
+
after(:all) do
|
100
|
+
Object.send(:remove_const, :OtherCollection)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "generates a form that can remove the item" do
|
104
|
+
str = button_for_remove_from_collection collection, item
|
105
|
+
doc = Nokogiri::HTML(str)
|
106
|
+
form = doc.xpath('//form').first
|
107
|
+
expect(form.attr('action')).to eq collection_path(collection)
|
108
|
+
expect(form.css('input#collection_members[type="hidden"][value="remove"]')).not_to be_empty
|
109
|
+
expect(form.css('input[type="hidden"][name="batch_document_ids[]"][value="changeme:123"]')).not_to be_empty
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "button_for_remove_selected_from_collection" do
|
115
|
+
let(:collection) { FactoryGirl.create(:collection) }
|
116
|
+
|
117
|
+
it "creates a button to the collections delete path" do
|
118
|
+
str = button_for_remove_selected_from_collection collection
|
119
|
+
doc = Nokogiri::HTML(str)
|
120
|
+
form = doc.xpath('//form').first
|
121
|
+
expect(form.attr('action')).to eq collection_path(collection)
|
122
|
+
i = form.xpath('.//input')[2]
|
123
|
+
expect(i.attr('value')).to eq("remove")
|
124
|
+
expect(i.attr('name')).to eq("collection[members]")
|
125
|
+
end
|
126
|
+
|
127
|
+
it "creates a button with my text" do
|
128
|
+
str = button_for_remove_selected_from_collection collection, "Remove My Button"
|
129
|
+
doc = Nokogiri::HTML(str)
|
130
|
+
form = doc.css('form').first
|
131
|
+
expect(form.attr('action')).to eq collection_path(collection)
|
132
|
+
expect(form.css('input[type="submit"]').attr('value').value).to eq "Remove My Button"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "hidden_collection_members" do
|
137
|
+
before { helper.params[:batch_document_ids] = ['foo:12', 'foo:23'] }
|
138
|
+
it "makes hidden fields" do
|
139
|
+
doc = Nokogiri::HTML(hidden_collection_members)
|
140
|
+
inputs = doc.xpath('//input[@type="hidden"][@name="batch_document_ids[]"]')
|
141
|
+
expect(inputs.length).to eq(2)
|
142
|
+
expect(inputs[0].attr('value')).to eq('foo:12')
|
143
|
+
expect(inputs[1].attr('value')).to eq('foo:23')
|
144
|
+
end
|
145
|
+
end
|
62
146
|
end
|