hydra-core 9.0.0.rc3 → 9.0.0
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/controller/download_behavior.rb +71 -32
- data/app/models/concerns/hydra/model_methods.rb +14 -21
- data/app/models/hydra/datastream/properties.rb +7 -0
- data/hydra-core.gemspec +5 -6
- data/lib/hydra-head/version.rb +1 -1
- data/spec/controllers/downloads_controller_spec.rb +36 -21
- data/spec/lib/model_methods_spec.rb +32 -28
- data/spec/test_app_templates/Gemfile.extra +0 -1
- metadata +27 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3dc0df874f1747bdf07a14695798097af242746
|
4
|
+
data.tar.gz: e71228bd90712613105a6f5cd95814ea96869bb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c77621d079b9c51f7f697ad91352c2c4568b97d66b7e4f555f53052050fafd45e72d85b3cf8e1c4649d675117e0e463228aebea2b19c49246b658243f62c0fa
|
7
|
+
data.tar.gz: 3b89bdaa8d927be310e0a9597c27ac4b9053bf01860de64490a27c60cee2e76778e83e52104f32d2d29e13e181a79ef8931fe9d5366601c1e660362ea2468174
|
@@ -2,15 +2,17 @@ module Hydra
|
|
2
2
|
module Controller
|
3
3
|
module DownloadBehavior
|
4
4
|
extend ActiveSupport::Concern
|
5
|
+
extend Deprecation
|
5
6
|
|
6
7
|
included do
|
7
8
|
include Hydra::Controller::ControllerBehavior
|
9
|
+
include ActionController::Live
|
8
10
|
before_filter :authorize_download!
|
9
11
|
end
|
10
12
|
|
11
|
-
# Responds to http requests to show the
|
13
|
+
# Responds to http requests to show the file
|
12
14
|
def show
|
13
|
-
if
|
15
|
+
if file.new_record?
|
14
16
|
render_404
|
15
17
|
else
|
16
18
|
send_content
|
@@ -34,7 +36,7 @@ module Hydra
|
|
34
36
|
|
35
37
|
# Customize the :download ability in your Ability class, or override this method
|
36
38
|
def authorize_download!
|
37
|
-
authorize! :download,
|
39
|
+
authorize! :download, file
|
38
40
|
end
|
39
41
|
|
40
42
|
def asset
|
@@ -42,19 +44,34 @@ module Hydra
|
|
42
44
|
end
|
43
45
|
|
44
46
|
def datastream
|
45
|
-
|
47
|
+
Deprecation.warn(DownloadBehavior, "datastream is deprecated and will be removed in hydra-head 10.0. Use `file` instead.")
|
48
|
+
file
|
46
49
|
end
|
47
50
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
def file
|
52
|
+
@file ||= load_file
|
53
|
+
end
|
54
|
+
|
55
|
+
# Override this method to change which file is shown.
|
56
|
+
# Loads the file specified by the HTTP parameter `:file_id`.
|
57
|
+
# If this object does not have a file by that name, return the default file
|
58
|
+
# as returned by {#default_file}
|
52
59
|
# @return [ActiveFedora::File] the file
|
60
|
+
def load_file
|
61
|
+
file_path = params[:file]
|
62
|
+
if !file_path && params[:datastream_id]
|
63
|
+
Deprecation.warn(DownloadBehavior, "Parameter `datastream_id` is deprecated and will be removed in hydra-head 10.0. Use `file` instead.")
|
64
|
+
file_path = params[:datastream_id]
|
65
|
+
end
|
66
|
+
f = asset.attached_files[file_path] if file_path
|
67
|
+
f ||= default_file
|
68
|
+
raise "Unable to find a file for #{asset}" if f.nil?
|
69
|
+
f
|
70
|
+
end
|
71
|
+
|
53
72
|
def datastream_to_show
|
54
|
-
|
55
|
-
|
56
|
-
raise "Unable to find a datastream for #{asset}" if ds.nil?
|
57
|
-
ds
|
73
|
+
Deprecation.warn(DownloadBehavior, "datastream_to_show is deprecated and will be removed in hydra-head 10.0")
|
74
|
+
load_file
|
58
75
|
end
|
59
76
|
|
60
77
|
# Handle the HTTP show request
|
@@ -73,69 +90,91 @@ module Hydra
|
|
73
90
|
|
74
91
|
# Create some headers for the datastream
|
75
92
|
def content_options
|
76
|
-
{disposition: 'inline', type:
|
93
|
+
{ disposition: 'inline', type: file.mime_type, filename: file_name }
|
77
94
|
end
|
78
95
|
|
79
96
|
# Override this if you'd like a different filename
|
80
97
|
# @return [String] the filename
|
81
98
|
def datastream_name
|
82
|
-
|
99
|
+
Deprecation.warn(DownloadBehavior, "datastream_name is deprecated and will be removed in hydra-head 10.0, use file_name instead")
|
100
|
+
file_name
|
101
|
+
end
|
102
|
+
|
103
|
+
# Override this if you'd like a different filename
|
104
|
+
# @return [String] the filename
|
105
|
+
def file_name
|
106
|
+
params[:filename] || file.original_name || (asset.respond_to?(:label) && asset.label) || file.id
|
83
107
|
end
|
84
108
|
|
85
109
|
|
86
110
|
# render an HTTP HEAD response
|
87
111
|
def content_head
|
88
|
-
response.headers['Content-Length'] =
|
89
|
-
response.headers['Content-Type'] =
|
112
|
+
response.headers['Content-Length'] = file.size
|
113
|
+
response.headers['Content-Type'] = file.mime_type
|
90
114
|
head :ok
|
91
115
|
end
|
92
116
|
|
93
|
-
|
94
117
|
# render an HTTP Range response
|
95
118
|
def send_range
|
96
119
|
_, range = request.headers['HTTP_RANGE'].split('bytes=')
|
97
120
|
from, to = range.split('-').map(&:to_i)
|
98
|
-
to =
|
121
|
+
to = file.size - 1 unless to
|
99
122
|
length = to - from + 1
|
100
|
-
response.headers['Content-Range'] = "bytes #{from}-#{to}/#{
|
123
|
+
response.headers['Content-Range'] = "bytes #{from}-#{to}/#{file.size}"
|
101
124
|
response.headers['Content-Length'] = "#{length}"
|
102
125
|
self.status = 206
|
103
126
|
prepare_file_headers
|
104
|
-
|
105
|
-
response.stream.write block
|
106
|
-
end
|
107
|
-
ensure
|
108
|
-
response.stream.close
|
127
|
+
stream_body file.stream(request.headers['HTTP_RANGE'])
|
109
128
|
end
|
110
129
|
|
111
130
|
def send_file_contents
|
112
131
|
self.status = 200
|
113
132
|
prepare_file_headers
|
114
|
-
|
115
|
-
response.stream.write block
|
116
|
-
end
|
117
|
-
ensure
|
118
|
-
response.stream.close
|
133
|
+
stream_body file.stream
|
119
134
|
end
|
120
135
|
|
121
136
|
def prepare_file_headers
|
122
137
|
send_file_headers! content_options
|
123
|
-
response.headers['Content-Type'] =
|
124
|
-
self.content_type =
|
138
|
+
response.headers['Content-Type'] = file.mime_type
|
139
|
+
self.content_type = file.mime_type
|
125
140
|
end
|
126
141
|
|
127
142
|
private
|
128
143
|
|
144
|
+
def stream_body(iostream)
|
145
|
+
iostream.each do |in_buff|
|
146
|
+
response.stream.write in_buff
|
147
|
+
end
|
148
|
+
ensure
|
149
|
+
response.stream.close
|
150
|
+
end
|
151
|
+
|
129
152
|
def default_content_ds
|
130
|
-
|
153
|
+
Deprecation.warn(DownloadBehavior, "default_content_ds is deprecated and will be removed in hydra-head 10.0, use default_file instead")
|
154
|
+
default_file
|
155
|
+
end
|
156
|
+
|
157
|
+
def default_file
|
158
|
+
if asset.class.respond_to?(:default_file_path)
|
159
|
+
asset.attached_files[asset.class.default_file_path]
|
160
|
+
elsif asset.class.respond_to?(:default_content_ds)
|
161
|
+
Deprecation.warn(DownloadBehavior, "default_content_ds is deprecated and will be removed in hydra-head 10.0, use default_file_path instead")
|
131
162
|
asset.attached_files[asset.class.default_content_ds]
|
163
|
+
elsif asset.attached_files.key?(DownloadsController.default_file_path)
|
164
|
+
asset.attached_files[DownloadsController.default_file_path]
|
132
165
|
elsif asset.attached_files.key?(DownloadsController.default_content_dsid)
|
166
|
+
Deprecation.warn(DownloadBehavior, "DownloadsController.default_content_dsid is deprecated and will be removed in hydra-head 10.0, use default_file_path instead")
|
133
167
|
asset.attached_files[DownloadsController.default_content_dsid]
|
134
168
|
end
|
135
169
|
end
|
136
170
|
|
137
171
|
module ClassMethods
|
138
172
|
def default_content_dsid
|
173
|
+
Deprecation.warn(DownloadBehavior, "default_content_dsid is deprecated and will be removed in hydra-head 10.0, use default_file_path instead")
|
174
|
+
default_file_path
|
175
|
+
end
|
176
|
+
|
177
|
+
def default_file_path
|
139
178
|
"content"
|
140
179
|
end
|
141
180
|
end
|
@@ -1,19 +1,11 @@
|
|
1
1
|
require 'mime/types'
|
2
2
|
|
3
3
|
module Hydra::ModelMethods
|
4
|
+
extend ActiveSupport::Concern
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
def apply_depositor_metadata(depositor)
|
10
|
-
depositor_id = depositor.respond_to?(:user_key) ? depositor.user_key : depositor
|
11
|
-
|
12
|
-
if respond_to? :depositor
|
13
|
-
self.depositor = depositor_id
|
14
|
-
end
|
15
|
-
self.edit_users += [depositor_id]
|
16
|
-
return true
|
6
|
+
included do
|
7
|
+
Deprecation.warn self, "Hydra::ModelMethods is deprecated and will be remove in hydra-head 10.0.0", caller(3)
|
8
|
+
include Hydra::WithDepositor
|
17
9
|
end
|
18
10
|
|
19
11
|
# Puts the contents of file (posted blob) into a datastream and sets the title and label
|
@@ -21,12 +13,12 @@ module Hydra::ModelMethods
|
|
21
13
|
#
|
22
14
|
# @param [#read] file the IO object that is the blob
|
23
15
|
# @param [String] file the IO object that is the blob
|
24
|
-
def add_file(file,
|
16
|
+
def add_file(file, path, file_name, mime_type=nil)
|
25
17
|
mime_type ||= best_mime_for_filename(file_name)
|
26
|
-
options = {
|
27
|
-
options[:
|
28
|
-
|
29
|
-
set_title_and_label(
|
18
|
+
options = { mime_type: mime_type, original_name: file_name }
|
19
|
+
options[:path] = path if path
|
20
|
+
super(file, options)
|
21
|
+
set_title_and_label(file_name, only_if_blank: true)
|
30
22
|
end
|
31
23
|
|
32
24
|
def best_mime_for_filename(file_name)
|
@@ -44,13 +36,13 @@ module Hydra::ModelMethods
|
|
44
36
|
# obj.set_title_and_label("My Title", :only_if_blank=> true)
|
45
37
|
def set_title_and_label(new_title, opts={})
|
46
38
|
if opts[:only_if_blank]
|
47
|
-
if
|
39
|
+
if respond_to?(:label) && label.blank?
|
48
40
|
self.label = new_title
|
49
|
-
|
41
|
+
set_title new_title
|
50
42
|
end
|
51
43
|
else
|
52
|
-
self.label = new_title
|
53
|
-
set_title
|
44
|
+
self.label = new_title if respond_to? :label
|
45
|
+
set_title new_title
|
54
46
|
end
|
55
47
|
end
|
56
48
|
|
@@ -62,6 +54,7 @@ module Hydra::ModelMethods
|
|
62
54
|
if respond_to? :title=
|
63
55
|
self.title = self.class.multiple?(:title) ? Array(new_title) : new_title
|
64
56
|
elsif attached_files.has_key?("descMetadata")
|
57
|
+
Deprecation.warn ModelMethods, 'setting title in descMetadata is deprecated and will be remove in hydra-head 10.0. If you need this behavior declare `has_attribute :title`'
|
65
58
|
if descMetadata.respond_to?(:title_values)
|
66
59
|
descMetadata.title_values = new_title
|
67
60
|
else
|
@@ -1,6 +1,13 @@
|
|
1
1
|
# properties datastream: catch-all for info that didn't have another home. Particularly depositor.
|
2
2
|
module Hydra::Datastream
|
3
3
|
class Properties < ActiveFedora::OmDatastream
|
4
|
+
extend Deprecation
|
5
|
+
|
6
|
+
def initialize(*)
|
7
|
+
super
|
8
|
+
Deprecation.warn(Properties, "Hydra::Datastream::Properties is deprecated and will be removed in hydra-head 10.0")
|
9
|
+
end
|
10
|
+
|
4
11
|
set_terminology do |t|
|
5
12
|
t.root(:path=>"fields", :xmlns => '', :namespace_prefix => nil)
|
6
13
|
|
data/hydra-core.gemspec
CHANGED
@@ -18,13 +18,12 @@ Gem::Specification.new do |gem|
|
|
18
18
|
|
19
19
|
gem.required_ruby_version = '>= 1.9.3'
|
20
20
|
|
21
|
-
gem.add_dependency "rails", '
|
22
|
-
gem.add_dependency 'block_helpers'
|
21
|
+
gem.add_dependency "rails", '~> 4.0'
|
23
22
|
gem.add_dependency 'hydra-access-controls', version
|
24
23
|
gem.add_dependency 'jettywrapper', '>= 2.0.0'
|
25
24
|
|
26
|
-
gem.add_development_dependency 'sqlite3'
|
27
|
-
gem.add_development_dependency 'yard'
|
28
|
-
gem.add_development_dependency 'rspec-rails'
|
29
|
-
gem.add_development_dependency 'factory_girl_rails'
|
25
|
+
gem.add_development_dependency 'sqlite3', '~> 1.3'
|
26
|
+
gem.add_development_dependency 'yard', '~> 0.8.7'
|
27
|
+
gem.add_development_dependency 'rspec-rails', '~> 3.1'
|
28
|
+
gem.add_development_dependency 'factory_girl_rails', '~> 4.2'
|
30
29
|
end
|
data/lib/hydra-head/version.rb
CHANGED
@@ -18,7 +18,6 @@ describe DownloadsController do
|
|
18
18
|
describe "with a file" do
|
19
19
|
before do
|
20
20
|
class ContentHolder < ActiveFedora::Base
|
21
|
-
include Hydra::ModelMethods
|
22
21
|
include Hydra::AccessControls::Permissions
|
23
22
|
contains 'thumbnail'
|
24
23
|
end
|
@@ -26,9 +25,9 @@ describe DownloadsController do
|
|
26
25
|
end
|
27
26
|
let(:obj) do
|
28
27
|
ContentHolder.new.tap do |obj|
|
29
|
-
obj.
|
30
|
-
obj.
|
31
|
-
obj.
|
28
|
+
obj.add_file('fizz', path: 'buzz', original_name: 'buzz.png', mime_type: 'image/png')
|
29
|
+
obj.add_file('foobarfoobarfoobar', path: 'content', original_name: 'world.png', mime_type: 'image/png')
|
30
|
+
obj.add_file("It's a stream", path: 'descMetadata', original_name: 'metadata.xml', mime_type: 'text/plain')
|
32
31
|
obj.read_users = [@user.user_key]
|
33
32
|
obj.save!
|
34
33
|
end
|
@@ -37,24 +36,25 @@ describe DownloadsController do
|
|
37
36
|
after do
|
38
37
|
obj.destroy
|
39
38
|
Object.send(:remove_const, :ContentHolder)
|
40
|
-
end
|
39
|
+
end
|
40
|
+
|
41
41
|
context "when not logged in" do
|
42
42
|
context "when a specific datastream is requested" do
|
43
43
|
it "should redirect to the root path and display an error" do
|
44
|
-
get :show, id: obj,
|
44
|
+
get :show, id: obj, file: "descMetadata"
|
45
45
|
expect(response).to redirect_to new_user_session_path
|
46
46
|
expect(flash[:alert]).to eq "You are not authorized to access this page."
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
50
|
context "when logged in, but without read access" do
|
51
|
-
let(:user) { User.
|
51
|
+
let(:user) { User.create(email: 'email2@example.com', password: 'password') }
|
52
52
|
before do
|
53
53
|
sign_in user
|
54
54
|
end
|
55
55
|
context "when a specific datastream is requested" do
|
56
56
|
it "should redirect to the root path and display an error" do
|
57
|
-
get :show, id: obj,
|
57
|
+
get :show, id: obj, file: "descMetadata"
|
58
58
|
expect(response).to redirect_to root_path
|
59
59
|
expect(flash[:alert]).to eq "You are not authorized to access this page."
|
60
60
|
end
|
@@ -69,14 +69,25 @@ describe DownloadsController do
|
|
69
69
|
describe "#show" do
|
70
70
|
it "should default to returning default download configured by object" do
|
71
71
|
allow(ContentHolder).to receive(:default_content_ds).and_return('buzz')
|
72
|
+
expect(Deprecation).to receive(:warn)
|
72
73
|
get :show, id: obj
|
73
74
|
expect(response).to be_successful
|
74
75
|
expect(response.headers['Content-Type']).to eq "image/png"
|
75
76
|
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"buzz.png\""
|
76
77
|
expect(response.body).to eq 'fizz'
|
77
78
|
end
|
79
|
+
|
80
|
+
it "should default to returning default download configured by object" do
|
81
|
+
allow(ContentHolder).to receive(:default_file_path).and_return('buzz')
|
82
|
+
get :show, id: obj
|
83
|
+
expect(response).to be_successful
|
84
|
+
expect(response.headers['Content-Type']).to eq "image/png"
|
85
|
+
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"buzz.png\""
|
86
|
+
expect(response.body).to eq 'fizz'
|
87
|
+
end
|
88
|
+
|
78
89
|
it "should default to returning default download configured by controller" do
|
79
|
-
expect(DownloadsController.
|
90
|
+
expect(DownloadsController.default_file_path).to eq "content"
|
80
91
|
get :show, id: obj
|
81
92
|
expect(response).to be_successful
|
82
93
|
expect(response.headers['Content-Type']).to eq "image/png"
|
@@ -87,13 +98,13 @@ describe DownloadsController do
|
|
87
98
|
context "when a specific datastream is requested" do
|
88
99
|
context "and it doesn't exist" do
|
89
100
|
it "should return :not_found when the datastream doesn't exist" do
|
90
|
-
get :show, id: obj,
|
101
|
+
get :show, id: obj, file: "thumbnail"
|
91
102
|
expect(response).to be_not_found
|
92
103
|
end
|
93
104
|
end
|
94
105
|
context "and it exists" do
|
95
106
|
it "should return it" do
|
96
|
-
get :show, id: obj,
|
107
|
+
get :show, id: obj, file: "descMetadata"
|
97
108
|
expect(response).to be_successful
|
98
109
|
expect(response.headers['Content-Type']).to eq "text/plain"
|
99
110
|
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"metadata.xml\""
|
@@ -120,23 +131,25 @@ describe DownloadsController do
|
|
120
131
|
let(:parent) { ActiveFedora::Base.new(id: '1234') }
|
121
132
|
|
122
133
|
before do
|
123
|
-
parent.
|
134
|
+
parent.add_file('one1two2threfour', path: 'webm', mime_type: 'video/webm', original_name: 'MyVideo.webm')
|
124
135
|
parent.save!
|
125
136
|
expect(controller).to receive(:authorize!).with(:download, instance_of(ActiveFedora::File)).and_return(true)
|
126
137
|
end
|
127
138
|
it "head request" do
|
128
139
|
request.env["HTTP_RANGE"] = 'bytes=0-15'
|
129
|
-
head :show, id: parent,
|
130
|
-
|
140
|
+
head :show, id: parent, file: 'webm'
|
141
|
+
# See https://github.com/rails/rails/issues/18714
|
142
|
+
# expect(response.headers['Content-Length']).to eq 16
|
131
143
|
expect(response.headers['Accept-Ranges']).to eq 'bytes'
|
132
144
|
expect(response.headers['Content-Type']).to eq 'video/webm'
|
133
145
|
end
|
134
146
|
it "should send the whole thing" do
|
135
147
|
request.env["HTTP_RANGE"] = 'bytes=0-15'
|
136
|
-
get :show, id: '1234',
|
148
|
+
get :show, id: '1234', file: 'webm'
|
137
149
|
expect(response.body).to eq 'one1two2threfour'
|
138
150
|
expect(response.headers["Content-Range"]).to eq 'bytes 0-15/16'
|
139
|
-
|
151
|
+
# See https://github.com/rails/rails/issues/18714
|
152
|
+
# expect(response.headers["Content-Length"]).to eq '16'
|
140
153
|
expect(response.headers['Accept-Ranges']).to eq 'bytes'
|
141
154
|
expect(response.headers['Content-Type']).to eq "video/webm"
|
142
155
|
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"MyVideo.webm\""
|
@@ -144,22 +157,24 @@ describe DownloadsController do
|
|
144
157
|
end
|
145
158
|
it "should send the whole thing when the range is open ended" do
|
146
159
|
request.env["HTTP_RANGE"] = 'bytes=0-'
|
147
|
-
get :show, id: '1234',
|
160
|
+
get :show, id: '1234', file: 'webm'
|
148
161
|
expect(response.body).to eq 'one1two2threfour'
|
149
162
|
end
|
150
163
|
it "should get a range not starting at the beginning" do
|
151
164
|
request.env["HTTP_RANGE"] = 'bytes=3-15'
|
152
|
-
get :show, id: '1234',
|
165
|
+
get :show, id: '1234', file: 'webm'
|
153
166
|
expect(response.body).to eq '1two2threfour'
|
154
167
|
expect(response.headers["Content-Range"]).to eq 'bytes 3-15/16'
|
155
|
-
|
168
|
+
# See https://github.com/rails/rails/issues/18714
|
169
|
+
# expect(response.headers["Content-Length"]).to eq '13'
|
156
170
|
end
|
157
171
|
it "should get a range not ending at the end" do
|
158
172
|
request.env["HTTP_RANGE"] = 'bytes=4-11'
|
159
|
-
get :show, id: '1234',
|
173
|
+
get :show, id: '1234', file: 'webm'
|
160
174
|
expect(response.body).to eq 'two2thre'
|
161
175
|
expect(response.headers["Content-Range"]).to eq 'bytes 4-11/16'
|
162
|
-
|
176
|
+
# See https://github.com/rails/rails/issues/18714
|
177
|
+
# expect(response.headers["Content-Length"]).to eq '8'
|
163
178
|
end
|
164
179
|
end
|
165
180
|
end
|
@@ -2,61 +2,65 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Hydra::ModelMethods do
|
4
4
|
|
5
|
-
before
|
5
|
+
before do
|
6
|
+
allow(Deprecation).to receive(:warn)
|
6
7
|
class TestModel < ActiveFedora::Base
|
7
8
|
include Hydra::AccessControls::Permissions
|
8
9
|
include Hydra::ModelMethods
|
9
|
-
|
10
|
-
|
10
|
+
property :depositor, predicate: ::RDF::URI.new("http://id.loc.gov/vocabulary/relators/dpt"), multiple: false
|
11
|
+
attr_accessor :label
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
describe "apply_depositor_metadata" do
|
17
|
-
it "should add edit access" do
|
18
|
-
subject.apply_depositor_metadata('naomi')
|
19
|
-
expect(subject.edit_users).to eq ['naomi']
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should not overwrite people with edit access" do
|
23
|
-
subject.edit_users = ['jessie']
|
24
|
-
subject.apply_depositor_metadata('naomi')
|
25
|
-
expect(subject.edit_users).to match_array ['naomi', 'jessie']
|
26
|
-
end
|
15
|
+
after { Object.send(:remove_const, :TestModel) }
|
27
16
|
|
28
|
-
|
29
|
-
subject.apply_depositor_metadata('chris')
|
30
|
-
expect(subject.properties.depositor).to eq ['chris']
|
31
|
-
end
|
32
|
-
it "should accept objects that respond_to? :user_key" do
|
33
|
-
stub_user = double(:user, :user_key=>'monty')
|
34
|
-
subject.apply_depositor_metadata(stub_user)
|
35
|
-
expect(subject.properties.depositor).to eq ['monty']
|
36
|
-
end
|
37
|
-
end
|
17
|
+
subject { TestModel.new }
|
38
18
|
|
39
19
|
describe 'add_file' do
|
40
20
|
let(:file_name) { "my_file.foo" }
|
41
21
|
let(:mock_file) { "File contents" }
|
42
22
|
|
43
23
|
it "should set the dsid, mimetype and content" do
|
44
|
-
expect(subject).to receive(:add_file_datastream).with(mock_file, label: file_name, mime_type: "mymimetype", dsid: 'bar', original_name: file_name)
|
45
24
|
expect(subject).to receive(:set_title_and_label).with(file_name, only_if_blank: true )
|
46
25
|
expect(MIME::Types).to receive(:of).with(file_name).and_return([double(content_type: "mymimetype")])
|
47
26
|
subject.add_file(mock_file, 'bar', file_name)
|
27
|
+
expect(subject.bar.content).to eq mock_file
|
48
28
|
end
|
49
29
|
|
50
30
|
it "should accept a supplied mime_type and content" do
|
51
|
-
expect(subject).to receive(:add_file_datastream).with(mock_file, label: file_name, mime_type: "image/png", dsid: 'bar', original_name: file_name)
|
52
31
|
expect(subject).to receive(:set_title_and_label).with(file_name, only_if_blank: true )
|
53
32
|
subject.add_file(mock_file, 'bar', file_name, 'image/png')
|
33
|
+
expect(subject.bar.content).to eq mock_file
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#set_title_and_label' do
|
38
|
+
context 'when only_if_blank is true' do
|
39
|
+
before do
|
40
|
+
subject.label = initial_label
|
41
|
+
subject.set_title_and_label('second', only_if_blank: true)
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'and label is already set' do
|
45
|
+
let(:initial_label) { 'first' }
|
46
|
+
it "should not update the label" do
|
47
|
+
expect(subject.label).to eq 'first'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'and label is not already set' do
|
52
|
+
let(:initial_label) { nil }
|
53
|
+
it "should not update the label" do
|
54
|
+
expect(subject.label).to eq 'second'
|
55
|
+
end
|
56
|
+
end
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
57
60
|
describe '#set_title' do
|
58
61
|
context "on a class with a title property" do
|
59
62
|
before do
|
63
|
+
expect(Deprecation).to receive(:warn)
|
60
64
|
class WithProperty < ActiveFedora::Base
|
61
65
|
include Hydra::ModelMethods
|
62
66
|
property :title, predicate: ::RDF::DC.title
|
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.0.0
|
4
|
+
version: 9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield,
|
@@ -9,56 +9,36 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 3.2.3
|
21
|
-
- - "<"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: '5'
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
requirements:
|
28
|
-
- - ">="
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: 3.2.3
|
31
|
-
- - "<"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '5'
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: block_helpers
|
36
|
-
requirement: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
18
|
+
- - "~>"
|
39
19
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
20
|
+
version: '4.0'
|
41
21
|
type: :runtime
|
42
22
|
prerelease: false
|
43
23
|
version_requirements: !ruby/object:Gem::Requirement
|
44
24
|
requirements:
|
45
|
-
- - "
|
25
|
+
- - "~>"
|
46
26
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
27
|
+
version: '4.0'
|
48
28
|
- !ruby/object:Gem::Dependency
|
49
29
|
name: hydra-access-controls
|
50
30
|
requirement: !ruby/object:Gem::Requirement
|
51
31
|
requirements:
|
52
32
|
- - '='
|
53
33
|
- !ruby/object:Gem::Version
|
54
|
-
version: 9.0.0
|
34
|
+
version: 9.0.0
|
55
35
|
type: :runtime
|
56
36
|
prerelease: false
|
57
37
|
version_requirements: !ruby/object:Gem::Requirement
|
58
38
|
requirements:
|
59
39
|
- - '='
|
60
40
|
- !ruby/object:Gem::Version
|
61
|
-
version: 9.0.0
|
41
|
+
version: 9.0.0
|
62
42
|
- !ruby/object:Gem::Dependency
|
63
43
|
name: jettywrapper
|
64
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,58 +57,58 @@ dependencies:
|
|
77
57
|
name: sqlite3
|
78
58
|
requirement: !ruby/object:Gem::Requirement
|
79
59
|
requirements:
|
80
|
-
- - "
|
60
|
+
- - "~>"
|
81
61
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
62
|
+
version: '1.3'
|
83
63
|
type: :development
|
84
64
|
prerelease: false
|
85
65
|
version_requirements: !ruby/object:Gem::Requirement
|
86
66
|
requirements:
|
87
|
-
- - "
|
67
|
+
- - "~>"
|
88
68
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
69
|
+
version: '1.3'
|
90
70
|
- !ruby/object:Gem::Dependency
|
91
71
|
name: yard
|
92
72
|
requirement: !ruby/object:Gem::Requirement
|
93
73
|
requirements:
|
94
|
-
- - "
|
74
|
+
- - "~>"
|
95
75
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
76
|
+
version: 0.8.7
|
97
77
|
type: :development
|
98
78
|
prerelease: false
|
99
79
|
version_requirements: !ruby/object:Gem::Requirement
|
100
80
|
requirements:
|
101
|
-
- - "
|
81
|
+
- - "~>"
|
102
82
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
83
|
+
version: 0.8.7
|
104
84
|
- !ruby/object:Gem::Dependency
|
105
85
|
name: rspec-rails
|
106
86
|
requirement: !ruby/object:Gem::Requirement
|
107
87
|
requirements:
|
108
|
-
- - "
|
88
|
+
- - "~>"
|
109
89
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
90
|
+
version: '3.1'
|
111
91
|
type: :development
|
112
92
|
prerelease: false
|
113
93
|
version_requirements: !ruby/object:Gem::Requirement
|
114
94
|
requirements:
|
115
|
-
- - "
|
95
|
+
- - "~>"
|
116
96
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
97
|
+
version: '3.1'
|
118
98
|
- !ruby/object:Gem::Dependency
|
119
99
|
name: factory_girl_rails
|
120
100
|
requirement: !ruby/object:Gem::Requirement
|
121
101
|
requirements:
|
122
|
-
- - "
|
102
|
+
- - "~>"
|
123
103
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
104
|
+
version: '4.2'
|
125
105
|
type: :development
|
126
106
|
prerelease: false
|
127
107
|
version_requirements: !ruby/object:Gem::Requirement
|
128
108
|
requirements:
|
129
|
-
- - "
|
109
|
+
- - "~>"
|
130
110
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
111
|
+
version: '4.2'
|
132
112
|
description: 'Hydra-Head is a Rails Engine containing the core code for a Hydra application.
|
133
113
|
The full hydra stack includes: Blacklight, Fedora, Solr, active-fedora, solrizer,
|
134
114
|
and om'
|
@@ -205,12 +185,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
185
|
version: 1.9.3
|
206
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
187
|
requirements:
|
208
|
-
- - "
|
188
|
+
- - ">="
|
209
189
|
- !ruby/object:Gem::Version
|
210
|
-
version:
|
190
|
+
version: '0'
|
211
191
|
requirements: []
|
212
192
|
rubyforge_project:
|
213
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.2.2
|
214
194
|
signing_key:
|
215
195
|
specification_version: 4
|
216
196
|
summary: Hydra-Head Rails Engine (requires Rails3)
|