curation_concerns 1.6.0 → 1.6.1
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 +4 -4
- data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +3 -7
- data/app/helpers/curation_concerns/collections_helper.rb +4 -7
- data/app/models/concerns/curation_concerns/work_behavior.rb +0 -8
- data/app/renderers/curation_concerns/renderers/rights_attribute_renderer.rb +1 -1
- data/app/services/curation_concerns/collections_service.rb +28 -0
- data/lib/curation_concerns/version.rb +1 -1
- data/spec/controllers/curation_concerns/collections_controller_spec.rb +14 -5
- data/spec/helpers/curation_concerns/collections_helper_spec.rb +9 -9
- data/spec/services/curation_concerns/collections_service_spec.rb +38 -0
- data/spec/views/catalog/index.html.erb_spec.rb +1 -0
- data/spec/views/curation_concerns/base/_show_actions.html.erb_spec.rb +3 -0
- data/spec/views/curation_concerns/base/show.html.erb_spec.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9058b4420919bb0e097ce662820daa18c23f734c
|
4
|
+
data.tar.gz: 50bd609db11df6df2f7e62ff29974e1677760d30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fa3bcd75d29b7778eca8b8afb90fd26f084b207e60c38d1c066fcaac83380b121c556be34cfd98f0c5727218c9ba2a8118d255249d22871e9e623079a2f37f7
|
7
|
+
data.tar.gz: 3a21293ef1519ae15d4fdd87fbf8fc292657c88f23cfa4abe9f842f08d71e8023980bbf408ce58b5292df218d47271151c07a0e2a991d0e1945d0a845ad0fdd1
|
@@ -74,6 +74,7 @@ module CurationConcerns
|
|
74
74
|
|
75
75
|
def edit
|
76
76
|
query_collection_members
|
77
|
+
# this is used to populate the "add to a collection" action for the members
|
77
78
|
@user_collections = find_collections_for_form
|
78
79
|
form
|
79
80
|
end
|
@@ -163,15 +164,10 @@ module CurationConcerns
|
|
163
164
|
|
164
165
|
protected
|
165
166
|
|
166
|
-
#
|
167
|
-
# TODO: It seems suspicious that this is returning collections with read
|
168
|
-
# access rather than collections with edit access
|
169
|
-
# run a solr query to get the collections the user has access to read
|
167
|
+
# run a solr query to get the collections the user has access to edit
|
170
168
|
# @return [Array] a list of the user's collections
|
171
169
|
def find_collections_for_form
|
172
|
-
|
173
|
-
response = repository.search(query)
|
174
|
-
response.documents
|
170
|
+
CurationConcerns::CollectionsService.new(self).search_results(:edit)
|
175
171
|
end
|
176
172
|
|
177
173
|
def remove_select_something_first_flash
|
@@ -86,17 +86,14 @@ module CurationConcerns::CollectionsHelper
|
|
86
86
|
if current_user.respond_to?(:collections)
|
87
87
|
return current_user.collections.map { |c| [c.title.join(', '), c.id] }
|
88
88
|
end
|
89
|
-
|
90
|
-
|
91
|
-
fl: 'title_tesim id',
|
92
|
-
rows: 1000)
|
93
|
-
)
|
89
|
+
service = CurationConcerns::CollectionsService.new(controller)
|
90
|
+
convert_solr_docs_to_select_options(service.search_results(:edit))
|
94
91
|
end
|
95
92
|
|
96
93
|
def convert_solr_docs_to_select_options(results)
|
97
94
|
option_values = results.map do |r|
|
98
|
-
title =
|
99
|
-
[title.present? ? title.join(', ') : nil, r
|
95
|
+
title = r.title
|
96
|
+
[title.present? ? title.join(', ') : nil, r.id]
|
100
97
|
end
|
101
98
|
option_values.sort do |a, b|
|
102
99
|
if a.first && b.first
|
@@ -19,7 +19,7 @@ module CurationConcerns
|
|
19
19
|
if parsed_uri.nil?
|
20
20
|
ERB::Util.h(value)
|
21
21
|
else
|
22
|
-
%(<a href=#{ERB::Util.h(value)} target="_blank">#{
|
22
|
+
%(<a href=#{ERB::Util.h(value)} target="_blank">#{CurationConcerns::LicenseService.new.label(value)}</a>)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module CurationConcerns
|
2
|
+
class CollectionsService
|
3
|
+
attr_reader :context
|
4
|
+
|
5
|
+
class_attribute :list_search_builder_class
|
6
|
+
self.list_search_builder_class = CurationConcerns::CollectionSearchBuilder
|
7
|
+
|
8
|
+
# @param [#repository,#blacklight_config,#current_ability] context
|
9
|
+
def initialize(context)
|
10
|
+
@context = context
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param [Symbol] access :read or :edit
|
14
|
+
def search_results(access)
|
15
|
+
builder = list_search_builder(access)
|
16
|
+
response = context.repository.search(builder)
|
17
|
+
response.documents
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def list_search_builder(access)
|
23
|
+
list_search_builder_class.new(context).tap do |builder|
|
24
|
+
builder.discovery_perms = [access]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -12,9 +12,9 @@ describe CollectionsController do
|
|
12
12
|
user: user,
|
13
13
|
depositor: user.user_key) }
|
14
14
|
let(:asset3) { build(:generic_work, title: ['Third of the Assets']) }
|
15
|
-
let
|
16
|
-
|
17
|
-
|
15
|
+
let(:asset4) { create(:generic_work,
|
16
|
+
title: ['Fourth of the Assets'],
|
17
|
+
user: user) }
|
18
18
|
let(:bogus_depositor_asset) { create(:generic_work,
|
19
19
|
title: ['Bogus Asset'],
|
20
20
|
depositor: 'abc') }
|
@@ -245,11 +245,20 @@ describe CollectionsController do
|
|
245
245
|
end
|
246
246
|
|
247
247
|
describe '#edit' do
|
248
|
-
|
248
|
+
let!(:my_collection) { create(:collection, user: user) }
|
249
|
+
|
250
|
+
before do
|
251
|
+
# We expect to not see this collection in the list
|
252
|
+
create(:collection, :public)
|
253
|
+
sign_in user
|
254
|
+
end
|
249
255
|
|
250
|
-
it '
|
256
|
+
it 'is successful' do
|
251
257
|
get :edit, params: { id: collection }
|
252
258
|
expect(flash[:notice]).to be_nil
|
259
|
+
# a list of collections I can add items to:
|
260
|
+
expect(assigns[:user_collections].map(&:id)).to match_array [collection.id,
|
261
|
+
my_collection.id]
|
253
262
|
end
|
254
263
|
end
|
255
264
|
end
|
@@ -34,27 +34,27 @@ describe CurationConcerns::CollectionsHelper do
|
|
34
34
|
describe '#collection_options_for_select' do
|
35
35
|
let(:user) { create(:user) }
|
36
36
|
let(:collection2) { double(id: '02870w10j') }
|
37
|
-
let(:doc1) {
|
38
|
-
let(:doc2) {
|
39
|
-
let(:doc3) {
|
37
|
+
let(:doc1) { SolrDocument.new("id" => "k930bx31t", "title_tesim" => ["One"]) }
|
38
|
+
let(:doc2) { SolrDocument.new("id" => "02870w10j", "title_tesim" => ["Two"]) }
|
39
|
+
let(:doc3) { SolrDocument.new("id" => "z029p500w", "title_tesim" => ["Three"]) }
|
40
|
+
let(:service) { instance_double(CurationConcerns::CollectionsService) }
|
40
41
|
|
41
42
|
before do
|
42
43
|
allow(helper).to receive(:current_user).and_return(user)
|
43
|
-
allow(
|
44
|
-
|
45
|
-
.and_return([doc1, doc2, doc3])
|
44
|
+
allow(CurationConcerns::CollectionsService).to receive(:new).with(controller).and_return(service)
|
45
|
+
expect(service).to receive(:search_results).with(:edit).and_return([doc1, doc2, doc3])
|
46
46
|
end
|
47
47
|
|
48
48
|
subject { helper.collection_options_for_select(collection2) }
|
49
49
|
|
50
50
|
it 'excludes the passed in collection' do
|
51
|
-
expect(subject).to eq "<option value=\"#{doc1
|
51
|
+
expect(subject).to eq "<option value=\"#{doc1.id}\">One</option>\n<option value=\"#{doc3.id}\">Three</option>"
|
52
52
|
end
|
53
53
|
|
54
54
|
context "when one of the documents doesn't have title_tesim" do
|
55
|
-
let(:doc1) {
|
55
|
+
let(:doc1) { SolrDocument.new("id" => "k930bx31t") }
|
56
56
|
it 'puts the collections without titles last' do
|
57
|
-
expect(subject).to eq "<option value=\"#{doc3
|
57
|
+
expect(subject).to eq "<option value=\"#{doc3.id}\">Three</option>\n<option value=\"#{doc1.id}\"></option>"
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe CurationConcerns::CollectionsService do
|
4
|
+
let(:controller) { ::CatalogController.new }
|
5
|
+
|
6
|
+
let(:context) do
|
7
|
+
double(current_ability: Ability.new(user),
|
8
|
+
repository: controller.repository,
|
9
|
+
blacklight_config: controller.blacklight_config)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:service) { described_class.new(context) }
|
13
|
+
let(:user) { create(:user) }
|
14
|
+
|
15
|
+
describe "#search_results" do
|
16
|
+
subject { service.search_results(access) }
|
17
|
+
let!(:collection1) { create(:collection, :public, title: ['foo']) }
|
18
|
+
let!(:collection2) { create(:collection, :public, title: ['bar']) }
|
19
|
+
let!(:collection3) { create(:collection, :public, edit_users: [user.user_key], title: ['baz']) }
|
20
|
+
before do
|
21
|
+
create(:admin_set, :public) # this should never be returned.
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with read access" do
|
25
|
+
let(:access) { :read }
|
26
|
+
it "returns three collections" do
|
27
|
+
expect(subject.map(&:id)).to match_array [collection1.id, collection2.id, collection3.id]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with edit access" do
|
32
|
+
let(:access) { :edit }
|
33
|
+
it "returns one collections" do
|
34
|
+
expect(subject.map(&:id)).to match_array [collection3.id]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -24,6 +24,7 @@ describe 'catalog/index.html.erb' do
|
|
24
24
|
allow(view).to receive(:document_counter_with_offset).and_return(5)
|
25
25
|
allow(view).to receive(:type_tab).and_return("TYPE")
|
26
26
|
allow(view).to receive(:search_state).and_return(search_state)
|
27
|
+
allow(view).to receive(:collection_options_for_select)
|
27
28
|
|
28
29
|
params[:view] = 'gallery'
|
29
30
|
|
@@ -3,8 +3,10 @@ require 'spec_helper'
|
|
3
3
|
describe 'curation_concerns/base/show_actions' do
|
4
4
|
let(:model) { double('model', persisted?: true, to_param: '123', model_name: GenericWork.model_name) }
|
5
5
|
let(:presenter) { double("presenter", human_readable_type: 'Image', id: '123', to_model: model, valid_child_concerns: [GenericWork]) }
|
6
|
+
|
6
7
|
before do
|
7
8
|
assign(:presenter, presenter)
|
9
|
+
allow(view).to receive(:collection_options_for_select)
|
8
10
|
render 'curation_concerns/base/show_actions.html.erb', collector: collector, editor: editor
|
9
11
|
end
|
10
12
|
|
@@ -15,6 +17,7 @@ describe 'curation_concerns/base/show_actions' do
|
|
15
17
|
expect(rendered).to have_link 'Add to a Collection'
|
16
18
|
end
|
17
19
|
end
|
20
|
+
|
18
21
|
context "as an editor" do
|
19
22
|
let(:editor) { true }
|
20
23
|
let(:collector) { true }
|
@@ -26,6 +26,7 @@ describe 'curation_concerns/base/show.html.erb' do
|
|
26
26
|
before do
|
27
27
|
allow(view).to receive(:can?).with(:edit, String).and_return(true)
|
28
28
|
allow(view).to receive(:can?).with(:collect, String).and_return(true)
|
29
|
+
allow(view).to receive(:collection_options_for_select)
|
29
30
|
assign(:presenter, presenter)
|
30
31
|
render
|
31
32
|
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: 1.6.
|
4
|
+
version: 1.6.1
|
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-09-
|
13
|
+
date: 2016-09-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hydra-head
|
@@ -854,6 +854,7 @@ files:
|
|
854
854
|
- app/search_builders/curation_concerns/work_search_builder.rb
|
855
855
|
- app/services/curation_concerns/actors/actor_factory.rb
|
856
856
|
- app/services/curation_concerns/admin_set_service.rb
|
857
|
+
- app/services/curation_concerns/collections_service.rb
|
857
858
|
- app/services/curation_concerns/contextual_path.rb
|
858
859
|
- app/services/curation_concerns/curation_concern.rb
|
859
860
|
- app/services/curation_concerns/derivative_path.rb
|
@@ -1247,6 +1248,7 @@ files:
|
|
1247
1248
|
- spec/search_builders/resource_types_service_spec.rb
|
1248
1249
|
- spec/services/curation_concern_spec.rb
|
1249
1250
|
- spec/services/curation_concerns/admin_set_service_spec.rb
|
1251
|
+
- spec/services/curation_concerns/collections_service_spec.rb
|
1250
1252
|
- spec/services/curation_concerns/license_service_spec.rb
|
1251
1253
|
- spec/services/curation_concerns/rights_statements_spec.rb
|
1252
1254
|
- spec/services/derivative_path_spec.rb
|
@@ -1469,6 +1471,7 @@ test_files:
|
|
1469
1471
|
- spec/search_builders/resource_types_service_spec.rb
|
1470
1472
|
- spec/services/curation_concern_spec.rb
|
1471
1473
|
- spec/services/curation_concerns/admin_set_service_spec.rb
|
1474
|
+
- spec/services/curation_concerns/collections_service_spec.rb
|
1472
1475
|
- spec/services/curation_concerns/license_service_spec.rb
|
1473
1476
|
- spec/services/curation_concerns/rights_statements_spec.rb
|
1474
1477
|
- spec/services/derivative_path_spec.rb
|