curation_concerns 0.14.0.pre1 → 0.14.0.pre2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f74821b31213e7a844b8f8e5314eac62b792ccba
4
- data.tar.gz: 3d63bba8d048b922a52e544b6296a58622137cf5
3
+ metadata.gz: 57de72e25be5af57715ccfdb367577a5ebd9b98b
4
+ data.tar.gz: 278a1dcc3a79d15ba8472222b04877c7c804aa5c
5
5
  SHA512:
6
- metadata.gz: 07a68173b77edab2e48638220ce12435e500aae53c28cb634bbe80a3ceec77e0eaba25bf722e3ad02836e0d9b4d955320247b749f035eeefe2c145bbaa60a6ba
7
- data.tar.gz: dcd8ca994910c1f326147e3a5d261a3d4e5afbec84fb3884d09801921c80463bd6435762a54fc8cbd9116d205c60ad537857a47bbe9414b112739238db75a1e4
6
+ metadata.gz: 03414390a8504f7001eaeea69c5929a41c27d3db1c191ea19266bd056a8e8666931c7e0a897e0a3a6f6519325a1aaae9c9ca33a4423f50af7bfe185c76a64e3a
7
+ data.tar.gz: 3d0b2327008ca3ce0b866d5faa07b8ddbde751e072f68b2126c6b222ef74e89f5fb03e7bb44d6b1cb4c4cae18519fbd45be2bfdc408216089c52c6354ce0e48b
@@ -11,17 +11,22 @@ module CurationConcerns
11
11
  @cloud_resources = attributes.delete(:cloud_resources.to_s)
12
12
  apply_creation_data_to_curation_concern
13
13
  apply_save_data_to_curation_concern(attributes)
14
- next_actor.create(attributes) && save
14
+ next_actor.create(attributes) && save && run_callbacks(:after_create_concern)
15
15
  end
16
16
 
17
17
  def update(attributes)
18
18
  apply_update_data_to_curation_concern
19
19
  apply_save_data_to_curation_concern(attributes)
20
- next_actor.update(attributes) && save
20
+ next_actor.update(attributes) && save && run_callbacks(:after_update_metadata)
21
21
  end
22
22
 
23
23
  protected
24
24
 
25
+ def run_callbacks(hook)
26
+ CurationConcerns.config.callback.run(hook, curation_concern, user)
27
+ true
28
+ end
29
+
25
30
  def apply_creation_data_to_curation_concern
26
31
  apply_depositor_metadata
27
32
  apply_deposit_date
@@ -1,5 +1,4 @@
1
1
  #brand-bar {
2
- margin-bottom :0;
3
2
  z-index: $zindex-navbar + 1;
4
3
  }
5
4
 
@@ -93,6 +93,7 @@ module CurationConcerns::CurationConcernController
93
93
  def destroy
94
94
  title = curation_concern.to_s
95
95
  curation_concern.destroy
96
+ CurationConcerns.config.callback.run(:after_destroy, curation_concern.id, current_user)
96
97
  after_destroy_response(title)
97
98
  end
98
99
 
@@ -92,6 +92,7 @@ module CurationConcerns
92
92
  respond_to do |wants|
93
93
  wants.html do
94
94
  initialize_edit_form
95
+ flash[:error] = "There was a problem processing your request."
95
96
  render 'edit', status: :unprocessable_entity
96
97
  end
97
98
  wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: @file_set.errors }) }
@@ -24,6 +24,6 @@ class IngestFileJob < ActiveJob::Base
24
24
 
25
25
  # Do post file ingest actions
26
26
  CurationConcerns::VersioningService.create(file_set.send(relation.to_sym), user)
27
- CurationConcerns.config.callback.run(:after_create_content, file_set, user)
27
+ CurationConcerns.config.callback.run(:after_create_fileset, file_set, user)
28
28
  end
29
29
  end
@@ -4,7 +4,7 @@ module CurationConcerns
4
4
  include PresentsAttributes
5
5
  attr_accessor :solr_document, :current_ability
6
6
 
7
- class_attribute :collection_presenter_class, :file_presenter_class
7
+ class_attribute :collection_presenter_class, :file_presenter_class, :work_presenter_class
8
8
 
9
9
  # modify this attribute to use an alternate presenter class for the collections
10
10
  self.collection_presenter_class = CollectionPresenter
@@ -12,6 +12,9 @@ module CurationConcerns
12
12
  # modify this attribute to use an alternate presenter class for the files
