curation_concerns 0.10.0 → 0.11.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -3
- data/CONTRIBUTING.md +111 -0
- data/Gemfile +1 -1
- data/README.md +16 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/curation_concerns/file_manager/save_manager.es6 +1 -1
- data/app/assets/stylesheets/curation_concerns/_positioning.scss +0 -4
- data/app/controllers/concerns/curation_concerns/catalog_controller.rb +1 -4
- data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +4 -8
- data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +15 -11
- data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +5 -13
- data/app/controllers/curation_concerns/permissions_controller.rb +3 -3
- data/app/forms/curation_concerns/forms/collection_edit_form.rb +1 -1
- data/app/forms/curation_concerns/forms/work_form.rb +2 -0
- data/app/helpers/curation_concerns/collections_helper.rb +21 -4
- data/app/jobs/visibility_copy_job.rb +2 -4
- data/app/presenters/curation_concerns/collection_presenter.rb +1 -1
- data/app/presenters/curation_concerns/work_show_presenter.rb +27 -4
- data/app/search_builders/curation_concerns/filter_by_type.rb +8 -1
- data/app/search_builders/curation_concerns/search_builder.rb +7 -14
- data/app/search_builders/curation_concerns/search_filters.rb +18 -0
- data/app/search_builders/curation_concerns/single_result.rb +1 -1
- data/app/search_builders/curation_concerns/single_use_link_search_builder.rb +1 -1
- data/app/search_builders/curation_concerns/work_search_builder.rb +1 -1
- data/app/views/curation_concerns/base/{_form_descriptive_fields.erb → _form_descriptive_fields.html.erb} +0 -0
- data/app/views/curation_concerns/base/_member.html.erb +12 -0
- data/app/views/curation_concerns/base/_related_files.html.erb +2 -2
- data/curation_concerns.gemspec +2 -1
- data/lib/curation_concerns/version.rb +1 -1
- data/lib/curation_concerns.rb +1 -0
- data/lib/generators/curation_concerns/assets_generator.rb +16 -0
- data/lib/generators/curation_concerns/install_generator.rb +7 -14
- data/lib/generators/curation_concerns/templates/catalog_controller.rb +4 -4
- data/lib/generators/curation_concerns/work/templates/controller.rb.erb +1 -1
- data/lib/generators/curation_concerns/work/templates/feature_spec.rb.erb +26 -0
- data/lib/generators/curation_concerns/work/work_generator.rb +5 -0
- data/spec/actors/curation_concerns/file_actor_spec.rb +1 -1
- data/spec/actors/curation_concerns/file_set_actor_spec.rb +4 -3
- data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +14 -1
- data/spec/controllers/curation_concerns/permissions_controller_spec.rb +1 -1
- data/spec/features/add_file_spec.rb +1 -1
- data/spec/features/collection_spec.rb +1 -11
- data/spec/features/create_work_spec.rb +1 -1
- data/spec/features/embargo_spec.rb +1 -1
- data/spec/features/lease_spec.rb +1 -1
- data/spec/features/update_file_spec.rb +1 -1
- data/spec/features/work_generator_spec.rb +1 -1
- data/spec/forms/work_form_spec.rb +5 -0
- data/spec/helpers/curation_concerns/collections_helper_spec.rb +19 -5
- data/spec/indexers/collection_indexer_spec.rb +1 -1
- data/spec/javascripts/save_manager_spec.coffee +1 -0
- data/spec/jobs/audit_job_spec.rb +3 -7
- data/spec/jobs/characterize_job_spec.rb +4 -4
- data/spec/jobs/create_derivatives_job_spec.rb +4 -4
- data/spec/jobs/import_url_job_spec.rb +6 -6
- data/spec/jobs/ingest_file_job_spec.rb +6 -6
- data/spec/jobs/visibility_copy_job_spec.rb +3 -3
- data/spec/models/file_set_spec.rb +6 -0
- data/spec/models/generic_work_spec.rb +6 -0
- data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +25 -1
- data/spec/search_builders/curation_concerns/file_set_search_builder_spec.rb +2 -2
- data/spec/search_builders/curation_concerns/search_builder_spec.rb +16 -3
- data/spec/spec_helper.rb +2 -2
- data/spec/test_app_templates/Gemfile.extra +0 -1
- data/spec/views/curation_concerns/{file_sets/_file_set.html.erb_spec.rb → base/_member.html.erb_spec.rb} +2 -2
- data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload-process.js +0 -0
- data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload-ui.js +0 -0
- data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload-validate.js +0 -0
- data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload.js +0 -0
- data/vendor/assets/{javascrips → javascripts}/fileupload/locale.js +0 -0
- data/vendor/assets/{javascrips → javascripts}/fileupload/tmpl.js +0 -0
- metadata +36 -21
- data/app/views/curation_concerns/file_sets/_file_set.html.erb +0 -12
- data/lib/curation_concerns/form_builder.rb +0 -16
- data/spec/jobs/active_fedora_id_based_job_spec.rb +0 -16
data/lib/curation_concerns.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module CurationConcerns
|
4
|
+
class Assets < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
def remove_blacklight_scss
|
8
|
+
remove_file 'app/assets/stylesheets/blacklight.css.scss'
|
9
|
+
end
|
10
|
+
|
11
|
+
def assets
|
12
|
+
copy_file 'curation_concerns.scss', 'app/assets/stylesheets/curation_concerns.scss'
|
13
|
+
copy_file 'curation_concerns.js', 'app/assets/javascripts/curation_concerns.js'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -5,6 +5,8 @@ module CurationConcerns
|
|
5
5
|
source_root File.expand_path('../templates', __FILE__)
|
6
6
|
|
7
7
|
argument :model_name, type: :string, default: 'user'
|
8
|
+
class_option :'skip-assets', type: :boolean, default: false, desc: "Skip generating javascript and css assets into the application"
|
9
|
+
|
8
10
|
desc 'This generator makes the following changes to your application:
|
9
11
|
1. Runs installers for blacklight & hydra-head (which also install & configure devise)
|
10
12
|
2. Runs curation_concerns:models:install
|
@@ -38,20 +40,12 @@ module CurationConcerns
|
|
38
40
|
"include CurationConcerns::ThemedLayoutController\n with_themed_layout '1_column'\n"
|
39
41
|
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
# "\n include CurationConcerns::SearchBuilder\n"
|
46
|
-
# end
|
47
|
-
# end
|
48
|
-
|
49
|
-
def remove_blacklight_scss
|
50
|
-
remove_file 'app/assets/stylesheets/blacklight.css.scss'
|
43
|
+
def insert_builder
|
44
|
+
insert_into_file 'app/models/search_builder.rb', after: /include Hydra::AccessControlsEnforcement/ do
|
45
|
+
"\n include CurationConcerns::SearchFilters\n"
|
46
|
+
end
|
51
47
|
end
|
52
48
|
|
53
|
-
# END Blacklight stuff
|
54
|
-
|
55
49
|
def inject_routes
|
56
50
|
# Remove root route that was added by blacklight generator
|
57
51
|
gsub_file 'config/routes.rb', /root (:to =>|to:) "catalog#index"/, ''
|
@@ -92,8 +86,7 @@ module CurationConcerns
|
|
92
86
|
end
|
93
87
|
|
94
88
|
def assets
|
95
|
-
|
96
|
-
copy_file 'curation_concerns.js', 'app/assets/javascripts/curation_concerns.js'
|
89
|
+
generate 'curation_concerns:assets' unless options[:'skip-assets']
|
97
90
|
end
|
98
91
|
|
99
92
|
def add_helper
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class CatalogController < ApplicationController
|
2
2
|
include CurationConcerns::CatalogController
|
3
3
|
configure_blacklight do |config|
|
4
|
-
config.search_builder_class =
|
4
|
+
# config.search_builder_class = ::SearchBuilder
|
5
5
|
## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
|
6
6
|
config.default_solr_params = {
|
7
|
-
qf:
|
8
|
-
qt:
|
9
|
-
rows:
|
7
|
+
qf: %w(title_tesim name_tesim),
|
8
|
+
qt: 'search',
|
9
|
+
rows: 10
|
10
10
|
}
|
11
11
|
|
12
12
|
# solr field configuration for search results/index views
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Generated via
|
2
|
+
# `rails generate curation_concerns:work <%= class_name %>`
|
3
|
+
require 'rails_helper'
|
4
|
+
include Warden::Test::Helpers
|
5
|
+
|
6
|
+
feature 'Create a <%= class_name %>' do
|
7
|
+
context 'a logged in user' do
|
8
|
+
let(:user_attributes) do
|
9
|
+
{ <%= Devise.authentication_keys.first %>: 'test@example.com' }
|
10
|
+
end
|
11
|
+
let(:user) do
|
12
|
+
User.new(user_attributes) { |u| u.save(validate: false) }
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
login_as user
|
17
|
+
end
|
18
|
+
|
19
|
+
scenario do
|
20
|
+
visit new_curation_concerns_<%= file_name %>_path
|
21
|
+
fill_in 'Title', with: 'Test <%= class_name %>'
|
22
|
+
click_button 'Create <%= class_name %>'
|
23
|
+
expect(page).to have_content 'Test <%= class_name %>'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -45,6 +45,11 @@ class CurationConcerns::WorkGenerator < Rails::Generators::NamedBase
|
|
45
45
|
template('form_spec.rb.erb', "spec/forms/curation_concerns/#{file_name}_form_spec.rb")
|
46
46
|
end
|
47
47
|
|
48
|
+
def create_feature_spec
|
49
|
+
return unless rspec_installed?
|
50
|
+
template('feature_spec.rb.erb', "spec/features/create_#{file_name}_spec.rb")
|
51
|
+
end
|
52
|
+
|
48
53
|
def create_controller
|
49
54
|
template('controller.rb.erb', "app/controllers/curation_concerns/#{plural_file_name}_controller.rb")
|
50
55
|
end
|
@@ -11,7 +11,7 @@ describe CurationConcerns::FileActor do
|
|
11
11
|
describe '#ingest_file' do
|
12
12
|
it 'calls ingest file job' do
|
13
13
|
expect(CharacterizeJob).to receive(:perform_later)
|
14
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set
|
14
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user.user_key, 'remastered')
|
15
15
|
actor.ingest_file(uploaded_file)
|
16
16
|
end
|
17
17
|
end
|
@@ -22,7 +22,7 @@ describe CurationConcerns::FileSetActor do
|
|
22
22
|
|
23
23
|
before do
|
24
24
|
expect(CharacterizeJob).to receive(:perform_later)
|
25
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set
|
25
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user.user_key, 'original_file')
|
26
26
|
allow(actor).to receive(:acquire_lock_for).and_yield
|
27
27
|
actor.create_metadata(work)
|
28
28
|
actor.create_content(uploaded_file)
|
@@ -68,14 +68,14 @@ describe CurationConcerns::FileSetActor do
|
|
68
68
|
describe '#create_content' do
|
69
69
|
it 'calls ingest file job' do
|
70
70
|
expect(CharacterizeJob).to receive(:perform_later)
|
71
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set
|
71
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user.user_key, 'original_file')
|
72
72
|
actor.create_content(uploaded_file)
|
73
73
|
end
|
74
74
|
|
75
75
|
context 'when an alternative relationship is specified' do
|
76
76
|
it 'calls ingest file job' do
|
77
77
|
expect(CharacterizeJob).to receive(:perform_later)
|
78
|
-
expect(IngestFileJob).to receive(:perform_later).with(file_set
|
78
|
+
expect(IngestFileJob).to receive(:perform_later).with(file_set, /world\.png$/, 'image/png', user.user_key, 'remastered')
|
79
79
|
actor.create_content(uploaded_file, 'remastered')
|
80
80
|
end
|
81
81
|
end
|
@@ -106,6 +106,7 @@ describe CurationConcerns::FileSetActor do
|
|
106
106
|
before do
|
107
107
|
allow(CharacterizeJob).to receive(:perform_later)
|
108
108
|
allow(file_set).to receive(:label).and_return(short_name)
|
109
|
+
# TODO: we should allow/expect call to IngestJob
|
109
110
|
actor.create_content(fixture_file_upload(file))
|
110
111
|
end
|
111
112
|
|
@@ -71,6 +71,19 @@ describe CurationConcerns::FileSetsController do
|
|
71
71
|
expect(response.body).to include('Error occurred while creating a FileSet.')
|
72
72
|
end
|
73
73
|
end
|
74
|
+
|
75
|
+
context 'when the file is not created' do
|
76
|
+
before do
|
77
|
+
allow(controller.send(:actor)).to receive(:create_metadata)
|
78
|
+
allow(controller.send(:actor)).to receive(:create_content).with(file).and_return(false)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'errors out of create after on continuous rsolr error' do
|
82
|
+
xhr :post, :create, parent_id: parent, file_set: { files: [file] },
|
83
|
+
permission: { group: { 'public' => 'read' } }, terms_of_service: '1'
|
84
|
+
expect(response.body).to include('Error creating generic file image.png')
|
85
|
+
end
|
86
|
+
end
|
74
87
|
end
|
75
88
|
|
76
89
|
describe 'destroy' do
|
@@ -152,7 +165,7 @@ describe CurationConcerns::FileSetsController do
|
|
152
165
|
context 'updating file content' do
|
153
166
|
it 'is successful' do
|
154
167
|
expect(IngestFileJob).to receive(:perform_later)
|
155
|
-
expect(CharacterizeJob).to receive(:perform_later).with(file_set
|
168
|
+
expect(CharacterizeJob).to receive(:perform_later).with(file_set, kind_of(String))
|
156
169
|
post :update, id: file_set, file_set: { files: [file] }
|
157
170
|
expect(response).to redirect_to main_app.curation_concerns_file_set_path(file_set)
|
158
171
|
end
|
@@ -17,7 +17,7 @@ describe CurationConcerns::PermissionsController do
|
|
17
17
|
let(:generic_work) { create(:generic_work, user: user) }
|
18
18
|
|
19
19
|
it 'adds a worker to the queue' do
|
20
|
-
expect(VisibilityCopyJob).to receive(:perform_later).with(generic_work
|
20
|
+
expect(VisibilityCopyJob).to receive(:perform_later).with(generic_work)
|
21
21
|
post :copy, id: generic_work
|
22
22
|
expect(response).to redirect_to main_app.curation_concerns_generic_work_path(generic_work)
|
23
23
|
expect(flash[:notice]).to eq 'Updating file permissions. This may take a few minutes. You may want to refresh your browser or return to this record later to see the updated file permissions.'
|
@@ -1,17 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
include CurationConcerns::SearchPathsHelper
|
3
3
|
|
4
|
-
|
5
|
-
def create_collection(title, description)
|
6
|
-
click_link 'Add a Collection'
|
7
|
-
fill_in('Title', with: title)
|
8
|
-
fill_in('collection_description', with: description)
|
9
|
-
click_button('Create Collection')
|
10
|
-
expect(page).to have_content 'Items in this Collection'
|
11
|
-
expect(page).to have_content title
|
12
|
-
expect(page).to have_content description
|
13
|
-
end
|
14
|
-
|
4
|
+
feature 'collection' do
|
15
5
|
let(:title1) { 'Test Collection 1' }
|
16
6
|
let(:description1) { 'Description for collection 1 we are testing.' }
|
17
7
|
let(:title2) { 'Test Collection 2' }
|
data/spec/features/lease_spec.rb
CHANGED
@@ -116,4 +116,9 @@ describe CurationConcerns::Forms::WorkForm do
|
|
116
116
|
subject { form.lease_expiration_date }
|
117
117
|
it { is_expected.to eq curation_concern.lease_expiration_date }
|
118
118
|
end
|
119
|
+
|
120
|
+
describe ".required_fields" do
|
121
|
+
subject { described_class.required_fields }
|
122
|
+
it { is_expected.to eq [:title] }
|
123
|
+
end
|
119
124
|
end
|
@@ -32,17 +32,31 @@ describe CurationConcerns::CollectionsHelper do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#collection_options_for_select' do
|
35
|
+
let(:user) { create(:user) }
|
36
|
+
let(:collection2) { double(id: '02870w10j') }
|
37
|
+
let(:doc1) { { "id" => "k930bx31t", "title_tesim" => ["One"] } }
|
38
|
+
let(:doc2) { { "id" => "02870w10j", "title_tesim" => ["Two"] } }
|
39
|
+
let(:doc3) { { "id" => "z029p500w", "title_tesim" => ["Three"] } }
|
40
|
+
|
35
41
|
before do
|
36
42
|
allow(helper).to receive(:current_user).and_return(user)
|
43
|
+
allow(ActiveFedora::SolrService).to receive(:query)
|
44
|
+
.with("_query_:\"{!field f=has_model_ssim}Collection\"",
|
45
|
+
fl: 'title_tesim id', rows: 1000)
|
46
|
+
.and_return([doc1, doc2, doc3])
|
37
47
|
end
|
38
|
-
|
39
|
-
let!(:collection1) { create(:collection, user: user, title: ['One']) }
|
40
|
-
let!(:collection2) { create(:collection, user: user, title: ['Two']) }
|
41
|
-
let!(:collection3) { create(:collection, user: user, title: ['Three']) }
|
48
|
+
|
42
49
|
subject { helper.collection_options_for_select(collection2) }
|
43
50
|
|
44
51
|
it 'excludes the passed in collection' do
|
45
|
-
expect(subject).to eq "<option value=\"#{
|
52
|
+
expect(subject).to eq "<option value=\"#{doc1['id']}\">One</option>\n<option value=\"#{doc3['id']}\">Three</option>"
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when one of the documents doesn't have title_tesim" do
|
56
|
+
let(:doc1) { { "id" => "k930bx31t" } }
|
57
|
+
it 'puts the collections without titles last' do
|
58
|
+
expect(subject).to eq "<option value=\"#{doc3['id']}\">Three</option>\n<option value=\"#{doc1['id']}\"></option>"
|
59
|
+
end
|
46
60
|
end
|
47
61
|
end
|
48
62
|
end
|
@@ -13,7 +13,7 @@ describe CurationConcerns::CollectionIndexer do
|
|
13
13
|
|
14
14
|
it "has required fields" do
|
15
15
|
expect(subject.fetch('generic_type_sim')).to eq ["Collection"]
|
16
|
-
expect(subject.fetch('
|
16
|
+
expect(subject.fetch('bytes_lts')).to eq(1000)
|
17
17
|
expect(subject.fetch('thumbnail_path_ss')).to eq "/downloads/1234?file=thumbnail"
|
18
18
|
end
|
19
19
|
end
|
@@ -43,6 +43,7 @@ describe "FileManager Save Button", ->
|
|
43
43
|
expect($("button.disabled").length).toEqual(1)
|
44
44
|
describe "#persist", ->
|
45
45
|
it "is called by clicking the save button", ->
|
46
|
+
Blacklight.activate();
|
46
47
|
spyOn(save_manager, "persist").and.callThrough()
|
47
48
|
save_manager.push_changed(handler)
|
48
49
|
|
data/spec/jobs/audit_job_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe AuditJob do
|
|
11
11
|
end
|
12
12
|
let(:file_id) { file.original_file.id }
|
13
13
|
|
14
|
-
let(:job) { described_class.perform_now(file
|
14
|
+
let(:job) { described_class.perform_now(file, file_id, uri) }
|
15
15
|
|
16
16
|
describe 'audit on content' do
|
17
17
|
let(:uri) { file.original_file.uri }
|
@@ -46,15 +46,11 @@ describe AuditJob do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
let(:job) do
|
49
|
-
described_class.new
|
50
|
-
j.id = file.id
|
51
|
-
j.file_id = file_id
|
52
|
-
j.uri = uri
|
53
|
-
end
|
49
|
+
described_class.new
|
54
50
|
end
|
55
51
|
|
56
52
|
it 'does not prune failed audits' do
|
57
|
-
5.times { job.send(:run_audit) }
|
53
|
+
5.times { job.send(:run_audit, file, file_id, uri) }
|
58
54
|
expect(ChecksumAuditLog.logs_for(file.id, file_id).map(&:pass)).to eq [0, 1, 0, 0, 1, 0, 1]
|
59
55
|
end
|
60
56
|
end
|
@@ -6,13 +6,13 @@ describe CharacterizeJob do
|
|
6
6
|
let(:filename) { double }
|
7
7
|
|
8
8
|
before do
|
9
|
-
allow(
|
9
|
+
allow(FileSet).to receive(:find).with(file_set_id).and_return(file_set)
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'runs Hydra::Works::CharacterizationService and creates a CreateDerivativesJob' do
|
13
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(
|
16
|
-
described_class.perform_now
|
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
|
17
17
|
end
|
18
18
|
end
|
@@ -6,7 +6,7 @@ describe CurationConcerns::CreateDerivativesJob do
|
|
6
6
|
before do
|
7
7
|
@ffmpeg_enabled = CurationConcerns.config.enable_ffmpeg
|
8
8
|
CurationConcerns.config.enable_ffmpeg = true
|
9
|
-
allow(
|
9
|
+
allow(FileSet).to receive(:find).with(id).and_return(file_set)
|
10
10
|
allow(file_set).to receive(:mime_type).and_return('audio/x-wav')
|
11
11
|
allow(file_set).to receive(:id).and_return(id)
|
12
12
|
end
|
@@ -21,7 +21,7 @@ describe CurationConcerns::CreateDerivativesJob do
|
|
21
21
|
it 'calls create_derivatives and save on a file set' do
|
22
22
|
expect(Hydra::Derivatives::AudioDerivatives).to receive(:create)
|
23
23
|
expect(file_set).to receive(:update_index)
|
24
|
-
CreateDerivativesJob.perform_now(
|
24
|
+
CreateDerivativesJob.perform_now(file_set, 'spec/fixtures/piano_note.wav')
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -37,7 +37,7 @@ describe CurationConcerns::CreateDerivativesJob do
|
|
37
37
|
|
38
38
|
it 'updates the index of the parent object' do
|
39
39
|
expect(parent).to receive(:update_index)
|
40
|
-
CreateDerivativesJob.perform_now(
|
40
|
+
CreateDerivativesJob.perform_now(file_set, 'spec/fixtures/piano_note.wav')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -46,7 +46,7 @@ describe CurationConcerns::CreateDerivativesJob do
|
|
46
46
|
|
47
47
|
it "doesn't update the parent's index" do
|
48
48
|
expect(parent).to_not receive(:update_index)
|
49
|
-
CreateDerivativesJob.perform_now(
|
49
|
+
CreateDerivativesJob.perform_now(file_set, 'spec/fixtures/piano_note.wav')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -7,13 +7,12 @@ describe ImportUrlJob do
|
|
7
7
|
let(:file_hash) { '/673467823498723948237462429793840923582' }
|
8
8
|
|
9
9
|
let(:file_set) do
|
10
|
-
FileSet.new(import_url: "http://example.org#{file_hash}",
|
10
|
+
FileSet.new(import_url: "http://example.org#{file_hash}",
|
11
|
+
label: file_path) do |f|
|
11
12
|
f.apply_depositor_metadata(user.user_key)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
|
-
let(:file_set_id) { 'abc123' }
|
16
|
-
|
17
16
|
let(:mock_response) do
|
18
17
|
double('response').tap do |http_res|
|
19
18
|
allow(http_res).to receive(:start).and_yield
|
@@ -24,8 +23,9 @@ describe ImportUrlJob do
|
|
24
23
|
|
25
24
|
context 'after running the job' do
|
26
25
|
let(:actor) { double }
|
26
|
+
|
27
27
|
before do
|
28
|
-
|
28
|
+
file_set.id = 'abc123'
|
29
29
|
allow(file_set).to receive(:reload)
|
30
30
|
allow(CurationConcerns::FileSetActor).to receive(:new).with(file_set, user).and_return(actor)
|
31
31
|
end
|
@@ -33,7 +33,7 @@ describe ImportUrlJob do
|
|
33
33
|
it 'creates the content' do
|
34
34
|
expect_any_instance_of(Net::HTTP).to receive(:request_get).with(file_hash).and_yield(mock_response)
|
35
35
|
expect(actor).to receive(:create_content).and_return(true)
|
36
|
-
described_class.perform_now(
|
36
|
+
described_class.perform_now(file_set)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -57,7 +57,7 @@ describe ImportUrlJob do
|
|
57
57
|
file_set.update(title: ['File One'])
|
58
58
|
|
59
59
|
# run the import job
|
60
|
-
described_class.perform_now(
|
60
|
+
described_class.perform_now(file_set)
|
61
61
|
|
62
62
|
# import job should not override the title set another process
|
63
63
|
file = FileSet.find(file_set_id)
|
@@ -20,14 +20,14 @@ describe IngestFileJob do
|
|
20
20
|
Object.send(:remove_const, :FileSetWithExtras)
|
21
21
|
end
|
22
22
|
it 'uses the provided relationship' do
|
23
|
-
described_class.perform_now(file_set
|
23
|
+
described_class.perform_now(file_set, filename, 'image/png', 'bob', 'remastered')
|
24
24
|
expect(file_set.reload.remastered.mime_type).to eq 'image/png'
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'when given a mime_type' do
|
29
29
|
it 'uses the provided mime_type' do
|
30
|
-
described_class.perform_now(file_set
|
30
|
+
described_class.perform_now(file_set, filename, 'image/png', 'bob')
|
31
31
|
expect(file_set.reload.original_file.mime_type).to eq 'image/png'
|
32
32
|
end
|
33
33
|
end
|
@@ -38,7 +38,7 @@ describe IngestFileJob do
|
|
38
38
|
# The parameter versioning: false instructs the machinery in Hydra::Works NOT to do versioning. So it can be handled later on.
|
39
39
|
allow(CurationConcerns::VersioningService).to receive(:create)
|
40
40
|
expect(Hydra::Works::AddFileToFileSet).to receive(:call).with(file_set, instance_of(::File), :original_file, versioning: false)
|
41
|
-
described_class.perform_now(file_set
|
41
|
+
described_class.perform_now(file_set, filename, nil, 'bob')
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -49,8 +49,8 @@ describe IngestFileJob do
|
|
49
49
|
let(:user2) { create(:user) }
|
50
50
|
|
51
51
|
before do
|
52
|
-
described_class.perform_now(file_set
|
53
|
-
described_class.perform_now(file_set
|
52
|
+
described_class.perform_now(file_set, file1, 'image/png', user.user_key)
|
53
|
+
described_class.perform_now(file_set, file2, 'text/plain', user2.user_key)
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'has two versions' do
|
@@ -72,7 +72,7 @@ describe IngestFileJob do
|
|
72
72
|
subject { CurationConcerns.config.callback }
|
73
73
|
it 'runs with file_set and user arguments' do
|
74
74
|
expect(subject).to receive(:run).with(:after_create_content, file_set, user)
|
75
|
-
described_class.perform_now(file_set
|
75
|
+
described_class.perform_now(file_set, filename, 'image/png', user.user_key)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -10,7 +10,7 @@ describe VisibilityCopyJob do
|
|
10
10
|
|
11
11
|
work.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
12
12
|
work.save
|
13
|
-
described_class.perform_now(work
|
13
|
+
described_class.perform_now(work)
|
14
14
|
work.reload.file_sets.each do |file|
|
15
15
|
expect(file.visibility).to eq 'open'
|
16
16
|
end
|
@@ -27,7 +27,7 @@ describe VisibilityCopyJob do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
before do
|
30
|
-
described_class.perform_now(work
|
30
|
+
described_class.perform_now(work)
|
31
31
|
work.reload
|
32
32
|
end
|
33
33
|
let(:file) { work.file_sets.first }
|
@@ -48,7 +48,7 @@ describe VisibilityCopyJob do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
before do
|
51
|
-
described_class.perform_now(work
|
51
|
+
described_class.perform_now(work)
|
52
52
|
work.reload
|
53
53
|
end
|
54
54
|
let(:file) { work.file_sets.first }
|
@@ -56,8 +56,31 @@ describe CurationConcerns::WorkShowPresenter do
|
|
56
56
|
|
57
57
|
it "displays them in order" do
|
58
58
|
expect(obj.ordered_member_ids).not_to eq obj.member_ids
|
59
|
+
expect(Deprecation).to receive(:warn)
|
59
60
|
expect(presenter.file_presenters.map(&:id)).to eq obj.ordered_member_ids
|
60
61
|
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#file_set_presenters" do
|
65
|
+
let(:obj) { create(:work_with_ordered_files) }
|
66
|
+
let(:attributes) { obj.to_solr }
|
67
|
+
|
68
|
+
it "displays them in order" do
|
69
|
+
expect(obj.ordered_member_ids).not_to eq obj.member_ids
|
70
|
+
expect(presenter.file_set_presenters.map(&:id)).to eq obj.ordered_member_ids
|
71
|
+
end
|
72
|
+
|
73
|
+
context "when some of the members are not file sets" do
|
74
|
+
let(:another_work) { create(:work) }
|
75
|
+
before do
|
76
|
+
obj.ordered_members << another_work
|
77
|
+
obj.save!
|
78
|
+
end
|
79
|
+
|
80
|
+
it "filters out members that are not file sets" do
|
81
|
+
expect(presenter.file_set_presenters.map(&:id)).not_to include another_work.id
|
82
|
+
end
|
83
|
+
end
|
61
84
|
|
62
85
|
describe "getting presenters from factory" do
|
63
86
|
let(:attributes) { {} }
|
@@ -65,12 +88,13 @@ describe CurationConcerns::WorkShowPresenter do
|
|
65
88
|
before do
|
66
89
|
allow(presenter).to receive(:file_presenter_class).and_return(presenter_class)
|
67
90
|
allow(presenter).to receive(:ordered_ids).and_return(['12', '33'])
|
91
|
+
allow(presenter).to receive(:file_set_ids).and_return(['33', '12'])
|
68
92
|
end
|
69
93
|
|
70
94
|
it "uses the set class" do
|
71
95
|
expect(CurationConcerns::PresenterFactory).to receive(:build_presenters)
|
72
96
|
.with(['12', '33'], presenter_class, ability)
|
73
|
-
presenter.
|
97
|
+
presenter.file_set_presenters
|
74
98
|
end
|
75
99
|
end
|
76
100
|
end
|