curation_concerns 1.7.0.beta1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/curation_concerns/application_controller_behavior.rb +2 -8
  3. data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +13 -13
  4. data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +40 -3
  5. data/app/controllers/concerns/curation_concerns/selects_collections.rb +2 -0
  6. data/app/controllers/concerns/curation_concerns/single_use_links_controller_behavior.rb +9 -7
  7. data/app/models/concerns/curation_concerns/solr_document_behavior.rb +8 -0
  8. data/app/models/concerns/curation_concerns/suppressible.rb +31 -0
  9. data/app/models/concerns/curation_concerns/work_behavior.rb +1 -1
  10. data/app/presenters/curation_concerns/inspect_work_presenter.rb +52 -0
  11. data/app/presenters/curation_concerns/work_show_presenter.rb +4 -0
  12. data/app/search_builders/curation_concerns/README.md +69 -0
  13. data/app/search_builders/curation_concerns/collection_search_builder.rb +35 -17
  14. data/app/search_builders/curation_concerns/filter_suppressed.rb +15 -0
  15. data/app/search_builders/curation_concerns/filter_suppressed_with_roles.rb +30 -0
  16. data/app/search_builders/curation_concerns/search_filters.rb +1 -0
  17. data/app/search_builders/curation_concerns/single_collection_search_builder.rb +5 -0
  18. data/app/search_builders/curation_concerns/work_search_builder.rb +1 -0
  19. data/app/services/curation_concerns/actors/actor_factory.rb +0 -1
  20. data/app/services/curation_concerns/embargo_service.rb +0 -13
  21. data/app/services/curation_concerns/workflow/action_taken_service.rb +25 -15
  22. data/app/services/curation_concerns/workflow/activate_object.rb +9 -2
  23. data/app/services/curation_concerns/workflow/deactivate_object.rb +9 -4
  24. data/app/services/curation_concerns/workflow/{remove_depositor_permissions.rb → grant_edit_to_depositor.rb} +4 -4
  25. data/app/services/curation_concerns/workflow/workflow_action_service.rb +1 -1
  26. data/app/services/curation_concerns/working_directory.rb +1 -1
  27. data/app/views/curation_concerns/base/inspect_work.html.erb +37 -0
  28. data/app/views/curation_concerns/base/unavailable.html.erb +10 -0
  29. data/app/views/curation_concerns/operations/index.html.erb +1 -1
  30. data/app/views/curation_concerns/operations/show.html.erb +1 -1
  31. data/config/locales/curation_concerns.en.yml +3 -0
  32. data/curation_concerns.gemspec +3 -3
  33. data/lib/curation_concerns/rails/routes.rb +1 -0
  34. data/lib/curation_concerns/version.rb +1 -1
  35. data/lib/curation_concerns/workflow_authorization_exception.rb +4 -0
  36. data/lib/generators/curation_concerns/templates/workflow.json.erb +1 -0
  37. data/spec/controllers/curation_concerns/generic_works_controller_spec.rb +78 -16
  38. data/spec/controllers/selects_collections_controller_spec.rb +2 -4
  39. data/spec/factories/generic_works.rb +6 -0
  40. data/spec/factories/workflows.rb +1 -1
  41. data/spec/features/add_file_spec.rb +3 -0
  42. data/spec/features/create_child_work_spec.rb +13 -7
  43. data/spec/features/update_file_spec.rb +3 -2
  44. data/spec/forms/curation_concerns/forms/workflow_action_form_spec.rb +2 -4
  45. data/spec/indexers/work_indexer_spec.rb +11 -7
  46. data/spec/jobs/characterize_job_spec.rb +2 -2
  47. data/spec/models/curation_concerns/work_behavior_spec.rb +1 -1
  48. data/spec/models/generic_work_spec.rb +16 -7
  49. data/spec/models/solr_document_spec.rb +13 -0
  50. data/spec/presenters/curation_concerns/inspect_work_presenter_spec.rb +58 -0
  51. data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +9 -0
  52. data/spec/presenters/curation_concerns/workflow_presenter_spec.rb +29 -15
  53. data/spec/routing/route_spec.rb +4 -0
  54. data/spec/services/curation_concerns/workflow/action_taken_service_spec.rb +5 -6
  55. data/spec/services/curation_concerns/workflow/activate_object_spec.rb +13 -12
  56. data/spec/services/curation_concerns/workflow/deactivate_object_spec.rb +14 -13
  57. data/spec/services/curation_concerns/workflow/grant_edit_to_depositor_spec.rb +20 -0
  58. data/spec/services/curation_concerns/workflow/permission_query_spec.rb +3 -3
  59. data/spec/services/curation_concerns/workflow/status_list_service_spec.rb +4 -1
  60. data/spec/services/curation_concerns/workflow/workflow_importer_spec.rb +2 -3
  61. data/spec/services/curation_concerns/working_directory_spec.rb +12 -0
  62. data/spec/views/curation_concerns/base/unavailable.html.erb_spec.rb +40 -0
  63. metadata +34 -20
  64. data/app/actors/curation_concerns/actors/grant_edit_to_depositor_actor.rb +0 -19
  65. data/app/models/concerns/curation_concerns/publishable.rb +0 -25
  66. data/app/models/curation_concerns/state_workflow.rb +0 -13
  67. data/app/views/curation_concerns/file_sets/_rights_modal.html.erb +0 -41
  68. data/app/views/records/_rights_modal.html.erb +0 -1
  69. data/spec/actors/curation_concerns/grant_edit_to_depositor_actor_spec.rb +0 -32
  70. data/spec/services/curation_concerns/workflow/remove_depositor_permissions_spec.rb +0 -21
