hydra-head 4.0.1 → 4.0.2

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.
Files changed (153) hide show
  1. data/.gitmodules +1 -0
  2. data/HISTORY.textile +6 -0
  3. data/app/assets/stylesheets/hydra/styles.css +1 -1
  4. data/app/controllers/user_sessions_controller.rb +1 -1
  5. data/app/helpers/hydra/application_helper_behavior.rb +0 -2
  6. data/app/helpers/hydra/blacklight_helper_behavior.rb +13 -16
  7. data/app/helpers/hydra/generic_content_objects_helper_behavior.rb +1 -6
  8. data/app/helpers/hydra/hydra_fedora_metadata_helper_behavior.rb +3 -1
  9. data/app/helpers/hydra/personalization_helper_behavior.rb +1 -1
  10. data/app/models/common_metadata_asset.rb +1 -1
  11. data/app/models/hydra/ability.rb +1 -1
  12. data/app/models/hydra/datastream/properties.rb +2 -2
  13. data/app/models/hydra/datastream/rights_metadata.rb +2 -2
  14. data/app/models/mods_asset.rb +3 -0
  15. data/app/models/superuser.rb +1 -1
  16. data/app/models/user_attribute.rb +2 -1
  17. data/app/models/uses_default_partials.rb +4 -3
  18. data/app/views/_user_util_links.html.erb +2 -2
  19. data/config/fedora.yml +1 -0
  20. data/config/solr.yml +1 -2
  21. data/hydra-head.gemspec +5 -4
  22. data/lib/generators/hydra/head_generator.rb +1 -1
  23. data/lib/generators/hydra/hyhead_fixtures_generator.rb +10 -10
  24. data/lib/hydra-head/engine.rb +0 -1
  25. data/lib/hydra-head/version.rb +1 -1
  26. data/lib/hydra/access_controls_enforcement.rb +1 -1
  27. data/lib/hydra/file_assets_helper.rb +3 -3
  28. data/lib/hydra/generic_content.rb +1 -1
  29. data/lib/hydra/generic_image.rb +2 -2
  30. data/lib/hydra/generic_user_attributes.rb +6 -4
  31. data/lib/hydra/model_mixins.rb +8 -3
  32. data/lib/hydra/model_mixins/rights_metadata.rb +357 -0
  33. data/lib/hydra/models/file_asset.rb +1 -1
  34. data/lib/hydra/mods_dataset.rb +5 -2
  35. data/lib/hydra/rights_metadata.rb +2 -2
  36. data/lib/hydra/superuser_attributes.rb +6 -5
  37. data/lib/mediashelf/active_fedora_helper.rb +1 -1
  38. data/lib/prev_next_links.rb +8 -3
  39. data/lib/user_attributes_loader.rb +22 -15
  40. data/lib/uva/mods_index_methods.rb +1 -1
  41. data/tasks/hydra-head.rake +4 -15
  42. data/tasks/hydra_jetty.rake +10 -1
  43. data/test_support/etc/Gemfile +13 -4
  44. data/test_support/features/support/paths.rb +5 -5
  45. data/test_support/spec/helpers/blacklight_helper_spec.rb +9 -5
  46. data/test_support/spec/helpers/generic_content_objects_helper_spec.rb +8 -0
  47. data/test_support/spec/helpers/hydra_fedora_metadata_helper_spec.rb +3 -0
  48. data/test_support/spec/helpers/hydra_helper_spec.rb +0 -1
  49. data/test_support/spec/models/generic_image_spec.rb +27 -30
  50. data/test_support/spec/models/user_spec.rb +9 -1
  51. data/test_support/spec/unit/rights_metadata_spec.rb +80 -0
  52. metadata +29 -111
  53. data/Gemfile.lock +0 -302
  54. data/test_support/etc/rvmrc +0 -32
  55. data/vendor/cache/RedCloth-4.2.9.gem +0 -0
  56. data/vendor/cache/actionmailer-3.2.3.gem +0 -0
  57. data/vendor/cache/actionpack-3.2.3.gem +0 -0
  58. data/vendor/cache/active-fedora-4.0.0.gem +0 -0
  59. data/vendor/cache/activemodel-3.2.3.gem +0 -0
  60. data/vendor/cache/activerecord-3.2.3.gem +0 -0
  61. data/vendor/cache/activeresource-3.2.3.gem +0 -0
  62. data/vendor/cache/activesupport-3.2.3.gem +0 -0
  63. data/vendor/cache/addressable-2.2.7.gem +0 -0
  64. data/vendor/cache/akami-1.0.0.gem +0 -0
  65. data/vendor/cache/arel-3.0.2.gem +0 -0
  66. data/vendor/cache/bcrypt-ruby-3.0.1.gem +0 -0
  67. data/vendor/cache/blacklight-3.3.2.gem +0 -0
  68. data/vendor/cache/block_helpers-0.3.3.gem +0 -0
  69. data/vendor/cache/builder-3.0.0.gem +0 -0
  70. data/vendor/cache/cancan-1.6.7.gem +0 -0
  71. data/vendor/cache/capybara-1.1.2.gem +0 -0
  72. data/vendor/cache/childprocess-0.3.1.gem +0 -0
  73. data/vendor/cache/chunky_png-1.2.5.gem +0 -0
  74. data/vendor/cache/compass-0.12.1.gem +0 -0
  75. data/vendor/cache/compass-rails-1.0.1.gem +0 -0
  76. data/vendor/cache/compass-susy-plugin-0.9.gem +0 -0
  77. data/vendor/cache/cucumber-1.1.9.gem +0 -0
  78. data/vendor/cache/cucumber-rails-1.3.0.gem +0 -0
  79. data/vendor/cache/daemons-1.1.8.gem +0 -0
  80. data/vendor/cache/devise-2.0.4.gem +0 -0
  81. data/vendor/cache/diff-lcs-1.1.3.gem +0 -0
  82. data/vendor/cache/equivalent-xml-0.2.9.gem +0 -0
  83. data/vendor/cache/erubis-2.7.0.gem +0 -0
  84. data/vendor/cache/factory_girl-2.6.4.gem +0 -0
  85. data/vendor/cache/fastercsv-1.5.4.gem +0 -0
  86. data/vendor/cache/ffi-1.0.11.gem +0 -0
  87. data/vendor/cache/fssm-0.2.9.gem +0 -0
  88. data/vendor/cache/gherkin-2.9.3.gem +0 -0
  89. data/vendor/cache/gyoku-0.4.4.gem +0 -0
  90. data/vendor/cache/hike-1.2.1.gem +0 -0
  91. data/vendor/cache/httpi-0.9.6.gem +0 -0
  92. data/vendor/cache/i18n-0.6.0.gem +0 -0
  93. data/vendor/cache/jettywrapper-1.2.1.gem +0 -0
  94. data/vendor/cache/journey-1.0.3.gem +0 -0
  95. data/vendor/cache/jquery-rails-2.0.2.gem +0 -0
  96. data/vendor/cache/json-1.6.6.gem +0 -0
  97. data/vendor/cache/kaminari-0.13.0.gem +0 -0
  98. data/vendor/cache/libwebsocket-0.1.3.gem +0 -0
  99. data/vendor/cache/logger-1.2.8.gem +0 -0
  100. data/vendor/cache/mail-2.4.4.gem +0 -0
  101. data/vendor/cache/marc-0.4.4.gem +0 -0
  102. data/vendor/cache/mediashelf-loggable-0.4.9.gem +0 -0
  103. data/vendor/cache/metaclass-0.0.1.gem +0 -0
  104. data/vendor/cache/mime-types-1.18.gem +0 -0
  105. data/vendor/cache/mocha-0.11.0.gem +0 -0
  106. data/vendor/cache/multi_json-1.3.2.gem +0 -0
  107. data/vendor/cache/multipart-post-1.1.2.gem +0 -0
  108. data/vendor/cache/nokogiri-1.5.2.gem +0 -0
  109. data/vendor/cache/nori-1.1.0.gem +0 -0
  110. data/vendor/cache/om-1.6.0.gem +0 -0
  111. data/vendor/cache/orm_adapter-0.0.7.gem +0 -0
  112. data/vendor/cache/polyglot-0.3.3.gem +0 -0
  113. data/vendor/cache/rack-1.4.1.gem +0 -0
  114. data/vendor/cache/rack-cache-1.2.gem +0 -0
  115. data/vendor/cache/rack-ssl-1.3.2.gem +0 -0
  116. data/vendor/cache/rack-test-0.6.1.gem +0 -0
  117. data/vendor/cache/rails-3.2.3.gem +0 -0
  118. data/vendor/cache/railties-3.2.3.gem +0 -0
  119. data/vendor/cache/rake-0.9.2.2.gem +0 -0
  120. data/vendor/cache/rdf-0.3.5.2.gem +0 -0
  121. data/vendor/cache/rdf-rdfxml-0.3.5.gem +0 -0
  122. data/vendor/cache/rdoc-3.12.gem +0 -0
  123. data/vendor/cache/rest-client-1.6.7.gem +0 -0
  124. data/vendor/cache/rsolr-1.0.8.gem +0 -0
  125. data/vendor/cache/rsolr-ext-1.0.3.gem +0 -0
  126. data/vendor/cache/rspec-2.9.0.gem +0 -0
  127. data/vendor/cache/rspec-core-2.9.0.gem +0 -0
  128. data/vendor/cache/rspec-expectations-2.9.1.gem +0 -0
  129. data/vendor/cache/rspec-mocks-2.9.0.gem +0 -0
  130. data/vendor/cache/rspec-rails-2.9.0.gem +0 -0
  131. data/vendor/cache/rubydora-0.5.8.gem +0 -0
  132. data/vendor/cache/rubyzip-0.9.7.gem +0 -0
  133. data/vendor/cache/sanitize-2.0.3.gem +0 -0
  134. data/vendor/cache/sass-3.1.16.gem +0 -0
  135. data/vendor/cache/sass-rails-3.2.5.gem +0 -0
  136. data/vendor/cache/savon-0.9.9.gem +0 -0
  137. data/vendor/cache/selenium-webdriver-2.21.2.gem +0 -0
  138. data/vendor/cache/solrizer-1.2.0.gem +0 -0
  139. data/vendor/cache/solrizer-fedora-2.0.0.gem +0 -0
  140. data/vendor/cache/sprockets-2.1.2.gem +0 -0
  141. data/vendor/cache/sqlite3-1.3.6.gem +0 -0
  142. data/vendor/cache/stomp-1.2.2.gem +0 -0
  143. data/vendor/cache/term-ansicolor-1.0.7.gem +0 -0
  144. data/vendor/cache/thor-0.14.6.gem +0 -0
  145. data/vendor/cache/tilt-1.3.3.gem +0 -0
  146. data/vendor/cache/treetop-1.4.10.gem +0 -0
  147. data/vendor/cache/tzinfo-0.3.33.gem +0 -0
  148. data/vendor/cache/unicode-0.4.2.gem +0 -0
  149. data/vendor/cache/warden-1.1.1.gem +0 -0
  150. data/vendor/cache/wasabi-2.1.0.gem +0 -0
  151. data/vendor/cache/xml-simple-1.1.1.gem +0 -0
  152. data/vendor/cache/xpath-0.1.4.gem +0 -0
  153. data/vendor/cache/yard-0.7.5.gem +0 -0
