hydra-core 9.5.0 → 9.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbc1d8abf41b8b2c7415d62572fd8c08508e539c
4
- data.tar.gz: cfb9c8633be3f2ba867b0633ea5fd41a8877bc78
3
+ metadata.gz: 7de2e1cf6d7fffb05b9d158a071a5233e757f251
4
+ data.tar.gz: 190764737d16b04bca3c887f5be91a67699e1ab7
5
5
  SHA512:
6
- metadata.gz: 8c8d0da2df3d2c30b13d5442be8a7f8083aa839dc40fb1157dc98d1f865a097cc4463dc671f411e3c7cf3ee13e5bdcf1ebcec43a5007f6447b247f3aa244edc3
7
- data.tar.gz: e6f73940366cd473be061df8433ce06ac223f694ba6b4d24cac2694303bc382f83363c74aee416b5f9450c66ab63da7efc72a3e4fed5bd4d7de6b987638de89f
6
+ metadata.gz: d6171dc2226ab963b5221e2a9de0e548307fbebd64881fe2b30947eb8688af55922c2ecb6f5aa9a2ee524fd38f1cc978ff6f300c26bd904899b4192b579e71de
7
+ data.tar.gz: 45508099ed34d6ff46463feccb5ed7214cbe8bb08a58033982f87febc83cfd46c2485503d9befbd6de279444943481161a17183ba16716350fa1987ff9cc8890
@@ -1,5 +1,23 @@
1
1
  module Hydra::Catalog
2
2
  extend ActiveSupport::Concern
3
3
  include Blacklight::Catalog
4
- include Hydra::Controller::SearchBuilder
4
+ include Blacklight::AccessControls::Catalog
5
+
6
+ # Action-specific enforcement
7
+ # Controller "before" filter for enforcing access controls on show actions
8
+ # @param [Hash] opts (optional, not currently used)
9
+ def enforce_show_permissions(opts={})
10
+ # The "super" method comes from blacklight-access_controls.
11
+ # It will check the read permissions for the record.
12
+ # By default, it will return a Hydra::PermissionsSolrDocument
13
+ # that contains the permissions fields for that record
14
+ # so that you can perform additional permissions checks.
15
+ permissions_doc = super
16
+
17
+ if permissions_doc.under_embargo? && !can?(:edit, permissions_doc)
18
+ raise Hydra::AccessDenied.new("This item is under embargo. You do not have sufficient access privileges to read this document.", :edit, params[:id])
19
+ end
20
+
21
+ permissions_doc
22
+ end
5
23
  end
@@ -1,9 +1,8 @@
1
1
  module Hydra::Controller::SearchBuilder
2
2
  extend ActiveSupport::Concern
3
3
 
4
- # Override blacklight to produce a search_builder that has the current ability in context
5
- def search_builder processor_chain = search_params_logic
6
- super.tap { |builder| builder.current_ability = current_ability }
4
+ included do
5
+ Deprecation.warn Hydra::Controller::SearchBuilder, "Hydra::Controller::SearchBuilder no longer does anything. It will be removed in Hydra version 10. The code that used to be in this module was moved to Blacklight::AccessControls::Catalog in the blacklight-access_controls gem."
7
6
  end
8
7
 
9
8
  end
@@ -1,5 +1,6 @@
1
1
  module Hydra
2
- class SearchBuilder < Blacklight::Solr::SearchBuilder
2
+ class SearchBuilder < Blacklight::SearchBuilder
3
+ include Blacklight::Solr::SearchBuilderBehavior
3
4
  include Hydra::AccessControlsEnforcement
4
5
  end
5
6
  end
@@ -5,16 +5,17 @@ class CatalogController < ApplicationController
5
5
 
6
6
  include Hydra::Catalog
7
7
  # These before_filters apply the hydra access controls
8
- before_filter :enforce_show_permissions, :only=>:show
8
+ before_filter :enforce_show_permissions, only: :show
9
+
9
10
  # This applies appropriate access controls to all solr queries