13
13
  self.file_presenter_class = FileSetPresenter
14
14
 
15
+ # modify this attribute to use an alternate presenter class for the child works
16
+ self.work_presenter_class = self
17
+
15
18
  # @param [SolrDocument] solr_document
16
19
  # @param [Ability] current_ability
17
20
  def initialize(solr_document, current_ability)
@@ -37,6 +40,11 @@ module CurationConcerns
37
40
  @file_set_presenters ||= member_presenters(ordered_ids & file_set_ids)
38
41
  end
39
42
 
43
+ # @return [Array<WorkShowPresenter>] presenters for the ordered_members that are not FileSets
44
+ def work_presenters
45
+ @work_presenters ||= member_presenters(ordered_ids - file_set_ids, work_presenter_class)
46
+ end
47
+
40
48
  # @deprecated
41
49
  # @return [Array<FileSetPresenter>] presenters for the orderd_members that are FileSets
42
50
  def file_presenters
@@ -44,10 +52,12 @@ module CurationConcerns
44
52
  member_presenters
45
53
  end
46
54
 
47
- # @return [Array<FileSetPresenter>] presenters for the ordered_members (not filtered by class)
48
- def member_presenters(ids = ordered_ids)
55
+ # @param [Array<String>] ids a list of ids to build presenters for
56
+ # @param [Class] presenter_class the type of presenter to build
57
+ # @return [Array<presenter_class>] presenters for the ordered_members (not filtered by class)
58
+ def member_presenters(ids = ordered_ids, presenter_class = file_presenter_class)
49
59
  PresenterFactory.build_presenters(ids,
50
- file_presenter_class,
60
+ presenter_class,
51
61
  current_ability)
52
62
  end
53
63
 
@@ -69,18 +79,22 @@ module CurationConcerns
69
79
 
70
80
  # TODO: Extract this to ActiveFedora::Aggregations::ListSource
71
81
  def ordered_ids
72
- ActiveFedora::SolrService.query("proxy_in_ssi:#{id}",
73
- fl: "ordered_targets_ssim")
74
- .flat_map { |x| x.fetch("ordered_targets_ssim", []) }
82
+ @ordered_ids ||= begin
83
+ ActiveFedora::SolrService.query("proxy_in_ssi:#{id}",
84
+ fl: "ordered_targets_ssim")
85
+ .flat_map { |x| x.fetch("ordered_targets_ssim", []) }
86
+ end
75
87
  end
76
88
 
77
89
  # These are the file sets that belong to this work, but not necessarily
78
90
  # in order.
79
91
  def file_set_ids
80
- ActiveFedora::SolrService.query("{!field f=has_model_ssim}FileSet",
81
- fl: ActiveFedora.id_field,
82
- fq: "{!join from=ordered_targets_ssim to=id}id:\"#{id}/list_source\"")
83
- .flat_map { |x| x.fetch(ActiveFedora.id_field, []) }
92
+ @file_set_ids ||= begin
93
+ ActiveFedora::SolrService.query("{!field f=has_model_ssim}FileSet",
94
+ fl: ActiveFedora.id_field,
95
+ fq: "{!join from=ordered_targets_ssim to=id}id:\"#{id}/list_source\"")
96
+ .flat_map { |x| x.fetch(ActiveFedora.id_field, []) }
97
+ end
84
98
  end
85
99
  end
86
100
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "breadcrumbs_on_rails", "~> 2.3"
24
24
  spec.add_dependency "jquery-ui-rails"
25
25
  spec.add_dependency "simple_form", '~> 3.1'
26
- spec.add_dependency 'hydra-editor', '~> 1.1'
26
+ spec.add_dependency 'hydra-editor', '~> 2.0'
27
27
  spec.add_dependency 'blacklight_advanced_search', '~> 6.0'
28
28
  spec.add_dependency 'rails_autolink'
29
29
  spec.add_dependency 'sprockets-es6'
@@ -132,11 +132,12 @@ module CurationConcerns
132
132
  @lock_retry_delay ||= 200 # milliseconds
133
133
  end
134
134
 
135
- callback.enable :after_create_content, :after_update_content,
136
- :after_revert_content, :after_update_metadata,
137
- :after_import_local_file_success,
135
+ callback.enable :after_create_concern, :after_create_fileset,
136
+ :after_update_content, :after_revert_content,
137
+ :after_update_metadata, :after_import_local_file_success,
138
138
  :after_import_local_file_failure, :after_audit_failure,
