curation_concerns 0.2.0 → 0.3.0

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -1
  4. data/.rubocop.yml +1 -1
  5. data/Gemfile +18 -9
  6. data/VERSION +1 -1
  7. data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +1 -1
  8. data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +6 -0
  9. data/app/presenters/curation_concerns/work_show_presenter.rb +16 -4
  10. data/app/views/catalog/_action_menu_partials/_default.html.erb +30 -28
  11. data/app/views/collections/_form.html.erb +1 -1
  12. data/app/views/collections/_form_permission.html.erb +1 -1
  13. data/app/views/collections/_form_to_add_member.html.erb +1 -1
  14. data/app/views/curation_concerns/base/_attributes.html.erb +1 -1
  15. data/app/views/curation_concerns/base/_form_media.html.erb +4 -0
  16. data/app/views/curation_concerns/base/_form_permission.html.erb +1 -1
  17. data/app/views/curation_concerns/base/_form_permission_under_embargo.html.erb +1 -1
  18. data/app/views/curation_concerns/base/_form_permission_under_lease.html.erb +1 -1
  19. data/app/views/curation_concerns/base/_form_representative.html.erb +12 -0
  20. data/app/views/curation_concerns/base/_form_supplementary_fields.html.erb +1 -1
  21. data/app/views/curation_concerns/base/_form_thumbnail.html.erb +12 -0
  22. data/app/views/curation_concerns/base/_show_actions.html.erb +9 -0
  23. data/app/views/curation_concerns/base/show.html.erb +1 -9
  24. data/app/views/curation_concerns/file_sets/show.html.erb +3 -3
  25. data/curation_concerns.gemspec +1 -1
  26. data/lib/curation_concerns/version.rb +1 -1
  27. data/spec/abilities/generic_work_abilities_spec.rb +2 -0
  28. data/spec/actors/curation_concerns/file_set_actor_spec.rb +50 -0
  29. data/spec/controllers/curation_concerns/generic_works_controller_json_spec.rb +1 -1
  30. data/spec/controllers/curation_concerns/generic_works_controller_spec.rb +16 -5
  31. data/spec/factories/collections.rb +1 -1
  32. data/spec/factories/file_sets.rb +1 -1
  33. data/spec/factories/generic_works.rb +8 -2
  34. data/spec/features/embargo_spec.rb +1 -1
  35. data/spec/features/lease_spec.rb +1 -1
  36. data/spec/features/work_generator_spec.rb +7 -7
  37. data/spec/indexers/generic_work_indexing_service_spec.rb +4 -2
  38. data/spec/jobs/create_derivatives_job_spec.rb +31 -3
  39. data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +25 -0
  40. data/spec/views/catalog/_action_menu_partials/_default.html.erb_spec.rb +14 -0
  41. metadata +12 -7
  42. data/app/views/curation_concerns/base/_form_representative_image.html.erb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 782489cf38f83c30ac855fbe3a965604bc2a4169
4
- data.tar.gz: db4129b1a303be1a6e1e7adc3ed000b72eb90220
3
+ metadata.gz: 7a6a05c11364b9cc72ba7f97963f9a3c32252d17
4
+ data.tar.gz: 61ad7ed57f29b8661b302527f9c2634eef19a52d
5
5
  SHA512:
6
- metadata.gz: e94379134b788b2a80094661da85dec7ad9ab23094203b604e3ca229d4417a26d41a80a13b986ce907721541a503e857656abc08e651b7cfa013a94b2237c1a0
7
- data.tar.gz: c77a0a7b3980c1dcd74542986d6e52041846ae11ed90afea9fd98c2b654b35a57198bbfc0a3cbf19fd102c4c7265288b6fb0bed9294efa61da8193cabe750308
6
+ metadata.gz: f79451b81f8820ee146a1438136f9bb3c526be5ed1e2d50922278c841d77cfb4ec276e6a7442c7c24b8172fa368775b2a500ea9752f4a3ac63a63922a29a101e
7
+ data.tar.gz: d5cba535b0c5d4279402f0b3709b0cc333c691e49713c150ac5110077c95b5e28074c58e01f9c3f10fe2f39cd2d73fa5ecae9c27d1f9de55954746bbbdc8f682
data/.gitignore CHANGED
@@ -9,4 +9,5 @@ jetty
9
9
  /.ruby-gemset
10
10
  solr_conf/
11
11
  spec/internal
12
+ .internal_test_app
12
13
  spec/mock_upload_directory
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --colour
2
- --exclude-pattern spec/internal/**/*
2
+ --exclude-pattern .internal_test_app/**/*
data/.rubocop.yml CHANGED
@@ -10,7 +10,7 @@ AllCops:
10
10
  - 'db/**/*'
11
11
  - 'script/**/*'
12
12
  - 'vendor/**/*'