@@ -1,10 +1,15 @@
1
1
  module CurationConcerns
2
2
  module Workflow
3
- # This is a built in function for workflow, so that a workflow action can be created that
4
- # deactivates an object.
3
+ ##
4
+ # This is a built in function for workflow, setting the `#state`
5
+ # of the target to the Fedora 'inactive' status URI
6
+ #
7
+ # @param target [#state] an instance of a model that includes `CurationConcerns::Suppressible`
8
+ #
9
+ # @return [RDF::Vocabulary::Term] the Fedora Resource Status 'inactive' term
5
10
  class DeactivateObject
6
- def self.call(entity:, **)
7
- entity.proxy_for.state = Vocab::FedoraResourceStatus.inactive
11
+ def self.call(target:, **)
12
+ target.state = Vocab::FedoraResourceStatus.inactive
8
13
  end
9
14
  end
10
15
  end
@@ -1,10 +1,10 @@
1
1
  module CurationConcerns
2
2
  module Workflow
3
3
  # This is a built in function for workflow, so that a workflow action can be created that
4
- # removes the creators ability to alter it.
5
- class RemoveDepositorPermissions
6
- def self.call(entity:, **)
7
- entity.proxy_for.edit_users = []
4
+ # grants the creator the ability to alter it.
5
+ class GrantEditToDepositor
6
+ def self.call(target:, **)
7
+ target.edit_users = [target.depositor]
8
8
  end
9
9
  end
10
10
  end
@@ -45,7 +45,7 @@ module CurationConcerns
45
45
  # Run any configured custom methods
46
46
  def handle_additional_sipity_workflow_action_processing(comment:)