139
- :after_destroy, :after_import_url_success, :after_import_url_failure
139
+ :after_destroy, :after_import_url_success,
140
+ :after_import_url_failure
140
141
 
141
142
  # Registers the given curation concern model in the configuration
142
143
  # @param [Array<Symbol>,Symbol] curation_concern_types
@@ -1,3 +1,3 @@
1
1
  module CurationConcerns
2
- VERSION = "0.14.0.pre1".freeze
2
+ VERSION = "0.14.0.pre2".freeze
3
3
  end
@@ -17,6 +17,7 @@ module CurationConcerns
17
17
  7. Adds CurationConcerns::SolrDocumentBehavior to app/models/solr_document.rb
18
18
  8. Adds config/authorities/rights.yml to the application
19
19
  9. Adds config/authorities/resource_types.yml to the application
20
+ 10. Runs simple_form:install --bootstrap
20
21
  '
21
22
 
22
23
  def run_required_generators
@@ -99,5 +100,9 @@ module CurationConcerns
99
100
  def resource_types_config
100
101
  copy_file "config/authorities/resource_types.yml", "config/authorities/resource_types.yml"
101
102
  end
103
+
104
+ def simple_form_bootstrap
105
+ generate 'simple_form:install --bootstrap'
106
+ end
102
107
  end
103
108
  end
@@ -7,12 +7,13 @@ describe CurationConcerns::GenericWorkActor do
7
7
  let(:user) { create(:user) }
8
8
  let(:file) { curation_concerns_fixture_file_upload('files/image.png', 'image/png') }
9
9
 
10
- let(:redlock_client_stub) { # stub out redis connection
10
+ # stub out redis connection
11
+ let(:redlock_client_stub) do
11
12
  client = double('redlock client')
12
13
  allow(client).to receive(:lock).and_yield(true)
13
14
  allow(Redlock::Client).to receive(:new).and_return(client)
14
15
  client
15
- }
16
+ end
16
17
 
17
18
  subject do
18
19
  CurationConcerns::CurationConcern.actor(curation_concern, user)
@@ -32,6 +33,17 @@ describe CurationConcerns::GenericWorkActor do
32
33
  end
33
34
  end
34
35
 
36
+ context 'success' do
37
+ before { redlock_client_stub }
38
+
39
+ it "invokes the after_create_concern callback" do
40
+ allow(CharacterizeJob).to receive(:perform_later).and_return(true)
41
+ expect(CurationConcerns.config.callback).to receive(:run)
42
+ .with(:after_create_concern, curation_concern, user)
43
+ subject.create(title: ['Foo Bar'])
44
+ end
45
+ end
46
+
35
47
  context 'valid attributes' do
36
48
  let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED }
37
49
 
@@ -151,6 +163,14 @@ describe CurationConcerns::GenericWorkActor do
151
163
  end
152
164
  end
153
165
 
166
+ context 'success' do
167
+ it "invokes the after_update_metadata callback" do
168
+ expect(CurationConcerns.config.callback).to receive(:run)
169
+ .with(:after_update_metadata, curation_concern, user)
170
+ subject.update(title: ['Other Title'])
171
+ end
172
+ end
173
+
154
174
  context 'adding to collections' do
155
175
  let!(:collection1) { create(:collection, user: user) }
156
176
  let!(:collection2) { create(:collection, user: user) }
@@ -135,6 +135,7 @@ describe CurationConcerns::FileSetsController do
135
135
  expect(response).to render_template('edit')
136
136
  expect(assigns[:groups]).to be_kind_of Array
137
137
  expect(assigns[:file_set]).to eq file_set
138
+ expect(flash[:error]).to eq "There was a problem processing your request."
138
139
  end
139
140
 
140
141
  context 'updating visibility' do
@@ -215,6 +215,12 @@ describe CurationConcerns::GenericWorksController do
215
215
  expect(GenericWork).not_to exist(work_to_be_deleted.id)
216
216
  end
217
217
 
218
+ it "invokes the after_destroy callback" do
219
+ expect(CurationConcerns.config.callback).to receive(:run)
220
+ .with(:after_destroy, work_to_be_deleted.id, user)
221
+ delete :destroy, id: work_to_be_deleted
222
+ end
223
+
218
224
  context 'someone elses public work' do
219
225
  let(:work_to_be_deleted) { create(:private_generic_work) }
220
226
  it 'shows unauthorized message' do
