hydra-core 11.0.1 → 12.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/hydra/catalog.rb +13 -0
- data/app/controllers/concerns/hydra/controller/download_behavior.rb +3 -1
- data/app/helpers/blacklight_helper.rb +1 -0
- data/app/helpers/hydra/blacklight_helper_behavior.rb +1 -5
- data/app/models/hydra/search_builder.rb +6 -0
- data/app/services/hydra/search_service.rb +10 -0
- data/hydra-core.gemspec +2 -2
- data/lib/generators/hydra/head_generator.rb +2 -10
- data/lib/hydra-head/version.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +20 -6
- data/spec/controllers/downloads_controller_spec.rb +7 -6
- data/spec/helpers/blacklight_helper_spec.rb +3 -1
- data/spec/search_builders/search_builder_spec.rb +3 -4
- data/spec/spec_helper.rb +4 -0
- metadata +13 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96b390ac2fd463cbf23bf2a462607eb28ee78e09f80b04bad1fc986a63fb0e2c
|
4
|
+
data.tar.gz: 285cf500187d865a5f1199181216f6d9205950a4cbe8eff5b3a3f19fe920aa98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a4c94027dffce66f71815e667305689616305423fcf8760e94a73e3b251da1b5655844d80345f158114eb6efcb2de4d22d192a0269f6fe483f8bd7ccf1885f2
|
7
|
+
data.tar.gz: d2aecf65ff515fc399a2876266644f2e2dc4e205e6ed97ca04e8404dc556bda9d46a6d9c20afea2710f3c30cbb0cb7c33242ecd6e6a14eab326afa4b6ea50c6d
|
@@ -3,6 +3,10 @@ module Hydra::Catalog
|
|
3
3
|
include Blacklight::Catalog
|
4
4
|
include Blacklight::AccessControls::Catalog
|
5
5
|
|
6
|
+
included do
|
7
|
+
self.search_service_class = Hydra::SearchService if respond_to?(:search_service_class)
|
8
|
+
end
|
9
|
+
|
6
10
|
# Action-specific enforcement
|
7
11
|
# Controller "before" filter for enforcing access controls on show actions
|
8
12
|
# @param [Hash] opts (optional, not currently used)
|
@@ -20,4 +24,13 @@ module Hydra::Catalog
|
|
20
24
|
|
21
25
|
permissions_doc
|
22
26
|
end
|
27
|
+
|
28
|
+
# @return [Hash] a hash of context information to pass through to the search service
|
29
|
+
def search_service_context
|
30
|
+
((super if defined?(super)) || {}).merge(hydra_search_service_context)
|
31
|
+
end
|
32
|
+
|
33
|
+
def hydra_search_service_context
|
34
|
+
{ current_ability: current_ability }
|
35
|
+
end
|
23
36
|
end
|
@@ -80,7 +80,9 @@ module Hydra
|
|
80
80
|
# Override this if you'd like a different filename
|
81
81
|
# @return [String] the filename
|
82
82
|
def file_name
|
83
|
-
params[:filename] || file.original_name || (asset.respond_to?(:label) && asset.label) || file.id
|
83
|
+
fname = params[:filename] || file.original_name || (asset.respond_to?(:label) && asset.label) || file.id
|
84
|
+
fname = URI.unescape(fname) if Rails.version >= '6.0'
|
85
|
+
fname
|
84
86
|
end
|
85
87
|
|
86
88
|
|
@@ -16,11 +16,7 @@ module Hydra
|
|
16
16
|
# => 'text_pdf'
|
17
17
|
def type_field_to_partial_name(document, display_type)
|
18
18
|
str = Array(display_type).join(' '.freeze).underscore
|
19
|
-
|
20
|
-
str.parameterize(separator: '_'.freeze)
|
21
|
-
else
|
22
|
-
str.parameterize('_'.freeze)
|
23
|
-
end
|
19
|
+
str.parameterize(separator: '_'.freeze)
|
24
20
|
end
|
25
21
|
end
|
26
22
|
end
|
data/hydra-core.gemspec
CHANGED
@@ -19,9 +19,9 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.required_ruby_version = '>= 2.4'
|
20
20
|
|
21
21
|
gem.add_dependency 'hydra-access-controls', version
|
22
|
-
gem.add_dependency "railties", '>=
|
22
|
+
gem.add_dependency "railties", '>= 5.2', '< 7'
|
23
23
|
|
24
24
|
gem.add_development_dependency 'rails-controller-testing', '~> 1'
|
25
|
-
gem.add_development_dependency 'rspec-rails', '~>
|
25
|
+
gem.add_development_dependency 'rspec-rails', '~> 4.0'
|
26
26
|
gem.add_development_dependency 'sqlite3', '~> 1.3'
|
27
27
|
end
|
@@ -49,14 +49,6 @@ module Hydra
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
# Add Hydra to the SearchBuilder
|
53
|
-
def inject_hydra_search_builder_behavior
|
54
|
-
insert_into_file "app/models/search_builder.rb", after: "include Blacklight::Solr::SearchBuilderBehavior\n" do
|
55
|
-
" # Add a filter query to restrict the search to documents the current user has access to\n" \
|
56
|
-
" include Hydra::AccessControlsEnforcement\n"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
52
|
# Copy all files in templates/config directory to host config
|
61
53
|
def create_configuration_files
|
62
54
|
|
@@ -79,7 +71,7 @@ module Hydra
|
|
79
71
|
def create_conneg_configuration
|
80
72
|
file_path = "config/initializers/mime_types.rb"
|
81
73
|
append_to_file file_path do
|
82
|
-
"Mime::Type.register \"application/n-triples\", :nt\n" +
|
74
|
+
"Mime::Type.register \"application/n-triples\", :nt\n" +
|
83
75
|
"Mime::Type.register \"application/ld+json\", :jsonld\n" +
|
84
76
|
"Mime::Type.register \"text/turtle\", :ttl"
|
85
77
|
end
|
@@ -89,7 +81,7 @@ module Hydra
|
|
89
81
|
file_path = "app/models/solr_document.rb"
|
90
82
|
if File.exists?(file_path)
|
91
83
|
inject_into_file file_path, :before => /end\Z/ do
|
92
|
-
"\n # Do content negotiation for AF models. \n" +
|
84
|
+
"\n # Do content negotiation for AF models. \n" +
|
93
85
|
"\n use_extension( Hydra::ContentNegotiation )\n"
|
94
86
|
end
|
95
87
|
end
|
data/lib/hydra-head/version.rb
CHANGED
@@ -48,9 +48,19 @@ describe CatalogController do
|
|
48
48
|
end
|
49
49
|
context "with no asset" do
|
50
50
|
it "returns a not found response code" do
|
51
|
-
|
51
|
+
handled = false
|
52
|
+
|
53
|
+
begin
|
54
|
+
get 'show', params: { id: "test", format: :nt }
|
55
|
+
# blacklight 6
|
56
|
+
expect(response).to be_not_found
|
57
|
+
handled = true
|
58
|
+
rescue Blacklight::Exceptions::RecordNotFound
|
59
|
+
# blacklight 7
|
60
|
+
handled = true
|
61
|
+
end
|
52
62
|
|
53
|
-
expect(
|
63
|
+
expect(handled).to eq true
|
54
64
|
end
|
55
65
|
end
|
56
66
|
context "with an asset" do
|
@@ -69,7 +79,7 @@ describe CatalogController do
|
|
69
79
|
it "is able to negotiate jsonld" do
|
70
80
|
get 'show', params: { id: asset.id, format: :jsonld }
|
71
81
|
|
72
|
-
expect(response).to
|
82
|
+
expect(response).to be_successful
|
73
83
|
expect(response.headers['Content-Type']).to include("application/ld+json")
|
74
84
|
graph = RDF::Reader.for(:jsonld).new(response.body)
|
75
85
|
expect(graph.statements.to_a.length).to eq 3
|
@@ -77,8 +87,8 @@ describe CatalogController do
|
|
77
87
|
|
78
88
|
it "is able to negotiate ttl" do
|
79
89
|
get 'show', params: { id: asset.id, format: :ttl }
|
80
|
-
|
81
|
-
expect(response).to
|
90
|
+
|
91
|
+
expect(response).to be_successful
|
82
92
|
graph = RDF::Reader.for(:ttl).new(response.body)
|
83
93
|
expect(graph.statements.to_a.length).to eq 3
|
84
94
|
end
|
@@ -115,7 +125,11 @@ describe CatalogController do
|
|
115
125
|
it "triggers enforce_show_permissions" do
|
116
126
|
allow(controller).to receive(:current_user).and_return(nil)
|
117
127
|
expect(controller).to receive(:enforce_show_permissions)
|
118
|
-
|
128
|
+
begin
|
129
|
+
get :show, params: { id: 'test:3' }
|
130
|
+
rescue Blacklight::Exceptions::RecordNotFound
|
131
|
+
# blacklight 7
|
132
|
+
end
|
119
133
|
end
|
120
134
|
end
|
121
135
|
end
|
@@ -76,7 +76,7 @@ describe DownloadsController do
|
|
76
76
|
get :show, params: { id: obj }
|
77
77
|
expect(response).to be_successful
|
78
78
|
expect(response.headers['Content-Type']).to start_with "image/png"
|
79
|
-
expect(response.headers["Content-Disposition"]).to
|
79
|
+
expect(response.headers["Content-Disposition"]).to start_with "inline; filename=\"buzz.png\""
|
80
80
|
expect(response.body).to eq 'fizz'
|
81
81
|
end
|
82
82
|
|
@@ -85,7 +85,7 @@ describe DownloadsController do
|
|
85
85
|
get :show, params: { id: obj }
|
86
86
|
expect(response).to be_successful
|
87
87
|
expect(response.headers['Content-Type']).to start_with "image/png"
|
88
|
-
expect(response.headers["Content-Disposition"]).to
|
88
|
+
expect(response.headers["Content-Disposition"]).to start_with "inline; filename=\"world.png\""
|
89
89
|
expect(response.body).to eq 'foobarfoobarfoobar'
|
90
90
|
end
|
91
91
|
|
@@ -101,7 +101,7 @@ describe DownloadsController do
|
|
101
101
|
get :show, params: { id: obj, file: "descMetadata" }
|
102
102
|
expect(response).to be_successful
|
103
103
|
expect(response.headers['Content-Type']).to start_with "text/plain"
|
104
|
-
expect(response.headers["Content-Disposition"]).to
|
104
|
+
expect(response.headers["Content-Disposition"]).to start_with "inline; filename=\"metadata.xml\""
|
105
105
|
expect(response.body).to eq "It's a stream"
|
106
106
|
end
|
107
107
|
end
|
@@ -111,7 +111,7 @@ describe DownloadsController do
|
|
111
111
|
get :show, params: { id: obj, disposition: "inline" }
|
112
112
|
expect(response).to be_successful
|
113
113
|
expect(response.headers['Content-Type']).to start_with "image/png"
|
114
|
-
expect(response.headers["Content-Disposition"]).to
|
114
|
+
expect(response.headers["Content-Disposition"]).to start_with "inline; filename=\"world.png\""
|
115
115
|
expect(response.body).to eq 'foobarfoobarfoobar'
|
116
116
|
end
|
117
117
|
|
@@ -119,7 +119,8 @@ describe DownloadsController do
|
|
119
119
|
get :show, params: { id: obj, "filename" => "my%20dog.png" }
|
120
120
|
expect(response).to be_successful
|
121
121
|
expect(response.headers['Content-Type']).to start_with "image/png"
|
122
|
-
expect(response.headers["Content-Disposition"]).to
|
122
|
+
expect(response.headers["Content-Disposition"]).to start_with "inline; filename="
|
123
|
+
expect(response.headers["Content-Disposition"]).to include "my%20dog.png"
|
123
124
|
expect(response.body).to eq 'foobarfoobarfoobar'
|
124
125
|
end
|
125
126
|
end
|
@@ -148,7 +149,7 @@ describe DownloadsController do
|
|
148
149
|
expect(response.headers["Content-Length"]).to eq '16'
|
149
150
|
expect(response.headers['Accept-Ranges']).to eq 'bytes'
|
150
151
|
expect(response.headers['Content-Type']).to start_with "video/webm"
|
151
|
-
expect(response.headers["Content-Disposition"]).to
|
152
|
+
expect(response.headers["Content-Disposition"]).to start_with "inline; filename=\"MyVideo.webm\""
|
152
153
|
expect(response.status).to eq 206
|
153
154
|
end
|
154
155
|
|
@@ -12,11 +12,13 @@ describe BlacklightHelper do
|
|
12
12
|
|
13
13
|
before do
|
14
14
|
allow(helper).to receive(:blacklight_config).and_return(config)
|
15
|
+
allow(helper).to receive(:blacklight_configuration_context).and_return(helper)
|
16
|
+
allow(helper).to receive(:evaluate_if_unless_configuration).and_return(true)
|
15
17
|
end
|
16
18
|
|
17
19
|
it "changes camel case to underscored lowercase" do
|
18
20
|
expect(helper.document_partial_name('has_model_s' => ["Presentation"])).to eq "presentation"
|
19
|
-
expect(helper.document_partial_name('has_model_s' => ["GenericContent"])).to eq
|
21
|
+
expect(helper.document_partial_name('has_model_s' => ["GenericContent"])).to eq("generic_content")
|
20
22
|
end
|
21
23
|
|
22
24
|
context "with a single valued field" do
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe SearchBuilder do
|
4
|
-
let(:
|
5
|
-
let(:context) { double('context') }
|
3
|
+
RSpec.describe Hydra::SearchBuilder do
|
4
|
+
let(:context) { CatalogController.new }
|
6
5
|
let(:user) { double('user', user_key: 'joe') }
|
7
6
|
let(:current_ability) { double('ability', user_groups: [], current_user: user) }
|
8
7
|
let(:search_builder) { described_class }
|
9
8
|
|
10
9
|
subject do
|
11
|
-
search_builder.new(
|
10
|
+
search_builder.new(context).with_ability(current_ability)
|
12
11
|
end
|
13
12
|
|
14
13
|
it "extends classes with the necessary Hydra modules" do
|
data/spec/spec_helper.rb
CHANGED
@@ -12,6 +12,7 @@ require 'hydra-core'
|
|
12
12
|
|
13
13
|
require 'simplecov'
|
14
14
|
require 'coveralls'
|
15
|
+
require 'rails-controller-testing'
|
15
16
|
|
16
17
|
SimpleCov.root(File.expand_path('../..', __dir__))
|
17
18
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
@@ -29,6 +30,9 @@ ActiveFedora::Base.logger = Logger.new(STDOUT)
|
|
29
30
|
require 'active_fedora/cleaner'
|
30
31
|
RSpec.configure do |config|
|
31
32
|
config.include Devise::Test::ControllerHelpers, type: :controller
|
33
|
+
config.include ::Rails::Controller::Testing::TemplateAssertions, type: :controller
|
34
|
+
config.include ::Rails::Controller::Testing::TestProcess, type: :controller
|
35
|
+
config.include ::Rails::Controller::Testing::Integration, type: :controller
|
32
36
|
config.use_transactional_fixtures = true
|
33
37
|
config.infer_spec_type_from_file_location!
|
34
38
|
|
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:
|
4
|
+
version: 12.0.1
|
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:
|
12
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hydra-access-controls
|
@@ -17,34 +17,34 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 12.0.1
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 12.0.1
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: railties
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: '5.2'
|
35
35
|
- - "<"
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
37
|
+
version: '7'
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
44
|
+
version: '5.2'
|
45
45
|
- - "<"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '7'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rails-controller-testing
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,14 +65,14 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '4.0'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '4.0'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: sqlite3
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,6 +113,8 @@ files:
|
|
113
113
|
- app/models/hydra/content_negotiation/fedora_uri_replacer.rb
|
114
114
|
- app/models/hydra/content_negotiation/graph_finder.rb
|
115
115
|
- app/models/hydra/content_negotiation/replacing_graph_finder.rb
|
116
|
+
- app/models/hydra/search_builder.rb
|
117
|
+
- app/services/hydra/search_service.rb
|
116
118
|
- config/locales/hydra.en.yml
|
117
119
|
- hydra-core.gemspec
|
118
120
|
- lib/application_helper.rb
|
@@ -164,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
166
|
- !ruby/object:Gem::Version
|
165
167
|
version: '0'
|
166
168
|
requirements: []
|
167
|
-
rubygems_version: 3.1.
|
169
|
+
rubygems_version: 3.1.4
|
168
170
|
signing_key:
|
169
171
|
specification_version: 4
|
170
172
|
summary: Hydra-Head Rails Engine (requires Rails3)
|