47
47
  CurationConcerns::Workflow::ActionTakenService.handle_action_taken(
48
- entity: subject.entity,
48
+ target: subject.work,
49
49
  comment: comment,
50
50
  action: action,
51
51
  user: subject.user
@@ -48,7 +48,7 @@ module CurationConcerns
48
48
  end
49
49
 
50
50
  def full_filename(id, original_name)
51
- pair = id.scan(/..?/).first(4)
51
+ pair = id.scan(/..?/).first(4).push(id)
52
52
  File.join(CurationConcerns.config.working_path, *pair, original_name)
53
53
  end
54
54
  end
@@ -0,0 +1,37 @@
1
+ <h1><%= t("inspect_work.link_text") %></h1>
2
+ <ul class="breadcrumb">
3
+ <li>
4
+ Back to <%= link_to @presenter.to_s, [main_app, @presenter] %>
5
+ </li>
6
+ </ul>
7
+
8
+ <h3>Workflow</h3>
9
+ <dl>
10
+ <% workflow = @presenter.inspect_work.workflow %>
11
+ <dt>Object Name</dt>
12
+ <dd><%= @presenter.to_s %></dd>
13
+ <dt>Processing Entity ID</dt>
14
+ <dd>Entity ID: <%= workflow[:entity_id] %> (Proxy for <%= workflow[:proxy_for] %>)</dd>
15
+ <dt>Workflow</dt>
16
+ <dd>Name: <%= workflow[:workflow_name] %> (ID=<%= workflow[:workflow_id] %>)</dd>
17
+ <dt>State</dt>
18
+ <dd>State Name: <%= workflow[:state_name] %> (ID=<%= workflow[:state_id] %>)</dd>
19
+ <dt>Workflow Comments</dt>
20
+ <dd>
21
+ <% workflow[:comments].each do |comment| %>
22
+ <dd><%= comment[:created_at] %>, <%= comment[:comment] %></dd>
23
+ <% end %>
24
+ </dd>
25
+ <dt>Roles</dt>
26
+ <dd>
27
+ <% workflow[:roles].each do |role| %>
28
+ <dd><%= role[:name] %> (ID=<%= role[:id] %>) <%= role[:description] %> Users: <%= role[:users] %></dd>
29
+ <% end %>
30
+ </dd>
31
+ </dl>
32
+
33
+ <h3>Persistence</h3>
34
+ <dl>
35
+ <dt>Solr</dt>
36
+ <dd><%= @presenter.inspect_work.solr %></dd>
37
+ </dl>
@@ -0,0 +1,10 @@
1
+ <h1><%= @presenter %> </h1>
2
+ <span class="state state-<%= @presenter.workflow.state %>"><%= @presenter.workflow.state_label %></span>
3
+ <% if @parent_presenter %>
4
+ <ul class="breadcrumb">
5
+ <li><%= link_to @parent_presenter, polymorphic_path([main_app, @parent_presenter]) %></li>
6
+ <li class="active"><%= @presenter.human_readable_type %></li>
7
+ </ul>
8
+ <% else %>
9
+ <span class="human_readable_type">(<%= @presenter.human_readable_type %>)</span>
10
+ <% end %>
@@ -13,7 +13,7 @@
13
13
  <tbody>
14
14
  <% @operations.each do |op| %>
15
15
  <tr>
16
- <td><%= link_to op.operation_type, sufia.user_operation_path(params[:user_id], op) %></td>
16
+ <td><%= link_to op.operation_type, curation_concerns.user_operation_path(params[:user_id], op) %></td>
17
17
  <td><span class="label <%= op.status == 'failure' ? 'label-danger' : 'label-success' %>"><%= op.status %></span></td>
18
18
  </tr>
19
19
  <% end %>
@@ -18,7 +18,7 @@
18
18
  <tbody>
19
19
  <% @operation.children.each do |op| %>
20
20
  <tr>
21
- <td><%= link_to op.operation_type, sufia.user_operation_path(params[:user_id], op) %></td>
21
+ <td><%= link_to op.operation_type, curation_concerns.user_operation_path(params[:user_id], op) %></td>
22
22
  <td><span class="label <%= op.status == 'failure' ? 'label-danger' : 'label-success' %>"><%= op.status %></span></td>
23
23
  <td><%= op.message %></td>
24
24
  </tr>
@@ -181,6 +181,7 @@ en:
181
181
  workflow:
182
182
  default:
183
183
  deposit: "Deposit"
184
+ unauthorized: "The work is not currently available because it has not yet completed the approval process"
184
185
  blacklight:
185
186
  search:
186
187
  fields:
@@ -233,6 +234,8 @@ en:
233
234
  submit:
234
235
  sipity_workflow_responsibility:
235
236
  create: "Add"
237
+ inspect_work:
238
+ link_text: 'Inspect Work'
236
239
  simple_form:
237
240
  required:
238
241
  html: '<span class="label label-info required-tag">required</span>'
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'hydra-head', '>= 10.0.0', '< 11'
21
+ spec.add_dependency 'hydra-head', '>= 10.3.0', '< 11'
22
22
  spec.add_dependency 'active-fedora', '>= 10.3.0.rc1'
23
23
  spec.add_dependency 'blacklight', '~> 6.3'
24
24
  spec.add_dependency 'breadcrumbs_on_rails', '>= 3.0.1', '< 4'
25
- spec.add_dependency 'jquery-ui-rails'
25
+ spec.add_dependency 'jquery-ui-rails', '~> 5.0.5'
26
26
  spec.add_dependency 'simple_form', '~> 3.1'
27
27
  spec.add_dependency 'hydra-editor', '>= 2', '< 4'
28
28
  spec.add_dependency 'rails_autolink'
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency 'rdf', '>= 1.99'
38
38
  spec.add_dependency 'rdf-vocab', '>= 0.8'
39
39
  spec.add_dependency 'awesome_nested_set', '~> 3.0'
40
- spec.add_dependency 'browse-everything', '~> 0.10'
40
+ spec.add_dependency 'browse-everything', '~> 0.10', '>= 0.10.5'
41
41
  spec.add_dependency 'clipboard-rails', '~> 1.5'
42
42
  spec.add_dependency 'power_converter', '~> 0.1', '>= 0.1.2'
43
43
  spec.add_dependency 'dry-validation', '~> 0.9'
@@ -16,6 +16,7 @@ module ActionDispatch::Routing
16
16
  namespaced_resources curation_concern_name, only: [] do
17
17
  member do
18
18
  get :file_manager
19
+ get :inspect_work
19
20
  end
20
21
  end
21
22
  end
@@ -1,3 +1,3 @@
1
1
  module CurationConcerns
2
- VERSION = '1.7.0.beta1'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
@@ -0,0 +1,4 @@
1
+ module CurationConcerns
2
+ class WorkflowAuthorizationException < StandardError
3
+ end
4
+ end
@@ -10,6 +10,7 @@
10
10
  "from_states": [],
11
11
  "transition_to": "deposited",
12
12
  "methods": [
13
+ "CurationConcerns::Workflow::GrantEditToDepositor",
13
14
  "CurationConcerns::Workflow::ActivateObject"
14
15
  ]
15
16
  }
