hydra-core 6.3.4 → 6.4.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8106466b12a6f1dba6af3166196978901845be03
4
- data.tar.gz: ad73413b369fea0f7f49f4905d99f3dc940bfada
3
+ metadata.gz: b2138b3738292db81150e74f4873486da132a065
4
+ data.tar.gz: 1493d7514bd788955066095b7b836afba12e9467
5
5
  SHA512:
6
- metadata.gz: da415a6c990c4feb67c452b9dc09265f0635f4f7130233eca0717727f18e6ccdfeefc3ad6c1f217aefaefbda94498c07d1c5beaa8dde53030758fdbc5a8c8fa4
7
- data.tar.gz: d5af7016ec5f63d9619f0938255d4bfb03b02477c4661de3595585030909eee3f518a91fbc4e1e822b6b17144eda54280b965fa3fc8051296e02c9c841a8c965
6
+ metadata.gz: ab203db4e2d63aa4e0c82bcd347685490f9575fe67ab50e291829f65a3c88f2e630401cb3c4b23b0a0e1aa4dd8bcd05dbaea69615b643a4829c7e27e234b8750
7
+ data.tar.gz: 6735a3ed38c61fdb294f8d3a780b4da2f39d5548981fd31fa8ae9d034d55df1626e694bde5f45d628321b283d15a3b19971b0fe4bd1d80d7d41baeba37241364
@@ -1,4 +1,3 @@
1
- require 'hydra'
2
1
  # An EXAMPLE Basic Model for Assets that conform to Hydra commonMetadata cModel and have basic MODS metadata (currently "Article" is the MODS exemplar)
3
2
  class ModsAsset < ActiveFedora::Base
4
3
 
@@ -1,9 +1,8 @@
1
1
  class Ability
2
- include Hydra::Ability
2
+ include Hydra::Ability
3
3
 
4
- # Define any customized permissions here. Some commented examples are included below.
4
+ # Define any customized permissions here.
5
5
  def custom_permissions
6
-
7
6
  # Limits deleting objects to a the admin user
8
7
  #
9
8
  # if current_user.admin?
@@ -15,7 +14,5 @@ class Ability
15
14
  # if user_groups.include? 'special_group'
16
15
  # can [:create], ActiveFedora::Base
17
16
  # end
18
-
19
17
  end
20
-
21
18
  end
data/lib/hydra-core.rb CHANGED
@@ -1,4 +1,20 @@
1
- require 'hydra'
1
+ require 'hydra-access-controls'
2
+
3
+ module Hydra
4
+ extend ActiveSupport::Autoload
5
+ autoload :GlobalConfigurable
6
+ extend GlobalConfigurable
7
+ autoload :Controller
8
+ autoload :ModelMethods
9
+ autoload :RepositoryController
10
+ autoload :Solr
11
+ module ModelMixins
12
+ # ModelMixins already loaded by hydra-access-controls
13
+ autoload :CommonMetadata
14
+ autoload :SolrDocumentExtension
15
+ end
16
+ autoload :Models
17
+ end
2
18
 
3
19
  module HydraHead
4
20
  require 'hydra-head/engine' if defined?(Rails)
@@ -1,4 +1,4 @@
1
1
  module HydraHead
2
- VERSION = "6.3.4"
2
+ VERSION = "6.4.0.pre1"
3
3
  end
4
4
 
@@ -14,15 +14,21 @@ module Hydra
14
14
  # we can now examine asset and determine if we should send_content, or some other action.
15
15
  send_content (asset)
16
16
  else
17
- logger.info "Can not read #{params['id']}"
18
- raise Hydra::AccessDenied.new("You do not have sufficient access privileges to read this document, which has been marked private.", :read, params[:id])
17
+ logger.info "Can not read #{params[asset_param_key]}"
18
+ raise Hydra::AccessDenied.new("You do not have sufficient access privileges to read this document, which has been marked private.", :read, params[asset_param_key])
19
19
  end
20
20
  end
21
21
 
22
22
  protected
23
23
 
