hydra-core 9.10.0 → 10.0.0.beta1

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: 7e7a09ee2cc35ca27116e0036a393f4926302802
4
- data.tar.gz: 5922a2cb6604399db64ab354164b73881af55f9e
3
+ metadata.gz: b7909e0bdec3dbba0591ceb4204e1ca6afaffb50
4
+ data.tar.gz: 18593bc5376cf62b90f4e0ed5da2b7ce12f4138e
5
5
  SHA512:
6
- metadata.gz: 6392ef2d4d05964fcf1f07a1f4e447a37958c7b5f01701e8530a094b69021f2ac198e34d2d2a54595f7ef2a68633437410c5b32f368fc3ff3d81a5459be8e9d9
7
- data.tar.gz: 61c0009af27eb9bcf16ae8e7805876e0c43bb73d6e8b841aefc3ca9c043f1a939f3ff66a902eb64ae635528229eb0d55f9127bb1dc94838d88aba865b14fc5ad
6
+ metadata.gz: d75dcabf8cc6510523dcab0a7a7dc51224716d0ce9da12fa147c2eaefba0a339fdf2307d2131330b427fa6d816f08481b5c9590c554e4bf049c2850aab64d36d
7
+ data.tar.gz: 379c8cc1b8ec7e1db064e50b65d3ce881ed8f5c976022c1be50d50e41d6085654e9477392a9fc7675d6cfad67e0b627b5660c4c67c85edee1d41fbceca8aa312
data/Rakefile CHANGED
@@ -1,5 +1,10 @@
1
1
  require 'rake/testtask'
2
2
  require 'bundler'
3
+ require 'rspec/core/rake_task'
3
4
  Bundler::GemHelper.install_tasks
4
5
 
5
6
  Dir.glob('tasks/*.rake').each { |r| import r }
7
+ desc "Run specs"
8
+ RSpec::Core::RakeTask.new
9
+
10
+ task :default => :spec
@@ -2,7 +2,6 @@ module Hydra
2
2
  module Controller
3
3
  module DownloadBehavior
4
4
  extend ActiveSupport::Concern
5
- extend Deprecation
6
5
 
7
6
  included do
8
7
  include Hydra::Controller::ControllerBehavior
@@ -42,11 +41,6 @@ module Hydra
42
41
  @asset ||= ActiveFedora::Base.find(params[asset_param_key])
43
42
  end
44
43
 
45
- def datastream
46
- Deprecation.warn(DownloadBehavior, "datastream is deprecated and will be removed in hydra-head 10.0. Use `file` instead.")
47
- file
48
- end
49
-
50
44
  def file
51
45
  @file ||= load_file
52
46
  end
@@ -58,21 +52,12 @@ module Hydra
58
52
  # @return [ActiveFedora::File] the file
59
53
  def load_file
60
54
  file_path = params[:file]
61
- if !file_path && params[:datastream_id]
62
- Deprecation.warn(DownloadBehavior, "Parameter `datastream_id` is deprecated and will be removed in hydra-head 10.0. Use `file` instead.")
63
- file_path = params[:datastream_id]
64
- end
65
55
  f = asset.attached_files[file_path] if file_path
66
56
  f ||= default_file
67
57
  raise "Unable to find a file for #{asset}" if f.nil?
68
58
  f
69
59
  end
70
60
 
71
- def datastream_to_show
72
- Deprecation.warn(DownloadBehavior, "datastream_to_show is deprecated and will be removed in hydra-head 10.0")
73
- load_file
74
- end
75
-
76
61
  # Handle the HTTP show request
77
62
  def send_content
78
63
 
@@ -92,13 +77,6 @@ module Hydra
92
77
  { disposition: 'inline', type: file.mime_type, filename: file_name }
93
78
  end
94
79
 