@@ -4,7 +4,25 @@ require 'spec_helper'
4
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
- before { sign_in user }
7
+ let(:work) { create(:generic_work, user: user) }
8
+ let!(:sipity_entity) do
9
+ create(:sipity_entity, proxy_for_global_id: work.to_global_id.to_s)
10
+ end
11
+ before do
12
+ sign_in user
13
+ end
14
+
15
+ describe 'integration test for suppressed documents' do
16
+ let(:work) do
17
+ create(:work, :public, state: Vocab::FedoraResourceStatus.inactive)
18
+ end
19
+ it 'renders the unavailable message because it is in workflow' do
20
+ get :show, params: { id: work }
21
+ expect(response.code).to eq '401'
22
+ expect(response).to render_template(:unavailable)
23
+ expect(flash[:notice]).to eq 'The work is not currently available because it has not yet completed the approval process'
24
+ end
25
+ end
8
26
 
9
27
  describe '#show' do
10
28
  context 'my own private work' do
@@ -16,6 +34,9 @@ describe CurationConcerns::GenericWorksController do
16
34
 
17
35
  context "with a parent work" do
18
36
  let(:parent) { create(:generic_work, title: ['Parent Work'], user: user, ordered_members: [work]) }
37
+ let!(:parent_sipity_entity) do
38
+ create(:sipity_entity, proxy_for_global_id: parent.to_global_id.to_s)
39
+ end
19
40
  it "sets the parent presenter" do
20
41
  get :show, params: { id: work, parent_id: parent }
21
42
  expect(response).to be_success
@@ -50,7 +71,7 @@ describe CurationConcerns::GenericWorksController do
50
71
  allow(presenter).to receive(:export_as_ttl).and_return("ttl graph")
51
72
  end
52
73
 
53
- it 'renders an turtle file' do
74
+ it 'renders a turtle file' do
54
75
  get :show, params: { id: '99999999', format: :ttl }
55
76
  expect(response).to be_successful
56
77
  expect(response.body).to eq "ttl graph"
@@ -68,6 +89,35 @@ describe CurationConcerns::GenericWorksController do
68
89
  end
69
90
  end
70
91
 
