hydra-core 7.0.0.rc1 → 7.0.0

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: a0dc08c45008a91c9a811309e7046e13c285c2e4
4
- data.tar.gz: 4bffc5b296a5e622b4ab50be22493e2edb6d206b
3
+ metadata.gz: 49c8a1e875c79d9755f8b70f052efd056e804411
4
+ data.tar.gz: 833a9c78e91293b4597d6ed8badee944ff3f4cbb
5
5
  SHA512:
6
- metadata.gz: b6203bbee0370a95eac826762d41b48689867426c7eb649cf6aeb656fda50615244c6bcc2884a8ad7e59bde32022bfccb3f2100a8e2e61ec2c3872f8c1a5c74a
7
- data.tar.gz: ca856202ea8a63dd572076bc42114717eb4bfbd9837548b998b317dfe3657986679b030323e5c245ca412bb51d8423239569cd18f89c1302a587cf7fd1c81bde
6
+ metadata.gz: ffe8839308cdf3dd9d3b7f5fc6ebefd0243c38012da3488b63bc4d764550b1bb940bfc184bbb50e62e0023ae1b509f8332d427d5aea067c02ef468eae04ca88e
7
+ data.tar.gz: 8d441b1be8af28f9ec9c99999d3b8e3c68c126ca4411c013f59b9308610c839ebce2a980a739f9b225a1fce7fc4e29323534c30048450c0d65d01670aff42bcd
@@ -2,21 +2,20 @@ module Hydra
2
2
  module BlacklightHelperBehavior
3
3
  include Blacklight::BlacklightHelperBehavior
4
4
 
5
+ ##
5
6
  # Given a Fedora uri, generate a reasonable partial name
6
7
  # Rails thinks that periods indicate a filename, so escape them with slashes.
7
- # @param [Hash] document the solr document (hash of fields & values)
8
- # @return [String] the name for the display partial
8
+ #
9
+ # @param [SolrDocument] document
10
+ # @param [String, Array] display_type a value suggestive of a partial
11
+ # @return [String] the name of the partial to render
9
12
  # @example
10
- # document_partial_name('has_model_s' => ["info:fedora/hull-cModel:genericContent"])
11
- # => "generic_content"
12
- # document_partial_name('has_model_s' => ["info:fedora/hull-cModel:text.pdf"])
13
- # => "text_pdf"
14
- def document_partial_name(document)
15
- display_type = document[blacklight_config.show.display_type_field]
16
-
17
- return 'default' unless display_type
18
-
19
- Array(display_type).first.gsub(/^[^\/]+\/[^:]+:/,"").gsub(/\./, '_').underscore
20
- end
13
+ # type_field_to_partial_name(["info:fedora/hull-cModel:genericContent"])
14
+ # => 'generic_content'
15
+ # type_field_to_partial_name(["info:fedora/hull-cModel:text.pdf"])
16
+ # => 'text_pdf'
17
+ def type_field_to_partial_name(document, display_type)
18
+ Array(display_type).first.gsub(/^[^\/]+\/[^:]+:/,"").gsub("-","_").underscore.parameterize("_")
19
+ end
21
20
  end
22
21
  end
@@ -1,85 +1,76 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require 'rails/generators'
3
- require 'rails/generators/migration'
4
3
 
5
4
  module Hydra
6
- class HeadGenerator < Rails::Generators::Base
7
- include Rails::Generators::Migration
5
+ class HeadGenerator < Rails::Generators::Base
8
6
 
9
- source_root File.expand_path('../templates', __FILE__)
7
+ source_root File.expand_path('../templates', __FILE__)
10
8
 
11
- argument :model_name, :type => :string , :default => "user"
9
+ argument :model_name, :type => :string , :default => "user"
12
10
 
13
- desc """
14
- This generator makes the following changes to your application:
15
- 1. Creates a database migration for superusers if they do not exist in /db/migrate
16
- 2. Adds additional mime types to you application in the file '/config/initializers/mime_types.rb'
17
- 3. Creates config/initializers/hydra_config.rb
18
- 4. Creates config/fedora.yml and config/solr.yml which you may need to modify to tell the hydra head where to find fedora & solr
19
- 5. Creates a number of role_map config files that are used in the placeholder user roles implementation
20
- Enjoy building your Hydra Head!
21
- """
11
+ desc """
12
+ This generator makes the following changes to your application:
13
+ 1. Creates config/initializers/hydra_config.rb
14
+ 2. Creates config/fedora.yml and config/solr.yml which you may need to modify to tell the hydra head where to find fedora & solr
15
+ 3. Creates a number of role_map config files that are used in the placeholder user roles implementation
16
+ Enjoy building your Hydra Head!
17
+ """
22
18
 