13
- - 'spec/internal/**/*'
13
+ - '.internal_test_app/**/*'
14
14
  - 'curation_concerns-models/app/models/concerns/curation_concerns/file_set/export.rb'
15
15
 
16
16
  Lint/AssignmentInCondition:
data/Gemfile CHANGED
@@ -17,18 +17,27 @@ group :development, :test do
17
17
  gem 'pry-byebug' unless ENV['CI']
18
18
  end
19
19
 
20
- file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path("../spec/internal", __FILE__))
20
+
21
+ # BEGIN ENGINE_CART BLOCK
22
+ # engine_cart: 0.8.0
23
+ # engine_cart stanza: 0.8.0
24
+ # the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
25
+ file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path(".internal_test_app", File.dirname(__FILE__)))
21
26
  if File.exists?(file)
22
- puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
23
- instance_eval File.read(file)
27
+ begin
28
+ eval_gemfile file
29
+ rescue Bundler::GemfileError => e
30
+ Bundler.ui.warn '[EngineCart] Skipping Rails application dependencies:'
31
+ Bundler.ui.warn e.message
32
+ end
24
33
  else
34
+ Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies"
25
35
  gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
26
- if ENV['RAILS_VERSION'] and ENV['RAILS_VERSION'] !~ /^4.2/
27
- gem 'sass-rails', "< 5.0"
28
- else
36
+ if ENV['RAILS_VERSION'].nil? || ENV['RAILS_VERSION'] =~ /^4.2/
37
+ gem 'responders', "~> 2.0"
29
38
  gem 'sass-rails', ">= 5.0"
39
+ else
40
+ gem 'sass-rails', "< 5.0"
30
41
  end
31
-
32
- extra_file = File.expand_path("../spec/test_app_templates/Gemfile.extra", __FILE__)
33
- instance_eval File.read(extra_file)
34
42
  end
43
+ # END ENGINE_CART BLOCK
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -127,7 +127,7 @@ module CurationConcerns::CurationConcernController
127
127
 
128
128
  def after_update_response
129
129
  # TODO: visibility or lease/embargo status
130
- if actor.visibility_changed?
130
+ if actor.visibility_changed? && curation_concern.file_sets.present?
131
131
  redirect_to main_app.confirm_curation_concerns_permission_path(curation_concern)
132
132
  else
133
133
  respond_to do |wants|
@@ -157,6 +157,12 @@ module CurationConcerns
157
157
  @_prefixes ||= super + ['curation_concerns/base']
158
158
  end
159
159
 
160
+ def json_error(error, name = nil, additional_arguments = {})
161
+ args = { error: error }
162
+ args[:name] = name if name
163
+ render additional_arguments.merge(json: [args])
164
+ end
165
+
160
166
  def empty_file?(file)
161
167
  (file.respond_to?(:tempfile) && file.tempfile.size == 0) || (file.respond_to?(:size) && file.size == 0)
162
168
  end
@@ -24,10 +24,22 @@ module CurationConcerns
24
24
  :embargo_release_date, :lease_expiration_date, :rights, to: :solr_document
25
25
 
26
26
  def file_presenters
27
- @file_sets ||= begin
28
- ids = solr_document.fetch('file_set_ids_ssim', [])
29
- PresenterFactory.build_presenters(ids, FileSetPresenter, current_ability)
30
- end
27
+ @file_sets ||= PresenterFactory.build_presenters(ordered_ids,
28
+ file_presenter_class,
29
+ current_ability)
31
30
  end
31
+
32
+ private
33
+
34
+ # TODO: Extract this to ActiveFedora::Aggregations::ListSource
35
+ def ordered_ids
36
+ ActiveFedora::SolrService.query("proxy_in_ssi:#{id}", fl: "ordered_targets_ssim")
37
+ .flat_map { |x| x.fetch("ordered_targets_ssim", []) }
38
+ end
39
+
40
+ # Override this method if you want to use an alternate presenter class for the files
41
+ def file_presenter_class
42
+ FileSetPresenter
43
+ end
32
44
  end
33
45
  end