92
+ context 'with work still in workflow' do
93
+ before do
94
+ allow(controller).to receive(:search_results).and_return([nil, document_list])
95
+ end
96
+ context 'with a user lacking workflow permission' do
97
+ before do
98
+ allow(SolrDocument).to receive(:find).and_return(document)
99
+ end
100
+ let(:document_list) { [] }
101
+ let(:document) { instance_double(SolrDocument, suppressed?: true) }
102
+ it 'shows the unauthorized message' do
103
+ get :show, params: { id: '99999' }
104
+ expect(response.code).to eq '401'
105
+ expect(response).to render_template(:unavailable)
106
+ expect(flash[:notice]).to eq 'The work is not currently available because it has not yet completed the approval process'
107
+ end
108
+ end
109
+ context 'with a user granted workflow permission' do
110
+ let(:document_list) { [document] }
111
+ let(:document) { instance_double(SolrDocument) }
112
+ it 'renders without the unauthorized message' do
113
+ get :show, params: { id: '88888' }
114
+ expect(response.code).to eq '200'
115
+ expect(response).to render_template(:show)
116
+ expect(flash[:notice]).to be_nil
117
+ end
118
+ end
119
+ end
120
+
71
121
  context 'when a ObjectNotFoundError is raised' do
72
122
  it 'returns 404 page' do
73
123
  allow(controller).to receive(:show).and_raise(ActiveFedora::ObjectNotFoundError)
@@ -193,7 +243,6 @@ describe CurationConcerns::GenericWorksController do
193
243
 
194
244
  context 'when there are children' do
195
245
  let(:work) { create(:work_with_one_file, user: user) }
196
-
197
246
  it 'prompts to change the files access' do
198
247
  patch :update, params: { id: work, generic_work: {} }
199
248
  expect(response).to redirect_to main_app.confirm_curation_concerns_permission_path(controller.curation_concern)
@@ -238,23 +287,23 @@ describe CurationConcerns::GenericWorksController do
238
287
  end
239
288
 
240
289
  describe '#destroy' do
241
- let(:work_to_be_deleted) { create(:private_generic_work, user: user) }
290
+ let(:work) { create(:private_generic_work, user: user) }
242
291
  let(:parent_collection) { create(:collection) }
243
292
 
244
293
  it 'deletes the work' do
245
- delete :destroy, params: { id: work_to_be_deleted }
294
+ delete :destroy, params: { id: work }
246
295
  expect(response).to redirect_to main_app.search_catalog_path
247
- expect(GenericWork).not_to exist(work_to_be_deleted.id)
296
+ expect(GenericWork).not_to exist(work.id)
248
297
  end
249
298
 
250
299
  context "when work is a member of a collection" do
251
300
  before do
252
- parent_collection.members = [work_to_be_deleted]
301
+ parent_collection.members = [work]
253
302
  parent_collection.save!
254
303
  end
255
304
  it 'deletes the work and updates the parent collection' do
256
- delete :destroy, params: { id: work_to_be_deleted }
257
- expect(GenericWork).not_to exist(work_to_be_deleted.id)
305
+ delete :destroy, params: { id: work }
306
+ expect(GenericWork).not_to exist(work.id)
258
307
  expect(response).to redirect_to main_app.search_catalog_path
259
308
  expect(parent_collection.reload.members).to eq []
260
309
  end
@@ -262,35 +311,48 @@ describe CurationConcerns::GenericWorksController do
262
311
 
263
312
  it "invokes the after_destroy callback" do
264
313
  expect(CurationConcerns.config.callback).to receive(:run)
265
- .with(:after_destroy, work_to_be_deleted.id, user)
266
- delete :destroy, params: { id: work_to_be_deleted }
314
+ .with(:after_destroy, work.id, user)
315
+ delete :destroy, params: { id: work }
267
316
  end
268
317
 
269
318
  context 'someone elses public work' do
270
- let(:work_to_be_deleted) { create(:private_generic_work) }
319
+ let(:work) { create(:private_generic_work) }
271
320
  it 'shows unauthorized message' do
272
- delete :destroy, params: { id: work_to_be_deleted }
321
+ delete :destroy, params: { id: work }
273
322
  expect(response.code).to eq '401'
274
323
  expect(response).to render_template(:unauthorized)
275
324
  end
276
325
  end
277
326
 
278
327
  context 'when I am a repository manager' do
279
- let(:work_to_be_deleted) { create(:private_generic_work) }
328
+ let(:work) { create(:private_generic_work) }
280
329
  before { allow_any_instance_of(User).to receive(:groups).and_return(['admin']) }
281
330
  it 'someone elses private work should delete the work' do
282
- delete :destroy, params: { id: work_to_be_deleted }
283
- expect(GenericWork).not_to exist(work_to_be_deleted.id)
331
+ delete :destroy, params: { id: work }
332
+ expect(GenericWork).not_to exist(work.id)
284
333
  end