@@ -1,4 +1,4 @@
1
- # @deprecated. Leftover from Hydrangea; will be removed in release 5.x
1
+ # @deprecated Leftover from Hydrangea; will be removed in release 5.x
2
2
  #
3
3
  # Stanford SolrHelper is a controller layer mixin. It is in the controller scope: request params, session etc.
4
4
  #
@@ -1,11 +1,15 @@
1
1
  # @deprecated no longer used. Will be removed no later than release 6.x
2
2
  # Custom pagination renderer
3
3
  # Call using will_paginate(@results, :renderer => 'PrevNextLinks')
4
+ require 'deprecation'
4
5
  class PrevNextLinks < WillPaginate::LinkRenderer
6
+ extend Deprecation
5
7
 
6
- def initialize
7
- ActiveSupport::Deprecation.warn("PrevNextLinks is deprecated and will be removed in release 5 or 6; we are no longer doing custom pagination.")
8
- super
8
+ self.deprecation_horizon = 'hydra-head 5.x'
9
+
10
+ def initialize(app)
11
+ Deprecation.warn("PrevNextLinks has been deprecated; it will be removed from HydraHead no later than release 6.")
12
+ @app = app
9
13
  end
10
14
 
11
15
  def to_html
@@ -24,5 +28,6 @@ class PrevNextLinks < WillPaginate::LinkRenderer
24
28
  html = links.join(@options[:separator])
