hydra-collections 5.0.2 → 5.0.3

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: f5ab9c82d9c2b45b6c93d58bb9629d142104cb77
4
- data.tar.gz: df870186ca05040cc5f4e07e38f29a03bcfb0900
3
+ metadata.gz: 7585019c90e5e1209d393c315e52f88b73169a95
4
+ data.tar.gz: 2655fad70f96136e738e3e11ffd81dcabb9ddfec
5
5
  SHA512:
6
- metadata.gz: d04a46fe91e9f572556e689bf0a7c759d5466f91bbcc8df17aebd68d5489f58629f2e1eeb1d9fdae8742d6ea0e2e497a89d70f0ed72fed7f5b4735cd46c28b31
7
- data.tar.gz: b18035284b01b0439912b716346eead6fdabbc6cad9aa8cec7d4ea2123c3c45f80d235ab9ad5b9cf25ba78fca2894b8b92c7843aba23e56ad420e84f81d0339d
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.8"
11
- - "RAILS_VERSION=4.2.0"
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: 'harai/kaminari', branch: 'route_prefix_prototype'
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
- # add one of the following methods as a before filter on any page that shows the form_for_select_collection
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
- def find_collections_with_edit_access
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?
@@ -172,7 +172,7 @@ module Hydra
172
172
 
173
173
  def add_members_to_collection collection = nil
174
174
  collection ||= @collection
175
- collection.member_ids = batch.concat(collection.member_ids)
175
+ collection.add_members batch
176
176
  end
177
177
 
178
178
  def remove_members_from_collection
@@ -21,5 +21,9 @@ module Hydra
21
21
  member.update_index
22
22
  end
23
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
24
28
  end
25
29
  end
@@ -1,5 +1,5 @@
1
1
  module Hydra
2
2
  module Collections
3
- VERSION = "5.0.2"
3
+ VERSION = "5.0.3"
4
4
  end
5
5
  end
@@ -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 eq([@asset1, @asset2])
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 eq([@asset1,@asset2])
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
- @collection1 = FactoryGirl.create(:collection)
9
- @collection2 = FactoryGirl.create(:collection)
10
- @collectible = CollectibleThing.new
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
- @collectible.save
15
- @collection1.members << @collectible
16
- @collection1.save
17
- @collectible.collections << @collection2
18
- reloaded = CollectibleThing.find(@collectible.id)
19
- expect(@collection2.reload.members).to eq [@collectible]
20
- expect(reloaded.collections).to eq [@collection1, @collection2]
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
- @collectible.save
26
- @collectible.collections << @collection1
27
- @collectible.collections << @collection2
32
+ collectible.save
33
+ collectible.collections << collection1
34
+ collectible.collections << collection2
28
35
  expect(Deprecation).to receive(:warn)
29
- expect(@collectible.index_collection_ids["collection_sim"]).to eq [@collection1.id, @collection2.id]
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 eq [gf1, gf2]
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 eq [gf1, gf2]
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: 'harai/kaminari', branch: 'route_prefix_prototype'
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
@@ -3,8 +3,6 @@ require 'rspec/core/rake_task'
3
3
  require 'jettywrapper'
4
4
  require 'engine_cart/rake_task'
5
5
 
6
- Jettywrapper.hydra_jetty_version = "v8.1.0"
7
-
8
6
  RSpec::Core::RakeTask.new(:spec) do |spec|
9
7
  spec.rspec_opts = ['--backtrace'] if ENV['CI']
10
8
  end
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.2
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-19 00:00:00.000000000 Z
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.4.6
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