10
- CatalogController.search_params_logic += [:add_access_controls_to_solr_params]
11
+ Hydra::SearchBuilder.default_processor_chain += [:add_access_controls_to_solr_params]
11
12
 
12
13
 
13
14
  configure_blacklight do |config|
14
15
  config.search_builder_class = Hydra::SearchBuilder
15
16
  config.default_solr_params = {
16
- :qt => 'search',
17
- :rows => 10
17
+ qt: 'search',
18
+ rows: 10
18
19
  }
19
20
 
20
21
  # solr field configuration for search results/index views
@@ -41,13 +42,13 @@ class CatalogController < ApplicationController
41
42
  #
42
43
  # :show may be set to false if you don't want the facet to be drawn in the
43
44
  # facet bar
44
- config.add_facet_field solr_name('object_type', :facetable), :label => 'Format'
45
- config.add_facet_field solr_name('pub_date', :facetable), :label => 'Publication Year'
46
- config.add_facet_field solr_name('subject_topic', :facetable), :label => 'Topic', :limit => 20
47
- config.add_facet_field solr_name('language', :facetable), :label => 'Language', :limit => true
48
- config.add_facet_field solr_name('lc1_letter', :facetable), :label => 'Call Number'
49
- config.add_facet_field solr_name('subject_geo', :facetable), :label => 'Region'
50
- config.add_facet_field solr_name('subject_era', :facetable), :label => 'Era'
45
+ config.add_facet_field solr_name('object_type', :facetable), label: 'Format'
46
+ config.add_facet_field solr_name('pub_date', :facetable), label: 'Publication Year'
47
+ config.add_facet_field solr_name('subject_topic', :facetable), label: 'Topic', limit: 20
48
+ config.add_facet_field solr_name('language', :facetable), label: 'Language', limit: true
49
+ config.add_facet_field solr_name('lc1_letter', :facetable), label: 'Call Number'
50
+ config.add_facet_field solr_name('subject_geo', :facetable), label: 'Region'
51
+ config.add_facet_field solr_name('subject_era', :facetable), label: 'Era'
51
52
 
52
53
  # Have BL send all facet field names to Solr, which has been the default
53
54
  # previously. Simply remove these lines if you'd rather use Solr request
@@ -59,32 +60,32 @@ class CatalogController < ApplicationController
59
60
 
60
61
  # solr fields to be displayed in the index (search results) view
61
62
  # The ordering of the field names is the order of the display
62
- config.add_index_field solr_name('title', :stored_searchable, type: :string), :label => 'Title:'
63
- config.add_index_field solr_name('title_vern', :stored_searchable, type: :string), :label => 'Title:'
64
- config.add_index_field solr_name('author', :stored_searchable, type: :string), :label => 'Author:'
65
- config.add_index_field solr_name('author_vern', :stored_searchable, type: :string), :label => 'Author:'
66
- config.add_index_field solr_name('format', :symbol), :label => 'Format:'
67
- config.add_index_field solr_name('language', :stored_searchable, type: :string), :label => 'Language:'
68
- config.add_index_field solr_name('published', :stored_searchable, type: :string), :label => 'Published:'
69
- config.add_index_field solr_name('published_vern', :stored_searchable, type: :string), :label => 'Published:'
70
- config.add_index_field solr_name('lc_callnum', :stored_searchable, type: :string), :label => 'Call number:'
63
+ config.add_index_field solr_name('title', :stored_searchable, type: :string), label: 'Title:'
64
+ config.add_index_field solr_name('title_vern', :stored_searchable, type: :string), label: 'Title:'
65
+ config.add_index_field solr_name('author', :stored_searchable, type: :string), label: 'Author:'
66
+ config.add_index_field solr_name('author_vern', :stored_searchable, type: :string), label: 'Author:'
67
+ config.add_index_field solr_name('format', :symbol), label: 'Format:'
68
+ config.add_index_field solr_name('language', :stored_searchable, type: :string), label: 'Language:'
69
+ config.add_index_field solr_name('published', :stored_searchable, type: :string), label: 'Published:'
70
+ config.add_index_field solr_name('published_vern', :stored_searchable, type: :string), label: 'Published:'
71
+ config.add_index_field solr_name('lc_callnum', :stored_searchable, type: :string), label: 'Call number:'
71
72
 