25
29
  @options[:container] ? @template.content_tag(:div, html, html_attributes) : html
26
30
  end
31
+ deprecation_deprecate :to_html
27
32
 
28
33
  end
@@ -1,19 +1,26 @@
1
- # @deprecated This code is unused / no longer useful. It will be removed no later than release 6.x
2
- # This middleware is for use in development mode, when User
3
- # is removed/reloaded each request. This makes sure modules
4
- # stay loaded.
5
- class UserAttributesLoader
6
- def initialize(app)
7
- ActiveSupport::Deprecation.warn("UserAttributesLoader has been deprecated; it will be removed no later than release 6.")
8
- @app = app
9
- end
1
+ # @deprecated This code is unused / no longer useful. It will be removed no later than release 6.x
2
+ # This middleware is for use in development mode, when User
3
+ # is removed/reloaded each request. This makes sure modules
4
+ # stay loaded.
5
+ require 'deprecation'
6
+ class UserAttributesLoader
7
+ extend Deprecation
8
+
9
+ self.deprecation_horizon = 'hydra-head 5.x'
10
+
11
+ def initialize(app)
12
+ Deprecation.warn("UserAttributesLoader has been deprecated; it will be removed from HydraHead no later than release 6.")
13
+ @app = app
14
+ end
10
15
 