285
334
  end
286
335
  end
287
336
 
288
337
  describe '#file_manager' do
289
338
  let(:work) { create(:private_generic_work, user: user) }
339
+
290
340
  it "is successful" do
291
341
  get :file_manager, params: { id: work.id }
292
342
  expect(response).to be_success
293
343
  expect(assigns(:presenter)).not_to be_blank
294
344
  end
295
345
  end
346
+
347
+ describe '#inspect_work' do
348
+ let(:work) { create(:private_generic_work, user: user) }
349
+ context 'when I am a repository manager' do
350
+ before { allow_any_instance_of(User).to receive(:groups).and_return(['admin']) }
351
+ it "the response is successful" do
352
+ get :inspect_work, params: { id: work.id }
353
+ expect(response).to be_success
354
+ expect(assigns(:presenter)).not_to be_blank
355
+ end
356
+ end
357
+ end
296
358
  end
@@ -11,10 +11,8 @@ end
11
11
  describe SelectsCollectionsController, type: :controller do
12
12
  describe "#find_collections" do
13
13
  it "uses the search builder" do
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]
14
+ expect(subject.collections_search_builder_class.default_processor_chain)
15
+ .to include(:default_solr_parameters, :add_query_to_solr, :add_access_controls_to_solr_params)
18
16
  expect(CurationConcerns::CollectionSearchBuilder).to receive(:new).with(subject).and_call_original
19
17
  subject.find_collections
20
18
  end
@@ -99,4 +99,10 @@ FactoryGirl.define do
99
99
  end
100
100
  end
101
101
  end
102
+
103
+ # Doesn't set up any edit_users
104
+ factory :work_without_access, class: GenericWork do
105
+ title ['Test title']
106
+ depositor { FactoryGirl.create(:user).user_key }
107
+ end
102
108
  end
@@ -1,5 +1,5 @@
1
1
  FactoryGirl.define do
2
2
  factory :workflow, class: Sipity::Workflow do
3
- name 'generic_work'
3
+ sequence(:name) { |n| "generic_work-#{n}" }
4
4
  end
5
5
  end
@@ -3,6 +3,9 @@ require 'spec_helper'
3
3
  feature 'Add an attached file' do
4
4
  let(:user) { create(:user) }
5
5
  let!(:work) { create(:work, user: user) }
6
+ let!(:sipity_entity) do
7
+ create(:sipity_entity, proxy_for_global_id: work.to_global_id.to_s)
8
+ end
6
9
 
7
10
  before do
8
11
  sign_in user
@@ -2,23 +2,23 @@ require 'spec_helper'
2
2
  require 'redlock'
3
3
 
4
4
  feature 'Creating a new child Work', :workflow do
5
- let(:user) { FactoryGirl.create(:user) }
6
-
5
+ let(:user) { create(:user) }
6
+ let!(:sipity_entity) do
7
+ create(:sipity_entity, proxy_for_global_id: parent.to_global_id.to_s)
8
+ end
7
9
  let(:redlock_client_stub) { # stub out redis connection
8
10
  client = double('redlock client')
9
11
  allow(client).to receive(:lock).and_yield(true)
10
12
  allow(Redlock::Client).to receive(:new).and_return(client)
11
13
  client
12
14
  }
13
- let(:parent) { FactoryGirl.create(:generic_work, user: user, title: ["Parent First"]) }
15
+ let!(:parent) { create(:generic_work, user: user, title: ["Parent First"]) }
14
16
 
15
17
  before do
16
18
  sign_in user
17
-
18
19
  # stub out characterization. Travis doesn't have fits installed, and it's not relevant to the test.
19
20
  allow(CharacterizeJob).to receive(:perform_later)
20
21
  redlock_client_stub
21
- parent
22
22
  end
23
23
 
24
24
  it 'creates the child work' do
@@ -34,7 +34,14 @@ feature 'Creating a new child Work', :workflow do
34
34
  end
35
35
 
36
36
  context "when it's being updated" do
