hydra-core 10.3.4 → 10.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hydra-head/version.rb +1 -1
- data/lib/tasks/hydra.rake +3 -1
- data/spec/controllers/catalog_controller_spec.rb +17 -13
- data/spec/controllers/downloads_controller_spec.rb +26 -23
- data/spec/models/user_spec.rb +24 -16
- data/spec/spec_helper.rb +2 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96edaa48ae802442e0cf200e2314d496c1d4ffb4
|
4
|
+
data.tar.gz: 70dcb3c1d56a9eb810ebf83218a7ee502c5f8159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ef8018d7bfd99c3e0a2a2c9b0de32f314d2b7ee9869ee8c017ce841b49516aa78db88fc7344917f623adf7fdc118ba67653b988d37caae0130ec735e269f533
|
7
|
+
data.tar.gz: db4fda19263dd2f2ffdc72587ae5e95fb8c98b04367c84976fc13593fb4f3d1fb4f1bcac296ed3c0ccd66676c94f2a9ca87f9d25903e3e753f281e34a9c5fea0
|
data/lib/hydra-head/version.rb
CHANGED
data/lib/tasks/hydra.rake
CHANGED
@@ -4,7 +4,9 @@ namespace :hydra do
|
|
4
4
|
desc "Start a solr, fedora and rails instance"
|
5
5
|
task :server do
|
6
6
|
with_server('development') do
|
7
|
-
|
7
|
+
# If HOST specified, bind to that IP with -b
|
8
|
+
server_options = " -b #{ENV['HOST']}" if ENV['HOST']
|
9
|
+
IO.popen("rails server#{server_options}") do |io|
|
8
10
|
begin
|
9
11
|
io.each do |line|
|
10
12
|
puts line
|
@@ -6,7 +6,7 @@ describe CatalogController do
|
|
6
6
|
session[:user]='bob'
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
9
|
+
it "uses the CatalogController" do
|
10
10
|
expect(controller).to be_an_instance_of CatalogController
|
11
11
|
end
|
12
12
|
|
@@ -47,8 +47,8 @@ describe CatalogController do
|
|
47
47
|
allow(controller).to receive(:enforce_show_permissions)
|
48
48
|
end
|
49
49
|
context "with no asset" do
|
50
|
-
it "
|
51
|
-
get 'show', :id
|
50
|
+
it "returns a not found response code" do
|
51
|
+
get 'show', params: { id: "test", format: :nt }
|
52
52
|
|
53
53
|
expect(response).to be_not_found
|
54
54
|
end
|
@@ -66,35 +66,39 @@ describe CatalogController do
|
|
66
66
|
let(:related) do
|
67
67
|
ActiveFedora::Base.create
|
68
68
|
end
|
69
|
-
it "
|
70
|
-
get 'show', :id
|
69
|
+
it "is able to negotiate jsonld" do
|
70
|
+
get 'show', params: { id: asset.id, format: :jsonld }
|
71
71
|
|
72
72
|
expect(response).to be_success
|
73
73
|
expect(response.headers['Content-Type']).to include("application/ld+json")
|
74
74
|
graph = RDF::Reader.for(:jsonld).new(response.body)
|
75
75
|
expect(graph.statements.to_a.length).to eq 3
|
76
76
|
end
|
77
|
-
|
78
|
-
|
77
|
+
|
78
|
+
it "is able to negotiate ttl" do
|
79
|
+
get 'show', params: { id: asset.id, format: :ttl }
|
79
80
|
|
80
81
|
expect(response).to be_success
|
81
82
|
graph = RDF::Reader.for(:ttl).new(response.body)
|
82
83
|
expect(graph.statements.to_a.length).to eq 3
|
83
84
|
end
|
84
|
-
|
85
|
-
|
85
|
+
|
86
|
+
it "returns an n-triples graph with just the content put in" do
|
87
|
+
get 'show', params: { id: asset.id, format: :nt }
|
86
88
|
|
87
89
|
graph = RDF::Reader.for(:ntriples).new(response.body)
|
88
90
|
statements = graph.statements.to_a
|
89
91
|
expect(statements.length).to eq 3
|
90
92
|
expect(statements.first.subject).to eq asset.rdf_subject
|
91
93
|
end
|
94
|
+
|
92
95
|
context "with a configured subject converter" do
|
93
96
|
before do
|
94
97
|
Hydra.config.id_to_resource_uri = lambda { |id, _| "http://hydra.box/catalog/#{id}" }
|
95
|
-
get 'show', :id
|
98
|
+
get 'show', params: { id: asset.id, format: :nt }
|
96
99
|
end
|
97
|
-
|
100
|
+
|
101
|
+
it "converts the subject using the specified converter" do
|
98
102
|
graph = RDF::Graph.new << RDF::Reader.for(:ntriples).new(response.body)
|
99
103
|
title_statement = graph.query([nil, RDF::Vocab::DC.title, nil]).first
|
100
104
|
related_statement = graph.query([nil, RDF::Vocab::DC.isReferencedBy, nil]).first
|
@@ -108,10 +112,10 @@ describe CatalogController do
|
|
108
112
|
|
109
113
|
describe "filters" do
|
110
114
|
describe "show" do
|
111
|
-
it "
|
115
|
+
it "triggers enforce_show_permissions" do
|
112
116
|
allow(controller).to receive(:current_user).and_return(nil)
|
113
117
|
expect(controller).to receive(:enforce_show_permissions)
|
114
|
-
get :show, id: 'test:3'
|
118
|
+
get :show, params: { id: 'test:3' }
|
115
119
|
end
|
116
120
|
end
|
117
121
|
end
|
@@ -10,8 +10,9 @@ describe DownloadsController do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "routing" do
|
13
|
-
it "
|
14
|
-
assert_recognizes(
|
13
|
+
it "routes" do
|
14
|
+
assert_recognizes({ controller: "downloads", action: "show", id: "test1" },
|
15
|
+
"/downloads/test1?filename=my%20dog.jpg")
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
@@ -41,8 +42,8 @@ describe DownloadsController do
|
|
41
42
|
context "when not logged in" do
|
42
43
|
|
43
44
|
context "when a specific datastream is requested" do
|
44
|
-
it "
|
45
|
-
get :show, id: obj, file: "descMetadata"
|
45
|
+
it "redirects to the root path and display an error" do
|
46
|
+
get :show, params: { id: obj, file: "descMetadata" }
|
46
47
|
expect(response).to redirect_to new_user_session_path
|
47
48
|
expect(flash[:alert]).to eq "You are not authorized to access this page."
|
48
49
|
end
|
@@ -55,8 +56,8 @@ describe DownloadsController do
|
|
55
56
|
sign_in user
|
56
57
|
end
|
57
58
|
context "when a specific datastream is requested" do
|
58
|
-
it "
|
59
|
-
get :show, id: obj, file: "descMetadata"
|
59
|
+
it "redirects to the root path and display an error" do
|
60
|
+
get :show, params: { id: obj, file: "descMetadata" }
|
60
61
|
expect(response).to redirect_to root_path
|
61
62
|
expect(flash[:alert]).to eq "You are not authorized to access this page."
|
62
63
|
end
|
@@ -72,7 +73,7 @@ describe DownloadsController do
|
|
72
73
|
describe "#show" do
|
73
74
|
it "defaults to returning default download configured by object" do
|
74
75
|
allow(ContentHolder).to receive(:default_file_path).and_return('buzz')
|
75
|
-
get :show, id: obj
|
76
|
+
get :show, params: { id: obj }
|
76
77
|
expect(response).to be_successful
|
77
78
|
expect(response.headers['Content-Type']).to start_with "image/png"
|
78
79
|
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"buzz.png\""
|
@@ -81,7 +82,7 @@ describe DownloadsController do
|
|
81
82
|
|
82
83
|
it "defaults to returning default download configured by controller" do
|
83
84
|
expect(DownloadsController.default_file_path).to eq "content"
|
84
|
-
get :show, id: obj
|
85
|
+
get :show, params: { id: obj }
|
85
86
|
expect(response).to be_successful
|
86
87
|
expect(response.headers['Content-Type']).to start_with "image/png"
|
87
88
|
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"world.png\""
|
@@ -90,14 +91,14 @@ describe DownloadsController do
|
|
90
91
|
|
91
92
|
context "when a specific datastream is requested" do
|
92
93
|
context "and it doesn't exist" do
|
93
|
-
it "
|
94
|
-
get :show, id: obj, file: "thumbnail"
|
94
|
+
it "returns :not_found when the datastream doesn't exist" do
|
95
|
+
get :show, params: { id: obj, file: "thumbnail" }
|
95
96
|
expect(response).to be_not_found
|
96
97
|
end
|
97
98
|
end
|
98
99
|
context "and it exists" do
|
99
|
-
it "
|
100
|
-
get :show, id: obj, file: "descMetadata"
|
100
|
+
it "returns it" do
|
101
|
+
get :show, params: { id: obj, file: "descMetadata" }
|
101
102
|
expect(response).to be_successful
|
102
103
|
expect(response.headers['Content-Type']).to start_with "text/plain"
|
103
104
|
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"metadata.xml\""
|
@@ -105,15 +106,17 @@ describe DownloadsController do
|
|
105
106
|
end
|
106
107
|
end
|
107
108
|
end
|
108
|
-
|
109
|
-
|
109
|
+
|
110
|
+
it "supports setting disposition to inline" do
|
111
|
+
get :show, params: { id: obj, disposition: "inline" }
|
110
112
|
expect(response).to be_successful
|
111
113
|
expect(response.headers['Content-Type']).to start_with "image/png"
|
112
114
|
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"world.png\""
|
113
115
|
expect(response.body).to eq 'foobarfoobarfoobar'
|
114
116
|
end
|
115
|
-
|
116
|
-
|
117
|
+
|
118
|
+
it "allows you to specify filename for download" do
|
119
|
+
get :show, params: { id: obj, "filename" => "my%20dog.png" }
|
117
120
|
expect(response).to be_successful
|
118
121
|
expect(response.headers['Content-Type']).to start_with "image/png"
|
119
122
|
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"my%20dog.png\""
|
@@ -131,7 +134,7 @@ describe DownloadsController do
|
|
131
134
|
|
132
135
|
it "head request" do
|
133
136
|
request.env["HTTP_RANGE"] = 'bytes=0-15'
|
134
|
-
head :show, id: parent, file: 'webm'
|
137
|
+
head :show, params: { id: parent, file: 'webm' }
|
135
138
|
expect(response.headers['Content-Length']).to eq 16
|
136
139
|
expect(response.headers['Accept-Ranges']).to eq 'bytes'
|
137
140
|
expect(response.headers['Content-Type']).to start_with 'video/webm'
|
@@ -139,7 +142,7 @@ describe DownloadsController do
|
|
139
142
|
|
140
143
|
it "sends the whole thing" do
|
141
144
|
request.env["HTTP_RANGE"] = 'bytes=0-15'
|
142
|
-
get :show, id: '1234', file: 'webm'
|
145
|
+
get :show, params: { id: '1234', file: 'webm' }
|
143
146
|
expect(response.body).to eq 'one1two2threfour'
|
144
147
|
expect(response.headers["Content-Range"]).to eq 'bytes 0-15/16'
|
145
148
|
expect(response.headers["Content-Length"]).to eq '16'
|
@@ -151,13 +154,13 @@ describe DownloadsController do
|
|
151
154
|
|
152
155
|
it "sends the whole thing when the range is open ended" do
|
153
156
|
request.env["HTTP_RANGE"] = 'bytes=0-'
|
154
|
-
get :show, id: '1234', file: 'webm'
|
157
|
+
get :show, params: { id: '1234', file: 'webm' }
|
155
158
|
expect(response.body).to eq 'one1two2threfour'
|
156
159
|
end
|
157
160
|
|
158
161
|
it "gets a range not starting at the beginning" do
|
159
162
|
request.env["HTTP_RANGE"] = 'bytes=3-15'
|
160
|
-
get :show, id: '1234', file: 'webm'
|
163
|
+
get :show, params: { id: '1234', file: 'webm' }
|
161
164
|
expect(response.body).to eq '1two2threfour'
|
162
165
|
expect(response.headers["Content-Range"]).to eq 'bytes 3-15/16'
|
163
166
|
expect(response.headers["Content-Length"]).to eq '13'
|
@@ -165,7 +168,7 @@ describe DownloadsController do
|
|
165
168
|
|
166
169
|
it "gets a range not ending at the end" do
|
167
170
|
request.env["HTTP_RANGE"] = 'bytes=4-11'
|
168
|
-
get :show, id: '1234', file: 'webm'
|
171
|
+
get :show, params: { id: '1234', file: 'webm' }
|
169
172
|
expect(response.body).to eq 'two2thre'
|
170
173
|
expect(response.headers["Content-Range"]).to eq 'bytes 4-11/16'
|
171
174
|
expect(response.headers["Content-Length"]).to eq '8'
|
@@ -182,9 +185,9 @@ describe DownloadsController do
|
|
182
185
|
end
|
183
186
|
sign_in @user
|
184
187
|
end
|
185
|
-
it "
|
188
|
+
it "uses the custom param value to retrieve the asset" do
|
186
189
|
allow(controller).to receive(:asset_param_key).and_return(:object_id)
|
187
|
-
get :show, object_id: obj
|
190
|
+
get :show, params: { object_id: obj }
|
188
191
|
expect(response).to be_successful
|
189
192
|
end
|
190
193
|
end
|
data/spec/models/user_spec.rb
CHANGED
@@ -2,31 +2,39 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe User do
|
4
4
|
|
5
|
-
describe "user_key" do
|
5
|
+
describe "#user_key" do
|
6
6
|
let(:user) { User.new.tap {|u| u.email = "foo@example.com"} }
|
7
7
|
before do
|
8
8
|
allow(user).to receive(:username).and_return('foo')
|
9
9
|
end
|
10
|
+
subject { user.user_key }
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
context "by default" do
|
13
|
+
it "returns email" do
|
14
|
+
expect(subject).to eq 'foo@example.com'
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
context "when devise is configured to use the username" do
|
19
|
+
before do
|
20
|
+
allow(Devise).to receive(:authentication_keys).and_return([:username])
|
21
|
+
end
|
22
|
+
it "returns username" do
|
23
|
+
expect(subject).to eq 'foo'
|
24
|
+
end
|
18
25
|
end
|
19
|
-
|
20
26
|
end
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
describe "#groups" do
|
29
|
+
let(:user) { FactoryGirl.create(:user) }
|
30
|
+
let(:mock_service) { double }
|
31
|
+
before do
|
32
|
+
user.group_service = mock_service
|
33
|
+
end
|
34
|
+
subject { user.groups }
|
35
|
+
it "returns a list of groups" do
|
36
|
+
expect(mock_service).to receive(:fetch_groups).with(user: user).and_return(['my_group'])
|
37
|
+
expect(subject).to eq ['my_group']
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
data/spec/spec_helper.rb
CHANGED
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: 10.
|
4
|
+
version: 10.4.0.rc1
|
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: 2017-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -37,14 +37,14 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 10.
|
40
|
+
version: 10.4.0.rc1
|
41
41
|
type: :runtime
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 10.
|
47
|
+
version: 10.4.0.rc1
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: sqlite3
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,12 +175,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: 1.9.3
|
176
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - "
|
178
|
+
- - ">"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
180
|
+
version: 1.3.1
|
181
181
|
requirements: []
|
182
182
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.
|
183
|
+
rubygems_version: 2.6.8
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Hydra-Head Rails Engine (requires Rails3)
|