hydra-collections 5.0.2 → 5.0.3
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/Gemfile +1 -1
- data/app/controllers/concerns/hydra/collections/selects_collections.rb +22 -3
- data/app/controllers/concerns/hydra/collections_controller_behavior.rb +1 -1
- data/app/models/concerns/hydra/collection.rb +4 -0
- data/lib/hydra/collections/version.rb +1 -1
- data/spec/controllers/collections_controller_spec.rb +2 -2
- data/spec/controllers/selects_collections_spec.rb +5 -0
- data/spec/lib/collectible_spec.rb +24 -17
- data/spec/models/collection_spec.rb +10 -2
- data/spec/test_app_templates/Gemfile.extra +1 -1
- data/spec/views/collections/_thumbnail_default.html.erb_spec.rb +1 -1
- data/tasks/hydra-collections-dev.rake +0 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7585019c90e5e1209d393c315e52f88b73169a95
|
4
|
+
data.tar.gz: 2655fad70f96136e738e3e11ffd81dcabb9ddfec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac2cedd5a619df9ae770e8c1f3998dd36ce5ab8352be884d75e08512f8dc0649890625ad7f384f4d697d216cc7f77653ab9e8ce60002d83a991528326d2a776b
|
7
|
+
data.tar.gz: cee8d4465333e5378c95c1ff3575b996b8e843cc8a552f1d3d713be40f7a6963bf55d538a229958ff6b560ef4c433d3ca6ba45360f87e5ce33d407e1b0d402ec
|
data/.travis.yml
CHANGED
@@ -7,8 +7,8 @@ env:
|
|
7
7
|
global:
|
8
8
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
9
9
|
matrix:
|
10
|
-
- "RAILS_VERSION=4.1.
|
11
|
-
- "RAILS_VERSION=4.2.
|
10
|
+
- "RAILS_VERSION=4.1.10"
|
11
|
+
- "RAILS_VERSION=4.2.1"
|
12
12
|
notifications:
|
13
13
|
email:
|
14
14
|
recipients:
|
@@ -21,3 +21,5 @@ notifications:
|
|
21
21
|
- "irc.freenode.org#projecthydra"
|
22
22
|
template:
|
23
23
|
- "%{repository}//%{branch}@%{commit} by %{author}: %{message} - %{build_url}"
|
24
|
+
before_script:
|
25
|
+
- jdk_switcher use oraclejdk8
|
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in hydra-collections.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem 'kaminari', github: '
|
6
|
+
gem 'kaminari', github: 'jcoyne/kaminari', branch: 'sufia'
|
7
7
|
|
8
8
|
group :development, :test do
|
9
9
|
gem 'sqlite3'
|
@@ -11,16 +11,35 @@ module Hydra::Collections::SelectsCollections
|
|
11
11
|
{ read: [:read, :edit], edit: [:edit] }
|
12
12
|
end
|
13
13
|
|
14
|
-
|
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
|
15
19
|
def find_collections_with_read_access
|
16
20
|
find_collections(:read)
|
17
21
|
end
|
18
22
|
|
19
|
-
|
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...")
|
20
34
|
find_collections(:edit)
|
35
|
+
default_option = SolrDocument.new(id: default_id, title_tesim: default_title)
|
36
|
+
@user_collections.unshift(default_option) if include_default
|
21
37
|
end
|
22
38
|
|
23
|
-
|
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
|
24
43
|
def find_collections (access_level = nil)
|
25
44
|
# need to know the user if there is an access level applied otherwise we are just doing public collections
|
26
45
|
authenticate_user! unless access_level.blank?
|
@@ -72,7 +72,7 @@ describe CollectionsController, :type => :controller do
|
|
72
72
|
@asset1 = ActiveFedora::Base.create!
|
73
73
|
@asset2 = ActiveFedora::Base.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 match_array [@asset1, @asset2]
|
76
76
|
end
|
77
77
|
it "should call after_create" do
|
78
78
|
expect(controller).to receive(:after_create).and_call_original
|
@@ -94,7 +94,7 @@ describe CollectionsController, :type => :controller do
|
|
94
94
|
@asset1 = GenericFile.create!
|
95
95
|
@asset2 = GenericFile.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 match_array [@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
|
@@ -91,6 +91,11 @@ describe SelectsCollectionsController, :type => :controller do
|
|
91
91
|
subject.find_collections_with_edit_access
|
92
92
|
expect(assigns[:user_collections].map(&:id)).to match_array [@collection.id, @collection3.id]
|
93
93
|
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
|
94
99
|
end
|
95
100
|
end
|
96
101
|
end
|
@@ -1,32 +1,39 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
class CollectibleThing < ActiveFedora::Base
|
3
|
-
include Hydra::Collections::Collectible
|
4
|
-
end
|
5
2
|
|
6
3
|
describe Hydra::Collections::Collectible do
|
7
4
|
before do
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
class CollectibleThing < ActiveFedora::Base
|
6
|
+
include Hydra::Collections::Collectible
|
7
|
+
end
|
11
8
|
end
|
9
|
+
|
10
|
+
let(:collection1) { FactoryGirl.create(:collection) }
|
11
|
+
let(:collection2) { FactoryGirl.create(:collection) }
|
12
|
+
let(:collectible) { CollectibleThing.new }
|
13
|
+
|
14
|
+
after do
|
15
|
+
Object.send(:remove_const, :CollectibleThing)
|
16
|
+
end
|
17
|
+
|
12
18
|
describe "collections associations" do
|
13
19
|
it "should allow adding and removing" do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
reloaded = CollectibleThing.find(
|
19
|
-
expect(
|
20
|
-
expect(reloaded.collections).to eq [
|
20
|
+
collectible.save
|
21
|
+
collection1.members << collectible
|
22
|
+
collection1.save
|
23
|
+
collectible.collections << collection2
|
24
|
+
reloaded = CollectibleThing.find(collectible.id)
|
25
|
+
expect(collection2.reload.members).to eq [collectible]
|
26
|
+
expect(reloaded.collections).to eq [collection1, collection2]
|
21
27
|
end
|
22
28
|
end
|
29
|
+
|
23
30
|
describe "index_collection_ids" do
|
24
31
|
it "should add ids for all associated collections" do
|
25
|
-
|
26
|
-
|
27
|
-
|
32
|
+
collectible.save
|
33
|
+
collectible.collections << collection1
|
34
|
+
collectible.collections << collection2
|
28
35
|
expect(Deprecation).to receive(:warn)
|
29
|
-
expect(
|
36
|
+
expect(collectible.index_collection_ids["collection_sim"]).to eq [collection1.id, collection2.id]
|
30
37
|
end
|
31
38
|
end
|
32
39
|
end
|
@@ -14,6 +14,7 @@ describe Collection, :type => :model do
|
|
14
14
|
|
15
15
|
let(:gf1) { GenericFile.create }
|
16
16
|
let(:gf2) { GenericFile.create }
|
17
|
+
let(:gf3) { GenericFile.create }
|
17
18
|
|
18
19
|
let(:user) { @user }
|
19
20
|
|
@@ -71,7 +72,7 @@ describe Collection, :type => :model do
|
|
71
72
|
subject { Collection.create(members: [gf1, gf2]) }
|
72
73
|
|
73
74
|
it "should have many files" do
|
74
|
-
expect(subject.reload.members).to
|
75
|
+
expect(subject.reload.members).to match_array [gf1, gf2]
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
@@ -84,7 +85,14 @@ describe Collection, :type => :model do
|
|
84
85
|
subject.reload
|
85
86
|
subject.members << gf2
|
86
87
|
subject.save
|
87
|
-
expect(subject.reload.members).to
|
88
|
+
expect(subject.reload.members).to match_array [gf1, gf2]
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should allow multiple files to be added" do
|
92
|
+
subject.reload
|
93
|
+
subject.add_members [gf2.id, gf3.id]
|
94
|
+
subject.save
|
95
|
+
expect(subject.reload.members).to match_array [gf1, gf2, gf3]
|
88
96
|
end
|
89
97
|
end
|
90
98
|
end
|
@@ -1 +1 @@
|
|
1
|
-
gem 'kaminari', github: '
|
1
|
+
gem 'kaminari', github: 'jcoyne/kaminari', branch: 'sufia'
|
@@ -9,7 +9,7 @@ describe 'collections/_thumbnail_default.html.erb' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
before do
|
12
|
-
assign :response, double(:params => {})
|
12
|
+
assign :response, double(:params => {}, :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: 5.0.
|
4
|
+
version: 5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carolyn Cole
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03
|
11
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hydra-head
|
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
205
|
version: '0'
|
206
206
|
requirements: []
|
207
207
|
rubyforge_project:
|
208
|
-
rubygems_version: 2.
|
208
|
+
rubygems_version: 2.2.2
|
209
209
|
signing_key:
|
210
210
|
specification_version: 4
|
211
211
|
summary: A rails engine for managing Hydra Collections
|