95
- # Override this if you'd like a different filename
96
- # @return [String] the filename
97
- def datastream_name
98
- Deprecation.warn(DownloadBehavior, "datastream_name is deprecated and will be removed in hydra-head 10.0, use file_name instead")
99
- file_name
100
- end
101
-
102
80
  # Override this if you'd like a different filename
103
81
  # @return [String] the filename
104
82
  def file_name
@@ -151,31 +129,15 @@ module Hydra
151
129
  response.stream.close
152
130
  end
153
131
 
154
- def default_content_ds
155
- Deprecation.warn(DownloadBehavior, "default_content_ds is deprecated and will be removed in hydra-head 10.0, use default_file instead")
156
- default_file
157
- end
158
-
159
132
  def default_file
160
133
  if asset.class.respond_to?(:default_file_path)
161
134
  asset.attached_files[asset.class.default_file_path]
162
- elsif asset.class.respond_to?(:default_content_ds)
163
- Deprecation.warn(DownloadBehavior, "default_content_ds is deprecated and will be removed in hydra-head 10.0, use default_file_path instead")
164
- asset.attached_files[asset.class.default_content_ds]
165
135
  elsif asset.attached_files.key?(DownloadsController.default_file_path)
166
136
  asset.attached_files[DownloadsController.default_file_path]
167
- elsif asset.attached_files.key?(DownloadsController.default_content_dsid)
168
- Deprecation.warn(DownloadBehavior, "DownloadsController.default_content_dsid is deprecated and will be removed in hydra-head 10.0, use default_file_path instead")
169
- asset.attached_files[DownloadsController.default_content_dsid]
170
137
  end
171
138
  end
172
139
 
173
140
  module ClassMethods
174
- def default_content_dsid
175
- Deprecation.warn(DownloadBehavior, "default_content_dsid is deprecated and will be removed in hydra-head 10.0, use default_file_path instead")
176
- default_file_path
177
- end
178
-
179
141
  def default_file_path
180
142
  "content"
181
143
  end
data/lib/hydra-core.rb CHANGED
@@ -1,11 +1,7 @@
1
1
  require 'hydra-access-controls'
2
2
  require 'deprecation'
3
3
 
4
- module HydraHead
5
- extend Deprecation
4
+ module HydraHead
6
5
  require 'hydra-head/engine' if defined?(Rails)
7
- def self.add_routes(router, options = {})
8
- Deprecation.warn HydraHead, "add_routes has been removed." # remove this warning in hydra-head 8
9
- end
10
6
  end
11
7
 
@@ -1,3 +1,3 @@
1
1
  module HydraHead
2
- VERSION = "9.10.0"
2
+ VERSION = "10.0.0.beta1"
3
3
  end
data/spec/.gitignore CHANGED
@@ -1 +0,0 @@
1
- internal
@@ -19,7 +19,7 @@ describe DownloadsController do
19
19
  before do
20
20
  class ContentHolder < ActiveFedora::Base
21
21
  include Hydra::AccessControls::Permissions
22
- contains 'thumbnail'
22
+ has_subresource 'thumbnail'
23
23
  end
24
24
  @user = User.new.tap {|u| u.email = 'email@example.com'; u.password = 'password'; u.save}
25
25
  end
@@ -68,18 +68,9 @@ describe DownloadsController do
68
68
  sign_in @user
69
69
  allow_any_instance_of(User).to receive(:groups).and_return([])
70
70
  end
71
- describe "#show" do
72
- it "should default to returning default download configured by object" do
73
- allow(ContentHolder).to receive(:default_content_ds).and_return('buzz')
74
- expect(Deprecation).to receive(:warn)
75
- get :show, id: obj
76
- expect(response).to be_successful
77
- expect(response.headers['Content-Type']).to eq "image/png"
78
- expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"buzz.png\""
79
- expect(response.body).to eq 'fizz'
80
- end
81
71
 
