hydra-collections 5.0.4 → 6.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +3 -2
- data/Gemfile +11 -19
- data/app/controllers/concerns/hydra/collections/selects_collections.rb +4 -23
- data/app/controllers/concerns/hydra/collections_controller_behavior.rb +4 -1
- data/app/models/concerns/hydra/collection.rb +3 -21
- data/app/models/concerns/hydra/collections/metadata.rb +19 -34
- data/hydra-collections.gemspec +2 -2
- data/lib/hydra-collections.rb +2 -1
- data/lib/hydra/collections/collectible.rb +17 -28
- data/lib/hydra/collections/search_behaviors.rb +7 -12
- data/lib/hydra/collections/version.rb +1 -1
- data/spec/controllers/collections_controller_spec.rb +35 -37
- data/spec/controllers/other_collections_controller_spec.rb +5 -9
- data/spec/controllers/selects_collections_spec.rb +5 -11
- data/spec/lib/collectible_spec.rb +15 -16
- data/spec/models/collection_spec.rb +10 -21
- data/spec/spec_helper.rb +4 -3
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/collections/_thumbnail_default.html.erb_spec.rb +2 -2
- metadata +10 -11
- data/app/models/concerns/hydra/collections/relations.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a55e2a03471e0659271fbbbc73f0dd6233119390
|
4
|
+
data.tar.gz: 872f3f1d0fc426e335b870b1384ebd71d0c8ba78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a029879709867b6df79503628696e37bcdb5e68ef69abbae331266ffdc2b604a66c6632c9f53dae9f0b7441b6441228866b868c6551d60c606e3abef51929bc
|
7
|
+
data.tar.gz: de9b2cbbe3e68940bf208d8ff90db132ddfecd6adc1a8f3f785514b614d63078041125d2b959baa7d1a6dfde7d1b82d1057a4f7e9b0970398aba52248085b383
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -2,12 +2,13 @@ language: ruby
|
|
2
2
|
cache: bundler
|
3
3
|
sudo: false
|
4
4
|
rvm:
|
5
|
-
- 2.
|
5
|
+
- 2.1
|
6
6
|
env:
|
7
7
|
global:
|
8
8
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
9
9
|
matrix:
|
10
|
-
- "RAILS_VERSION=4.
|
10
|
+
- "RAILS_VERSION=4.1.10"
|
11
|
+
- "RAILS_VERSION=4.2.1"
|
11
12
|
notifications:
|
12
13
|
email:
|
13
14
|
recipients:
|
data/Gemfile
CHANGED
@@ -3,8 +3,6 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in hydra-collections.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem 'kaminari', github: 'jcoyne/kaminari', branch: 'sufia'
|
7
|
-
|
8
6
|
group :development, :test do
|
9
7
|
gem 'sqlite3'
|
10
8
|
gem "factory_girl_rails"
|
@@ -16,28 +14,22 @@ group :development, :test do
|
|
16
14
|
gem 'rspec-activemodel-mocks'
|
17
15
|
end
|
18
16
|
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
file
|
24
|
-
|
25
|
-
begin
|
26
|
-
eval_gemfile file
|
27
|
-
rescue Bundler::GemfileError => e
|
28
|
-
Bundler.ui.warn '[EngineCart] Skipping Rails application dependencies:'
|
29
|
-
Bundler.ui.warn e.message
|
30
|
-
end
|
17
|
+
gem 'slop', '~> 3.6' # because rails installs byebug in the Gemfile
|
18
|
+
|
19
|
+
file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path("../spec/internal", __FILE__))
|
20
|
+
if File.exists?(file)
|
21
|
+
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
|
22
|
+
instance_eval File.read(file)
|
31
23
|
else
|
32
|
-
|
24
|
+
extra_file = File.expand_path("../spec/test_app_templates/Gemfile.extra", __FILE__)
|
25
|
+
instance_eval File.read(extra_file)
|
33
26
|
|
34
27
|
gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
|
35
28
|
|
36
|
-
if ENV['RAILS_VERSION']
|
29
|
+
if ENV['RAILS_VERSION'] and ENV['RAILS_VERSION'] !~ /^4.2/
|
30
|
+
gem 'sass-rails', "< 5.0"
|
31
|
+
else
|
37
32
|
gem 'responders', "~> 2.0"
|
38
33
|
gem 'sass-rails', ">= 5.0"
|
39
|
-
else
|
40
|
-
gem 'sass-rails', "< 5.0"
|
41
34
|
end
|
42
35
|
end
|
43
|
-
# END ENGINE_CART BLOCK
|
@@ -11,35 +11,16 @@ module Hydra::Collections::SelectsCollections
|
|
11
11
|
{ read: [:read, :edit], edit: [:edit] }
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
# Return list of collections for which the current user has read access.
|
16
|
-
# Add this or find_collections_with_edit_access as a before filter on any page that shows the form_for_select_collection
|
17
|
-
#
|
18
|
-
# @return [Array<SolrDocument>] Solr documents for each collection the user has read access
|
14
|
+
# add one of the following methods as a before filter on any page that shows the form_for_select_collection
|
19
15
|
def find_collections_with_read_access
|
20
16
|
find_collections(:read)
|
21
17
|
end
|
22
18
|
|
23
|
-
|
24
|
-
# Return list of collections for which the current user has edit access. Optionally prepend with default
|
25
|
-
# that can be used in a select menu to instruct user to select a collection.
|
26
|
-
# Add this or find_collections_with_read_access as a before filter on any page that shows the form_for_select_collection
|
27
|
-
#
|
28
|
-
# @param [TrueClass|FalseClass] :include_default if true, prepends the default_option; otherwise, if false, returns only collections
|
29
|
-
# @param [Fixnum] :default_id for select menus, this is the id of the first selection representing the instructions
|
30
|
-
# @param [String] :default_title for select menus, this is the text displayed as the first item serving as instructions
|
31
|
-
#
|
32
|
-
# @return [Array<SolrDocument>] Solr documents for each collection the user has edit access, plus optional instructions
|
33
|
-
def find_collections_with_edit_access(include_default=false, default_id=-1, default_title="Select collection...")
|
19
|
+
def find_collections_with_edit_access
|
34
20
|
find_collections(:edit)
|
35
|
-
default_option = SolrDocument.new(id: default_id, title_tesim: default_title)
|
36
|
-
@user_collections.unshift(default_option) if include_default
|
37
21
|
end
|
38
22
|
|
39
|
-
|
40
|
-
# Return list of collections matching the passed in access_level for the current user.
|
41
|
-
# @param [Symbol] :access_level one of :read or :edit
|
42
|
-
# @return [Array<SolrDocument>] Solr documents for each collection the user has the appropriate access level
|
23
|
+
#
|
43
24
|
def find_collections (access_level = nil)
|
44
25
|
# need to know the user if there is an access level applied otherwise we are just doing public collections
|
45
26
|
authenticate_user! unless access_level.blank?
|
@@ -66,7 +47,7 @@ module Hydra::Collections::SelectsCollections
|
|
66
47
|
# Defines which search_params_logic should be used when searching for Collections
|
67
48
|
def collection_search_params_logic
|
68
49
|
[:default_solr_parameters, :add_query_to_solr, :add_access_controls_to_solr_params,
|
69
|
-
:add_collection_filter, :some_rows
|
50
|
+
:add_collection_filter, :some_rows]
|
70
51
|
end
|
71
52
|
|
72
53
|
end
|
@@ -172,7 +172,10 @@ module Hydra
|
|
172
172
|
|
173
173
|
def add_members_to_collection collection = nil
|
174
174
|
collection ||= @collection
|
175
|
-
|
175
|
+
batch.each do |id|
|
176
|
+
collection.child_generic_works << ActiveFedora::Base.find(id)
|
177
|
+
end
|
178
|
+
#TODO this old way was more efficient #collection.member_ids = batch.concat(collection.member_ids)
|
176
179
|
end
|
177
180
|
|
178
181
|
def remove_members_from_collection
|
@@ -2,28 +2,10 @@ module Hydra
|
|
2
2
|
module Collection
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
extend Deprecation
|
5
|
+
include Hydra::Works::CollectionBehavior
|
5
6
|
include Hydra::WithDepositor # for access to apply_depositor_metadata
|
6
7
|
include Hydra::AccessControls::Permissions
|
7
|
-
include Hydra::Collections::Collectible
|
8
8
|
include Hydra::Collections::Metadata
|
9
|
-
include Hydra::
|
10
|
-
|
11
|
-
def update_all_members
|
12
|
-
Deprecation.warn(Collection, 'update_all_members is deprecated and will be removed in version 5.0')
|
13
|
-
self.members.collect { |m| update_member(m) }
|
14
|
-
end
|
15
|
-
|
16
|
-
# TODO: Use solr atomic updates to accelerate this process
|
17
|
-
def update_member member
|
18
|
-
Deprecation.warn(Collection, 'update_member is deprecated and will be removed in version 5.0')
|
19
|
-
# because the member may have its collections cached, reload that cache so that it indexes the correct fields.
|
20
|
-
member.collections(true) if member.respond_to? :collections
|
21
|
-
member.update_index
|
22
|
-
end
|
23
|
-
|
24
|
-
def add_members new_member_ids
|
25
|
-
return if new_member_ids.nil? || new_member_ids.size < 1
|
26
|
-
self.members << ActiveFedora::Base.find(new_member_ids)
|
27
|
-
end
|
28
|
-
end
|
9
|
+
include Hydra::Works::CollectionBehavior
|
10
|
+
end
|
29
11
|
end
|
@@ -2,76 +2,61 @@ module Hydra::Collections
|
|
2
2
|
module Metadata
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
included do
|
5
|
-
property :depositor, predicate: RDF::
|
5
|
+
property :depositor, predicate: ::RDF::URI.new("http://id.loc.gov/vocabulary/relators/dpt"), multiple: false do |index|
|
6
6
|
index.as :symbol, :stored_searchable
|
7
7
|
end
|
8
8
|
|
9
|
-
property :part_of, predicate: RDF::
|
10
|
-
|
11
|
-
property :contributor, predicate: RDF::Vocab::DC.contributor do |index|
|
9
|
+
property :part_of, predicate: RDF::DC.isPartOf
|
10
|
+
property :contributor, predicate: RDF::DC.contributor do |index|
|
12
11
|
index.as :stored_searchable, :facetable
|
13
12
|
end
|
14
|
-
|
15
|
-
property :creator, predicate: RDF::Vocab::DC.creator do |index|
|
13
|
+
property :creator, predicate: RDF::DC.creator do |index|
|
16
14
|
index.as :stored_searchable, :facetable
|
17
15
|
end
|
18
|
-
|
19
|
-
|
20
|
-
index.as :stored_searchable, :sortable
|
16
|
+
property :title, predicate: RDF::DC.title, multiple: false do |index|
|
17
|
+
index.as :stored_searchable
|
21
18
|
end
|
22
|
-
|
23
|
-
property :description, predicate: RDF::Vocab::DC.description, multiple: false do |index|
|
19
|
+
property :description, predicate: RDF::DC.description, multiple: false do |index|
|
24
20
|
index.type :text
|
25
21
|
index.as :stored_searchable
|
26
22
|
end
|
27
|
-
|
28
|
-
property :publisher, predicate: RDF::Vocab::DC.publisher do |index|
|
23
|
+
property :publisher, predicate: RDF::DC.publisher do |index|
|
29
24
|
index.as :stored_searchable, :facetable
|
30
25
|
end
|
31
|
-
|
32
|
-
property :date_created, predicate: RDF::Vocab::DC.created do |index|
|
26
|
+
property :date_created, predicate: RDF::DC.created do |index|
|
33
27
|
index.as :stored_searchable
|
34
28
|
end
|
35
|
-
|
36
|
-
property :date_uploaded, predicate: RDF::Vocab::DC.dateSubmitted, multiple: false do |index|
|
29
|
+
property :date_uploaded, predicate: RDF::DC.dateSubmitted, multiple: false do |index|
|
37
30
|
index.type :date
|
38
31
|
index.as :stored_sortable
|
39
32
|
end
|
40
|
-
|
41
|
-
property :date_modified, predicate: RDF::Vocab::DC.modified, multiple: false do |index|
|
33
|
+
property :date_modified, predicate: RDF::DC.modified, multiple: false do |index|
|
42
34
|
index.type :date
|
43
35
|
index.as :stored_sortable
|
44
36
|
end
|
45
|
-
|
46
|
-
property :subject, predicate: RDF::Vocab::DC.subject do |index|
|
37
|
+
property :subject, predicate: RDF::DC.subject do |index|
|
47
38
|
index.as :stored_searchable, :facetable
|
48
39
|
end
|
49
|
-
|
50
|
-
property :language, predicate: RDF::Vocab::DC.language do |index|
|
40
|
+
property :language, predicate: RDF::DC.language do |index|
|
51
41
|
index.as :stored_searchable, :facetable
|
52
42
|
end
|
53
|
-
|
54
|
-
property :rights, predicate: RDF::Vocab::DC.rights do |index|
|
43
|
+
property :rights, predicate: RDF::DC.rights do |index|
|
55
44
|
index.as :stored_searchable
|
56
45
|
end
|
57
|
-
|
58
|
-
property :resource_type, predicate: RDF::Vocab::DC.type do |index|
|
46
|
+
property :resource_type, predicate: RDF::DC.type do |index|
|
59
47
|
index.as :stored_searchable, :facetable
|
60
48
|
end
|
61
|
-
|
62
|
-
property :identifier, predicate: RDF::Vocab::DC.identifier do |index|
|
49
|
+
property :identifier, predicate: RDF::DC.identifier do |index|
|
63
50
|
index.as :stored_searchable
|
64
51
|
end
|
65
|
-
|
66
|
-
property :based_near, predicate: RDF::Vocab::FOAF.based_near do |index|
|
52
|
+
property :based_near, predicate: RDF::FOAF.based_near do |index|
|
67
53
|
index.as :stored_searchable, :facetable
|
68
54
|
end
|
69
|
-
|
70
|
-
property :tag, predicate: RDF::Vocab::DC.relation do |index|
|
55
|
+
property :tag, predicate: RDF::DC.relation do |index|
|
71
56
|
index.as :stored_searchable, :facetable
|
72
57
|
end
|
73
|
-
|
74
58
|
property :related_url, predicate: RDF::RDFS.seeAlso
|
59
|
+
|
75
60
|
end
|
76
61
|
end
|
77
62
|
end
|
data/hydra-collections.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'hydra-head', '~> 9.1'
|
22
22
|
spec.add_dependency 'deprecation', '~> 0.1'
|
23
23
|
spec.add_dependency 'blacklight', '~> 5.10'
|
24
|
-
spec.add_dependency '
|
24
|
+
spec.add_dependency 'hydra-works', '~> 0.1'
|
25
25
|
|
26
|
-
spec.add_development_dependency 'engine_cart', '~> 0.
|
26
|
+
spec.add_development_dependency 'engine_cart', '~> 0.5'
|
27
27
|
spec.add_development_dependency 'rspec-rails', '~> 3.1'
|
28
28
|
end
|
data/lib/hydra-collections.rb
CHANGED
@@ -1,36 +1,25 @@
|
|
1
1
|
# This module adds a `has_many :collections` association to any models that you mix it into, using the :has_collection_member property
|
2
2
|
# It also provides methods to help you index the information as a facet
|
3
3
|
require 'deprecation'
|
4
|
-
module Hydra::Collections
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
module Hydra::Collections
|
5
|
+
module Collectible
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
extend Deprecation
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
included do
|
10
|
+
include Hydra::Works::GenericWorkBehavior
|
11
|
+
Deprecation.warn(Collectible, "Hydra::Collections::Collectible is deprecated. include Hydra::Works::GenericWorkBehavior instead. Hydra::Collections::Collectible will be removed in Hydra::Collections 7.0")
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# super(solr_doc, opts)
|
18
|
-
# index_collection_ids(solr_doc)
|
19
|
-
# return solr_doc
|
20
|
-
# end
|
21
|
-
def index_collection_ids(solr_doc={})
|
22
|
-
Deprecation.warn(Hydra::Collections::Collectible, 'index_collection_ids is deprecated and will be removed in version 5.0')
|
23
|
-
# CollectionAssociation#ids_reader loads from solr on each call, so only call it once
|
24
|
-
# see https://github.com/projecthydra/active_fedora/issues/644
|
25
|
-
ids = collection_ids
|
26
|
-
solr_doc[Solrizer.solr_name(:collection, :facetable)] = ids
|
27
|
-
solr_doc[Solrizer.solr_name(:collection)] = ids
|
28
|
-
solr_doc
|
29
|
-
end
|
14
|
+
def collection_ids
|
15
|
+
Deprecation.warn(Collectible, "collection_ids is deprecated and will be removed in Hydra::Collections 7.0. Use parent_collections.map(&:id) instead.")
|
16
|
+
parent_collections.map(&:id)
|
17
|
+
end
|
30
18
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
def collections
|
20
|
+
Deprecation.warn(Collectible, "collections is deprecated and will be removed in Hydra::Collections 7.0. Use parent_collections instead.")
|
21
|
+
parent_collections
|
22
|
+
end
|
35
23
|
|
24
|
+
end
|
36
25
|
end
|
@@ -1,4 +1,10 @@
|
|
1
1
|
module Hydra::Collections::SearchBehaviors
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
class_attribute :from_field
|
6
|
+
self.from_field = 'member_ids_ssim'
|
7
|
+
end
|
2
8
|
|
3
9
|
def collection
|
4
10
|
scope.collection
|
@@ -7,7 +13,7 @@ module Hydra::Collections::SearchBehaviors
|
|
7
13
|
# include filters into the query to only include the collection memebers
|
8
14
|
def include_collection_ids(solr_parameters)
|
9
15
|
solr_parameters[:fq] ||= []
|
10
|
-
solr_parameters[:fq] << "{!join from
|
16
|
+
solr_parameters[:fq] << "{!join from=#{from_field} to=id}id:#{collection.id}"
|
11
17
|
end
|
12
18
|
|
13
19
|
def some_rows(solr_parameters)
|
@@ -19,13 +25,6 @@ module Hydra::Collections::SearchBehaviors
|
|
19
25
|
solr_parameters[:fq] << ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::Collection.to_class_uri)
|
20
26
|
end
|
21
27
|
|
22
|
-
# Sort results by title if no query was supplied.
|
23
|
-
# This overrides the default 'relevance' sort.
|
24
|
-
def sort_by_title(solr_parameters)
|
25
|
-
return if solr_parameters[:q]
|
26
|
-
solr_parameters[:sort] ||= "#{sort_field} asc"
|
27
|
-
end
|
28
|
-
|
29
28
|
def discovery_perms= perms
|
30
29
|
@discovery_perms = perms
|
31
30
|
end
|
@@ -34,8 +33,4 @@ module Hydra::Collections::SearchBehaviors
|
|
34
33
|
@discovery_perms || super
|
35
34
|
end
|
36
35
|
|
37
|
-
def sort_field
|
38
|
-
Solrizer.solr_name('title', :sortable)
|
39
|
-
end
|
40
|
-
|
41
36
|
end
|
@@ -10,11 +10,11 @@ describe CollectionsController, :type => :controller do
|
|
10
10
|
config.default_solr_params = {:qf => 'label_tesim'}
|
11
11
|
end
|
12
12
|
|
13
|
-
class
|
14
|
-
include Hydra::Collections::Collectible
|
13
|
+
class GenericWork < ActiveFedora::Base
|
15
14
|
include Hydra::AccessControls::Permissions
|
15
|
+
include Hydra::Works::GenericWorkBehavior
|
16
16
|
|
17
|
-
property :title, predicate: ::RDF::
|
17
|
+
property :title, predicate: ::RDF::DC.title, multiple: false
|
18
18
|
|
19
19
|
def to_solr(solr_doc={})
|
20
20
|
super.tap do |solr_doc|
|
@@ -25,7 +25,7 @@ describe CollectionsController, :type => :controller do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
after(:all) do
|
28
|
-
Object.send(:remove_const, :
|
28
|
+
Object.send(:remove_const, :GenericWork)
|
29
29
|
end
|
30
30
|
|
31
31
|
let(:user) { FactoryGirl.create(:user) }
|
@@ -39,15 +39,15 @@ describe CollectionsController, :type => :controller do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
describe "#index" do
|
42
|
-
let!(:collection1) { Collection.create
|
43
|
-
let!(:collection2) { Collection.create
|
44
|
-
let!(:generic_file) {
|
42
|
+
let!(:collection1) { Collection.create { |c| c.apply_depositor_metadata(user.user_key) } }
|
43
|
+
let!(:collection2) { Collection.create { |c| c.apply_depositor_metadata(user.user_key) } }
|
44
|
+
let!(:generic_file) { GenericWork.create }
|
45
45
|
|
46
|
-
it "
|
46
|
+
it "should show a list of collections" do
|
47
47
|
get :index
|
48
48
|
expect(response).to be_successful
|
49
49
|
expect(assigns[:document_list].map(&:id)).not_to include generic_file.id
|
50
|
-
expect(assigns[:document_list].map(&:id)).to eq [
|
50
|
+
expect(assigns[:document_list].map(&:id)).to eq [collection1.id, collection2.id]
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -69,10 +69,10 @@ describe CollectionsController, :type => :controller do
|
|
69
69
|
expect(response).to redirect_to collections.collection_path(assigns[:collection])
|
70
70
|
end
|
71
71
|
it "should add docs to collection if batch ids provided" do
|
72
|
-
@asset1 =
|
73
|
-
@asset2 =
|
72
|
+
@asset1 = GenericWork.create!
|
73
|
+
@asset2 = GenericWork.create!
|
74
74
|
post :create, batch_document_ids: [@asset1, @asset2], collection: {title: "My Secong Collection ", description: "The Description\r\n\r\nand more"}
|
75
|
-
expect(assigns[:collection].members).to
|
75
|
+
expect(assigns[:collection].members).to eq([@asset1, @asset2])
|
76
76
|
end
|
77
77
|
it "should call after_create" do
|
78
78
|
expect(controller).to receive(:after_create).and_call_original
|
@@ -80,26 +80,26 @@ describe CollectionsController, :type => :controller do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should add one doc to collection if batch ids provided and add the collection id to the document in the colledction" do
|
83
|
-
@asset1 =
|
83
|
+
@asset1 = GenericWork.create!
|
84
84
|
post :create, batch_document_ids: [@asset1], collection: {title: "My Secong Collection ", description: "The Description\r\n\r\nand more"}
|
85
85
|
expect(assigns[:collection].members).to eq [@asset1]
|
86
86
|
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset1.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
|
87
87
|
expect(asset_results["response"]["numFound"]).to eq(1)
|
88
88
|
doc = asset_results["response"]["docs"].first
|
89
89
|
expect(doc["id"]).to eq(@asset1.id)
|
90
|
-
afterupdate =
|
90
|
+
afterupdate = GenericWork.find(@asset1.id)
|
91
91
|
expect(doc[Solrizer.solr_name(:collection)]).to eq(afterupdate.to_solr[Solrizer.solr_name(:collection)])
|
92
92
|
end
|
93
93
|
it "should add docs to collection if batch ids provided and add the collection id to the documents int he colledction" do
|
94
|
-
@asset1 =
|
95
|
-
@asset2 =
|
94
|
+
@asset1 = GenericWork.create!
|
95
|
+
@asset2 = GenericWork.create!
|
96
96
|
post :create, batch_document_ids: [@asset1,@asset2], collection: {title: "My Secong Collection ", description: "The Description\r\n\r\nand more"}
|
97
|
-
expect(assigns[:collection].members).to
|
97
|
+
expect(assigns[:collection].members).to eq([@asset1,@asset2])
|
98
98
|
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset1.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
|
99
99
|
expect(asset_results["response"]["numFound"]).to eq(1)
|
100
100
|
doc = asset_results["response"]["docs"].first
|
101
101
|
expect(doc["id"]).to eq(@asset1.id)
|
102
|
-
afterupdate =
|
102
|
+
afterupdate = GenericWork.find(@asset1.id)
|
103
103
|
expect(doc[Solrizer.solr_name(:collection)]).to eq(afterupdate.to_solr[Solrizer.solr_name(:collection)])
|
104
104
|
end
|
105
105
|
end
|
@@ -107,9 +107,9 @@ describe CollectionsController, :type => :controller do
|
|
107
107
|
describe "#update" do
|
108
108
|
before do
|
109
109
|
@collection = Collection.create { |c| c.apply_depositor_metadata(user.user_key) }
|
110
|
-
@asset1 =
|
111
|
-
@asset2 =
|
112
|
-
@asset3 =
|
110
|
+
@asset1 = GenericWork.create!
|
111
|
+
@asset2 = GenericWork.create!
|
112
|
+
@asset3 = GenericWork.create!
|
113
113
|
allow(controller).to receive(:authorize!).and_return(true)
|
114
114
|
expect(controller).to receive(:authorize!).at_least(:once)
|
115
115
|
end
|
@@ -187,27 +187,25 @@ describe CollectionsController, :type => :controller do
|
|
187
187
|
expect(controller).to receive(:authorize!).and_return(true)
|
188
188
|
end
|
189
189
|
|
190
|
-
it "
|
190
|
+
it "deletes the collection" do
|
191
191
|
delete :destroy, id: @collection
|
192
192
|
expect(response).to redirect_to Rails.application.routes.url_helpers.catalog_index_path
|
193
193
|
expect(flash[:notice]).to eq("Collection was successfully deleted.")
|
194
194
|
end
|
195
195
|
|
196
|
-
it "
|
196
|
+
it "calls after_destroy" do
|
197
197
|
expect(controller).to receive(:after_destroy).and_call_original
|
198
198
|
delete :destroy, id: @collection
|
199
199
|
end
|
200
200
|
|
201
|
-
it "
|
202
|
-
|
203
|
-
@collection.members <<
|
204
|
-
@collection.save
|
205
|
-
|
206
|
-
@asset1.update_index
|
207
|
-
expect(@asset1.collections).to eq [@collection]
|
201
|
+
it "updates members" do
|
202
|
+
asset1 = GenericWork.create!
|
203
|
+
@collection.members << asset1
|
204
|
+
@collection.save!
|
205
|
+
expect(asset1.parent_collections).to eq [@collection]
|
208
206
|
|
209
207
|
delete :destroy, id: @collection
|
210
|
-
expect(
|
208
|
+
expect(asset1.parent_collections).to eq []
|
211
209
|
end
|
212
210
|
end
|
213
211
|
|
@@ -232,9 +230,9 @@ describe CollectionsController, :type => :controller do
|
|
232
230
|
end
|
233
231
|
|
234
232
|
context "with a number of assets" do
|
235
|
-
let(:asset1) {
|
236
|
-
let(:asset2) {
|
237
|
-
let(:asset3) {
|
233
|
+
let(:asset1) { GenericWork.create!(title: "First of the Assets", read_users: [user.user_key]) }
|
234
|
+
let(:asset2) { GenericWork.create!(title: "Second of the Assets", read_users: [user.user_key]) }
|
235
|
+
let(:asset3) { GenericWork.create!(title: "Third of the Assets", read_users: [user.user_key]) }
|
238
236
|
let!(:collection) do
|
239
237
|
Collection.create!(id: "abc123", title: "My collection",
|
240
238
|
members: [asset1, asset2, asset3]) do |col|
|
@@ -256,7 +254,7 @@ describe CollectionsController, :type => :controller do
|
|
256
254
|
end
|
257
255
|
|
258
256
|
describe "additional collections" do
|
259
|
-
let(:asset4) {
|
257
|
+
let(:asset4) { GenericWork.create!(title: "#{asset1.id}", read_users: [user.user_key]) }
|
260
258
|
let!(:collection2) do
|
261
259
|
Collection.create!(id: "abc1234", title: "Other collection", members: [asset4]) do |col|
|
262
260
|
col.apply_depositor_metadata(user.user_key)
|
@@ -277,8 +275,8 @@ describe CollectionsController, :type => :controller do
|
|
277
275
|
|
278
276
|
context "When there are search matches that are not in the collection" do
|
279
277
|
before do
|
280
|
-
|
281
|
-
|
278
|
+
GenericWork.create!(title: "#{asset1.id} #{asset1.title}")
|
279
|
+
GenericWork.create!(title: asset1.title.to_s)
|
282
280
|
end
|
283
281
|
# NOTE: This test depends on title_tesim being in the qf in solrconfig.xml
|
284
282
|
it "only shows the collection assets" do
|
@@ -5,13 +5,11 @@ describe OtherCollectionsController, :type => :controller do
|
|
5
5
|
before(:all) do
|
6
6
|
class OtherCollection < ActiveFedora::Base
|
7
7
|
include Hydra::Collection
|
8
|
-
include Hydra::Collections::Collectible
|
9
8
|
end
|
10
9
|
|
11
10
|
class Member < ActiveFedora::Base
|
12
11
|
include Hydra::Collections::Collectible
|
13
12
|
include Hydra::AccessControls::Permissions
|
14
|
-
attr_accessor :title
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
@@ -20,19 +18,17 @@ describe OtherCollectionsController, :type => :controller do
|
|
20
18
|
Object.send(:remove_const, :OtherCollection)
|
21
19
|
end
|
22
20
|
|
23
|
-
let(:user) { FactoryGirl.
|
21
|
+
let(:user) { FactoryGirl.create(:user) }
|
24
22
|
|
25
23
|
before do
|
26
24
|
allow(controller).to receive(:has_access?).and_return(true)
|
27
25
|
sign_in user
|
28
|
-
# allow_any_instance_of(User).to receive(:groups).and_return([])
|
29
|
-
# allow(controller).to receive(:clear_session_user) ## Don't clear out the authenticated session
|
30
26
|
end
|
31
27
|
|
32
28
|
describe "#show" do
|
33
|
-
let(:asset1) { Member.create!(
|
34
|
-
let(:asset2) { Member.create!(
|
35
|
-
let(:asset3) { Member.create!(
|
29
|
+
let(:asset1) { Member.create!(read_users: [user.user_key]) }
|
30
|
+
let(:asset2) { Member.create!(read_users: [user.user_key]) }
|
31
|
+
let(:asset3) { Member.create!(read_users: [user.user_key]) }
|
36
32
|
let(:collection) do
|
37
33
|
OtherCollection.create(id: 'foo123', title: "My collection",
|
38
34
|
members: [asset1, asset2, asset3]) do |collection|
|
@@ -44,7 +40,7 @@ describe OtherCollectionsController, :type => :controller do
|
|
44
40
|
allow(controller).to receive(:apply_gated_search)
|
45
41
|
end
|
46
42
|
|
47
|
-
it "
|
43
|
+
it "shows the collections" do
|
48
44
|
get :show, id: collection
|
49
45
|
expect(assigns[:collection].title).to eq collection.title
|
50
46
|
ids = assigns[:member_docs].map(&:id)
|
@@ -11,8 +11,8 @@ end
|
|
11
11
|
describe SelectsCollectionsController, :type => :controller do
|
12
12
|
|
13
13
|
describe "#find_collections" do
|
14
|
-
it "
|
15
|
-
expect(subject.collection_search_params_logic).to eq
|
14
|
+
it "should use collection_search_params_logic" do
|
15
|
+
expect(subject.collection_search_params_logic).to eq([:default_solr_parameters, :add_query_to_solr, :add_access_controls_to_solr_params, :add_collection_filter, :some_rows])
|
16
16
|
expect(Hydra::Collections::SearchBuilder).to receive(:new).with(subject.collection_search_params_logic, subject).and_call_original
|
17
17
|
subject.find_collections
|
18
18
|
end
|
@@ -47,14 +47,13 @@ describe SelectsCollectionsController, :type => :controller do
|
|
47
47
|
context "when there are more than 10" do
|
48
48
|
before do
|
49
49
|
11.times do |i|
|
50
|
-
Collection.
|
50
|
+
Collection.create(title:"Test Public #{i}", read_groups: ["public"]) do |col|
|
51
51
|
col.apply_depositor_metadata(@user.user_key)
|
52
|
-
col.read_groups = ["public"]
|
53
|
-
col.save!
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
57
|
-
|
55
|
+
|
56
|
+
it "returns all public collections" do
|
58
57
|
subject.find_collections
|
59
58
|
expect(assigns[:user_collections].count).to eq(12)
|
60
59
|
end
|
@@ -91,11 +90,6 @@ describe SelectsCollectionsController, :type => :controller do
|
|
91
90
|
subject.find_collections_with_edit_access
|
92
91
|
expect(assigns[:user_collections].map(&:id)).to match_array [@collection.id, @collection3.id]
|
93
92
|
end
|
94
|
-
|
95
|
-
it "should return only public or editable collections & instructions" do
|
96
|
-
subject.find_collections_with_edit_access(true)
|
97
|
-
expect(assigns[:user_collections].map(&:id)).to match_array [-1, @collection.id, @collection3.id]
|
98
|
-
end
|
99
93
|
end
|
100
94
|
end
|
101
95
|
end
|
@@ -7,33 +7,32 @@ describe Hydra::Collections::Collectible do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
let(:collection1) { FactoryGirl.
|
10
|
+
let(:collection1) { FactoryGirl.build(:collection) }
|
11
11
|
let(:collection2) { FactoryGirl.create(:collection) }
|
12
|
-
let(:collectible) { CollectibleThing.
|
12
|
+
let(:collectible) { CollectibleThing.create }
|
13
13
|
|
14
14
|
after do
|
15
15
|
Object.send(:remove_const, :CollectibleThing)
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "collections associations" do
|
19
|
-
|
20
|
-
collectible.save
|
19
|
+
before do
|
21
20
|
collection1.members << collectible
|
22
21
|
collection1.save
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
collection2.members << collectible
|
23
|
+
collection2.save
|
24
|
+
end
|
25
|
+
|
26
|
+
it "queries the members" do
|
27
|
+
expect(collectible.reload.collections).to eq [collection1, collection2]
|
28
|
+
end
|
29
|
+
|
30
|
+
it "counts the members" do
|
31
|
+
expect(collectible.reload.collections.size).to eq 2
|
27
32
|
end
|
28
|
-
end
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
collectible.save
|
33
|
-
collectible.collections << collection1
|
34
|
-
collectible.collections << collection2
|
35
|
-
expect(Deprecation).to receive(:warn)
|
36
|
-
expect(collectible.index_collection_ids["collection_sim"]).to eq [collection1.id, collection2.id]
|
34
|
+
it "queries the ids" do
|
35
|
+
expect(collectible.reload.collection_ids).to eq [collection1.id, collection2.id]
|
37
36
|
end
|
38
37
|
end
|
39
38
|
end
|
@@ -14,7 +14,6 @@ describe Collection, :type => :model do
|
|
14
14
|
|
15
15
|
let(:gf1) { GenericFile.create }
|
16
16
|
let(:gf2) { GenericFile.create }
|
17
|
-
let(:gf3) { GenericFile.create }
|
18
17
|
|
19
18
|
let(:user) { @user }
|
20
19
|
|
@@ -23,9 +22,8 @@ describe Collection, :type => :model do
|
|
23
22
|
|
24
23
|
subject { collection.to_solr }
|
25
24
|
|
26
|
-
it "
|
25
|
+
it "should have title and depositor information" do
|
27
26
|
expect(subject['title_tesim']).to eq ['A good title']
|
28
|
-
expect(subject['title_si']).to eq 'A good title'
|
29
27
|
expect(subject['depositor_tesim']).to eq [user.user_key]
|
30
28
|
expect(subject['depositor_ssim']).to eq [user.user_key]
|
31
29
|
end
|
@@ -49,12 +47,8 @@ describe Collection, :type => :model do
|
|
49
47
|
end
|
50
48
|
|
51
49
|
describe "the ability" do
|
52
|
-
let(:collection)
|
53
|
-
|
54
|
-
collection.apply_depositor_metadata(user)
|
55
|
-
collection.save
|
56
|
-
end
|
57
|
-
end
|
50
|
+
let(:collection) { Collection.create { |c| c.apply_depositor_metadata(user) } }
|
51
|
+
|
58
52
|
subject { Ability.new(user) }
|
59
53
|
|
60
54
|
it "should allow the depositor to edit and read" do
|
@@ -73,7 +67,7 @@ describe Collection, :type => :model do
|
|
73
67
|
subject { Collection.create(members: [gf1, gf2]) }
|
74
68
|
|
75
69
|
it "should have many files" do
|
76
|
-
expect(subject.reload.members).to
|
70
|
+
expect(subject.reload.members).to eq [gf1, gf2]
|
77
71
|
end
|
78
72
|
end
|
79
73
|
|
@@ -86,14 +80,7 @@ describe Collection, :type => :model do
|
|
86
80
|
subject.reload
|
87
81
|
subject.members << gf2
|
88
82
|
subject.save
|
89
|
-
expect(subject.reload.members).to
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should allow multiple files to be added" do
|
93
|
-
subject.reload
|
94
|
-
subject.add_members [gf2.id, gf3.id]
|
95
|
-
subject.save
|
96
|
-
expect(subject.reload.members).to match_array [gf1, gf2, gf3]
|
83
|
+
expect(subject.reload.members).to eq [gf1, gf2]
|
97
84
|
end
|
98
85
|
end
|
99
86
|
end
|
@@ -102,11 +89,13 @@ describe Collection, :type => :model do
|
|
102
89
|
context "removing members" do
|
103
90
|
before do
|
104
91
|
subject.members = [gf1, gf2]
|
105
|
-
subject.save
|
92
|
+
subject.save!
|
106
93
|
end
|
107
94
|
|
108
|
-
it "
|
109
|
-
|
95
|
+
it "allows files to be removed" do
|
96
|
+
# force the "parent_collections" to be cached:
|
97
|
+
expect(gf1.parent_collections).to eq [subject]
|
98
|
+
|
110
99
|
# We need to ensure that deleting causes the collection to be flushed.
|
111
100
|
subject.reload.members.delete(gf1)
|
112
101
|
subject.save
|
data/spec/spec_helper.rb
CHANGED
@@ -5,11 +5,12 @@ else
|
|
5
5
|
require 'byebug'
|
6
6
|
end
|
7
7
|
|
8
|
-
ENV["RAILS_ENV"] ||= 'test'
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
11
|
+
ENV["RAILS_ENV"] ||= 'test'
|
12
12
|
|
13
|
+
require File.expand_path("config/environment", ENV['RAILS_ROOT'] || File.expand_path("../internal", __FILE__))
|
13
14
|
require 'rspec/rails'
|
14
15
|
require 'hydra-collections'
|
15
16
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
|
3
3
|
class TestAppGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path("../../../../
|
4
|
+
source_root File.expand_path("../../../../test_app_templates", __FILE__)
|
5
5
|
|
6
6
|
def update_gemfile
|
7
7
|
append_to_file "Gemfile" do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'collections/_thumbnail_default.html.erb' do
|
4
|
-
let(:document) { SolrDocument.new :
|
4
|
+
let(:document) { SolrDocument.new id: 'xyz', format: 'a', thumbnail_url: 'http://localhost/logo.png' }
|
5
5
|
let :blacklight_config do
|
6
6
|
Blacklight::Configuration.new do |config|
|
7
7
|
config.index.thumbnail_field = :thumbnail_url
|
@@ -9,7 +9,7 @@ describe 'collections/_thumbnail_default.html.erb' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
before do
|
12
|
-
assign :response, double(:
|
12
|
+
assign :response, double(start: 0)
|
13
13
|
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
|
14
14
|
allow(view).to receive(:render_grouped_response?).and_return(false)
|
15
15
|
allow(view).to receive(:current_search_session).and_return nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-collections
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carolyn Cole
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hydra-head
|
@@ -53,33 +53,33 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.10'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: hydra-works
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '0.1'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '0.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: engine_cart
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
75
|
+
version: '0.5'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
82
|
+
version: '0.5'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec-rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,7 +124,6 @@ files:
|
|
124
124
|
- app/models/concerns/hydra/collection.rb
|
125
125
|
- app/models/concerns/hydra/collections/actions.rb
|
126
126
|
- app/models/concerns/hydra/collections/metadata.rb
|
127
|
-
- app/models/concerns/hydra/collections/relations.rb
|
128
127
|
- app/models/solr_document.rb
|
129
128
|
- app/search_builders/hydra/collections/search_builder.rb
|
130
129
|
- app/views/batch_select/_add_button.html.erb
|
@@ -214,12 +213,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
213
|
version: '0'
|
215
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
215
|
requirements:
|
217
|
-
- - "
|
216
|
+
- - ">"
|
218
217
|
- !ruby/object:Gem::Version
|
219
|
-
version:
|
218
|
+
version: 1.3.1
|
220
219
|
requirements: []
|
221
220
|
rubyforge_project:
|
222
|
-
rubygems_version: 2.4.
|
221
|
+
rubygems_version: 2.4.3
|
223
222
|
signing_key:
|
224
223
|
specification_version: 4
|
225
224
|
summary: A rails engine for managing Hydra Collections
|