11
- def call(env)
12
- User.class_eval do
13
- unless ancestors.include?(Hydra::GenericUserAttributes)
14
- include Hydra::GenericUserAttributes
15
- end
16
+ def call(env)
17
+ User.class_eval do
18
+ unless ancestors.include?(Hydra::GenericUserAttributes)
19
+ include Hydra::GenericUserAttributes
16
20
  end
17
- @app.call(env)
18
21
  end
22
+ @app.call(env)
19
23
  end
24
+ deprecation_deprecate :call
25
+
26
+ end
@@ -1,4 +1,4 @@
1
- # @deprecated. Leftover from Hydrangea; will be removed in release 5.x
1
+ # @deprecated Leftover from Hydrangea; will be removed in release 5.x
2
2
  module Uva
3
3
  module ModsIndexMethods
4
4
 
@@ -98,7 +98,7 @@ namespace :hyhead do
98
98
 
99
99
  ### Don't call this directly, use hyhead:cucumber
100
100
  Cucumber::Rake::Task.new(:cmd) do |t|
101
- t.cucumber_opts = "../../test_support/features --format pretty"
101
+ t.cucumber_opts = "../../test_support/features --format progress"
102
102
  end
103
103
  end
104
104
 
@@ -118,15 +118,11 @@ namespace :hyhead do
118
118
 
119
119
  FileUtils.mkdir_p(path)
120
120
 
121
- puts "Copying over .rvmrc file"
122
- FileUtils.cp("./test_support/etc/rvmrc",File.join(path,".rvmrc"))
123
- FileUtils.cd("tmp")
124
- system("source ./test_app/.rvmrc")
125
-
126
121
  puts "Installing rails, bundler and devise"
127
- %x[gem install --no-rdoc --no-ri 'rails' -v "<3.1"]
122
+ %x[gem install --no-rdoc --no-ri 'rails' -v "<4"]
128
123
  %x[gem install --no-rdoc --no-ri 'bundler']
129
124
 
125
+ FileUtils.cd('tmp')
130
126
  puts "Generating new rails app"
131
127
  %x[rails new test_app]
132
128
  errors << 'Error generating new rails test app' unless $?.success?
@@ -137,9 +133,6 @@ namespace :hyhead do
137
133
  puts "Copying Gemfile from test_support/etc"
138
134
  FileUtils.cp('../../test_support/etc/Gemfile','./Gemfile')
139
135
 
140
- puts "Creating local vendor/cache dir and copying gems from hyhead-rails3 gemset"
141
- FileUtils.cp_r(File.join('..','..','vendor','cache'), './vendor')
142
-
143
136
  puts "Copying fixtures into test app spec/fixtures directory"
144
137
  FileUtils.mkdir_p( File.join('.','spec') )
145
138
  FileUtils.cp_r(File.join('..','..','test_support','fixtures'), File.join('.','spec','fixtures'))
@@ -158,7 +151,7 @@ namespace :hyhead do
158
151
  errors << 'Error generating default blacklight install' unless $?.success?
159
152
 
160
153
  puts "generating default hydra-head install"
