hydra-head 4.0.0.rc2 → 4.0.0.rc3
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.
- data/Gemfile +8 -1
- data/Gemfile.lock +46 -46
- data/HISTORY.textile +2 -0
- data/app/controllers/hydra/application_controller.rb +5 -0
- data/app/controllers/hydra/contributors_controller.rb +2 -1
- data/app/controllers/hydra/permissions_controller.rb +2 -2
- data/app/helpers/hydra/hydra_assets_helper_behavior.rb +4 -3
- data/app/models/ability.rb +97 -0
- data/app/models/common_metadata_asset.rb +2 -2
- data/app/models/generic_content.rb +2 -4
- data/app/models/generic_image.rb +3 -3
- data/app/models/hydra/datastream/common_mods_index_methods.rb +45 -0
- data/app/models/hydra/datastream/mods_article.rb +528 -0
- data/app/models/hydra/datastream/mods_dataset.rb +166 -0
- data/app/models/hydra/datastream/mods_generic_content.rb +496 -0
- data/app/models/hydra/datastream/mods_image.rb +496 -0
- data/app/models/hydra/datastream/rights_metadata.rb +190 -0
- data/app/models/mods_asset.rb +4 -4
- data/app/models/uses_default_partials.rb +2 -2
- data/app/views/catalog/_edit_partials/_default.html.erb +1 -1
- data/app/views/catalog/show.html.erb +1 -1
- data/app/views/contributors/_edit_conference.html.erb +1 -1
- data/app/views/contributors/_edit_organization.html.erb +1 -1
- data/app/views/contributors/_edit_person.html.erb +1 -1
- data/app/views/contributors/_show_organization.html.erb +1 -1
- data/app/views/hydra/file_assets/_index.html.erb +1 -1
- data/app/views/hydra/file_assets/_result.html.erb +1 -1
- data/app/views/hydra/permissions/index.html.erb +1 -1
- data/app/views/hydra/permissions/new.html.erb +1 -1
- data/app/views/mods_assets/_show_permissions.html.erb +1 -1
- data/hydra-head.gemspec +4 -6
- data/lib/hydra/access_controls_enforcement.rb +10 -6
- data/lib/hydra/access_controls_evaluation.rb +7 -71
- data/lib/hydra/assets.rb +1 -4
- data/lib/hydra/common_mods_index_methods.rb +5 -0
- data/lib/hydra/controller.rb +4 -7
- data/lib/hydra/file_assets.rb +3 -8
- data/lib/hydra/model_methods.rb +3 -2
- data/lib/hydra/model_mixins/common_metadata.rb +2 -2
- data/lib/hydra/model_mixins/mods_object.rb +3 -3
- data/lib/hydra/models/file_asset.rb +3 -3
- data/lib/hydra/mods_article.rb +7 -1
- data/lib/hydra/mods_dataset.rb +8 -0
- data/lib/hydra/mods_generic_content.rb +5 -0
- data/lib/hydra/mods_image.rb +5 -0
- data/lib/hydra/repository_controller.rb +14 -15
- data/lib/hydra/rights_metadata.rb +5 -1
- data/lib/hydra/submission_workflow.rb +1 -1
- data/lib/hydra-head/version.rb +1 -1
- data/lib/hydra.rb +1 -0
- data/lib/mediashelf/active_fedora_helper.rb +71 -0
- data/lib/uva/mods_index_methods.rb +5 -0
- data/test_support/etc/Gemfile +3 -2
- data/test_support/spec/controllers/catalog_controller_viewing_context_spec.rb +5 -7
- data/test_support/spec/controllers/file_assets_controller_spec.rb +3 -14
- data/test_support/spec/controllers/hydra-assets_controller_spec.rb +2 -2
- data/test_support/spec/helpers/access_controls_enforcement_spec.rb +14 -0
- data/test_support/spec/helpers/access_controls_evaluation_spec.rb +7 -16
- data/test_support/spec/helpers/hydra-repository_controller_spec.rb +0 -14
- data/test_support/spec/helpers/hydra_assets_helper_spec.rb +11 -11
- data/test_support/spec/helpers/hydra_model_methods_spec.rb +2 -2
- data/test_support/spec/integration/file_asset_spec.rb +0 -1
- data/test_support/spec/lib/common_mods_index_methods_spec.rb +1 -1
- data/test_support/spec/lib/hydra_submission_workflow_spec.rb +1 -1
- data/test_support/spec/models/ability_spec.rb +16 -0
- data/test_support/spec/models/file_asset_spec.rb +0 -1
- data/test_support/spec/models/hydra_rights_metadata_spec.rb +4 -5
- data/test_support/spec/models/mods_asset_spec.rb +2 -11
- data/vendor/cache/{active-fedora-4.0.0.rc13.gem → active-fedora-4.0.0.rc18.gem} +0 -0
- data/vendor/cache/blacklight-3.3.1.gem +0 -0
- data/vendor/cache/cancan-1.6.7.gem +0 -0
- data/vendor/cache/compass-0.12.1.gem +0 -0
- data/vendor/cache/compass-rails-1.0.1.gem +0 -0
- data/vendor/cache/compass-susy-plugin-0.9.gem +0 -0
- data/vendor/cache/factory_girl-2.6.4.gem +0 -0
- data/vendor/cache/gherkin-2.9.1.gem +0 -0
- data/vendor/cache/mail-2.4.4.gem +0 -0
- data/vendor/cache/nokogiri-1.5.2.gem +0 -0
- data/vendor/cache/om-1.6.0.rc3.gem +0 -0
- data/vendor/cache/orm_adapter-0.0.7.gem +0 -0
- data/vendor/cache/rack-cache-1.2.gem +0 -0
- data/vendor/cache/rspec-2.9.0.gem +0 -0
- data/vendor/cache/rspec-core-2.9.0.gem +0 -0
- data/vendor/cache/rspec-expectations-2.9.0.gem +0 -0
- data/vendor/cache/rspec-mocks-2.9.0.gem +0 -0
- data/vendor/cache/rspec-rails-2.9.0.gem +0 -0
- data/vendor/cache/sass-rails-3.2.5.gem +0 -0
- data/vendor/cache/stomp-1.2.2.gem +0 -0
- metadata +71 -59
- data/lib/hydra/image.rb +0 -178
- data/uninstall.rb +0 -1
- data/vendor/cache/compass-0.12.rc.1.gem +0 -0
- data/vendor/cache/factory_girl-2.6.1.gem +0 -0
- data/vendor/cache/gherkin-2.9.0.gem +0 -0
- data/vendor/cache/mail-2.4.3.gem +0 -0
- data/vendor/cache/nokogiri-1.5.0.gem +0 -0
- data/vendor/cache/om-1.5.3.gem +0 -0
- data/vendor/cache/orm_adapter-0.0.6.gem +0 -0
- data/vendor/cache/rack-cache-1.1.gem +0 -0
- data/vendor/cache/rspec-2.6.0.gem +0 -0
- data/vendor/cache/rspec-core-2.6.4.gem +0 -0
- data/vendor/cache/rspec-expectations-2.6.0.gem +0 -0
- data/vendor/cache/rspec-mocks-2.6.0.gem +0 -0
- data/vendor/cache/rspec-rails-2.6.1.gem +0 -0
- data/vendor/cache/sass-rails-3.2.4.gem +0 -0
- data/vendor/cache/stomp-1.2.1.gem +0 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
# Stanford SolrHelper is a controller layer mixin. It is in the controller scope: request params, session etc.
|
2
|
+
#
|
3
|
+
# NOTE: Be careful when creating variables here as they may be overriding something that already exists.
|
4
|
+
# The ActionController docs: http://api.rubyonrails.org/classes/ActionController/Base.html
|
5
|
+
#
|
6
|
+
# Override these methods in your own controller for customizations:
|
7
|
+
#
|
8
|
+
# class HomeController < ActionController::Base
|
9
|
+
#
|
10
|
+
# include Stanford::SolrHelper
|
11
|
+
#
|
12
|
+
# def solr_search_params
|
13
|
+
# super.merge :per_page=>10
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
require 'active_fedora/version'
|
19
|
+
module MediaShelf
|
20
|
+
module ActiveFedoraHelper
|
21
|
+
def self.included(base)
|
22
|
+
ActiveSupport::Deprecation.warn("ActiveFedoraHelper is deprecated for removal")
|
23
|
+
end
|
24
|
+
|
25
|
+
def retrieve_af_model(class_name, opts={})
|
26
|
+
if !class_name.nil?
|
27
|
+
klass = Module.const_get(class_name.camelcase)
|
28
|
+
else
|
29
|
+
klass = nil
|
30
|
+
end
|
31
|
+
#klass.included_modules.include?(ActiveFedora::Model)
|
32
|
+
if klass.is_a?(Class) && klass.superclass == ActiveFedora::Base
|
33
|
+
return klass
|
34
|
+
else
|
35
|
+
return opts.fetch(:default, false)
|
36
|
+
end
|
37
|
+
rescue NameError
|
38
|
+
return false
|
39
|
+
end
|
40
|
+
|
41
|
+
def load_af_instance_from_solr(doc)
|
42
|
+
pid = doc[:id] ? doc[:id] : doc[:id.to_s]
|
43
|
+
pid ? ActiveFedora::Base.load_instance_from_solr(pid,doc) : nil
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def require_solr
|
49
|
+
ActiveFedora::SolrService.register(ActiveFedora.solr_config[:url])
|
50
|
+
end
|
51
|
+
|
52
|
+
#underscores are escaped w/ + signs, which are unescaped by rails to spaces
|
53
|
+
def unescape_keys(attrs)
|
54
|
+
h=Hash.new
|
55
|
+
attrs.each do |k,v|
|
56
|
+
h[k.gsub(/ /, '_')]=v
|
57
|
+
|
58
|
+
end
|
59
|
+
h
|
60
|
+
end
|
61
|
+
def escape_keys(attrs)
|
62
|
+
h=Hash.new
|
63
|
+
attrs.each do |k,v|
|
64
|
+
h[k.gsub(/_/, '+')]=v
|
65
|
+
|
66
|
+
end
|
67
|
+
h
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -1,5 +1,10 @@
|
|
1
1
|
module Uva
|
2
2
|
module ModsIndexMethods
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
ActiveSupport::Deprecation.warn("Uva::ModsIndexMethods has been deprecated and its functionality has been encorporated into Hydra::Datastream::ModsArticle")
|
6
|
+
end
|
7
|
+
|
3
8
|
# extracts the last_name##full_name##computing_id to be used by home view
|
4
9
|
def extract_person_full_names_and_computing_ids
|
5
10
|
names = {}
|
data/test_support/etc/Gemfile
CHANGED
@@ -9,16 +9,17 @@ gem "rails", '~> 3.2.2'
|
|
9
9
|
gem 'sqlite3-ruby', :require => 'sqlite3'
|
10
10
|
#gem 'sqlite3'
|
11
11
|
|
12
|
-
gem 'blacklight',
|
12
|
+
gem 'blacklight', '~>3.3.0'
|
13
13
|
|
14
14
|
|
15
15
|
gem 'hydra-head', :path => '../../'
|
16
16
|
gem 'devise'
|
17
17
|
gem 'jettywrapper'
|
18
|
+
gem 'cancan'
|
18
19
|
|
19
20
|
# For testing
|
20
21
|
group :development, :test do
|
21
|
-
gem 'rspec-rails'
|
22
|
+
gem 'rspec-rails'
|
22
23
|
gem 'mocha'
|
23
24
|
gem 'cucumber-rails'
|
24
25
|
gem 'capybara'
|
@@ -16,15 +16,13 @@ describe CatalogController do
|
|
16
16
|
|
17
17
|
describe "show" do
|
18
18
|
it "should redirect to edit view if session is in edit context and user has edit permission" do
|
19
|
-
controller.stubs(:
|
20
|
-
controller.expects(:editor?).returns(true)
|
21
|
-
|
19
|
+
controller.stubs(:can?).returns(true)
|
22
20
|
controller.session[:viewing_context] = "edit"
|
23
21
|
get(:show, {:id=>"hydrangea:fixture_mods_article1"})
|
24
22
|
response.should redirect_to(:action => 'edit')
|
25
23
|
end
|
26
24
|
it "should allow you to reset the session context to browse using :viewing_context param" do
|
27
|
-
controller.stubs(:
|
25
|
+
controller.stubs(:can?).returns(true)
|
28
26
|
controller.session[:viewing_context] = "edit"
|
29
27
|
get(:show, :id=>"hydrangea:fixture_mods_article1", :viewing_context=>"browse")
|
30
28
|
session[:viewing_context].should == "browse"
|
@@ -32,8 +30,8 @@ describe CatalogController do
|
|
32
30
|
end
|
33
31
|
|
34
32
|
it "should quietly switch session state to browse if user does not have edit permissions" do
|
35
|
-
controller.
|
36
|
-
controller.
|
33
|
+
controller.stubs(:can?).with(:edit, anything()).returns(false)
|
34
|
+
controller.stubs(:can?).with(:read, anything()).returns(true)
|
37
35
|
controller.session[:viewing_context] = "edit"
|
38
36
|
get(:show, {:id=>"hydrangea:fixture_mods_article1"})
|
39
37
|
session[:viewing_context].should == "browse"
|
@@ -53,7 +51,7 @@ describe CatalogController do
|
|
53
51
|
flash[:notice].should == "You do not have sufficient privileges to edit this document. You have been redirected to the read-only view."
|
54
52
|
end
|
55
53
|
it "should render normally if user has edit permissions" do
|
56
|
-
controller.expects(:
|
54
|
+
controller.expects(:can?).with(:edit, anything()).returns(true)
|
57
55
|
get :edit, :id=>"hydrangea:fixture_mods_article1"
|
58
56
|
response.should_not redirect_to(:action => 'show')
|
59
57
|
end
|
@@ -34,7 +34,7 @@ describe Hydra::FileAssetsController do
|
|
34
34
|
controller.expects(:get_solr_response_for_doc_id).with('_PID_').returns(["container solr response","container solr doc"])
|
35
35
|
controller.stubs(:load_permissions_from_solr)
|
36
36
|
|
37
|
-
ActiveFedora::Base.expects(:find).with("_PID_").returns(mock_container)
|
37
|
+
ActiveFedora::Base.expects(:find).with("_PID_", :cast=>true).returns(mock_container)
|
38
38
|
xhr :get, :index, :asset_id=>"_PID_"
|
39
39
|
assigns[:response].should == "assets solr response"
|
40
40
|
assigns[:document_list].should == "assets solr list"
|
@@ -45,17 +45,6 @@ describe Hydra::FileAssetsController do
|
|
45
45
|
assigns[:container].should == mock_container
|
46
46
|
end
|
47
47
|
|
48
|
-
it "should find all file assets belonging to a given container object if container_id or container_id is provided" do
|
49
|
-
pending
|
50
|
-
# this was testing a hacked version
|
51
|
-
mock_solr_hash = {"has_collection_member_field"=>["info:fedora/foo:id"]}
|
52
|
-
mock_container = mock("container")
|
53
|
-
mock_container.expects(:collection_members).with(:response_format=>:solr).returns("solr result")
|
54
|
-
ActiveFedora::Base.expects(:find).with("_PID_").returns(mock_container)
|
55
|
-
xhr :get, :index, :asset_id=>"_PID_"
|
56
|
-
assigns[:solr_result].should == "solr result"
|
57
|
-
assigns[:container].should == mock_container
|
58
|
-
end
|
59
48
|
end
|
60
49
|
|
61
50
|
describe "new" do
|
@@ -113,7 +102,7 @@ describe Hydra::FileAssetsController do
|
|
113
102
|
describe "destroy" do
|
114
103
|
it "should delete the asset identified by pid" do
|
115
104
|
mock_obj = mock("asset", :delete)
|
116
|
-
ActiveFedora::Base.expects(:find).with("__PID__").returns(mock_obj)
|
105
|
+
ActiveFedora::Base.expects(:find).with("__PID__", :cast=>true).returns(mock_obj)
|
117
106
|
delete(:destroy, :id => "__PID__")
|
118
107
|
end
|
119
108
|
it "should remove container relationship and perform proper garbage collection" do
|
@@ -121,7 +110,7 @@ describe Hydra::FileAssetsController do
|
|
121
110
|
mock_container = mock("asset")
|
122
111
|
mock_container.expects(:file_objects_remove).with("_file_asset_pid_")
|
123
112
|
FileAsset.expects(:garbage_collect).with("_file_asset_pid_")
|
124
|
-
ActiveFedora::Base.expects(:find).with("_container_pid_").returns(mock_container)
|
113
|
+
ActiveFedora::Base.expects(:find).with("_container_pid_", :cast=>true).returns(mock_container)
|
125
114
|
delete(:destroy, :id => "_file_asset_pid_", :asset_id=>"_container_pid_")
|
126
115
|
end
|
127
116
|
end
|
@@ -108,7 +108,7 @@ describe Hydra::AssetsController do
|
|
108
108
|
it "should delete the asset identified by pid" do
|
109
109
|
mock_obj = mock("asset", :delete)
|
110
110
|
mock_obj.expects(:destroy_child_assets).returns([])
|
111
|
-
ActiveFedora::Base.expects(:find).with("__PID__").returns(mock_obj)
|
111
|
+
ActiveFedora::Base.expects(:find).with("__PID__", :cast=>true).returns(mock_obj)
|
112
112
|
delete(:destroy, :id => "__PID__")
|
113
113
|
end
|
114
114
|
end
|
@@ -119,7 +119,7 @@ describe Hydra::AssetsController do
|
|
119
119
|
it "should withdraw the asset identified by pid" do
|
120
120
|
mock_obj = mock("asset", :delete)
|
121
121
|
mock_obj.expects(:destroy_child_assets).returns([])
|
122
|
-
ActiveFedora::Base.expects(:find).with("__PID__").returns(mock_obj)
|
122
|
+
ActiveFedora::Base.expects(:find).with("__PID__", :cast=>true).returns(mock_obj)
|
123
123
|
delete(:withdraw, :id => "__PID__")
|
124
124
|
end
|
125
125
|
end
|
@@ -2,6 +2,20 @@
|
|
2
2
|
require File.expand_path( File.join( File.dirname(__FILE__),'..','spec_helper') )
|
3
3
|
|
4
4
|
describe Hydra::AccessControlsEnforcement do
|
5
|
+
describe "enforce_access_controls" do
|
6
|
+
describe "when the method exists" do
|
7
|
+
it "should call the method" do
|
8
|
+
params[:action] = :index
|
9
|
+
helper.enforce_access_controls.should be_true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
describe "when the method doesn't exist" do
|
13
|
+
it "should not call the method, but should return true" do
|
14
|
+
params[:action] = :facet
|
15
|
+
helper.enforce_access_controls.should be_true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
5
19
|
|
6
20
|
describe "apply_gated_discovery" do
|
7
21
|
before(:each) do
|
@@ -2,32 +2,23 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe Hydra::AccessControlsEvaluation do
|
4
4
|
|
5
|
-
describe "test_permission" do
|
6
|
-
it "should automatically add logged-in users to 'registered' group" do
|
7
|
-
mock_user = mock("User", :email => "logged_in_person@example.com")
|
8
|
-
helper.stubs(:read_groups).returns(["registered"])
|
9
|
-
helper.stubs(:current_user).returns(nil)
|
10
|
-
helper.test_permission(:read).should == false
|
11
|
-
helper.stubs(:current_user).returns(mock_user)
|
12
|
-
helper.test_permission(:read).should == true
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
5
|
describe "editor?" do
|
17
6
|
it "should return true if current_user.is_being_superuser? is true" do
|
18
|
-
mock_user = mock("User"
|
7
|
+
mock_user = mock("User")
|
8
|
+
mock_user.stubs(:email).returns "BigWig@example.com"
|
19
9
|
mock_user.stubs(:is_being_superuser?).returns true
|
20
|
-
|
10
|
+
controller.stubs(:current_user).returns mock_user
|
21
11
|
helper.editor?.should be_true
|
22
12
|
end
|
23
13
|
it "should return false if the session[:user] is not logged in" do
|
24
|
-
|
14
|
+
controller.stubs(:current_user).returns(nil)
|
25
15
|
helper.editor?.should be_false
|
26
16
|
end
|
27
17
|
it "should return false if the session[:user] does not have an editor role" do
|
28
|
-
mock_user = mock("User"
|
18
|
+
mock_user = mock("User")
|
19
|
+
mock_user.stubs(:email).returns "nobody_special@example.com"
|
29
20
|
mock_user.stubs(:is_being_superuser?).returns(false)
|
30
|
-
|
21
|
+
controller.stubs(:current_user).returns(mock_user)
|
31
22
|
helper.editor?.should be_false
|
32
23
|
end
|
33
24
|
end
|
@@ -51,18 +51,4 @@ describe Hydra::RepositoryController do
|
|
51
51
|
|
52
52
|
end
|
53
53
|
|
54
|
-
describe "load_af_instance_from_solr" do
|
55
|
-
it "should return an ActiveFedora object given a valid solr doc same as loading from Fedora" do
|
56
|
-
pid = "hydrangea:fixture_mods_article1"
|
57
|
-
result = ActiveFedora::Base.find_by_solr(pid)
|
58
|
-
solr_doc = result.first
|
59
|
-
solr_af_obj = helper.load_af_instance_from_solr(solr_doc)
|
60
|
-
fed_af_obj = ActiveFedora::Base.find(pid)
|
61
|
-
#check both inbound and outbound match
|
62
|
-
fed_af_obj.outbound_relationships.to_hash.should == solr_af_obj.outbound_relationships.to_hash
|
63
|
-
fed_af_obj.inbound_relationships.should == solr_af_obj.inbound_relationships
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
54
|
end
|
@@ -63,8 +63,8 @@ describe HydraAssetsHelper do
|
|
63
63
|
describe "get_file_asset_count" do
|
64
64
|
describe "with outbound has_part" do
|
65
65
|
before do
|
66
|
-
@asset_object4 =
|
67
|
-
@file_object1 =
|
66
|
+
@asset_object4 =ModsAsset.new
|
67
|
+
@file_object1 = ModsAsset.create
|
68
68
|
@asset_object4.add_relationship(:has_part,@file_object1)
|
69
69
|
@asset_object4.save
|
70
70
|
end
|
@@ -74,17 +74,17 @@ describe HydraAssetsHelper do
|
|
74
74
|
end
|
75
75
|
it "should find one" do
|
76
76
|
#outbound has_part
|
77
|
-
doc =
|
77
|
+
doc = ModsAsset.find_by_solr(@asset_object4.pid).first
|
78
78
|
get_file_asset_count(doc).should == 1
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
describe "with has_part and inbound is_part_of" do
|
83
83
|
before do
|
84
|
-
@asset_object5 =
|
85
|
-
@file_object1 =
|
86
|
-
@file_object2 =
|
87
|
-
@file_object2.
|
84
|
+
@asset_object5 =ModsAsset.create
|
85
|
+
@file_object1 = FileAsset.create
|
86
|
+
@file_object2 = FileAsset.create
|
87
|
+
@file_object2.container = @asset_object5
|
88
88
|
@asset_object5.add_relationship(:has_part,@file_object1)
|
89
89
|
@asset_object5.save
|
90
90
|
@file_object2.save
|
@@ -102,9 +102,9 @@ describe HydraAssetsHelper do
|
|
102
102
|
|
103
103
|
describe "with inbound is_part_of" do
|
104
104
|
before do
|
105
|
-
@asset_object6 =
|
106
|
-
@file_object1 =
|
107
|
-
@file_object1.
|
105
|
+
@asset_object6 =ModsAsset.create
|
106
|
+
@file_object1 = FileAsset.create
|
107
|
+
@file_object1.container = @asset_object6
|
108
108
|
@asset_object6.save
|
109
109
|
@file_object1.save
|
110
110
|
end
|
@@ -120,7 +120,7 @@ describe HydraAssetsHelper do
|
|
120
120
|
|
121
121
|
describe "with inbound is_part_of" do
|
122
122
|
before do
|
123
|
-
@asset_object7 =
|
123
|
+
@asset_object7 =ModsAsset.create
|
124
124
|
end
|
125
125
|
after do
|
126
126
|
@asset_object7.delete
|
@@ -37,7 +37,7 @@ describe Hydra::ModelMethods do
|
|
37
37
|
describe "set_title" do
|
38
38
|
it "should set the title if the descMetadata is a NokogiriDatastream that responds to :title term" do
|
39
39
|
obj = ActiveFedora::Base.new
|
40
|
-
dm = Hydra::ModsArticle.new(obj.inner_object, nil)
|
40
|
+
dm = Hydra::Datastream::ModsArticle.new(obj.inner_object, nil)
|
41
41
|
dm.stubs(:content).returns('')
|
42
42
|
helper.stubs(:datastreams).returns("descMetadata"=>dm)
|
43
43
|
helper.set_title("My title")
|
@@ -50,7 +50,7 @@ describe Hydra::ModelMethods do
|
|
50
50
|
#dm = ActiveFedora::QualifiedDublinCoreDatastream.new nil, nil
|
51
51
|
helper.stubs(:datastreams).returns("descMetadata"=>dm)
|
52
52
|
helper.set_title("My title")
|
53
|
-
dm.
|
53
|
+
dm.title.should == ["My title"]
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require File.expand_path( File.join( File.dirname(__FILE__),'..','spec_helper') )
|
3
3
|
|
4
4
|
|
5
|
-
describe Hydra::CommonModsIndexMethods do
|
5
|
+
describe Hydra::Datastream::CommonModsIndexMethods do
|
6
6
|
describe "extract_person_full_names" do
|
7
7
|
it "should return an array of Solr::Field objects for :person_full_name_facet" do
|
8
8
|
ma = ModsAsset.find("hydrangea:fixture_mods_article1")
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Ability do
|
4
|
+
|
5
|
+
describe "initialize" do
|
6
|
+
it "should automatically add logged-in users to 'registered' group" do
|
7
|
+
mock_user = mock("User")
|
8
|
+
mock_user.stubs(:email).returns "logged_in_person@example.com"
|
9
|
+
mock_user.stubs(:is_being_superuser?).returns false
|
10
|
+
ability = Ability.new(nil)
|
11
|
+
ability.user_groups.should_not include 'registered'
|
12
|
+
ability = Ability.new(mock_user)
|
13
|
+
ability.user_groups.should include 'registered'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require "active_fedora"
|
3
2
|
require "nokogiri"
|
4
3
|
|
5
|
-
describe Hydra::RightsMetadata do
|
4
|
+
describe Hydra::Datastream::RightsMetadata do
|
6
5
|
|
7
6
|
before(:each) do
|
8
7
|
# The way RubyDora loads objects prevents us from stubbing the fedora connection :(
|
9
8
|
# ActiveFedora::RubydoraConnection.stubs(:instance).returns(stub_everything())
|
10
9
|
obj = ActiveFedora::Base.new
|
11
|
-
@sample = Hydra::RightsMetadata.new(obj.inner_object, nil)
|
10
|
+
@sample = Hydra::Datastream::RightsMetadata.new(obj.inner_object, nil)
|
12
11
|
@sample.stubs(:content).returns('')
|
13
12
|
end
|
14
13
|
|
@@ -128,10 +127,10 @@ describe Hydra::RightsMetadata do
|
|
128
127
|
it "should solrize fixture content correctly" do
|
129
128
|
fixture_xml = Nokogiri::XML::Document.parse( File.new(File.join( File.dirname(__FILE__), "../../fixtures/hydrangea_fixture_mods_article1.foxml.xml") ))
|
130
129
|
fixture_rights = fixture_xml.xpath("//foxml:datastream[@ID='rightsMetadata']/foxml:datastreamVersion[last()]/foxml:xmlContent", {'foxml'=>"info:fedora/fedora-system:def/foxml#"}).first.to_xml
|
131
|
-
lsample = Hydra::RightsMetadata.new(nil, nil)
|
130
|
+
lsample = Hydra::Datastream::RightsMetadata.new(nil, nil)
|
132
131
|
lsample.content = fixture_rights
|
133
132
|
# lsample.expects(:content).returns('')
|
134
|
-
lsample = Hydra::RightsMetadata.from_xml(fixture_rights, lsample)
|
133
|
+
lsample = Hydra::Datastream::RightsMetadata.from_xml(fixture_rights, lsample)
|
135
134
|
solr_doc = lsample.to_solr
|
136
135
|
solr_doc["edit_access_person_t"].should == ["researcher1"]
|
137
136
|
solr_doc["edit_access_group_t"].should == ["archivist"]
|
@@ -3,10 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe ModsAsset do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
# Fedora::Repository.stubs(:instance).returns(stub_everything())
|
7
6
|
@asset = ModsAsset.new nil
|
8
|
-
# @asset.stubs(:create_date).returns("2008-07-02T05:09:42.015Z")
|
9
|
-
# @asset.stubs(:modified_date).returns("2008-09-29T21:21:52.892Z")
|
10
7
|
end
|
11
8
|
|
12
9
|
it "Should be a kind of ActiveFedora::Base" do
|
@@ -15,15 +12,9 @@ describe ModsAsset do
|
|
15
12
|
|
16
13
|
it "should set up descMetadata and rightsMetadata datastreams" do
|
17
14
|
@asset.datastreams.should have_key("descMetadata")
|
18
|
-
@asset.datastreams["descMetadata"].should be_instance_of(Hydra::ModsArticle)
|
15
|
+
@asset.datastreams["descMetadata"].should be_instance_of(Hydra::Datastream::ModsArticle)
|
19
16
|
@asset.datastreams.should have_key("rightsMetadata")
|
20
|
-
@asset.datastreams["rightsMetadata"].should be_instance_of(Hydra::RightsMetadata)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should have has_model relationships pointing to commonMetadata and modsObject cModels" do
|
24
|
-
pending "this is waiting for ActiveFedora::Base to support a self.relationships method"
|
25
|
-
@asset.relationships[:self][:has_model].should include("info:fedora/hydra-cModel:commonMetadata")
|
26
|
-
@asset.relationships[:self][:has_model].should include("info:fedora/hydra-cModel:modsObject")
|
17
|
+
@asset.datastreams["rightsMetadata"].should be_instance_of(Hydra::Datastream::RightsMetadata)
|
27
18
|
end
|
28
19
|
|
29
20
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|