@@ -21,21 +21,6 @@ describe SelectsCollectionsController, type: :controller do
21
21
  let!(:collection2) { FactoryGirl.create(:collection, read_users: [user.user_key]) }
22
22
  let!(:collection3) { FactoryGirl.create(:collection, edit_users: [user.user_key]) }
23
23
  let!(:collection4) { FactoryGirl.create(:collection) }
24
- # # collection = Collection.new title:"Test Public"
25
- # # collection.apply_depositor_metadata(@user.user_key)
26
- # # collection.read_groups = ["public"]
27
- # # collection.save
28
- # collection2 = Collection.new title:"Test Read"
29
- # collection2.apply_depositor_metadata('abc123@test.com')
30
- # collection2.read_users = [@user.user_key]
31
- # collection2.save
32
- # collection3 = Collection.new title:"Test Edit"
33
- # collection3.apply_depositor_metadata('abc123@test.com')
34
- # collection3.edit_users = [@user.user_key]
35
- # collection3.save
36
- # collection4 = Collection.new title:"Test No Access"
37
- # collection4.apply_depositor_metadata('abc123@test.com')
38
- # collection4.save
39
24
 
40
25
  describe "Public Access" do
41
26
  it "only returns public collections" do
@@ -59,8 +44,9 @@ describe SelectsCollectionsController, type: :controller do
59
44
 
60
45
  describe "Read Access" do
61
46
  describe "not signed in" do
62
- it "errors if the user is not signed in" do
63
- expect { subject.find_collections_with_read_access }.to raise_error
47
+ it "redirects the user to sign in" do
48
+ expect(subject).to receive(:authenticate_user!)
49
+ subject.find_collections_with_read_access
64
50
  end
65
51
  end
66
52
  describe "signed in" do
@@ -75,8 +61,9 @@ describe SelectsCollectionsController, type: :controller do
75
61
 
76
62
  describe "Edit Access" do
77
63
  describe "not signed in" do
78
- it "errors if the user is not signed in" do
79
- expect { subject.find_collections_with_edit_access }.to raise_error
64
+ it "redirects the user to sign in" do
65
+ expect(subject).to receive(:authenticate_user!)
66
+ subject.find_collections_with_edit_access
80
67
  end
81
68
  end
82
69
 
@@ -23,6 +23,13 @@ FactoryGirl.define do
23
23
  end
24
24
  end
25
25
 
26
+ factory :work_with_file_and_work do
27
+ before(:create) do |work, evaluator|
28
+ work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user)
29
+ work.ordered_members << FactoryGirl.create(:generic_work, user: evaluator.user)
30
+ end
31
+ end
32
+
26
33
  factory :work_with_files do
27
34
  before(:create) { |work, evaluator| 2.times { work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user) } }
28
35
  end
@@ -68,10 +68,10 @@ describe IngestFileJob do
68
68
  end
69
69
  end
70
70
 
71
- describe "the after_create_content callback" do
71
+ describe "the after_create_fileset callback" do
72
72
  subject { CurationConcerns.config.callback }
73
73
  it 'runs with file_set and user arguments' do
74
- expect(subject).to receive(:run).with(:after_create_content, file_set, user)
74
+ expect(subject).to receive(:run).with(:after_create_fileset, file_set, user)
75
75
  described_class.perform_now(file_set, filename, 'image/png', user)
76
76
  end
77
77
  end
@@ -61,6 +61,16 @@ describe CurationConcerns::WorkShowPresenter do
61
61
  end
62
62
  end
63
63
 
64
+ describe "#work_presenters" do
65
+ let(:obj) { create(:work_with_file_and_work) }
66
+ let(:attributes) { obj.to_solr }
67
+
68
+ it "filters out members that are file sets" do
69
+ expect(presenter.work_presenters.size).to eq 1
70
+ expect(presenter.work_presenters.first).to be_instance_of(described_class)
71
+ end
72
+ end
73
+
64
74
  describe "#file_set_presenters" do
65
75
  let(:obj) { create(:work_with_ordered_files) }
66
76
  let(:attributes) { obj.to_solr }
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.14.0.pre1
4
+ version: 0.14.0.pre2
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: 2016-04-25 00:00:00.000000000 Z
13
+ date: 2016-04-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hydra-head
@@ -88,14 +88,14 @@ dependencies:
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: '1.1'
91
+ version: '2.0'
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: '1.1'
98
+ version: '2.0'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: blacklight_advanced_search
101
101
  requirement: !ruby/object:Gem::Requirement