23
- #
24
- # Config Files & Initializers
25
- #
19
+ #
20
+ # Config Files & Initializers
21
+ #
26
22
 
27
- def inject_test_framework
28
- application("\n" <<
29
- " config.generators do |g|\n" <<
30
- " g.test_framework :rspec, :spec => true\n" <<
31
- " end\n\n"
32
- )
23
+ def inject_test_framework
24
+ application("\n" <<
25
+ " config.generators do |g|\n" <<
26
+ " g.test_framework :rspec, :spec => true\n" <<
27
+ " end\n\n"
28
+ )
33
29
 
34
- gem_group :development, :test do
35
- gem "rspec-rails"
36
- gem 'jettywrapper'
37
- end
30
+ gem_group :development, :test do
31
+ gem "rspec-rails"
32
+ gem 'jettywrapper'
33
+ end
38
34
 
39
- Bundler.with_clean_env do
40
- run "bundle install"
35
+ Bundler.with_clean_env do
36
+ run "bundle install"
37
+ end
41
38
  end
42
- end
43
39
 
44
- # Copy all files in templates/config directory to host config
45
- def create_configuration_files
46
- copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
40
+ # Copy all files in templates/config directory to host config
41
+ def create_configuration_files
42
+ copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
47
43
 
48
- # Initializers
49
- file_path = "config/initializers/hydra_config.rb"
50
- copy_file "config/initializers/hydra_config.rb", file_path
51
- unless model_name == 'user'
52
- insert_into_file file_path, :after => 'Hydra.configure do |config|' do
53
- "\n config.user_model = '#{model_name.classify}'"
44
+ # Initializers
45
+ file_path = "config/initializers/hydra_config.rb"
46
+ copy_file "config/initializers/hydra_config.rb", file_path
47
+ unless model_name == 'user'
48
+ insert_into_file file_path, :after => 'Hydra.configure do |config|' do
49
+ "\n config.user_model = '#{model_name.classify}'"
50
+ end
54
51
  end
55
- end
56
-
57
- copy_file "config/initializers/action_dispatch_http_upload_monkey_patch.rb", "config/initializers/action_dispatch_http_upload_monkey_patch.rb"
58
52
 
59
- # Role Mappings
60
- copy_file "config/role_map_cucumber.yml", "config/role_map_cucumber.yml"
61
- copy_file "config/role_map_development.yml", "config/role_map_development.yml"
62
- copy_file "config/role_map_production.yml", "config/role_map_production.yml"
63
- copy_file "config/role_map_test.yml", "config/role_map_test.yml"
53
+ # Role Mappings
54
+ copy_file "config/role_map.yml", "config/role_map.yml"
64
55
 
65
- # CanCan ability.rb
66
- copy_file "ability.rb", "app/models/ability.rb"
56
+ # CanCan ability.rb
57
+ copy_file "ability.rb", "app/models/ability.rb"
67
58
 
68
- # Fedora & Solr YAML files
69
- invoke('active_fedora:config')
70
- end
59
+ # Fedora & Solr YAML files
60
+ invoke('active_fedora:config')
61
+ end
71
62
 
72
- # Add Hydra behaviors to the user model
73
- def inject_hydra_user_behavior
74
- file_path = "app/models/#{model_name.underscore}.rb"
75
- if File.exists?(file_path)
76
- inject_into_class file_path, model_name.classify do
77
- "# Connects this user object to Hydra behaviors. " +
78
- "\n include Hydra::User\n"
63
+ # Add Hydra behaviors to the user model
64
+ def inject_hydra_user_behavior
65
+ file_path = "app/models/#{model_name.underscore}.rb"
66
+ if File.exists?(file_path)
67
+ inject_into_class file_path, model_name.classify do
68
+ "# Connects this user object to Hydra behaviors. " +
69
+ "\n include Hydra::User\n"
70
+ end
71
+ else
72
+ puts " \e[31mFailure\e[0m Hydra requires a user object in order to apply access controls. This generators assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails -g hydra:head client"
79
73
  end