161
- puts %x[rails generate hydra:head -df] # using -f to force overwriting of solr.yml
154
+ puts %x[rails generate hydra:head -f] # using -f to force overwriting of solr.yml
162
155
  errors << 'Error generating default hydra-head install' unless $?.success?
163
156
 
164
157
  # set log_level to :warn in the test app's test environment. (:debug is too verbose)
@@ -168,12 +161,8 @@ namespace :hyhead do
168
161
  puts "Running rake db:migrate"
169
162
  %x[rake db:migrate]
170
163
  raise "Errors: #{errors.join("; ")}" unless errors.empty?
171
-
172
-
173
164
 
174
165
  FileUtils.cd('../../')
175
-
176
-
177
166
  end
178
167
 
179
168
  task :set_test_host_path do
@@ -6,7 +6,11 @@ namespace :hydra do
6
6
  namespace :jetty do
7
7
  desc "Copies the default Solr & Fedora configs into the bundled Hydra Testing Server"
8
8
  task :config do
9
+ Rake::Task["hydra:jetty:reset"].reenable
10
+ Rake::Task["hydra:jetty:reset"].invoke
11
+ Rake::Task["hydra:jetty:config_fedora"].reenable
9
12
  Rake::Task["hydra:jetty:config_fedora"].invoke
13
+ Rake::Task["hydra:jetty:config_solr"].reenable
10
14
  Rake::Task["hydra:jetty:config_solr"].invoke
11
15
  end
12
16
 
@@ -28,7 +32,7 @@ namespace :hydra do
28
32
  app_root = File.join(File.dirname(__FILE__),"..")
29
33
  end
30
34
 
31
- fcfg = File.join(app_root,"fedora_conf","conf","fedora.fcfg")
35
+ fcfg = File.join(app_root,"fedora_conf","conf","test","fedora.fcfg")
32
36
  puts "PWD:: #{FileUtils.pwd}"
33
37
  if File.exists?(fcfg)
34
38
  puts "copying over fedora.fcfg"
@@ -41,5 +45,10 @@ namespace :hydra do
41
45
  desc "Copies the default SOLR config files and starts up the fedora instance."
42
46
  task :load => [:config, 'jetty:start']
43
47
 
48
+ desc "return development jetty to its pristine state, as pulled from git"
49
+ task :reset => ['jetty:stop'] do
50
+ system("cd jetty && git reset --hard HEAD && git clean -dfx & cd ..")
51
+ sleep 2
52
+ end
44
53
  end
45
54
  end
@@ -5,11 +5,20 @@ source 'http://rubygems.org'
5
5
 
6
6
  gem "rails", '~> 3.2.2'
7
7
 
8
- gem 'sqlite3'
8
+ gem 'blacklight', '~>3.4.1'
9
9
 
10
- gem 'blacklight', '~>3.3.0'
10
+ platforms :jruby do
11
+ gem 'jruby-openssl'
12
+ gem 'activerecord-jdbcsqlite3-adapter'
13
+ gem 'jdbc-sqlite3'
14
+ gem 'therubyrhino'
15
+ end
11
16
 
12
- gem 'therubyracer' # For compiling js - needed on the ci server
17
+ platforms :ruby do
18
+ gem 'sqlite3'
19
+ gem 'execjs'
20
+ gem 'therubyracer'
21
+ end
13
22
 
14
23
  gem 'hydra-head', :path => '../../'
15
24
  gem 'devise'
@@ -23,7 +32,7 @@ group :development, :test do
23
32
  gem 'capybara'
24
33
  gem 'factory_girl', '~> 2.6.0'
25
34
  gem 'rest-client'
26
- gem 'solrizer-fedora', '>=1.2.5'
35
+ gem 'solrizer-fedora', '>=2.1.0'
27
36
  end
28
37
 
29
38
  # Gems used only for assets and not required
@@ -12,7 +12,7 @@ module NavigationHelpers
12
12
  when /the home\s?page/
13
13
  '/'
14
14
  when /the search page/
15
- '/catalog'
15
+ '/'
16
16
  when /logout/
17
17
  destroy_user_session_path
18
18
  when /my account info/
@@ -20,9 +20,9 @@ module NavigationHelpers
20
20
  when /the base search page/
21
21
  '/catalog?q=&search_field=search&action=index&controller=catalog&commit=search'
22
22
  when /the document page for id (.+)/