@@ -1,29 +1,31 @@
1
- <div class="btn-group">
2
- <button class="btn btn-default btn-small dropdown-toggle" data-toggle="dropdown" href="#">Select an action <span class="caret"></span></button>
3
- <ul class="dropdown-menu">
4
- <% if can? :edit, document %>
5
- <li>
6
- <%= link_to [:edit, :curation_concerns, document], class: 'itemicon itemedit' do %><i class="glyphicon glyphicon-pencil"></i> Edit <%= document.human_readable_type %>
7
- <% end %>
8
- </li>
9
- <li>
10
- <% if @collection || (@presenter and @presenter.collection?) # We're on the view page for @collection. -%>
11
- <%= link_to_remove_from_collection(document) %>
12
- <% else %>
13
- <%= link_to [:curation_concerns, document], class: 'itemicon itemtrash',
14
- title: "Delete #{document.human_readable_type}", method: :delete,
15
- data: {
16
- confirm: "Deleting a #{document.human_readable_type} from #{t('curation_concerns.product_name')} is permanent. Click OK to delete this #{document.human_readable_type} from #{t('curation_concerns.product_name')}, or Cancel to cancel this operation" } do %>
17
- <i class="glyphicon glyphicon-trash"></i> Delete <%= document.human_readable_type %>
1
+ <% if can?(:edit, document) || can?(:collect, document) %>
2
+ <div class="btn-group">
3
+ <button class="btn btn-default btn-small dropdown-toggle" data-toggle="dropdown" href="#">Select an action <span class="caret"></span></button>
4
+ <ul class="dropdown-menu">
5
+ <% if can? :edit, document %>
6
+ <li>
7
+ <%= link_to [:edit, :curation_concerns, document], class: 'itemicon itemedit' do %><i class="glyphicon glyphicon-pencil"></i> Edit <%= document.human_readable_type %>
18
8
  <% end %>
19
- <% end %>
20
- </li>
21
- <% end %>
22
- <% if can? :collect, document %>
23
- <li>
24
- <%= link_to_select_collection document %>
25
- </li>
26
- <% end %>
27
- </ul>
28
- <%= render 'collections/add_to_collection_modal', collectible: document if can? :collect, document %>
29
- </div>
9
+ </li>
10
+ <li>
11
+ <% if @collection || (@presenter and @presenter.collection?) # We're on the view page for @collection. -%>
12
+ <%= link_to_remove_from_collection(document) %>
13
+ <% else %>
14
+ <%= link_to [:curation_concerns, document], class: 'itemicon itemtrash',
15
+ title: "Delete #{document.human_readable_type}", method: :delete,
16
+ data: {
17
+ confirm: "Deleting a #{document.human_readable_type} from #{t('curation_concerns.product_name')} is permanent. Click OK to delete this #{document.human_readable_type} from #{t('curation_concerns.product_name')}, or Cancel to cancel this operation" } do %>
18
+ <i class="glyphicon glyphicon-trash"></i> Delete <%= document.human_readable_type %>
19
+ <% end %>
20
+ <% end %>
21
+ </li>
22
+ <% end %>
23
+ <% if can? :collect, document %>
24
+ <li>
25
+ <%= link_to_select_collection document %>
26
+ </li>
27
+ <% end %>
28
+ </ul>
29
+ <%= render 'collections/add_to_collection_modal', collectible: document if can? :collect, document %>
30
+ </div>
31
+ <% end %>
@@ -10,7 +10,7 @@
10
10
  <%= render 'form_descriptive_fields', curation_concern: @collection, f: f %>
11
11
  <%= render 'form_permission', f: f %>
12
12
 
13
- <%= render "curation_concerns/base/form_representative_image", f: f %>
13
+ <%= render "curation_concerns/base/form_media", f: f %>
14
14
 
15
15
  <div class="row">
16
16
  <div class="col-md-12 form-actions">
@@ -1,7 +1,7 @@
1
1
  <div id="set-access-controls">
2
2
  <fieldset>
3
3
  <legend>
4
- Access Rights
4
+ Visibility
5
5
  <small>Who should be able to view your collection?</small>
6
6
  </legend>
7
7
 
@@ -9,7 +9,7 @@
9
9
  <div class="form-group collection_id">
10
10
  <div class="controls">
11
11
  <%= select_tag :id, collection_options_for_select(collectible), prompt: 'Make a Selection',
12
- class: 'form-control', :'aria-labelledby' => select_label_id %>
12
+ class: 'form-control', :'aria-labelledby' => select_label_id, required: 'required' %>
13
13
  </div>
14
14
  </div>
15
15
 
@@ -6,7 +6,7 @@
6
6
  <tbody>
7
7
  <%= render 'attribute_rows' %>
8
8
  <tr>
9
- <th>Access Rights</th>
9
+ <th>Visibility</th>
10
10
  <td>
11
11
  <%= @presenter.permission_badge %>
12
12
  </td>
@@ -0,0 +1,4 @@
1
+ <% if f.object.persisted? && f.object.member_ids.present? %>
2
+ <%= render 'form_representative', f: f %>
3
+ <%= render 'form_thumbnail', f: f %>
4
+ <% end %>
@@ -6,7 +6,7 @@
6
6
  <% else %>
7
7
  <fieldset id="set-access-controls">
8
8
  <legend>
9
- Access Rights
9
+ Visibility
10
10
  <small>Who should be able to view or download this content?</small>
11
11
  </legend>
12
12
 
@@ -1,6 +1,6 @@
1
1
  <fieldset id="set-access-controls">
2
2
  <legend>