80
- else
81
- puts " \e[31mFailure\e[0m Hydra requires a user object in order to apply access controls. This generators assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails -g hydra:head client"
82
74
  end
83
- end
84
- end # HeadGenerator
75
+ end # HeadGenerator
85
76
  end # Hydra
@@ -9,8 +9,6 @@ class CatalogController < ApplicationController
9
9
  before_filter :enforce_show_permissions, :only=>:show
10
10
  # This applies appropriate access controls to all solr queries
11
11
  CatalogController.solr_search_params_logic += [:add_access_controls_to_solr_params]
12
- # This filters out objects that you want to exclude from search results, like FileAssets
13
- CatalogController.solr_search_params_logic += [:exclude_unwanted_models]
14
12
 
15
13
 
16
14
  configure_blacklight do |config|
@@ -0,0 +1,19 @@
1
+ development:
2
+ archivist:
3
+ - archivist1@example.com
4
+ test:
5
+ archivist:
6
+ - archivist1@example.com
7
+ - archivist2@example.com
8
+ - leland_himself@example.com
9
+ admin_policy_object_editor:
10
+ - archivist1@example.com
11
+ donor:
12
+ - donor1@example.com
13
+ - leland_himself@example.com
14
+ researcher:
15
+ - archivist1@example.com
16
+ - researcher1@example.com
17
+ patron:
18
+ - patron1@example.com
19
+ - leland_himself@example.com
@@ -1,4 +1,4 @@
1
1
  module HydraHead
2
- VERSION = "7.0.0.rc1"
2
+ VERSION = "7.0.0"
3
3
  end
4
4
 
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: 7.0.0.rc1
4
+ version: 7.0.0
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: 2014-03-18 00:00:00.000000000 Z
12
+ date: 2014-03-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -51,14 +51,14 @@ dependencies:
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 7.0.0.rc1
54
+ version: 7.0.0
55
55
  type: :runtime
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 7.0.0.rc1
61
+ version: 7.0.0
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: jettywrapper
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -143,34 +143,24 @@ files:
143
143
  - app/controllers/concerns/hydra/controller.rb
144
144
  - app/controllers/concerns/hydra/controller/controller_behavior.rb
145
145
  - app/controllers/concerns/hydra/controller/download_behavior.rb
146
- - app/controllers/concerns/hydra/controller/upload_behavior.rb
147
146
  - app/helpers/blacklight_helper.rb
148
147
  - app/helpers/hydra/blacklight_helper_behavior.rb
149
148
  - app/models/concerns/hydra/model_methods.rb
150
149
  - app/models/concerns/hydra/models.rb
151
- - app/models/concerns/hydra/models/file_asset.rb
152
150
  - app/models/concerns/hydra/solr.rb
153
- - app/models/file_asset.rb
154
151
  - app/models/hydra/datastream/properties.rb
155
152
  - app/models/mods_asset.rb
156
153
  - config/jetty.yml
157
154
  - config/locales/hydra.en.yml
158
155
  - hydra-core.gemspec
159
156
  - lib/application_helper.rb
160
- - lib/generators/hydra/cucumber_support_generator.rb
161
157
  - lib/generators/hydra/head_generator.rb
162
158
  - lib/generators/hydra/hyhead_fixtures_generator.rb
163
159
  - lib/generators/hydra/jetty_generator.rb
164
160
  - lib/generators/hydra/templates/ability.rb
165
161
  - lib/generators/hydra/templates/catalog_controller.rb
166
- - lib/generators/hydra/templates/config/fedora.yml
167
- - lib/generators/hydra/templates/config/initializers/action_dispatch_http_upload_monkey_patch.rb
168
162
  - lib/generators/hydra/templates/config/initializers/hydra_config.rb
169
- - lib/generators/hydra/templates/config/role_map_cucumber.yml
170
- - lib/generators/hydra/templates/config/role_map_development.yml
171
- - lib/generators/hydra/templates/config/role_map_production.yml
172
- - lib/generators/hydra/templates/config/role_map_test.yml
173
- - lib/generators/hydra/templates/config/solr.yml
163
+ - lib/generators/hydra/templates/config/role_map.yml
174
164
  - lib/hydra-core.rb