72
73
  # solr fields to be displayed in the show (single result) view
73
74
  # The ordering of the field names is the order of the display
74
- config.add_show_field solr_name('title', :stored_searchable, type: :string), :label => 'Title:'
75
- config.add_show_field solr_name('title_vern', :stored_searchable, type: :string), :label => 'Title:'
76
- config.add_show_field solr_name('subtitle', :stored_searchable, type: :string), :label => 'Subtitle:'
77
- config.add_show_field solr_name('subtitle_vern', :stored_searchable, type: :string), :label => 'Subtitle:'
78
- config.add_show_field solr_name('author', :stored_searchable, type: :string), :label => 'Author:'
79
- config.add_show_field solr_name('author_vern', :stored_searchable, type: :string), :label => 'Author:'
80
- config.add_show_field solr_name('format', :symbol), :label => 'Format:'
81
- config.add_show_field solr_name('url_fulltext_tsim', :stored_searchable, type: :string), :label => 'URL:'
82
- config.add_show_field solr_name('url_suppl_tsim', :stored_searchable, type: :string), :label => 'More Information:'
83
- config.add_show_field solr_name('language', :stored_searchable, type: :string), :label => 'Language:'
84
- config.add_show_field solr_name('published', :stored_searchable, type: :string), :label => 'Published:'
85
- config.add_show_field solr_name('published_vern', :stored_searchable, type: :string), :label => 'Published:'
86
- config.add_show_field solr_name('lc_callnum', :stored_searchable, type: :string), :label => 'Call number:'
87
- config.add_show_field solr_name('isbn', :stored_searchable, type: :string), :label => 'ISBN:'
75
+ config.add_show_field solr_name('title', :stored_searchable, type: :string), label: 'Title:'
76
+ config.add_show_field solr_name('title_vern', :stored_searchable, type: :string), label: 'Title:'
77
+ config.add_show_field solr_name('subtitle', :stored_searchable, type: :string), label: 'Subtitle:'
78
+ config.add_show_field solr_name('subtitle_vern', :stored_searchable, type: :string), label: 'Subtitle:'
79
+ config.add_show_field solr_name('author', :stored_searchable, type: :string), label: 'Author:'
80
+ config.add_show_field solr_name('author_vern', :stored_searchable, type: :string), label: 'Author:'
81
+ config.add_show_field solr_name('format', :symbol), label: 'Format:'
82
+ config.add_show_field solr_name('url_fulltext_tsim', :stored_searchable, type: :string), label: 'URL:'
83
+ config.add_show_field solr_name('url_suppl_tsim', :stored_searchable, type: :string), label: 'More Information:'
84
+ config.add_show_field solr_name('language', :stored_searchable, type: :string), label: 'Language:'
85
+ config.add_show_field solr_name('published', :stored_searchable, type: :string), label: 'Published:'
86
+ config.add_show_field solr_name('published_vern', :stored_searchable, type: :string), label: 'Published:'
87
+ config.add_show_field solr_name('lc_callnum', :stored_searchable, type: :string), label: 'Call number:'
88
+ config.add_show_field solr_name('isbn', :stored_searchable, type: :string), label: 'ISBN:'
88
89
 
89
90
  # "fielded" search configuration. Used by pulldown among other places.
90
91
  # For supported keys in hash, see rdoc for Blacklight::SearchFields
@@ -104,7 +105,7 @@ class CatalogController < ApplicationController
104
105
  # solr request handler? The one set in config[:default_solr_parameters][:qt],
105
106
  # since we aren't specifying it otherwise.
106
107
 
107
- config.add_search_field 'all_fields', :label => 'All Fields'
108
+ config.add_search_field 'all_fields', label: 'All Fields'
108
109
 
109
110
 
110
111
  # Now we see how to over-ride Solr request handler defaults, in this
