curation_concerns 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/search_builders/curation_concerns/collection_search_builder.rb +2 -2
- data/app/search_builders/curation_concerns/filter_suppressed_with_roles.rb +3 -0
- data/app/search_builders/curation_concerns/work_search_builder.rb +4 -0
- data/lib/curation_concerns/version.rb +1 -1
- data/spec/search_builders/curation_concerns/work_search_builder_spec.rb +67 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26855485f2643a47ee5a78b29009b4fbcfe706c6
|
4
|
+
data.tar.gz: 88f265f67966b7e34a60fa75b04a1a89b6c690d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2104575cd50826e59ddc75148a96060e4d9f016d70d717e46228d008cb6995eb01ef3a86c099c8b3c2772acce9e23215c4d92c26e389a6c2c07ae99b2b539039
|
7
|
+
data.tar.gz: cfa2b836990e759572ed1ee9f12c1db96f678be38ea065443ad8c220e3fa719d4a1b24b1c33fbeb511fe3e2cca51383b74a3039f7701aa41f679925a3b34043e
|
@@ -9,9 +9,9 @@ module CurationConcerns
|
|
9
9
|
class CollectionSearchBuilder < ::SearchBuilder
|
10
10
|
include FilterByType
|
11
11
|
# Defines which search_params_logic should be used when searching for Collections
|
12
|
-
def initialize(
|
12
|
+
def initialize(*)
|
13
13
|
@rows = 100
|
14
|
-
super
|
14
|
+
super
|
15
15
|
end
|
16
16
|
|
17
17
|
# @return [String] Solr field name indicating default sort order
|
@@ -25,6 +25,9 @@ module CurationConcerns
|
|
25
25
|
|
26
26
|
def user_has_active_workflow_role?
|
27
27
|
CurationConcerns::Workflow::PermissionQuery.scope_permitted_workflow_actions_available_for_current_state(user: current_ability.current_user, entity: current_work).any?
|
28
|
+
rescue PowerConverter::ConversionError
|
29
|
+
# The current_work doesn't have a sipity workflow entity
|
30
|
+
false
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
@@ -1,4 +1,8 @@
|
|
1
1
|
module CurationConcerns
|
2
|
+
# Finds a single work result. It returns no result if you don't have
|
3
|
+
# access to the requested work. If the work is suppressed (due to being in a
|
4
|
+
# workflow), then it checks to see if the current_user has any workflow role
|
5
|
+
# on the given work.
|
2
6
|
class WorkSearchBuilder < ::SearchBuilder
|
3
7
|
include CurationConcerns::SingleResult
|
4
8
|
include CurationConcerns::FilterSuppressedWithRoles
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe CurationConcerns::WorkSearchBuilder do
|
4
|
+
let(:me) { create(:user) }
|
5
|
+
let(:config) { CatalogController.blacklight_config }
|
6
|
+
let(:scope) do
|
7
|
+
double('The scope',
|
8
|
+
blacklight_config: config,
|
9
|
+
current_ability: Ability.new(me),
|
10
|
+
current_user: me)
|
11
|
+
end
|
12
|
+
let(:builder) { described_class.new(scope).with(params) }
|
13
|
+
let(:params) { { id: '123abc' } }
|
14
|
+
|
15
|
+
before do
|
16
|
+
allow(builder).to receive(:gated_discovery_filters).and_return(["access_filter1", "access_filter2"])
|
17
|
+
|
18
|
+
# This prevents any generated classes from interfering with this test:
|
19
|
+
allow(builder).to receive(:work_classes).and_return([GenericWork])
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#query" do
|
23
|
+
subject { builder.query }
|
24
|
+
let(:doc) { instance_double(SolrDocument) }
|
25
|
+
before do
|
26
|
+
allow(SolrDocument).to receive(:find).and_return(doc)
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when the current_work has a workflow entity" do
|
30
|
+
before do
|
31
|
+
expect(CurationConcerns::Workflow::PermissionQuery).to receive(:scope_permitted_workflow_actions_available_for_current_state)
|
32
|
+
.with(user: me,
|
33
|
+
entity: doc).and_return(roles)
|
34
|
+
end
|
35
|
+
context "and the current user has a role" do
|
36
|
+
let(:roles) { [double] }
|
37
|
+
it "filters for id, access, suppressed and type" do
|
38
|
+
expect(subject[:fq]).to eq ["access_filter1 OR access_filter2",
|
39
|
+
"{!terms f=has_model_ssim}GenericWork,Collection",
|
40
|
+
"{!raw f=id}123abc"]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
context "and the current user doesn't have a role" do
|
44
|
+
let(:roles) { [] }
|
45
|
+
it "filters for id, access, suppressed and type" do
|
46
|
+
expect(subject[:fq]).to eq ["access_filter1 OR access_filter2",
|
47
|
+
"{!terms f=has_model_ssim}GenericWork,Collection",
|
48
|
+
"-suppressed_bsi:true",
|
49
|
+
"{!raw f=id}123abc"]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when the current_work doesn't have a workflow entity" do
|
55
|
+
before do
|
56
|
+
expect(CurationConcerns::Workflow::PermissionQuery).to receive(:scope_permitted_workflow_actions_available_for_current_state)
|
57
|
+
.and_raise(PowerConverter::ConversionError.new(double, {}))
|
58
|
+
end
|
59
|
+
it "filters for id, access, suppressed and type" do
|
60
|
+
expect(subject[:fq]).to eq ["access_filter1 OR access_filter2",
|
61
|
+
"{!terms f=has_model_ssim}GenericWork,Collection",
|
62
|
+
"-suppressed_bsi:true",
|
63
|
+
"{!raw f=id}123abc"]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
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.7.
|
4
|
+
version: 1.7.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-12-
|
13
|
+
date: 2016-12-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hydra-head
|
@@ -1479,6 +1479,7 @@ files:
|
|
1479
1479
|
- spec/search_builders/curation_concerns/file_set_search_builder_spec.rb
|
1480
1480
|
- spec/search_builders/curation_concerns/lease_search_builder_spec.rb
|
1481
1481
|
- spec/search_builders/curation_concerns/work_relation_spec.rb
|
1482
|
+
- spec/search_builders/curation_concerns/work_search_builder_spec.rb
|
1482
1483
|
- spec/search_builders/resource_types_service_spec.rb
|
1483
1484
|
- spec/services/curation_concern_spec.rb
|
1484
1485
|
- spec/services/curation_concerns/admin_set_service_spec.rb
|
@@ -1772,6 +1773,7 @@ test_files:
|
|
1772
1773
|
- spec/search_builders/curation_concerns/file_set_search_builder_spec.rb
|
1773
1774
|
- spec/search_builders/curation_concerns/lease_search_builder_spec.rb
|
1774
1775
|
- spec/search_builders/curation_concerns/work_relation_spec.rb
|
1776
|
+
- spec/search_builders/curation_concerns/work_search_builder_spec.rb
|
1775
1777
|
- spec/search_builders/resource_types_service_spec.rb
|
1776
1778
|
- spec/services/curation_concern_spec.rb
|
1777
1779
|
- spec/services/curation_concerns/admin_set_service_spec.rb
|