175
165
  - lib/hydra-head/engine.rb
176
166
  - lib/hydra-head/version.rb
@@ -183,10 +173,8 @@ files:
183
173
  - spec/controllers/downloads_controller_spec.rb
184
174
  - spec/factories.rb
185
175
  - spec/helpers/blacklight_helper_spec.rb
186
- - spec/helpers/upload_behavior_spec.rb
187
176
  - spec/lib/catalog_spec.rb
188
177
  - spec/lib/model_methods_spec.rb
189
- - spec/models/file_asset_spec.rb
190
178
  - spec/models/mods_asset_spec.rb
191
179
  - spec/models/solr_document_spec.rb
192
180
  - spec/models/user_spec.rb
@@ -225,9 +213,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
213
  version: 1.9.3
226
214
  required_rubygems_version: !ruby/object:Gem::Requirement
227
215
  requirements:
228
- - - ">"
216
+ - - ">="
229
217
  - !ruby/object:Gem::Version
230
- version: 1.3.1
218
+ version: '0'
231
219
  requirements: []
232
220
  rubyforge_project:
233
221
  rubygems_version: 2.2.2
@@ -241,10 +229,8 @@ test_files:
241
229
  - spec/controllers/downloads_controller_spec.rb
242
230
  - spec/factories.rb
243
231
  - spec/helpers/blacklight_helper_spec.rb
244
- - spec/helpers/upload_behavior_spec.rb
245
232
  - spec/lib/catalog_spec.rb
246
233
  - spec/lib/model_methods_spec.rb
247
- - spec/models/file_asset_spec.rb
248
234
  - spec/models/mods_asset_spec.rb
249
235
  - spec/models/solr_document_spec.rb
250
236
  - spec/models/user_spec.rb