37
- let(:curation_concern) { FactoryGirl.create(:generic_work, user: user) }
37
+ let(:curation_concern) { create(:generic_work, user: user) }
38
+ let(:new_parent) { create(:generic_work, user: user) }
39
+ let!(:cc_sipity_entity) do
40
+ create(:sipity_entity, proxy_for_global_id: curation_concern.to_global_id.to_s)
41
+ end
42
+ let!(:new_sipity_entity) do
43
+ create(:sipity_entity, proxy_for_global_id: new_parent.to_global_id.to_s)
44
+ end
38
45
  before do
39
46
  parent.ordered_members << curation_concern
40
47
  parent.save!
@@ -46,7 +53,6 @@ feature 'Creating a new child Work', :workflow do
46
53
  expect(parent.reload.ordered_members.to_a.length).to eq 1
47
54
  end
48
55
  it "doesn't lose other memberships" do
49
- new_parent = FactoryGirl.create(:generic_work, user: user)
50
56
  new_parent.ordered_members << curation_concern
51
57
  new_parent.save!
52
58
 
@@ -4,7 +4,9 @@ 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 }
7
-
7
+ let!(:sipity_entity) do
8
+ create(:sipity_entity, proxy_for_global_id: parent.to_global_id.to_s)
9
+ end
8
10
  around do |example|
9
11
  original_adapter = ActiveJob::Base.queue_adapter
10
12
  ActiveJob::Base.queue_adapter = :inline
@@ -14,7 +16,6 @@ feature 'Editing attached files' do
14
16
 
15
17
  before do
16
18
  sign_in user
17
-
18
19
  # stub out characterization. Travis doesn't have fits installed, and it's not relevant to the test.
19
20
  expect(CharacterizeJob).to receive(:perform_later)
20
21
  end
@@ -3,9 +3,7 @@ require 'spec_helper'
3
3
  RSpec.describe CurationConcerns::Forms::WorkflowActionForm, no_clean: true do
4
4
  let(:work) { create(:work) }
5
5
  let(:sipity_entity) do
6
- create(:sipity_entity,
7
- proxy_for_global_id: work.to_global_id.to_s,
8
- workflow_state_id: 2)
6
+ create(:sipity_entity, proxy_for_global_id: work.to_global_id.to_s, workflow_state_id: 2)
9
7
  end
10
8
  let(:user) { create(:user) }
11
9
  let(:current_ability) { double(current_user: user) }
@@ -102,7 +100,7 @@ RSpec.describe CurationConcerns::Forms::WorkflowActionForm, no_clean: true do
102
100
 
103
101
  it 'will send the #handle_action_taken message to CurationConcerns::Workflow::ActionTakenService' do
104
102
  expect(CurationConcerns::Workflow::ActionTakenService).to(
105
- receive(:handle_action_taken).with(entity: sipity_entity, comment: kind_of(Sipity::Comment), action: an_action, user: user)
103
+ receive(:handle_action_taken).with(target: work, comment: kind_of(Sipity::Comment), action: an_action, user: user)
106
104
  )
107
105
  subject
108
106
  end
@@ -37,30 +37,34 @@ describe CurationConcerns::WorkIndexer do
37
37
  end
38
38
  end
39
39
 
40
- context "the object status" do
40
+ describe 'suppressed state' do
41
+ before { allow(work).to receive(:suppressed?).and_return(suppressed) }
41
42
  context "when suppressed" do
42
- before { allow(work).to receive(:suppressed?).and_return(true) }
43
-
44
- it "indexed the suppressed field" do
43
+ let(:suppressed) { true }
44
+ it "indexes the suppressed field with a true value" do
45
45
  expect(solr_document.fetch('suppressed_bsi')).to be true
46
46
  end
47
47
  end
48
48
 
49
49
  context "when not suppressed" do
50
- it "indexed the suppressed field" do
50
+ let(:suppressed) { false }
51
+ it "indexes the suppressed field with a false value" do
51
52
  expect(solr_document.fetch('suppressed_bsi')).to be false
52
53
  end
53
54
  end
54
55
  end
55
56
 
56
57
  context "the actionable workflow roles" do
58
+ let!(:sipity_entity) do
59
+ create(:sipity_entity, proxy_for_global_id: work.to_global_id.to_s)
60
+ end
57
61
  before do
58
- allow(PowerConverter).to receive(:convert_to_sipity_entity).with(work).and_return(create(:sipity_entity))
62
+ allow(PowerConverter).to receive(:convert_to_sipity_entity).with(work).and_return(sipity_entity)
59
63
  allow(CurationConcerns::Workflow::PermissionQuery).to receive(:scope_roles_associated_with_the_given_entity)