82
- it "should default to returning default download configured by object" do
72
+ describe "#show" do
73
+ it "defaults to returning default download configured by object" do
83
74
  allow(ContentHolder).to receive(:default_file_path).and_return('buzz')
84
75
  get :show, id: obj
85
76
  expect(response).to be_successful
@@ -88,7 +79,7 @@ describe DownloadsController do
88
79
  expect(response.body).to eq 'fizz'
89
80
  end
90
81
 
91
- it "should default to returning default download configured by controller" do
82
+ it "defaults to returning default download configured by controller" do
92
83
  expect(DownloadsController.default_file_path).to eq "content"
93
84
  get :show, id: obj
94
85
  expect(response).to be_successful
@@ -8,14 +8,12 @@ describe SearchBuilder do
8
8
  let(:search_builder) { described_class }
9
9
 
10
10
  subject do
11
- Deprecation.silence(Hydra::SearchBuilder) do
12
- search_builder.new(processor_chain, context)
13
- end
11
+ search_builder.new(processor_chain, context)
14
12
  end
15
13
  before { subject.current_ability = current_ability }
16
14
 
17
15
  it "extends classes with the necessary Hydra modules" do
18
- expect(Hydra::SearchBuilder.included_modules).to include(Hydra::AccessControlsEnforcement)
16
+ expect(described_class.included_modules).to include(Hydra::AccessControlsEnforcement)
19
17
  end
20
18
 
21
19
  context "when a query is generated" do
@@ -24,19 +22,4 @@ describe SearchBuilder do
24
22
  subject.query
25
23
  end
26
24
  end
27
-
28
- context "the deprecated Hydra::SearchBuilder" do
29
- let(:search_builder) { Hydra::SearchBuilder }
30
-
31
- it "extends classes with the necessary Hydra modules" do
32
- expect(Hydra::SearchBuilder.included_modules).to include(Hydra::AccessControlsEnforcement)
33
- end
34
-
35
- context "when a query is generated" do
36
- it "triggers add_access_controls_to_solr_params" do
37
- expect(subject).to receive(:add_access_controls_to_solr_params)
38
- subject.query
39
- end
40
- end
41
- end
42
25
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,9 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
-
4
1
  ENV["RAILS_ENV"] ||= "test"
5
2
 
6
- require File.expand_path("config/environment", ENV['RAILS_ROOT'] || File.expand_path("../internal", __FILE__))
3
+ require 'engine_cart'
4
+ path = File.expand_path(File.join('..', '..', '..', '.internal_test_app'), __FILE__)
5
+ EngineCart.load_application! path
6
+
7
7
  require 'bundler/setup'
8
8
  require 'rspec/rails'
9
9
  require 'hydra-core'
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.10.0
4
+ version: 10.0.0.beta1
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: 2016-04-19 00:00:00.000000000 Z
12
+ date: 2016-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 9.10.0
34
+ version: 10.0.0.beta1
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 9.10.0
41
+ version: 10.0.0.beta1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: sqlite3
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -111,19 +111,15 @@ files:
111
111
  - app/controllers/concerns/hydra/controller/controller_behavior.rb
112
112
  - app/controllers/concerns/hydra/controller/download_behavior.rb
113
113
  - app/controllers/concerns/hydra/controller/ip_based_ability.rb
114
- - app/controllers/concerns/hydra/controller/search_builder.rb
115
114
  - app/helpers/blacklight_helper.rb
116
115
  - app/helpers/hydra/blacklight_helper_behavior.rb
117
116
  - app/models/concerns/hydra/content_negotiation.rb
118
- - app/models/concerns/hydra/model_methods.rb
119
117
  - app/models/concerns/hydra/models.rb
120
118
  - app/models/concerns/hydra/solr.rb
121
119
  - app/models/hydra/content_negotiation/clean_graph_repository.rb
122
120
  - app/models/hydra/content_negotiation/fedora_uri_replacer.rb
123
121
  - app/models/hydra/content_negotiation/graph_finder.rb