24
+ # Override this method if asset PID is not passed in params[:id],
25
+ # for example, in a nested resource.
26
+ def asset_param_key
27
+ :id
28
+ end
29
+
24
30
  def load_asset
25
- @asset = ActiveFedora::Base.load_instance_from_solr(params[:id])
31
+ @asset = ActiveFedora::Base.load_instance_from_solr(params[asset_param_key])
26
32
  end
27
33
 
28
34
  def load_datastream
@@ -7,7 +7,6 @@ namespace :hydra do
7
7
 
8
8
  desc "Load hydra-head models"
9
9
  task :load_models do
10
- require "hydra"
11
10
  Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), "..",'app','models', '*.rb')).each do |model|
12
11
  load model
13
12
  end
@@ -74,9 +74,9 @@ describe DownloadsController do
74
74
  end
75
75
  describe "stream" do
76
76
  before do
77
- stub_response = stub()
77
+ stub_response = double()
78
78
  stub_response.stub(:read_body).and_yield("one1").and_yield('two2').and_yield('thre').and_yield('four')
79
- stub_repo = stub()
79
+ stub_repo = double()
80
80
  stub_repo.stub(:datastream_dissemination).and_yield(stub_response)
81
81
  stub_ds = ActiveFedora::Datastream.new
82
82
  stub_ds.stub(:repository).and_return(stub_repo)
@@ -84,7 +84,7 @@ describe DownloadsController do
84
84
  stub_ds.stub(:dsSize).and_return(16)
85
85
  stub_ds.stub(:dsid).and_return('webm')
86
86
  stub_ds.stub(:pid).and_return('changeme:test')
87
- stub_file = stub('stub object', datastreams: {'webm' => stub_ds}, pid:'changeme:test', label: "MyVideo.webm")
87
+ stub_file = double('stub object', datastreams: {'webm' => stub_ds}, pid:'changeme:test', label: "MyVideo.webm")
88
88
  ActiveFedora::Base.should_receive(:load_instance_from_solr).with('changeme:test').and_return(stub_file)
89
89
  controller.stub(:can?).with(:read, 'changeme:test').and_return(true)
90
90
  controller.stub(:log_download)
@@ -139,5 +139,22 @@ describe DownloadsController do
139
139
  end
140
140
  end
141
141
  end
142
+
143
+ describe "overriding the default asset param key" do
144
+ before do
145
+ Rails.application.routes.draw do
146
+ scope 'objects/:object_id' do
147
+ get 'download' => 'downloads#show'
148
+ end
149
+ end
150
+ sign_in @user
151
+ end
152
+ it "should use the custom param value to retrieve the asset" do
153
+ controller.stub(:asset_param_key).and_return(:object_id)
154
+ get "show", :object_id => @obj.pid
155
+ response.should be_successful
156
+ end
157
+ end
158
+
142
159
  end
143
160
  end
@@ -8,28 +8,28 @@ describe Hydra::Controller::UploadBehavior do
8
8
 
9
9
  describe "add_posted_blob_to_asset" do
10
10
  it "should set object title and label, relying on datastream_id to set dsId" do
11
- mock_file = mock("File")
11
+ mock_file = double("File")
12
12
  file_name = "Posted Filename.foo"
13
13
  helper.stub(:params).and_return( :Filedata=>[mock_file], :Filename=>file_name, "container_id"=>"hydrangea:2973" )
14
- mock_fa = mock("file asset")
14
+ mock_fa = double("file asset")
15
15
  helper.stub(:datastream_id).and_return('bar')
16
16
  mock_fa.should_receive(:add_file).with(mock_file, 'bar', file_name)
17
17
  helper.add_posted_blob_to_asset(mock_fa,mock_file, file_name) # this is the deprecated 2 argument method
18
18
  end
19
19
 
20
20
  it "should support submissions from swfupload" do
21
- mock_file = mock("File")
21
+ mock_file = double("File")
22
22
  file_name = "Posted Filename.foo"
23
23
  helper.stub(:params).and_return( :Filedata=>[mock_file], :Filename=>file_name, "container_id"=>"hydrangea:2973" )