23
- catalog_path(CGI.escape($1))
23
+ catalog_path($1)
24
24
  when /the edit page for id (.+)/
25
- edit_catalog_path(CGI.escape($1))
25
+ edit_catalog_path($1)
26
26
  when /the catalog index page/
27
27
  catalog_index_path
28
28
  # Add more mappings here.
@@ -32,9 +32,9 @@ module NavigationHelpers
32
32
  # user_profile_path(User.find_by_login($1))
33
33
 
34
34
  when /the edit document page for (.*)$/i
35
- edit_catalog_path(CGI.escape $1)
35
+ edit_catalog_path($1)
36
36
  when /the show document page for (.*)$/i
37
- catalog_path(CGI.escape $1)
37
+ catalog_path($1)
38
38
  when /the delete confirmation page for (.*)$/i
39
39
  delete_catalog_path($1)
40
40
 
@@ -1,15 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe BlacklightHelper do
4
- it "should include HydraHelper" do
5
- BlacklightHelper.included_modules.should include(HydraHelper)
6
- end
7
4
 
8
5
  describe "Overridden blacklight methods" do
9
6
  describe "document_partial_name" do
10
7
 
11
- it "Should lop off everything before the first colin after the slash" do
12
- @config = Blacklight::Configuration.new.configure do |config|
8
+ it "Should lop off everything before the first colin after the slash" do
9
+ @config = Blacklight::Configuration.new.configure do |config|
13
10
  config.show.display_type = 'has_model_s'
14
11
  end
15
12
  helper.stubs(:blacklight_config).returns(@config)
@@ -41,6 +38,13 @@ describe BlacklightHelper do
41
38
 
42
39
  describe "SALT methods" do
43
40
  describe "get_data_with_linked_label" do
41
+ before(:all) do
42
+ @orig_deprecation_behavior = Hydra::BlacklightHelperBehavior.deprecation_behavior
43
+ Hydra::BlacklightHelperBehavior.deprecation_behavior = :silence
44
+ end
45
+ after(:all) do
46
+ Hydra::BlacklightHelperBehavior.deprecation_behavior = @orig_deprecation_behavior
47
+ end
44
48
  before(:each) do
45
49
  @doc = {"field"=>["Item1","Item2","Item3"]}
46
50
  end
@@ -0,0 +1,8 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe GenericContentObjectsHelper do
4
+ it "should have a url for a pid" do
5
+ helper.datastream_disseminator_url('hydra:123', 'sampleDs').should match /http:\/\/127.0.0.1:898\d\/fedora-test\/get\/hydra:123\/sampleDs/
6
+ end
7
+
8
+ end
@@ -106,6 +106,9 @@ describe HydraFedoraMetadataHelper do
106
106
  generated_html.should have_selector "textarea#subject_1.editable-edit.edit", :value => "topic2"
107
107
  generated_html.should have_selector "a.destructive.field"
108
108
  end
109
+ it "should make the text area required when the flag is set" do
110
+ helper.fedora_text_area(@resource, "simple_ds", "subject", :required => true).should have_selector "textarea#subject_0[required]"
111
+ end
109
112
  it "should render an empty control if the field has no values" do
110
113
  helper.fedora_text_area(@resource,"empty_ds","something").should have_selector "textarea#something_0.editable-edit.edit", :value => ""
111
114
  end
@@ -1,5 +1,4 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
- #require 'RedCloth'
3
2
  include HydraHelper
4
3
 
5
4
 
@@ -3,61 +3,58 @@ require "active_fedora"
3
3
 
4
4
  describe GenericImage do
5
5
 
6
- before(:each) do
7
- # Fedora::Repository.stubs(:instance).returns(stub_everything())
8
- @hydra_image = GenericImage.new
9
-
10
- end
6
+ subject { GenericImage.new(:pid=>'test:pid')}
11
7
 
12
8
  it "Should be a kind of ActiveFedora::Base" do
13
- @hydra_image.should be_kind_of(ActiveFedora::Base)
9
+ subject.should be_kind_of(ActiveFedora::Base)
14
10
  end
15
11
 
16
12
  it "should include Hydra Model Methods" do
17
- @hydra_image.class.included_modules.should include(Hydra::ModelMethods)
18
- @hydra_image.should respond_to(:apply_depositor_metadata)
13
+ subject.class.included_modules.should include(Hydra::ModelMethods)
14
+ subject.should respond_to(:apply_depositor_metadata)
19
15
  end