@@ -117,15 +118,15 @@ class CatalogController < ApplicationController
117
118
  # Solr parameter de-referencing like $title_qf.
118
119
  # See: http://wiki.apache.org/solr/LocalParams
119
120
  field.solr_local_parameters = {
120
- :qf => '$title_qf',
121
- :pf => '$title_pf'
121
+ qf: '$title_qf',
122
+ pf: '$title_pf'
122
123
  }
123
124
  end
124
125
 
125
126
  config.add_search_field('author') do |field|
126
127
  field.solr_local_parameters = {
127
- :qf => '$author_qf',
128
- :pf => '$author_pf'
128
+ qf: '$author_qf',
129
+ pf: '$author_pf'
129
130
  }
130
131
  end
131
132
 
@@ -135,8 +136,8 @@ class CatalogController < ApplicationController
135
136
  config.add_search_field('subject') do |field|
136
137
  field.qt = 'search'
137
138
  field.solr_local_parameters = {
138
- :qf => '$subject_qf',
139
- :pf => '$subject_pf'
139
+ qf: '$subject_qf',
140
+ pf: '$subject_pf'
140
141
  }
141
142
  end
142
143
 
@@ -144,10 +145,10 @@ class CatalogController < ApplicationController
144
145
  # label in pulldown is followed by the name of the SOLR field to sort by and
145
146
  # whether the sort is ascending or descending (it must be asc or desc
146
147
  # except in the relevancy case).
147
- config.add_sort_field 'score desc, pub_date_dtsi desc, title_tesi asc', :label => 'relevance'
148
- config.add_sort_field 'pub_date_dtsi desc, title_tesi asc', :label => 'year'
149
- config.add_sort_field 'author_tesi asc, title_tesi asc', :label => 'author'
150
- config.add_sort_field 'title_tesi asc, pub_date_dtsi desc', :label => 'title'
148
+ config.add_sort_field 'score desc, pub_date_dtsi desc, title_tesi asc', label: 'relevance'
149
+ config.add_sort_field 'pub_date_dtsi desc, title_tesi asc', label: 'year'
150
+ config.add_sort_field 'author_tesi asc, title_tesi asc', label: 'author'
151
+ config.add_sort_field 'title_tesi asc, pub_date_dtsi desc', label: 'title'
151
152
 
152
153
  # If there are more than this many search results, no spelling ("did you
153
154
  # mean") suggestion is offered.
@@ -1,3 +1,3 @@
1
1
  module HydraHead
2
- VERSION = "9.5.0"
2
+ VERSION = "9.6.0"
3
3
  end
@@ -18,27 +18,13 @@ describe CatalogController do
18
18
  end
19
19
  end
20
20
 
21
- describe "Paths Generated by Custom Routes:" do
22
- # paths generated by custom routes
23
- it "should map {:controller=>'catalog', :action=>'index'} to GET /catalog" do
24
- expect(get: "/catalog").to route_to(controller: 'catalog', action: 'index')
25
- end
26
- it "should map {:controller=>'catalog', :action=>'show', :id=>'test:3'} to GET /catalog/test:3" do
27
- expect(get: "/catalog/test:3").to route_to(controller: 'catalog', action: 'show', id: 'test:3')
28
- end
29
-
30
- it "should map catalog_path" do
31
- expect(catalog_path("test:3")).to eq '/catalog/test:3'
32
- end
33
- end
34
-
35
21
  describe "index" do
36
22
  describe "access controls" do
37
23
  before(:all) do
38
24
  fq = "read_access_group_ssim:public OR edit_access_group_ssim:public OR discover_access_group_ssim:public"
39
25
  solr_opts = { fq: fq }
40
26
  response = ActiveFedora::SolrService.instance.conn.get('select', params: solr_opts)
41
- @public_only_results = Blacklight::SolrResponse.new(response, solr_opts)
27
+ @public_only_results = Blacklight::Solr::Response.new(response, solr_opts)
42
28
  end
43
29
 
44
30
  it "should only return public documents if role does not have permissions" do