60
64
  .and_return(['approve', 'reject'])
61
65
  end
62
66
  it "indexed the roles and state" do
63
- expect(solr_document.fetch('actionable_workflow_roles_ssim')).to eq ["generic_work-approve", "generic_work-reject"]
67
+ expect(solr_document.fetch('actionable_workflow_roles_ssim')).to eq ["#{sipity_entity.workflow.name}-approve", "#{sipity_entity.workflow.name}-reject"]
64
68
  expect(solr_document.fetch('workflow_state_name_ssim')).to eq "initial"
65
69
  end
66
70
  end
@@ -4,8 +4,8 @@ describe CharacterizeJob do
4
4
  include CurationConcerns::FactoryHelpers
5
5
 
6
6
  let(:file_set) { FileSet.new(id: file_set_id) }
7
- let(:file_set_id) { 'abc12345678' }
8
- let(:file_path) { Rails.root + 'tmp' + 'uploads' + 'ab' + 'c1' + '23' + '45' + 'picture.png' }
7
+ let(:file_set_id) { 'abc12345' }
8
+ let(:file_path) { Rails.root + 'tmp' + 'uploads' + 'ab' + 'c1' + '23' + '45' + 'abc12345' + 'picture.png' }
9
9
  let(:filename) { file_path.to_s }
10
10
  let(:file) do
11
11
  Hydra::PCDM::File.new.tap do |f|
@@ -13,7 +13,7 @@ describe CurationConcerns::WorkBehavior do
13
13
  subject { EssentialWork.new }
14
14
 
15
15
  it 'mixes together all the goodness' do
16
- [::CurationConcerns::WithFileSets, ::CurationConcerns::HumanReadableType, CurationConcerns::Noid, CurationConcerns::Serializers, Hydra::WithDepositor, Hydra::AccessControls::Embargoable, Solrizer::Common].each do |mixin|
16
+ [::CurationConcerns::WithFileSets, ::CurationConcerns::HumanReadableType, CurationConcerns::Noid, CurationConcerns::Serializers, Hydra::WithDepositor, Hydra::AccessControls::Embargoable, Solrizer::Common, ::CurationConcerns::Suppressible].each do |mixin|
17
17
  expect(subject.class.ancestors).to include(mixin)
18
18
  end
19
19
  end
@@ -35,16 +35,25 @@ describe GenericWork do
35
35
 
36
36
  describe '#suppressed?' do
37
37
  let(:work) { described_class.new(state: state) }
38
- subject { work.suppressed? }
39
-
40
- context "when the state is 'pending'" do
41
- let(:state) { 'pending' }
42
- it { is_expected.to be true }
38
+ context "when state is inactive" do
39
+ let(:state) { ::RDF::URI('http://fedora.info/definitions/1/0/access/ObjState#inactive') }
40
+ it 'is suppressed' do
41
+ expect(work).to be_suppressed
42
+ end
43
43
  end
44
44
 
45
- context "when the state is something else" do
45
+ context "when the state is active" do
46
46
  let(:state) { ::RDF::URI('http://fedora.info/definitions/1/0/access/ObjState#active') }
47
- it { is_expected.to be false }
47
+ it 'is not suppressed' do
48
+ expect(work).not_to be_suppressed
49
+ end
50
+ end
51
+
52
+ context "when the state is nil" do
53
+ let(:state) { nil }
54
+ it 'is not suppressed' do
55
+ expect(work).not_to be_suppressed
56
+ end
48
57
  end
49
58
  end
50
59
 
@@ -22,6 +22,19 @@ describe SolrDocument do
22
22
  it { is_expected.to eq 'one' }
23
23
  end
24
24
 
25
+ describe "#suppressed?" do
26
+ let(:attributes) { { 'suppressed_bsi' => suppressed_value } }
27
+ subject { document }
28
+ context 'when true' do
29
+ let(:suppressed_value) { true }
30
+ it { is_expected.to be_suppressed }
31
+ end
32
+ context 'when false' do
33
+ let(:suppressed_value) { false }
34
+ it { is_expected.not_to be_suppressed }
35
+ end
36
+ end
37
+
25
38
  describe "creator" do
26
39
  subject { document.creator }
27
40