curation_concerns 0.10.0 → 0.11.0.rc1

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -3
  3. data/CONTRIBUTING.md +111 -0
  4. data/Gemfile +1 -1
  5. data/README.md +16 -0
  6. data/VERSION +1 -1
  7. data/app/assets/javascripts/curation_concerns/file_manager/save_manager.es6 +1 -1
  8. data/app/assets/stylesheets/curation_concerns/_positioning.scss +0 -4
  9. data/app/controllers/concerns/curation_concerns/catalog_controller.rb +1 -4
  10. data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +4 -8
  11. data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +15 -11
  12. data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +5 -13
  13. data/app/controllers/curation_concerns/permissions_controller.rb +3 -3
  14. data/app/forms/curation_concerns/forms/collection_edit_form.rb +1 -1
  15. data/app/forms/curation_concerns/forms/work_form.rb +2 -0
  16. data/app/helpers/curation_concerns/collections_helper.rb +21 -4
  17. data/app/jobs/visibility_copy_job.rb +2 -4
  18. data/app/presenters/curation_concerns/collection_presenter.rb +1 -1
  19. data/app/presenters/curation_concerns/work_show_presenter.rb +27 -4
  20. data/app/search_builders/curation_concerns/filter_by_type.rb +8 -1
  21. data/app/search_builders/curation_concerns/search_builder.rb +7 -14
  22. data/app/search_builders/curation_concerns/search_filters.rb +18 -0
  23. data/app/search_builders/curation_concerns/single_result.rb +1 -1
  24. data/app/search_builders/curation_concerns/single_use_link_search_builder.rb +1 -1
  25. data/app/search_builders/curation_concerns/work_search_builder.rb +1 -1
  26. data/app/views/curation_concerns/base/{_form_descriptive_fields.erb → _form_descriptive_fields.html.erb} +0 -0
  27. data/app/views/curation_concerns/base/_member.html.erb +12 -0
  28. data/app/views/curation_concerns/base/_related_files.html.erb +2 -2
  29. data/curation_concerns.gemspec +2 -1
  30. data/lib/curation_concerns/version.rb +1 -1
  31. data/lib/curation_concerns.rb +1 -0
  32. data/lib/generators/curation_concerns/assets_generator.rb +16 -0
  33. data/lib/generators/curation_concerns/install_generator.rb +7 -14
  34. data/lib/generators/curation_concerns/templates/catalog_controller.rb +4 -4
  35. data/lib/generators/curation_concerns/work/templates/controller.rb.erb +1 -1
  36. data/lib/generators/curation_concerns/work/templates/feature_spec.rb.erb +26 -0
  37. data/lib/generators/curation_concerns/work/work_generator.rb +5 -0
  38. data/spec/actors/curation_concerns/file_actor_spec.rb +1 -1
  39. data/spec/actors/curation_concerns/file_set_actor_spec.rb +4 -3
  40. data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +14 -1
  41. data/spec/controllers/curation_concerns/permissions_controller_spec.rb +1 -1
  42. data/spec/features/add_file_spec.rb +1 -1
  43. data/spec/features/collection_spec.rb +1 -11
  44. data/spec/features/create_work_spec.rb +1 -1
  45. data/spec/features/embargo_spec.rb +1 -1
  46. data/spec/features/lease_spec.rb +1 -1
  47. data/spec/features/update_file_spec.rb +1 -1
  48. data/spec/features/work_generator_spec.rb +1 -1
  49. data/spec/forms/work_form_spec.rb +5 -0
  50. data/spec/helpers/curation_concerns/collections_helper_spec.rb +19 -5
  51. data/spec/indexers/collection_indexer_spec.rb +1 -1
  52. data/spec/javascripts/save_manager_spec.coffee +1 -0
  53. data/spec/jobs/audit_job_spec.rb +3 -7
  54. data/spec/jobs/characterize_job_spec.rb +4 -4
  55. data/spec/jobs/create_derivatives_job_spec.rb +4 -4
  56. data/spec/jobs/import_url_job_spec.rb +6 -6
  57. data/spec/jobs/ingest_file_job_spec.rb +6 -6
  58. data/spec/jobs/visibility_copy_job_spec.rb +3 -3
  59. data/spec/models/file_set_spec.rb +6 -0
  60. data/spec/models/generic_work_spec.rb +6 -0
  61. data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +25 -1
  62. data/spec/search_builders/curation_concerns/file_set_search_builder_spec.rb +2 -2
  63. data/spec/search_builders/curation_concerns/search_builder_spec.rb +16 -3
  64. data/spec/spec_helper.rb +2 -2
  65. data/spec/test_app_templates/Gemfile.extra +0 -1
  66. data/spec/views/curation_concerns/{file_sets/_file_set.html.erb_spec.rb → base/_member.html.erb_spec.rb} +2 -2
  67. data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload-process.js +0 -0
  68. data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload-ui.js +0 -0
  69. data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload-validate.js +0 -0
  70. data/vendor/assets/{javascrips → javascripts}/fileupload/jquery.fileupload.js +0 -0
  71. data/vendor/assets/{javascrips → javascripts}/fileupload/locale.js +0 -0
  72. data/vendor/assets/{javascrips → javascripts}/fileupload/tmpl.js +0 -0
  73. metadata +36 -21
  74. data/app/views/curation_concerns/file_sets/_file_set.html.erb +0 -12
  75. data/lib/curation_concerns/form_builder.rb +0 -16
  76. data/spec/jobs/active_fedora_id_based_job_spec.rb +0 -16