3
- Access Rights
3
+ Visibility
4
4
  <small>Who should be able to view or download this content?</small>
5
5
  </legend>
6
6
 
@@ -1,6 +1,6 @@
1
1
  <fieldset id="set-access-controls">
2
2
  <legend>
3
- Access Rights
3
+ Visibility
4
4
  <small>Who should be able to view or download this content?</small>
5
5
  </legend>
6
6
 
@@ -0,0 +1,12 @@
1
+ <div class="row">
2
+ <div class="col-md-12">
3
+ <fieldset id="representative-media">
4
+ <legend>
5
+ Representative Media
6
+ </legend>
7
+ <p>Select the file with media that represents this <%= f.object.human_readable_type %>.</p>
8
+ <%= f.select :representative_id, @form.select_files, {}, { class: 'form-control' } %>
9
+ </fieldset>
10
+ </div>
11
+ </div>
12
+
@@ -1,5 +1,5 @@
1
1
  <%= render "form_files_and_links", f: f %>
2
- <%= render "form_representative_image", f: f %>
2
+ <%= render "form_media", f: f %>
3
3
 
4
4
  <div class="row with-headroom">
5
5
  <div class="col-md-12">
@@ -0,0 +1,12 @@
1
+ <div class="row">
2
+ <div class="col-md-12">
3
+ <fieldset id="representative-image">
4
+ <legend>
5
+ Thumbnail
6
+ </legend>
7
+ <p>Select the file to be used as the thumbnail for this <%= f.object.human_readable_type %>.</p>
8
+ <%= f.select :thumbnail_id, @form.select_files, {}, { class: 'form-control' } %>
9
+ </fieldset>
10
+ </div>
11
+ </div>
12
+
@@ -0,0 +1,9 @@
1
+ <% if collector || editor %>
2
+ <div class="form-actions">
3
+ <% if editor %>
4
+ <%= link_to "Edit This #{@presenter.human_readable_type}", edit_polymorphic_path([main_app, :curation_concerns, @presenter]), class: 'btn btn-default' %>
5
+ <%= link_to "Attach a File", main_app.new_curation_concerns_file_set_path(@presenter), class: 'btn btn-default' %>
6
+ <%= link_to "Delete This #{@presenter.human_readable_type}", [main_app, :curation_concerns, @presenter], class: 'btn btn-danger pull-right', data: { confirm: "Delete this #{@presenter.human_readable_type}?" }, method: :delete %>
7
+ <% end %>
8
+ </div>
9
+ <% end %>
@@ -13,12 +13,4 @@
13
13
  <%= render partial: 'curation_concerns/file_sets/multiple_upload', presenter: @presenter %>
14
14
  <% end %>
15
15
 
16
- <% if collector || editor %>
17
- <div class="form-actions">
18
- <% if editor %>
19
- <%= link_to "Edit This #{@presenter.human_readable_type}", edit_polymorphic_path([main_app, :curation_concerns, @presenter]), class: 'btn btn-default' %>
20
- <%= link_to "Attach a File", main_app.new_curation_concerns_file_set_path(@presenter), class: 'btn btn-default' %>
21
- <%= link_to "Delete This #{@presenter.human_readable_type}", [main_app, :curation_concerns, @presenter], class: 'btn btn-danger pull-right', data: { confirm: "Delete this #{@presenter.human_readable_type}?" }, method: :delete %>
22
- <% end %>
23
- </div>
24
- <% end %>
16
+ <%= render "show_actions", collector: collector, editor: editor%>
@@ -6,10 +6,10 @@
6
6
  <%= render "attributes", curation_concern: @presenter %>
7
7
 
8
8
  <div class="form-actions">
9
- <%= link_to "Download this File", main_app.download_path(@presenter), class: 'btn btn-primary' %>
9
+ <%= link_to "Download this File", main_app.download_path(@presenter), class: 'btn btn-default' %>
10
10
  <% if can? :edit, @presenter.id %>
11
- <%= link_to "Edit this File", edit_polymorphic_path([main_app, :curation_concerns, @presenter]), class: 'btn btn-primary' %>
11
+ <%= link_to "Edit this File", edit_polymorphic_path([main_app, :curation_concerns, @presenter]), class: 'btn btn-default' %>
12
12
  <% end %>
13
13
 
14
- <%= link_to "Back to #{parent.human_readable_type}", parent_path(parent), class: 'btn btn-primary' %>
14
+ <%= link_to "Back to #{parent.human_readable_type}", parent_path(parent), class: 'btn btn-default' %>
15
15
  </div>
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "devise", "~> 3.0"
31
31
  spec.add_development_dependency "bundler", "~> 1.6"
32
32
  spec.add_development_dependency "rake"
33
- spec.add_development_dependency "engine_cart", "~> 0.7"
33
+ spec.add_development_dependency "engine_cart", "~> 0.8"
34
34
  spec.add_development_dependency "sqlite3"