24
- mock_fa = mock("file asset")
24
+ mock_fa = double("file asset")
25
25
  mock_fa.should_receive(:add_file).with(mock_file, 'content', file_name)
26
26
  helper.add_posted_blob_to_asset(mock_fa,mock_file, file_name)
27
27
  end
28
28
  it "should support submissions from single-file uploader, defaulting to dsId of content" do
29
- mock_file = mock("File")
29
+ mock_file = double("File")
30
30
  file_name = "Posted Filename.foo"
31
31
  helper.stub(:params).and_return( :Filedata=>[mock_file], :container_id=>"hydrangea:2973" )
32
- mock_fa = mock("file asset")
32
+ mock_fa = double("file asset")
33
33
  mock_fa.should_receive(:add_file).with(mock_file, 'content', file_name)
34
34
  helper.add_posted_blob_to_asset(mock_fa,mock_file, file_name)
35
35
  end
@@ -27,7 +27,7 @@ describe Hydra::ModelMethods do
27
27
  subject.properties.depositor.should == ['chris']
28
28
  end
29
29
  it "should accept objects that respond_to? :user_key" do
30
- stub_user = stub(:user, :user_key=>'monty')
30
+ stub_user = double(:user, :user_key=>'monty')
31
31
  subject.apply_depositor_metadata(stub_user)
32
32
  subject.properties.depositor.should == ['monty']
33
33
  end
@@ -39,7 +39,7 @@ describe Hydra::ModelMethods do
39
39
  mock_file = "File contents"
40
40
  subject.should_receive(:add_file_datastream).with(mock_file, :label=>file_name, :mimeType=>"mymimetype", :dsid=>'bar')
41
41
  subject.should_receive(:set_title_and_label).with( file_name, :only_if_blank=>true )
42
- MIME::Types.should_receive(:of).with(file_name).and_return([stub(:content_type=>"mymimetype")])
42
+ MIME::Types.should_receive(:of).with(file_name).and_return([double(:content_type=>"mymimetype")])
43
43
  subject.add_file(mock_file, 'bar', file_name)
44
44
  end
45
45
  end
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: 6.3.4
4
+ version: 6.4.0.pre1
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: 2013-08-27 00:00:00.000000000 Z
12
+ date: 2013-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -93,14 +93,14 @@ dependencies:
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 6.3.4
96
+ version: 6.4.0.pre1
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 6.3.4
103
+ version: 6.4.0.pre1
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: jettywrapper
106
106
  requirement: !ruby/object:Gem::Requirement
@@ -211,7 +211,6 @@ files:
211
211
  - lib/hydra-head/engine.rb
212
212
  - lib/hydra-head/routes.rb
213
213
  - lib/hydra-head/version.rb
214
- - lib/hydra.rb
215
214
  - lib/hydra/controller.rb
216
215
  - lib/hydra/controller/controller_behavior.rb
217
216
  - lib/hydra/controller/download_behavior.rb
@@ -276,9 +275,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
276
275
  version: 1.9.3
277
276
  required_rubygems_version: !ruby/object:Gem::Requirement
278
277
  requirements:
279
- - - '>='
278
+ - - '>'
280
279
  - !ruby/object:Gem::Version
281
- version: '0'
280
+ version: 1.3.1
282
281
  requirements: []
283
282
  rubyforge_project:
284
283
  rubygems_version: 2.0.5
data/lib/hydra.rb DELETED
@@ -1,17 +0,0 @@
1
- require 'hydra-access-controls'
2
-
3
- module Hydra
4
- extend ActiveSupport::Autoload
5
- autoload :GlobalConfigurable
6
- extend GlobalConfigurable
7
- autoload :Controller
8
- autoload :ModelMethods
9
- autoload :RepositoryController
10
- autoload :Solr
11
- module ModelMixins
12
- # ModelMixins already loaded by hydra-access-controls
13
- autoload :CommonMetadata
14
- autoload :SolrDocumentExtension
15
- end
16
- autoload :Models
17
- end