124
122
  - app/models/hydra/content_negotiation/replacing_graph_finder.rb
125
- - app/models/hydra/datastream/properties.rb
126
- - app/search_builders/hydra/search_builder.rb
127
123
  - config/locales/hydra.en.yml
128
124
  - hydra-core.gemspec
129
125
  - lib/application_helper.rb
@@ -136,9 +132,7 @@ files:
136
132
  - lib/hydra-core.rb
137
133
  - lib/hydra-head/engine.rb
138
134
  - lib/hydra-head/version.rb
139
- - lib/mods_asset.rb
140
135
  - lib/railties/active-fedora.rake
141
- - lib/railties/hydra_jetty.rake
142
136
  - lib/tasks/hydra.rake
143
137
  - spec/.gitignore
144
138
  - spec/controllers/catalog_controller_spec.rb
@@ -146,25 +140,20 @@ files:
146
140
  - spec/controllers/ip_based_ability_spec.rb
147
141
  - spec/factories.rb
148
142
  - spec/helpers/blacklight_helper_spec.rb
149
- - spec/lib/model_methods_spec.rb
150
143
  - spec/models/solr_document_spec.rb
151
144
  - spec/models/user_spec.rb
152
145
  - spec/rcov.opts
153
146
  - spec/search_builders/search_builder_spec.rb
154
147
  - spec/spec.opts
155
148
  - spec/spec_helper.rb
156
- - spec/support/app/controllers/downloads_controller.rb
157
149
  - spec/support/app/models/sample.rb
158
150
  - spec/support/app/models/solr_document.rb
159
151
  - spec/support/db/migrate/20111101221803_create_searches.rb
160
- - spec/support/lib/generators/test_app_generator.rb
161
- - spec/support/lib/tasks/rspec.rake
162
152
  - spec/support/matchers/helper_matcher.rb
163
153
  - spec/support/matchers/solr_matchers.rb
164
154
  - spec/test_app_templates/Gemfile.extra
165
155
  - spec/unit/hydra-head-engine_spec.rb
166
156
  - spec/unit/hydra-head_spec.rb
167
- - tasks/rspec.rake
168
157
  homepage: http://projecthydra.org
169
158
  licenses:
170
159
  - APACHE2
@@ -180,12 +169,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
169
  version: 1.9.3
181
170
  required_rubygems_version: !ruby/object:Gem::Requirement
182
171
  requirements:
183
- - - ">="
172
+ - - ">"
184
173
  - !ruby/object:Gem::Version
185
- version: '0'
174
+ version: 1.3.1
186
175
  requirements: []
187
176
  rubyforge_project:
188
- rubygems_version: 2.4.5.1
177
+ rubygems_version: 2.5.1
189
178
  signing_key:
190
179
  specification_version: 4
191
180
  summary: Hydra-Head Rails Engine (requires Rails3)
@@ -196,19 +185,15 @@ test_files:
196
185
  - spec/controllers/ip_based_ability_spec.rb
197
186
  - spec/factories.rb
198
187
  - spec/helpers/blacklight_helper_spec.rb
199
- - spec/lib/model_methods_spec.rb
200
188
  - spec/models/solr_document_spec.rb
201
189
  - spec/models/user_spec.rb
202
190
  - spec/rcov.opts
203
191
  - spec/search_builders/search_builder_spec.rb
204
192
  - spec/spec.opts
205
193
  - spec/spec_helper.rb
206
- - spec/support/app/controllers/downloads_controller.rb
207
194
  - spec/support/app/models/sample.rb
208
195
  - spec/support/app/models/solr_document.rb
209
196
  - spec/support/db/migrate/20111101221803_create_searches.rb
210
- - spec/support/lib/generators/test_app_generator.rb
211
- - spec/support/lib/tasks/rspec.rake
212
197
  - spec/support/matchers/helper_matcher.rb