35
35
  spec.add_development_dependency "rspec-its"
36
36
  spec.add_development_dependency "rspec-rails"
@@ -1,3 +1,3 @@
1
1
  module CurationConcerns
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -40,6 +40,7 @@ describe 'User' do
40
40
  should_not be_able_to(:read, generic_work)
41
41
  should_not be_able_to(:update, generic_work)
42
42
  should_not be_able_to(:destroy, generic_work)
43
+ should be_able_to(:collect, generic_work)
43
44
  end
44
45
  end
45
46
 
@@ -51,6 +52,7 @@ describe 'User' do
51
52
  should_not be_able_to(:read, generic_work)
52
53
  should_not be_able_to(:update, generic_work)
53
54
  should_not be_able_to(:destroy, generic_work)
55
+ should_not be_able_to(:collect, generic_work)
54
56
  end
55
57
  end
56
58
  end
@@ -177,4 +177,54 @@ describe CurationConcerns::FileSetActor do
177
177
  expect(work_v1.members.size).to eq 3
178
178
  end
179
179
  end
180
+
181
+ describe "#set_representative" do
182
+ let!(:work) { build(:generic_work, representative: rep) }
183
+ let!(:file_set) { build(:file_set) }
184
+
185
+ before do
186
+ actor.send(:set_representative, work, file_set)
187
+ end
188
+
189
+ context "when the representative isn't set" do
190
+ let(:rep) { nil }
191
+
192
+ it 'sets the representative' do
193
+ expect(work.representative).to eq file_set
194
+ end
195
+ end
196
+
197
+ context 'when the representative is already set' do
198
+ let(:rep) { build(:file_set, id: '123') }
199
+
200
+ it 'keeps the existing representative' do
201
+ expect(work.representative).to eq rep
202
+ end
203
+ end
204
+ end
205
+
206
+ describe "#set_thumbnail" do
207
+ let!(:work) { build(:generic_work, thumbnail: thumb) }
208
+ let!(:file_set) { build(:file_set) }
209
+
210
+ before do
211
+ actor.send(:set_thumbnail, work, file_set)
212
+ end
213
+
214
+ context "when the thumbnail isn't set" do
215
+ let(:thumb) { nil }
216
+
217
+ it 'sets the thumbnail' do
218
+ expect(work.thumbnail).to eq file_set
219
+ end
220
+ end
221
+
222
+ context 'when the thumbnail is already set' do
223
+ let(:thumb) { build(:file_set, id: '123') }
224
+
225
+ it 'keeps the existing thumbnail' do
226
+ expect(work.thumbnail).to eq thumb
227
+ end
228
+ end
229
+ end
180
230
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  # This tests the CurationConcerns::CurationConcernController module
4
- # which is included into spec/internal/app/controllers/generic_works_controller.rb
4
+ # which is included into .internal_test_app/app/controllers/generic_works_controller.rb
5
5
  describe CurationConcerns::GenericWorksController do
6
6
  let(:user) { create(:user) }
7
7
  before { sign_in user }
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  # This tests the CurationConcerns::CurationConcernController module
4
- # which is included into spec/internal/app/controllers/generic_works_controller.rb
4
+ # which is included into .internal_test_app/app/controllers/generic_works_controller.rb
5
5
  describe CurationConcerns::GenericWorksController do
6
6
  let(:user) { create(:user) }
7
7
  before { sign_in user }
@@ -100,7 +100,7 @@ describe CurationConcerns::GenericWorksController do
100
100
  end
101
101
 
102
102
  describe '#update' do
103
- let(:a_work) { FactoryGirl.create(:private_generic_work, user: user) }
103
+ let(:a_work) { create(:private_generic_work, user: user) }
104
104
  before do
105
105
  allow(controller).to receive(:actor).and_return(actor)
106
106
  end
@@ -114,9 +114,20 @@ describe CurationConcerns::GenericWorksController do
114
114
  describe 'changing rights' do
115
115
  let(:actor) { double(update: true, visibility_changed?: true) }
116
116
 
117
- it 'prompts to change the files access' do
118
- patch :update, id: a_work
119
- expect(response).to redirect_to main_app.confirm_curation_concerns_permission_path(controller.curation_concern)
117
+ context 'when there are children' do
118
+ let(:a_work) { create(:work_with_one_file, user: user) }
119
+
120
+ it 'prompts to change the files access' do
121
+ patch :update, id: a_work
122
+ expect(response).to redirect_to main_app.confirm_curation_concerns_permission_path(controller.curation_concern)
123
+ end
124
+ end
125
+
126
+ context 'without children' do
127
+ it "doesn't prompt to change the files access" do
128
+ patch :update, id: a_work
129
+ expect(response).to redirect_to main_app.curation_concerns_generic_work_path(a_work)
130
+ end
120
131
  end