20
16
 
21
17
  it "should include Hydra Generic Image Methods" do
22
- @hydra_image.class.included_modules.should include(Hydra::GenericImage)
23
- @hydra_image.should respond_to(:derivation_options)
18
+ subject.class.included_modules.should include(Hydra::GenericImage)
19
+ subject.should respond_to(:derivation_options)
24
20
  end
25
21
 
26
22
  it "should have accessors for its default datastreams of content and original" do
27
- @hydra_image.should respond_to(:has_content?)
28
- @hydra_image.should respond_to(:content)
29
- @hydra_image.should respond_to(:content=)
30
- @hydra_image.should respond_to(:has_original?)
31
- @hydra_image.should respond_to(:original)
32
- @hydra_image.should respond_to(:original=)
23
+ subject.should respond_to(:has_content?)
24
+ subject.should respond_to(:content)
25
+ subject.should respond_to(:content=)
26
+ subject.should respond_to(:has_original?)
27
+ subject.should respond_to(:original)
28
+ subject.should respond_to(:original=)
33
29
  end
34
30
 
35
31
  it "should have accessors for its default datastreams of max, screen and thumbnail" do
36
- @hydra_image.should respond_to(:has_max?)
37
- @hydra_image.should respond_to(:max)
38
- @hydra_image.should respond_to(:max=)
39
- @hydra_image.should respond_to(:has_screen?)
40
- @hydra_image.should respond_to(:screen)
41
- @hydra_image.should respond_to(:screen=)
42
- @hydra_image.should respond_to(:has_thumbnail?)
43
- @hydra_image.should respond_to(:thumbnail)
44
- @hydra_image.should respond_to(:thumbnail=)
32
+ subject.should respond_to(:has_max?)
33
+ subject.should respond_to(:max)
34
+ subject.should respond_to(:max=)
35
+ subject.should respond_to(:has_screen?)
36
+ subject.should respond_to(:screen)
37
+ subject.should respond_to(:screen=)
38
+ subject.should respond_to(:has_thumbnail?)
39
+ subject.should respond_to(:thumbnail)
40
+ subject.should respond_to(:thumbnail=)
45
41
  end
46
42
 
47
43
  it "should create a max datastream when setting max value to image file" do
48
44
  f = File.new(File.join( File.dirname(__FILE__), "../../fixtures/image.jp2" ))
49
- @hydra_image.max = f
45
+ subject.max = f
50
46
  end
51
47
 
52
48
  describe '#content=' do
53
- it "should create a content datastream when given an image file" do
54
- end
49
+ it "should create a content datastream when given an image file"
55
50
  end
56
51
 
57
52
  describe '#derive_all' do
58
- it "should create a max, screen and thumbnail file" do
59
- end
53
+ it "should create a max, screen and thumbnail file"
60
54
  end
61
55
 