@@ -1,38 +0,0 @@
1
- module Hydra::Controller::UploadBehavior
2
-
3
- # Creates a File Asset, adding the posted blob to the File Asset's datastreams and saves the File Asset
4
- #
5
- # @return [FileAsset] the File Asset
6
- def create_and_save_file_assets_from_params
7
- if params.has_key?(:Filedata)
8
- @file_assets = []
9
- params[:Filedata].each do |file|
10
- @file_asset = FileAsset.new
11
- @file_asset.label = file.original_filename
12
- add_posted_blob_to_asset(@file_asset, file, file.original_filename)
13
- @file_asset.save!
14
- @file_assets << @file_asset
15
- end
16
- return @file_assets
17
- else
18
- render :text => "400 Bad Request", :status => 400
19
- end
20
- end
21
-
22
- # Puts the contents of params[:Filedata] (posted blob) into a datastream within the given @asset
23
- # Sets asset label and title to filename if they're empty
24
- #
25
- # @param [FileAsset] asset the File Asset to add the blob to
26
- # @param [#read] file the IO object that is the blob
27
- # @param [String] file the IO object that is the blob
28
- # @return [FileAsset] file the File Asset
29
- def add_posted_blob_to_asset(asset, file, file_name)
30
- file_name ||= file.original_filename
31
- asset.add_file(file, datastream_id, file_name)
32
- end
33
-
34
- #Override this if you want to specify the datastream_id (dsID) for the created blob
35
- def datastream_id
36
- "content"
37
- end
38
- end
@@ -1,75 +0,0 @@
1
- # will move to lib/hydra/model/file_asset_behavior in release 5.x
2
- module Hydra
3
- module Models
4
- # Defines Behaviors for a FileAsset Model
5
- # Conforms to the Hydra genericContent cModel -- the "content" is in a datastream called content
6
- # TODO: Could we just move this behavior into app/models/file_asset.rb?
7
- module FileAsset
8
- extend ActiveSupport::Concern
9
- included do
10
- include Hydra::ModelMethods
11
-
12
- belongs_to :container, :class_name=>'ActiveFedora::Base', :property=>:is_part_of
13
- has_metadata :name => "descMetadata", :type => ActiveFedora::QualifiedDublinCoreDatastream do |m|
14
- end
15
- end
16
-
17
-
18
- # Returns a human readable filesize appropriate for the given number of bytes (ie. automatically chooses 'bytes','KB','MB','GB','TB')
19
- # Based on a bit of python code posted here: http://blogmag.net/blog/read/38/Print_human_readable_file_size
20
- # @param [Numeric] num file size in bits
21
- def bits_to_human_readable(num)
22
- ['bytes','KB','MB','GB','TB'].each do |x|
23
- if num < 1024.0
24
- return "#{num.to_i} #{x}"
25
- else
26
- num = num/1024.0
27
- end
28
- end
29
- end
30
-
31
-
32
- def label
33
- descMetadata.title.first
34
- end
35
-
36
- def label=(label)
37
- super
38
- descMetadata.title = label
39
- end
40
-
41
- # augments add_file_datastream to also put file size (in bytes/KB/MB/GB/TB) in dc:extent
42
- def add_file_datastream(file, opts={})
43
- super
44
- if file.respond_to?(:size)
45
- size = bits_to_human_readable(file.size)
46
- elsif file.kind_of?(File)
47
- size = bits_to_human_readable(File.size(file))
48
- else
49
- size = ""
50
- end
51
- datastreams["descMetadata"].extent = size
52
- end
53
-
54
- # Override ActiveFedora::Base.to_solr to...
55
- # Check if we are dealing with a child of FileAsset and if so when calling to_solr from Solrizer indexer we want to skip loading parent metadata again
56
- #
57
- # if known models greater than one (without ActiveFedora::Base) and
58
- # known models contains a child of FileAsset and
59
- # opts[:model_only] == true and
60
- # current object class is FileAsset
61
- # that means that the child already has had to_solr called which included metadata from FileAsset
62
- # if any of the above is false then call to_solr as normal
63
- def to_solr(solr_doc=Hash.new, opts={})
64
-
65
- active_fedora_model_s = solr_doc["active_fedora_model_s"] if solr_doc["active_fedora_model_s"]
66
- actual_class = active_fedora_model_s.constantize if active_fedora_model_s
67
- if actual_class && actual_class != self.class && actual_class.superclass == ::FileAsset
68
- solr_doc
69
- else
70
- super(solr_doc,opts)
71
- end
72
- end
73
- end
74
- end
75
- end
@@ -1,5 +0,0 @@
1
- # model for a FileAsset ActiveFedora object
2
- # a file asset is a generic notion of a file, which could have, for example, image or text or video behaviors.
3
- class FileAsset < ActiveFedora::Base
4
- include Hydra::Models::FileAsset
5
- end
@@ -1,29 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'rails/generators'
3
- require 'rails/generators/migration'
4
-
5
- module Hydra
6
- class CucumberSupportGenerator < Rails::Generators::Base
7
-
8
- source_root File.expand_path('../../../../test_support/features', __FILE__)
9
-
10
- argument :features_dir, :type => :string , :default => "features"
11
-
12
- desc """
13
- This Generator copies Hydra's cucumber step definitions and paths into your application's features directory.
14
- We have plans to provide the step definitions directly through the hydra-head gem without requiring this step of copying the files.
15
- In the meantime, you need to copy the files in order to use them.
16
-
17
- Defaults to assuming that your cucumber features live in a directory called \"features\". To pass in an alternative path to your features directory,
18
-
19
- rails generate hydra:cucumber_support test_support/features
20
-
21
- """
22
-
23
- def copy_cucumber_support
24
- directory("step_definitions", "#{features_dir}/step_definitions")
25
- copy_file("support/paths.rb", "#{features_dir}/support/paths.rb")
26
- end
27
-
28
- end
29
- end
@@ -1,14 +0,0 @@
1
- development:
2
- user: fedoraAdmin
3
- password: fedoraAdmin
4
- url: http://127.0.0.1:8983/fedora
5
- test: &TEST
6
- user: fedoraAdmin
7
- password: fedoraAdmin
8
- url: <%= "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8983}/fedora-test" %>
9
- production:
10
- user: fedoraAdmin
11
- password: fedoraAdmin
12
- url: http://your.production.server:8080/fedora
13
- cucumber:
14
- <<: *TEST
@@ -1,12 +0,0 @@
1
- module ActionDispatch
2
- module Http
3
- class UploadedFile
4
- def closed?
5
- @tempfile.closed?
6
- end
7
- def close
8
- @tempfile.close
9
- end
10
- end
11
- end
12
- end
@@ -1,10 +0,0 @@
1
- archivist:
2
- - archivist1@example.com
3
- donor:
4
- - donor1@example.com
5
- researcher:
6
- - researcher1@example.com
7
- patron:
8
- - patron1@example.com
9
- admin_policy_object_editor:
10
- - archivist1@example.com
@@ -1,12 +0,0 @@
1
- uva-only:
2
- - uva-only
3
- archivist:
4
- - archivist1@example.com
5
- donor:
6
- - donor1@example.com
7
- researcher:
8
- - researcher1@example.com
9
- patron:
10
- - patron1@example.com
11
- admin_policy_object_editor:
12
- - archivist1@example.com
@@ -1,15 +0,0 @@
1
- archivist:
2
- - archivist1@example.com
3
- - archivist2@example.com
4
- - leland_himself@example.com
5
- admin_policy_object_editor:
6
- - archivist1@example.com
7
- donor:
8
- - donor1@example.com
9
- - leland_himself@example.com
10
- researcher:
11
- - archivist1@example.com
12
- - researcher1@example.com
13
- patron:
14
- - patron1@example.com
15
- - leland_himself@example.com
@@ -1,10 +0,0 @@
1
- # This is a sample config file that does not have multiple solr instances. You will also need to be sure to
2
- # edit the fedora.yml file to match the solr URL for active-fedora.
3
- development:
4
- url: http://localhost:8983/solr/development
5
- test: &TEST
6
- url: <%= "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8983}/solr/test" %>
7
- cucumber:
8
- <<: *TEST
9
- production:
10
- url: http://your.production.server:8080/bl_solr/core0
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Hydra::Controller::UploadBehavior do
4
-
5
- it "should respond to datastream_id" do
6
- helper.should respond_to :datastream_id ### API method, test that it's there to be overridden
7
- end
8
-
9
- describe "add_posted_blob_to_asset" do
10
- it "should set object title and label, relying on datastream_id to set dsId" do
11
- mock_file = double("File")
12
- file_name = "Posted Filename.foo"
13
- helper.stub(:params).and_return( :Filedata=>[mock_file], :Filename=>file_name, "container_id"=>"hydrangea:2973" )
14
- mock_fa = double("file asset")
15
- helper.stub(:datastream_id).and_return('bar')
16
- mock_fa.should_receive(:add_file).with(mock_file, 'bar', file_name)
17
- helper.add_posted_blob_to_asset(mock_fa,mock_file, file_name) # this is the deprecated 2 argument method
18
- end
19
-
20
- it "should support submissions from swfupload" do
21
- mock_file = double("File")
22
- file_name = "Posted Filename.foo"
23
- helper.stub(:params).and_return( :Filedata=>[mock_file], :Filename=>file_name, "container_id"=>"hydrangea:2973" )
24
- mock_fa = double("file asset")
25
- mock_fa.should_receive(:add_file).with(mock_file, 'content', file_name)
26
- helper.add_posted_blob_to_asset(mock_fa,mock_file, file_name)
27
- end
28
- it "should support submissions from single-file uploader, defaulting to dsId of content" do
29
- mock_file = double("File")
30
- file_name = "Posted Filename.foo"
31
- helper.stub(:params).and_return( :Filedata=>[mock_file], :container_id=>"hydrangea:2973" )
32
- mock_fa = double("file asset")
33
- mock_fa.should_receive(:add_file).with(mock_file, 'content', file_name)
34
- helper.add_posted_blob_to_asset(mock_fa,mock_file, file_name)
35
- end
36
- end
37
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FileAsset do
4
-
5
- before(:each) do
6
- @file_asset = FileAsset.new
7
- @file_asset.stub(:create_date).and_return("2008-07-02T05:09:42.015Z")
8
- @file_asset.stub(:modified_date).and_return("2008-09-29T21:21:52.892Z")
9
- end
10
-
11
- it "Should be a kind of ActiveFedora::Base" do
12
- @file_asset.should be_kind_of(ActiveFedora::Base)
13
- end
14
-
15
- it "should include Hydra Model Methods" do
16
- @file_asset.class.included_modules.should include(Hydra::ModelMethods)
17
- @file_asset.should respond_to(:apply_depositor_metadata)
18
- end
19
-
20
- describe 'label' do
21
- asset = FileAsset.new
22
- asset.label = 'image.jp2'
23
- asset.label.should == 'image.jp2'
24
- end
25
- end