121
132
  end
122
133
 
@@ -1,5 +1,5 @@
1
1
  FactoryGirl.define do
2
- # The ::Collection model is defined in spec/internal/app/models by the
2
+ # The ::Collection model is defined in .internal_test_app/app/models by the
3
3
  # curation_concerns:install generator.
4
4
  factory :collection do
5
5
  transient do
@@ -1,5 +1,5 @@
1
1
  FactoryGirl.define do
2
- # The ::FileSet model is defined in spec/internal/app/models by the
2
+ # The ::FileSet model is defined in .internal_test_app/app/models by the
3
3
  # curation_concerns:install generator.
4
4
  factory :file_set, class: FileSet do
5
5
  transient do
@@ -1,6 +1,6 @@
1
1
  FactoryGirl.define do
2
- # The ::GenericWork model is defined in spec/internal/app/models by the
3
- # curation_concerns:install generator.
2
+ # The ::GenericWork model is defined in .internal_test_app/app/models by the
3
+ # curation_concerns:test_app generator.
4
4
  factory :generic_work, aliases: [:work, :private_generic_work], class: GenericWork do
5
5
  transient do
6
6
  user { FactoryGirl.create(:user) }
@@ -26,6 +26,12 @@ FactoryGirl.define do
26
26
  factory :work_with_files do
27
27
  before(:create) { |work, evaluator| 2.times { work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user) } }
28
28
  end
29
+ factory :work_with_ordered_files do
30
+ before(:create) do |work, evaluator|
31
+ work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user)
32
+ work.ordered_member_proxies.insert_target_at(0, FactoryGirl.create(:file_set, user: evaluator.user))
33
+ end
34
+ end
29
35
 
30
36
  factory :with_embargo_date do
31
37
  transient do
@@ -34,7 +34,7 @@ describe 'embargo' do
34
34
  fill_in 'until', with: later_future_date.to_s
35
35
 
36
36
  click_button 'Update Embargo'
37
- expect(page).to have_content(later_future_date.to_date.to_formatted_s(:long_ordinal))
37
+ expect(page).to have_content(later_future_date.iso8601)
38
38
  end
39
39
  end
40
40
 
@@ -31,7 +31,7 @@ describe 'leases' do
31
31
  fill_in 'until', with: later_future_date.to_s
32
32
 
33
33
  click_button 'Update Lease'
34
- expect(page).to have_content(later_future_date.to_date.to_formatted_s(:long_ordinal)) # new lease date is displayed in message
34
+ expect(page).to have_content(later_future_date.iso8601) # new lease date is displayed in message
35
35
  end
36
36
  end
37
37
 
@@ -14,13 +14,13 @@ describe 'Creating a new Work' do
14
14
 
15
15
  before do
16
16
  Rails::Generators.invoke('curation_concerns:work', ['Catapult'], destination_root: Rails.root)
17
- load 'spec/internal/app/models/catapult.rb'
18
- load 'spec/internal/app/controllers/curation_concerns/catapults_controller.rb'
19
- load 'spec/internal/app/actors/curation_concerns/catapult_actor.rb'
20
- load 'spec/internal/app/forms/curation_concerns/catapult_form.rb'
21
- load 'spec/internal/config/initializers/curation_concerns.rb'
22
- load 'spec/internal/config/routes.rb'
23
- load 'app/helpers/curation_concerns/url_helper.rb'
17
+ load "#{EngineCart.destination}/app/models/catapult.rb"
18
+ load "#{EngineCart.destination}/app/controllers/curation_concerns/catapults_controller.rb"
19
+ load "#{EngineCart.destination}/app/actors/curation_concerns/catapult_actor.rb"
20
+ load "#{EngineCart.destination}/app/forms/curation_concerns/catapult_form.rb"
21
+ load "#{EngineCart.destination}/config/initializers/curation_concerns.rb"
22
+ load "#{EngineCart.destination}/config/routes.rb"
23
+ load "app/helpers/curation_concerns/url_helper.rb"
24
24
  sign_in user
25
25
 
26
26
  # stub out characterization. Travis doesn't have fits installed, and it's not relevant to the test.
@@ -4,18 +4,20 @@ describe CurationConcerns::WorkIndexingService do
4
4
  # TODO: file_set_ids returns an empty set unless you persist the work
5
5
  let(:user) { create(:user) }
6
6
  let!(:generic_work) { create(:work_with_one_file, user: user) }
7
+ let!(:child_work) { create(:generic_work, user: user) }
7
8
  let(:service) { described_class.new(generic_work) }
8
9
  let(:file) { generic_work.file_sets.first }
9
10
 
10
11
  before do
12
+ generic_work.works << child_work
11
13
  allow(CurationConcerns::ThumbnailPathService).to receive(:call).and_return("/downloads/#{file.id}?file=thumbnail")