56
+ its(:datastream_url) { should match /http:\/\/127.0.0.1:\d{2,5}\/fedora-test\/objects\/test:pid\/datastreams\/content\/content$/ }
57
+ its(:admin_site) { match /http:\/\/127.0.0.1:\d{2,5}\// }
58
+
62
59
 
63
60
  end
@@ -2,8 +2,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
  require "active_fedora"
3
3
 
4
4
  describe User do
5
-
5
+
6
6
  describe "superuser" do
7
+ before(:all) do
8
+ @orig_deprecation_behavior = Hydra::SuperuserAttributes.deprecation_behavior
9
+ Hydra::SuperuserAttributes.deprecation_behavior = :silence
10
+ end
11
+ after(:all) do
12
+ Hydra::SuperuserAttributes.deprecation_behavior = @orig_deprecation_behavior
13
+ end
14
+
7
15
  before(:each) do
8
16
  @user = User.create(:email=> "testuser@example.com", :password=> "password", :password_confirmation => "password")
9
17
  end
@@ -0,0 +1,80 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Hydra::ModelMixins::RightsMetadata do
4
+ subject { ModsAsset.new }
5
+ it "should have a set of permissions" do
6
+ subject.discover_groups=['group1', 'group2']
7
+ subject.edit_users=['user1']
8
+ subject.read_users=['user2', 'user3']
9
+ subject.permissions.should include({:type=>"group", :access=>"discover", :name=>"group1"},
10
+ {:type=>"group", :access=>"discover", :name=>"group2"},
11
+ {:type=>"user", :access=>"read", :name=>"user2"},
12
+ {:type=>"user", :access=>"read", :name=>"user3"},
13
+ {:type=>"user", :access=>"edit", :name=>"user1"})
14
+ end
15
+
16
+ describe "updating permissions" do
17
+ it "should create new group permissions" do
18
+ subject.permissions = [{:name=>'group1', :access=>'discover', :type=>'group'}]
19
+ subject.permissions.should == [{:type=>'group', :access=>'discover', :name=>'group1'}]
20
+ end
21
+ it "should create new user permissions" do
22
+ subject.permissions = [{:name=>'user1', :access=>'discover', :type=>'user'}]
23
+ subject.permissions.should == [{:type=>'user', :access=>'discover', :name=>'user1'}]
24
+ end
25
+ it "should not replace existing groups" do
26
+ subject.permissions = [{:name=>'group1', :access=>'discover', :type=>'group'}]
27
+ subject.permissions = [{:name=>'group2', :access=>'discover', :type=>'group'}]
28
+ subject.permissions.should == [{:type=>'group', :access=>'discover', :name=>'group1'},
29
+ {:type=>'group', :access=>'discover', :name=>'group2'}]
30
+ end
31
+ it "should not replace existing users" do
32
+ subject.permissions = [{:name=>'user1', :access=>'discover', :type=>'user'}]
33
+ subject.permissions = [{:name=>'user2', :access=>'discover', :type=>'user'}]
34
+ subject.permissions.should == [{:type=>'user', :access=>'discover', :name=>'user1'},
35
+ {:type=>'user', :access=>'discover', :name=>'user2'}]
36
+ end
37
+ it "should update permissions on existing users" do
38
+ subject.permissions = [{:name=>'user1', :access=>'discover', :type=>'user'}]
39
+ subject.permissions = [{:name=>'user1', :access=>'edit', :type=>'user'}]
40
+ subject.permissions.should == [{:type=>'user', :access=>'edit', :name=>'user1'}]
41
+ end
42
+ it "should update permissions on existing groups" do
43
+ subject.permissions = [{:name=>'group1', :access=>'discover', :type=>'group'}]
44
+ subject.permissions = [{:name=>'group1', :access=>'edit', :type=>'group'}]
45
+ subject.permissions.should == [{:type=>'group', :access=>'edit', :name=>'group1'}]
46
+ end
47
+
48
+ end
49
+
50
+ context "with rightsMetadata" do
51
+ before do
52
+ subject.rightsMetadata.update_permissions("person"=>{"person1"=>"read","person2"=>"discover"}, "group"=>{'group-6' => 'read', "group-7"=>'read', 'group-8'=>'edit'})
53
+ subject.save
54
+ end
55
+ it "should have read groups accessor" do
56
+ subject.read_groups.should == ['group-6', 'group-7']
57
+ end
58
+ it "should have read groups string accessor" do
59
+ subject.read_groups_string.should == 'group-6, group-7'
60
+ end
61
+ it "should have read groups writer" do
62
+ subject.read_groups = ['group-2', 'group-3']
63
+ subject.rightsMetadata.groups.should == {'group-2' => 'read', 'group-3'=>'read', 'group-8' => 'edit'}
64
+ subject.rightsMetadata.individuals.should == {"person1"=>"read","person2"=>"discover"}
65
+ end
66
+
67
+ it "should have read groups string writer" do
68
+ subject.read_groups_string = 'umg/up.dlt.staff, group-3'
69
+ subject.rightsMetadata.groups.should == {'umg/up.dlt.staff' => 'read', 'group-3'=>'read', 'group-8' => 'edit'}
70
+ subject.rightsMetadata.individuals.should == {"person1"=>"read","person2"=>"discover"}
71
+ end
72
+ it "should only revoke eligible groups" do
73
+ subject.set_read_groups(['group-2', 'group-3'], ['group-6'])
74
+ # 'group-7' is not eligible to be revoked
75
+ subject.rightsMetadata.groups.should == {'group-2' => 'read', 'group-3'=>'read', 'group-7' => 'read', 'group-8' => 'edit'}
76
+ subject.rightsMetadata.individuals.should == {"person1"=>"read","person2"=>"discover"}
77
+ end
78
+ end
79
+
80
+ end