@@ -72,9 +58,9 @@ describe CatalogController do
72
58
  let(:related_uri) { related.rdf_subject }
73
59
  let(:asset) do
74
60
  ActiveFedora::Base.create do |g|
75
- g.resource << [g.rdf_subject, RDF::DC.title, "Test Title"]
61
+ g.resource << [g.rdf_subject, RDF::Vocab::DC.title, "Test Title"]
76
62
  g.resource << [g.rdf_subject, RDF.type, type]
77
- g.resource << [g.rdf_subject, RDF::DC.isReferencedBy, related_uri]
63
+ g.resource << [g.rdf_subject, RDF::Vocab::DC.isReferencedBy, related_uri]
78
64
  end
79
65
  end
80
66
  let(:related) do
@@ -130,4 +116,46 @@ describe CatalogController do
130
116
  end
131
117
  end
132
118
 
119
+ describe "enforce_show_permissions" do
120
+ let(:email_edit_access) { "edit_access@example.com" }
121
+ let(:email_read_access) { "read_access@example.com" }
122
+ let(:future_date) { 2.days.from_now.strftime("%Y-%m-%dT%H:%M:%SZ") }
123
+
124
+ let(:embargoed_object) {
125
+ doc = SolrDocument.new(id: '123',
126
+ "edit_access_person_ssim" => [email_edit_access],
127
+ "read_access_person_ssim" => [email_read_access],
128
+ "embargo_release_date_dtsi" => future_date)
129
+ solr = Blacklight.default_index.connection
130
+ solr.add(doc)
131
+ solr.commit
132
+ doc
133
+ }
134
+
135
+ before do
136
+ controller.params = { id: embargoed_object.id }
137
+ allow(controller).to receive(:current_user).and_return(user)
138
+ end
139
+
140
+ context 'a user with edit permissions' do
141
+ let(:user) { User.new email: email_edit_access }
142
+
143
+ it 'allows the user to view an embargoed object' do
144
+ expect {
145
+ controller.send(:enforce_show_permissions, {})
146
+ }.not_to raise_error
147
+ end
148
+ end
149
+
150
+ context 'a user without edit permissions' do
151
+ let(:user) { User.new email: email_read_access }
152
+
153
+ it 'denies access to the embargoed object' do
154
+ expect {
155
+ controller.send(:enforce_show_permissions, {})
156
+ }.to raise_error Hydra::AccessDenied, "This item is under embargo. You do not have sufficient access privileges to read this document."
157
+ end
158
+ end
159
+ end
160
+
133
161
  end
@@ -39,6 +39,7 @@ describe DownloadsController do
39
39
  end
40
40
 
41
41
  context "when not logged in" do
42
+
42
43
  context "when a specific datastream is requested" do
43
44
  it "should redirect to the root path and display an error" do
44
45
  get :show, id: obj, file: "descMetadata"
@@ -47,6 +48,7 @@ describe DownloadsController do
47
48
  end
48
49
  end
49
50
  end
51
+
50
52
  context "when logged in, but without read access" do
51
53
  let(:user) { User.create(email: 'email2@example.com', password: 'password') }
52
54
  before do
@@ -1,3 +1,6 @@
1
1
  gem 'rspec-rails', '~> 3.1', group: :test
2
2
  gem 'rspec-its'
3
3
  gem 'byebug' unless ENV['CI']
4
+
5
+ gem 'rails', ENV.fetch('RAILS_VERSION', '4.2.5')
6
+ gem 'blacklight', ENV.fetch('BLACKLIGHT_VERSION', '6.0.0')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.5.0
4
+ version: 9.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield,
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-11 00:00:00.000000000 Z
12
+ date: 2016-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 9.5.0
34
+ version: 9.6.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 9.5.0
41
+ version: 9.6.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: jettywrapper
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  version: '0'
216
216
  requirements: []
217
217
  rubyforge_project:
218
- rubygems_version: 2.4.5.1
218
+ rubygems_version: 2.5.1
219
219
  signing_key:
220
220
  specification_version: 4
221
221
  summary: Hydra-Head Rails Engine (requires Rails3)