213
198
  - spec/support/matchers/solr_matchers.rb
214
199
  - spec/test_app_templates/Gemfile.extra
@@ -1,8 +0,0 @@
1
- module Hydra::Controller::SearchBuilder
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- Deprecation.warn Hydra::Controller::SearchBuilder, "Hydra::Controller::SearchBuilder no longer does anything. It will be removed in Hydra version 10. The code that used to be in this module was moved to Blacklight::AccessControls::Catalog in the blacklight-access_controls gem."
6
- end
7
-
8
- end
@@ -1,66 +0,0 @@
1
- require 'mime/types'
2
-
3
- module Hydra::ModelMethods
4
- extend ActiveSupport::Concern
5
-
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
9
- end
10
-
11
- # Puts the contents of file (posted blob) into a datastream and sets the title and label
12
- # Sets asset label and title to filename if they're empty
13
- #
14
- # @param [#read] file the IO object that is the blob
15
- # @param [String] file the IO object that is the blob
16
- def add_file(file, path, file_name, mime_type=nil)
17
- mime_type ||= best_mime_for_filename(file_name)
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)
22
- end
23
-
24
- def best_mime_for_filename(file_name)
25
- mime_types = MIME::Types.of(file_name)
26
- mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
27
- end
28
-
29
-
30
- # Set the title and label on the current object
31
- #
32
- # @param [String] new_title
33
- # @param [Hash] opts (optional) hash of configuration options
34
- #
35
- # @example Use :only_if_blank option to only update the values when the label is empty
36
- # obj.set_title_and_label("My Title", :only_if_blank=> true)
37
- def set_title_and_label(new_title, opts={})
38
- if opts[:only_if_blank]
39
- if respond_to?(:label) && label.blank?
40
- self.label = new_title
41
- set_title new_title
42
- end
43
- else
44
- self.label = new_title if respond_to? :label
45
- set_title new_title
46
- end
47
- end
48
-
49
- # Set the title and label on the current object
50
- #
51
- # @param [String] new_title
52
- # @param [Hash] opts (optional) hash of configuration options
53
- def set_title(new_title, opts={})
54
- if respond_to? :title=
55
- self.title = self.class.multiple?(:title) ? Array(new_title) : new_title
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`'
58
- if descMetadata.respond_to?(:title_values)
59
- descMetadata.title_values = new_title
60
- else
61
- descMetadata.title = new_title
62
- end
63
- end
64
- end
65
-
66
- end
@@ -1,31 +0,0 @@
1
- # properties datastream: catch-all for info that didn't have another home. Particularly depositor.
2
- module Hydra::Datastream
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
-
11
- set_terminology do |t|
12
- t.root(:path=>"fields", :xmlns => '', :namespace_prefix => nil)
13
-
14
- # This is where we put the user id of the object depositor -- impacts permissions/access controls
15
- t.depositor :xmlns => '', :namespace_prefix => nil
16
-
17
- # @deprecated Collection should be tracked in RELS-EXT RDF. collection term will be removed no later than release 6.x
18
- t.collection :xmlns => '', :namespace_prefix => nil
19
- # @deprecated Title should be tracked in descMetadata. title term will be removed no later than release 6.x
20
- t.title :xmlns => '', :namespace_prefix => nil
21
- end
22
-
23
- def self.xml_template
24
- builder = Nokogiri::XML::Builder.new do |xml|
25
- xml.fields
26
- end
27
-
28
- builder.doc
29
- end
30
- end
31
- end
@@ -1,12 +0,0 @@
1
- module Hydra
2
- class SearchBuilder < Blacklight::SearchBuilder
3
- include Blacklight::Solr::SearchBuilderBehavior
4
- include Hydra::AccessControlsEnforcement
5
- extend Deprecation
6
-
7
- def initialize(*)
8
- Deprecation.warn SearchBuilder, "Hydra::SearchBuilder is deprecated and will be removed in hydra-head 10.0. Instead add include Hydra::AccessControlsEnforcement to app/models/search_builder.rb"
9
- super
10
- end
11
- end
12
- end
data/lib/mods_asset.rb DELETED
@@ -1,15 +0,0 @@
1
- # An EXAMPLE Basic Model for Assets that conform to Hydra commonMetadata cModel and have basic MODS metadata (currently "Article" is the MODS exemplar)
2
- class ModsAsset < ActiveFedora::Base
3
- extend Deprecation
4
-
5
- def initialize(*)
6
- Deprecation.warn(ModsAsset, "ModsAsset is deprecated and will be removed in hydra-head 10")
7
- super
8
- end
9
-
10
- ## Convenience methods for manipulating the rights metadata datastream
11
- include Hydra::AccessControls::Permissions
12
-
13
- # adds helpful methods for basic hydra objects
14
- include Hydra::ModelMethods
15
- end
@@ -1,26 +0,0 @@
1
- namespace :jetty do
2
- desc "Apply all configs to Testing Server (relies on hydra:jetty:config tasks unless you override it)"
3
- task :config do
4
- Rake::Task["hydra:jetty:config"].invoke
5
- end
6
- end
7
-
8
- namespace :hydra do
9
- namespace :jetty do
10
- desc "Copies the default Solr config into the bundled Hydra Testing Server"
11
- task :config do
12
- Rake::Task["hydra:jetty:config_solr"].invoke
13
- end
14
-
15
- desc "Copies the contents of solr_conf into the Solr development-core and test-core of Testing Server"
16
- task :config_solr do
17
- FileList['solr_conf/conf/*'].each do |f|
18
- cp("#{f}", 'jetty/solr/development-core/conf/', :verbose => true)
19
- cp("#{f}", 'jetty/solr/test-core/conf/', :verbose => true)
20
- end
21
- end
22
-
23
- desc "Copies the default SOLR config files and starts up the fedora instance."
24
- task :load => [:config, 'jetty:start']
25
- end
26
- end
@@ -1,78 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Hydra::ModelMethods do
4
-
5
- before do
6
- allow(Deprecation).to receive(:warn)
7
- class TestModel < ActiveFedora::Base
8
- include Hydra::AccessControls::Permissions
9
- include Hydra::ModelMethods
10
- property :depositor, predicate: ::RDF::URI.new("http://id.loc.gov/vocabulary/relators/dpt"), multiple: false
11
- attr_accessor :label
12
- end
13
- end
14
-
15
- after { Object.send(:remove_const, :TestModel) }
16
-
17
- subject { TestModel.new }
18
-
19
- describe 'add_file' do
20
- let(:file_name) { "my_file.foo" }
21
- let(:mock_file) { "File contents" }
22
-
23
- it "should set the dsid, mimetype and content" do
24
- expect(subject).to receive(:set_title_and_label).with(file_name, only_if_blank: true )
25
- expect(MIME::Types).to receive(:of).with(file_name).and_return([double(content_type: "mymimetype")])
26
- subject.add_file(mock_file, 'bar', file_name)
27
- expect(subject.bar.content).to eq mock_file
28
- end
29
-
30
- it "should accept a supplied mime_type and content" do
31
- expect(subject).to receive(:set_title_and_label).with(file_name, only_if_blank: true )
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
57
- end
58
- end
59
-
60
- describe '#set_title' do
61
- context "on a class with a title property" do
62
- before do
63
- expect(Deprecation).to receive(:warn)
64
- class WithProperty < ActiveFedora::Base
65
- include Hydra::ModelMethods
66
- property :title, predicate: ::RDF::DC.title
67
- end
68
- end
69
-
70
- subject { WithProperty.new }
71
-
72
- it "should set the property" do
73
- subject.set_title('foo')
74
- expect(subject.title).to eq ['foo']
75
- end
76
- end
77
- end
78
- end
@@ -1,3 +0,0 @@
1
- class DownloadsController < ApplicationController
2
- include Hydra::Controller::DownloadBehavior
3
- end
@@ -1,30 +0,0 @@
1
- require 'rails/generators'
2
-
3
- class TestAppGenerator < Rails::Generators::Base
4
- source_root File.expand_path("../../../../support", __FILE__)
5
-
6
- def copy_test_classes
7
- # Download controller
8
- copy_file "app/controllers/downloads_controller.rb"
9
- end
10
-
11
- def copy_rspec_rake_task
12
- copy_file "lib/tasks/rspec.rake"
13
- end
14
-
15
- def run_blacklight_generator
16
- say_status("warning", "GENERATING BL", :yellow)
17
-
18
- generate 'blacklight:install', '--devise'
19
- end
20
-
21
- def run_hydra_head_generator
22
- say_status("warning", "GENERATING HH", :yellow)
23
-
24
- generate 'hydra:head', '-f --skip-rspec'
25
- end
26
-
27
- def remove_generated_user_spec
28
- remove_file 'spec/models/user_spec.rb'
29
- end
30
- end
@@ -1,8 +0,0 @@
1
- require 'rspec/core/rake_task'
2
- desc "run the hydra-core gem spec"
3
- gem_home = File.expand_path('../../../../..', __FILE__)
4
- RSpec::Core::RakeTask.new(:myspec) do |t|
5
- t.pattern = gem_home + '/spec/**/*_spec.rb'
6
- t.rspec_opts = ["--colour", '--backtrace']
7
- t.ruby_opts = "-I#{gem_home}/spec"
8
- end
data/tasks/rspec.rake DELETED
@@ -1,52 +0,0 @@
1
- ENV["RAILS_ROOT"] ||= 'spec/internal'
2
-
3
- GEM_ROOT= File.expand_path(File.join(File.dirname(__FILE__),".."))
4
-
5
- desc "Run specs"
6
- task spec: :generate do |t|
7
- focused_spec = ENV['SPEC'] ? " SPEC=#{File.join(GEM_ROOT, ENV['SPEC'])}" : ''
8
- within_test_app do
9
- system "rake myspec#{focused_spec}"
10
- abort "Error running hydra-core" unless $?.success?
11
- end
12
- end
13
-
14
-
15
- desc "Create the test rails app"
16
- task :generate do
17
- unless File.exists?('spec/internal/Rakefile')
18
- puts "Generating rails app"
19
- `rails new spec/internal`
20
- puts "Updating gemfile"
21
- `echo " gem 'hydra-access-controls', :path=>'../../../hydra-access-controls'" >> spec/internal/Gemfile`
22
- `echo " gem 'hydra-core', :path=>'../../', :require=>'hydra-core'" >> spec/internal/Gemfile`
23
- `echo " eval File.read('../test_app_templates/Gemfile.extra'), nil, '../test_app_templates/Gemfile.extra'" >> spec/internal/Gemfile`
24
- `echo " gem 'factory_girl_rails'" >> spec/internal/Gemfile`
25
- puts "Copying generator"
26
- `cp -r spec/support/lib/generators spec/internal/lib`
27
- within_test_app do
28
- puts "Bundle install"
29
- `bundle install`
30
- puts "running test_app_generator"
31
- system "rails generate test_app"
32
-
33
- puts "running migrations"
34
- puts `rake db:migrate db:test:prepare`
35
- end
36
- end
37
- puts "Running specs"
38
- end
39
-
40
- desc "Clean out the test rails app"
41
- task :clean do
42
- puts "Removing sample rails app"
43
- `rm -rf spec/internal`
44
- end
45
-
46
- def within_test_app
47
- FileUtils.cd('spec/internal')
48
- Bundler.with_clean_env do
49
- yield
50
- end
51
- FileUtils.cd('../..')
52
- end