@@ -2,6 +2,7 @@ require 'curation_concerns/version'
2
2
  require 'curation_concerns/engine'
3
3
  require 'curation_concerns/configuration'
4
4
  require 'blacklight_advanced_search'
5
+ require 'kaminari_route_prefix'
5
6
 
6
7
  module CurationConcerns
7
8
  end
@@ -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
- # def insert_builder
42
- # insert_into_file 'app/models/search_builder.rb', after: /include Blacklight::Solr::SearchBuilderBehavior/ do
43
- # # First line should be generated by Hydra. projecthydra/hydra-head#255
44
- # "\n include Hydra::AccessControlsEnforcement" +
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
- copy_file 'curation_concerns.scss', 'app/assets/stylesheets/curation_concerns.scss'
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 = CurationConcerns::SearchBuilder
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: search_config['qf'],
8
- qt: search_config['qt'],
9
- rows: search_config['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
@@ -3,5 +3,5 @@
3
3
 
4
4
  class CurationConcerns::<%= class_name.pluralize %>Controller < ApplicationController
5
5
  include CurationConcerns::CurationConcernController
6
- set_curation_concern_type <%= class_name %>
6
+ self.curation_concern_type = <%= class_name %>
7
7
  end
@@ -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.id, /world\.png$/, 'image/png', user.user_key, 'remastered')
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.id, /world\.png$/, 'image/png', user.user_key, 'original_file')
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.id, /world\.png$/, 'image/png', user.user_key, 'original_file')
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.id, /world\.png$/, 'image/png', user.user_key, 'remastered')
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.id, kind_of(String))
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.id)
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,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Add an attached file' do
3
+ feature 'Add an attached file' do
4
4
  let(:user) { create(:user) }
5
5
  let!(:work) { create(:work, user: user) }
6
6
 
@@ -1,17 +1,7 @@
1
1
  require 'spec_helper'
2
2
  include CurationConcerns::SearchPathsHelper
3
3
 
4
- describe 'collection' do
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' }
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'redlock'
3
3
 
4
- describe 'Creating a new Work' do
4
+ feature 'Creating a new Work' do
5
5
  let(:user) { FactoryGirl.create(:user) }
6
6
 
7
7
  let(:redlock_client_stub) { # stub out redis connection
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'embargo' do
3
+ feature 'embargo' do
4
4
  let(:user) { FactoryGirl.create(:user) }
5
5
  before do
6
6
  sign_in user
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'leases' do
3
+ feature 'leases' do
4
4
  let(:user) { FactoryGirl.create(:user) }
5
5
  before do
6
6
  sign_in user
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Editing attached files' do
3
+ feature 'Editing attached files' do
4
4
  let(:user) { create(:user) }
5
5
  let!(:parent) { create(:work_with_one_file, user: user) }
6
6
  let!(:file_set) { parent.file_sets.first }
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'rails/generators'
3
3
  require 'redlock'
4
4
 
5
- describe 'Creating a new Work' do
5
+ feature 'Creating a new Work' do
6
6
  let(:user) { FactoryGirl.create(:user) }
7
7
 
8
8
  let(:redlock_client_stub) { # stub out redis connection
@@ -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
- let(:user) { create(:user) }
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=\"#{collection1.id}\">One</option>\n<option value=\"#{collection3.id}\">Three</option>"
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('bytes_is')).to eq(1000)
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
 
@@ -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.id, file_id, uri) }
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.tap do |j|
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(ActiveFedora::Base).to receive(:find).with(file_set_id).and_return(file_set)
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(file_set_id, filename)
16
- described_class.perform_now file_set_id, 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
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(ActiveFedora::Base).to receive(:find).with(id).and_return(file_set)
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(id, 'spec/fixtures/piano_note.wav')
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(id, 'spec/fixtures/piano_note.wav')
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(id, 'spec/fixtures/piano_note.wav')
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}", label: file_path) do |f|
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
- allow(ActiveFedora::Base).to receive(:find).with(file_set_id).and_return(file_set)
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(file_set_id)
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(file_set_id)
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.id, filename, 'image/png', 'bob', 'remastered')
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.id, filename, 'image/png', 'bob')
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.id, filename, nil, 'bob')
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.id, file1, 'image/png', user.user_key)
53
- described_class.perform_now(file_set.id, file2, 'text/plain', user2.user_key)
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.id, filename, 'image/png', user.user_key)
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.id)
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.id)
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.id)
51
+ described_class.perform_now(work)
52
52
  work.reload
53
53
  end
54
54
  let(:file) { work.file_sets.first }
@@ -613,4 +613,10 @@ describe FileSet do
613
613
  end
614
614
  end
615
615
  end
616
+
617
+ describe "#to_global_id" do
618
+ let(:file_set) { described_class.new(id: '123') }
619
+ subject { file_set.to_global_id }
620
+ it { is_expected.to be_kind_of GlobalID }
621
+ end
616
622
  end
@@ -56,4 +56,10 @@ describe GenericWork do
56
56
  }.to change { FileSet.count }.by(-2)
57
57
  end
58
58
  end
59
+
60
+ describe "#to_global_id" do
61
+ let(:work) { described_class.new(id: '123') }
62
+ subject { work.to_global_id }
63
+ it { is_expected.to be_kind_of GlobalID }
64
+ end
59
65
  end
@@ -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.file_presenters
97
+ presenter.file_set_presenters
74
98
  end
75
99
  end
76
100
  end