12
14
  generic_work.representative_id = file.id
13
15
  end
14
16
 
15
17
  subject { service.generate_solr_document }
16
18
 
17
- it 'indexes files' do
18
- expect(subject['file_set_ids_ssim']).to eq generic_work.member_ids
19
+ it 'indexes member work and file_set ids' do
20
+ expect(subject['member_ids_ssim']).to eq generic_work.member_ids
19
21
  expect(subject['generic_type_sim']).to eq ['Work']
20
22
  expect(subject.fetch('thumbnail_path_ss')).to eq "/downloads/#{file.id}?file=thumbnail"
21
23
  end
@@ -1,12 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CurationConcerns::CreateDerivativesJob do
4
+ let(:id) { '123' }
5
+
4
6
  before do
5
7
  @ffmpeg_enabled = CurationConcerns.config.enable_ffmpeg
6
8
  CurationConcerns.config.enable_ffmpeg = true
7
- allow(ActiveFedora::Base).to receive(:find).with('123').and_return(file_set)
9
+ allow(ActiveFedora::Base).to receive(:find).with(id).and_return(file_set)
8
10
  allow(file_set).to receive(:mime_type).and_return('audio/x-wav')
9
- allow(file_set).to receive(:id).and_return('123')
11
+ allow(file_set).to receive(:id).and_return(id)
10
12
  end
11
13
 
12
14
  let(:file_set) { FileSet.new }
@@ -19,7 +21,33 @@ describe CurationConcerns::CreateDerivativesJob do
19
21
  it 'calls create_derivatives and save on a file set' do
20
22
  expect(Hydra::Derivatives::AudioDerivatives).to receive(:create)
21
23
  expect(file_set).to receive(:update_index)
22
- CreateDerivativesJob.perform_now('123', 'spec/fixtures/piano_note.wav')
24
+ CreateDerivativesJob.perform_now(id, 'spec/fixtures/piano_note.wav')
25
+ end
26
+ end
27
+
28
+ context 'with a parent object' do
29
+ before do
30
+ allow(file_set).to receive(:parent).and_return(parent)
31
+ # Stub out the actual derivative creation
32
+ expect(file_set).to receive(:create_derivatives)
33
+ end
34
+
35
+ context 'when the file_set is the thumbnail of the parent' do
36
+ let(:parent) { GenericWork.new(thumbnail_id: id) }
37
+
38
+ it 'updates the index of the parent object' do
39
+ expect(parent).to receive(:update_index)
40
+ CreateDerivativesJob.perform_now(id, 'spec/fixtures/piano_note.wav')
41
+ end
42
+ end
43
+
44
+ context "when the file_set isn't the parent's thumbnail" do
45
+ let(:parent) { GenericWork.new }
46
+
47
+ it "doesn't update the parent's index" do
48
+ expect(parent).to_not receive(:update_index)
49
+ CreateDerivativesJob.perform_now(id, 'spec/fixtures/piano_note.wav')
50
+ end
23
51
  end
24
52
  end
25
53
  end
@@ -32,4 +32,29 @@ describe CurationConcerns::WorkShowPresenter do
32
32
  presenter.permission_badge
33
33
  end
34
34
  end
35
+
36
+ describe "#file_presenters" do
37
+ let(:obj) { create(:work_with_ordered_files) }
38
+ let(:attributes) { obj.to_solr }
39
+
40
+ it "displays them in order" do
41
+ expect(obj.ordered_member_ids).not_to eq obj.member_ids
42
+ expect(presenter.file_presenters.map(&:id)).to eq obj.ordered_member_ids
43
+ end
44
+
45
+ describe "getting presenters from factory" do
46
+ let(:attributes) { {} }
47
+ let(:presenter_class) { double }
48
+ before do
49
+ allow(presenter).to receive(:file_presenter_class).and_return(presenter_class)
50
+ allow(presenter).to receive(:ordered_ids).and_return(['12', '33'])
51
+ end
52
+
53
+ it "uses the set class" do
54
+ expect(CurationConcerns::PresenterFactory).to receive(:build_presenters)
55
+ .with(['12', '33'], presenter_class, ability)
56
+ presenter.file_presenters
57
+ end
58
+ end
59
+ end
35
60
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'catalog/_action_menu_partials/_default.html.erb' do
4
+ let(:document) { double }
5
+ subject { rendered }
6
+
7
+ context "when neither a editor or a collector" do
8
+ before do
9
+ allow(view).to receive(:can?).and_return(false)
10
+ render 'catalog/_action_menu_partials/default.html.erb', document: document
11
+ end
12
+ it { is_expected.to eq '' }
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curation_concerns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
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: 2015-10-21 00:00:00.000000000 Z
13
+ date: 2015-11-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hydra-head
@@ -74,14 +74,14 @@ dependencies:
74
74
  requirements:
75
75
  - - '='
76
76
  - !ruby/object:Gem::Version
77
- version: 0.2.0
77
+ version: 0.3.0
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - '='
83
83
  - !ruby/object:Gem::Version
84
- version: 0.2.0
84
+ version: 0.3.0
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: hydra-editor
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -164,14 +164,14 @@ dependencies:
164
164
  requirements:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: '0.7'
167
+ version: '0.8'
168
168
  type: :development
169
169
  prerelease: false
170
170
  version_requirements: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - "~>"
173
173
  - !ruby/object:Gem::Version
174
- version: '0.7'
174
+ version: '0.8'
175
175
  - !ruby/object:Gem::Dependency
176
176
  name: sqlite3
177
177
  requirement: !ruby/object:Gem::Requirement
@@ -471,19 +471,22 @@ files:
471
471
  - app/views/curation_concerns/base/_form_additional_information.html.erb
472
472
  - app/views/curation_concerns/base/_form_descriptive_fields.erb
473
473
  - app/views/curation_concerns/base/_form_files_and_links.html.erb
474
+ - app/views/curation_concerns/base/_form_media.html.erb
474
475
  - app/views/curation_concerns/base/_form_permission.html.erb
475
476
  - app/views/curation_concerns/base/_form_permission_embargo.html.erb
476
477
  - app/views/curation_concerns/base/_form_permission_lease.html.erb
477
478
  - app/views/curation_concerns/base/_form_permission_note.html.erb
478
479
  - app/views/curation_concerns/base/_form_permission_under_embargo.html.erb
479
480
  - app/views/curation_concerns/base/_form_permission_under_lease.html.erb
480
- - app/views/curation_concerns/base/_form_representative_image.html.erb
481
+ - app/views/curation_concerns/base/_form_representative.html.erb
481
482
  - app/views/curation_concerns/base/_form_required_information.html.erb
482
483
  - app/views/curation_concerns/base/_form_rights.html.erb
483
484
  - app/views/curation_concerns/base/_form_supplementary_fields.html.erb
485
+ - app/views/curation_concerns/base/_form_thumbnail.html.erb
484
486
  - app/views/curation_concerns/base/_legally_binding_text.html.erb
485
487
  - app/views/curation_concerns/base/_related_files.html.erb
486
488
  - app/views/curation_concerns/base/_representative_media.html.erb
489
+ - app/views/curation_concerns/base/_show_actions.html.erb
487
490
  - app/views/curation_concerns/base/_versioning.html.erb
488
491
  - app/views/curation_concerns/base/edit.html.erb
489
492
  - app/views/curation_concerns/base/new.html.erb
@@ -717,6 +720,7 @@ files:
717
720
  - spec/tasks/rake_spec.rb
718
721
  - spec/test_app_templates/Gemfile.extra
719
722
  - spec/test_app_templates/lib/generators/test_app_generator.rb
723
+ - spec/views/catalog/_action_menu_partials/_default.html.erb_spec.rb
720
724
  - spec/views/catalog/index.html.erb_spec.rb
721
725
  - spec/views/curation_concerns/base/_attributes.html.erb_spec.rb
722
726
  - spec/views/curation_concerns/base/_form_permission.html.erb_spec.rb
@@ -901,6 +905,7 @@ test_files:
901
905
  - spec/tasks/rake_spec.rb
902
906
  - spec/test_app_templates/Gemfile.extra
903
907
  - spec/test_app_templates/lib/generators/test_app_generator.rb
908
+ - spec/views/catalog/_action_menu_partials/_default.html.erb_spec.rb
904
909
  - spec/views/catalog/index.html.erb_spec.rb
905
910
  - spec/views/curation_concerns/base/_attributes.html.erb_spec.rb
906
911
  - spec/views/curation_concerns/base/_form_permission.html.erb_spec.rb
@@ -1,25 +0,0 @@
1
- <% if f.object.persisted? && f.object.member_ids.present? %>
2
- <div class="row">
3
- <div class="col-md-12">
4
- <fieldset id="representative-media">
5
- <legend>
6
- Representative Media
7
- </legend>
8
- <p>Select the file with media that represents this <%= f.object.human_readable_type %>.</p>
9
- <%= f.select :representative_id, @form.select_files, {}, { class: 'form-control' } %>
10
- </fieldset>
11
- </div>
12
- </div>
13
-
14
- <div class="row">
15
- <div class="col-md-12">
16
- <fieldset id="representative-image">
17
- <legend>
18
- Thumbnail
19
- </legend>
20
- <p>Select the file to be used as the thumbnail for this <%= f.object.human_readable_type %>.</p>
21
- <%= f.select :thumbnail_id, @form.select_files, {}, { class: 'form-control' } %>
22
- </fieldset>
23
- </div>
24
- </div>
25
- <% end %>