hydra-collections 2.0.5 → 3.0.0.beta1
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/.gitignore +1 -0
 - data/.gitmodules +0 -4
 - data/.rspec +1 -0
 - data/Gemfile +9 -0
 - data/README.md +3 -3
 - data/Rakefile +8 -8
 - data/{lib → app/controllers/concerns}/hydra/collections/selects_collections.rb +3 -8
 - data/app/controllers/concerns/hydra/collections_controller_behavior.rb +19 -20
 - data/app/helpers/collections_search_helper.rb +2 -1
 - data/app/models/concerns/hydra/collection.rb +80 -16
 - data/app/views/collections/_search_form.html.erb +0 -16
 - data/hydra-collections.gemspec +4 -4
 - data/lib/hydra/collections/accepts_batches.rb +5 -5
 - data/lib/hydra/collections/collectible.rb +15 -8
 - data/lib/hydra/collections/solr_document_behavior.rb +0 -15
 - data/lib/hydra/collections/version.rb +1 -1
 - data/spec/controllers/catalog_controller_spec.rb +5 -19
 - data/spec/controllers/collections_controller_spec.rb +125 -154
 - data/spec/controllers/other_collections_controller_spec.rb +13 -15
 - data/spec/controllers/selects_collections_spec.rb +39 -48
 - data/spec/factories.rb +0 -14
 - data/spec/factories/users.rb +0 -14
 - data/spec/helpers/collections_helper_spec.rb +14 -16
 - data/spec/helpers/collections_search_helper_spec.rb +4 -2
 - data/spec/lib/collectible_spec.rb +7 -7
 - data/spec/models/collection_spec.rb +40 -42
 - data/spec/spec_helper.rb +12 -1
 - data/spec/{support → test_app_templates}/app/models/sample.rb +0 -0
 - data/spec/{support → test_app_templates}/app/models/solr_document.rb +0 -0
 - data/spec/{support → test_app_templates}/app/views/catalog/_document_header.html.erb +0 -0
 - data/spec/{support → test_app_templates}/app/views/catalog/_index_collection.html.erb +0 -0
 - data/spec/{support → test_app_templates}/app/views/catalog/_sort_and_per_page.html.erb +0 -0
 - data/spec/{support → test_app_templates}/db/migrate/20111101221803_create_searches.rb +0 -0
 - data/spec/{support → test_app_templates}/lib/generators/test_app_generator.rb +10 -2
 - data/spec/{support → test_app_templates}/lib/tasks/rspec.rake +0 -0
 - data/tasks/hydra-collections-dev.rake +16 -56
 - metadata +33 -36
 - data/app/models/datastreams/hydra/collection_rdf_datastream.rb +0 -58
 - data/spec/factories/.gitkeep +0 -0
 
| 
         @@ -14,21 +14,21 @@ class OtherCollection < ActiveFedora::Base 
     | 
|
| 
       14 
14 
     | 
    
         
             
              include Hydra::Collection
         
     | 
| 
       15 
15 
     | 
    
         
             
              include Hydra::Collections::Collectible
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
              def to_solr(solr_doc={} 
     | 
| 
       18 
     | 
    
         
            -
                super 
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                 
     | 
| 
      
 17 
     | 
    
         
            +
              def to_solr(solr_doc={})
         
     | 
| 
      
 18 
     | 
    
         
            +
                super.tap do |solr_doc|
         
     | 
| 
      
 19 
     | 
    
         
            +
                  index_collection_ids(solr_doc)
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
       21 
21 
     | 
    
         
             
              end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
22 
     | 
    
         
             
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       24 
24 
     | 
    
         
             
            class Member < ActiveFedora::Base
         
     | 
| 
       25 
25 
     | 
    
         
             
              include Hydra::Collections::Collectible
         
     | 
| 
       26 
26 
     | 
    
         
             
              attr_accessor :title
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
              def to_solr(solr_doc={} 
     | 
| 
       29 
     | 
    
         
            -
                super 
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                 
     | 
| 
      
 28 
     | 
    
         
            +
              def to_solr(solr_doc={})
         
     | 
| 
      
 29 
     | 
    
         
            +
                super.tap do |solr_doc|
         
     | 
| 
      
 30 
     | 
    
         
            +
                  index_collection_ids(solr_doc)
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
       32 
32 
     | 
    
         
             
              end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
            end
         
     | 
| 
         @@ -75,12 +75,10 @@ describe OtherCollectionsController, :type => :controller do 
     | 
|
| 
       75 
75 
     | 
    
         
             
                end
         
     | 
| 
       76 
76 
     | 
    
         
             
                it "should show the collections" do
         
     | 
| 
       77 
77 
     | 
    
         
             
                  routes.draw { resources :other_collections, except: :index }
         
     | 
| 
       78 
     | 
    
         
            -
                  get :show, id: collection 
     | 
| 
       79 
     | 
    
         
            -
                  expect(assigns[:collection].title).to eq 
     | 
| 
       80 
     | 
    
         
            -
                  ids = assigns[:member_docs].map 
     | 
| 
       81 
     | 
    
         
            -
                  expect(ids).to include 
     | 
| 
       82 
     | 
    
         
            -
                  expect(ids).to include asset2.pid
         
     | 
| 
       83 
     | 
    
         
            -
                  expect(ids).to include asset3.pid
         
     | 
| 
      
 78 
     | 
    
         
            +
                  get :show, id: collection
         
     | 
| 
      
 79 
     | 
    
         
            +
                  expect(assigns[:collection].title).to eq collection.title
         
     | 
| 
      
 80 
     | 
    
         
            +
                  ids = assigns[:member_docs].map(&:id)
         
     | 
| 
      
 81 
     | 
    
         
            +
                  expect(ids).to include(asset1.id, asset2.id, asset3.id)
         
     | 
| 
       84 
82 
     | 
    
         
             
                end
         
     | 
| 
       85 
83 
     | 
    
         
             
              end
         
     | 
| 
       86 
84 
     | 
    
         | 
| 
         @@ -24,7 +24,7 @@ describe SelectsCollectionsController, :type => :controller do 
     | 
|
| 
       24 
24 
     | 
    
         
             
              end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
              describe "Select Collections" do
         
     | 
| 
       27 
     | 
    
         
            -
                before  
     | 
| 
      
 27 
     | 
    
         
            +
                before do
         
     | 
| 
       28 
28 
     | 
    
         
             
                  @user = FactoryGirl.find_or_create(:user)
         
     | 
| 
       29 
29 
     | 
    
         
             
                  @collection = Collection.new title:"Test Public"
         
     | 
| 
       30 
30 
     | 
    
         
             
                  @collection.apply_depositor_metadata(@user.user_key)
         
     | 
| 
         @@ -41,36 +41,34 @@ describe SelectsCollectionsController, :type => :controller do 
     | 
|
| 
       41 
41 
     | 
    
         
             
                  @collection4 = Collection.new title:"Test No Access"
         
     | 
| 
       42 
42 
     | 
    
         
             
                  @collection4.apply_depositor_metadata('abc123@test.com')
         
     | 
| 
       43 
43 
     | 
    
         
             
                  @collection4.save
         
     | 
| 
       44 
     | 
    
         
            -
                  @collections = []
         
     | 
| 
       45 
     | 
    
         
            -
                  (1..11).each do |i|
         
     | 
| 
       46 
     | 
    
         
            -
                    collection = Collection.new title:"Test Public #{i}"
         
     | 
| 
       47 
     | 
    
         
            -
                    collection.apply_depositor_metadata(@user.user_key)
         
     | 
| 
       48 
     | 
    
         
            -
                    collection.read_groups = ["public"]
         
     | 
| 
       49 
     | 
    
         
            -
                    collection.save
         
     | 
| 
       50 
     | 
    
         
            -
                    @collections << collection
         
     | 
| 
       51 
     | 
    
         
            -
                  end
         
     | 
| 
       52 
     | 
    
         
            -
                end
         
     | 
| 
       53 
     | 
    
         
            -
                after (:all) do
         
     | 
| 
       54 
     | 
    
         
            -
                  Collection.delete_all
         
     | 
| 
       55 
44 
     | 
    
         
             
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
       56 
46 
     | 
    
         
             
                describe "Public Access" do
         
     | 
| 
       57 
     | 
    
         
            -
                   
     | 
| 
      
 47 
     | 
    
         
            +
                  let(:user_collections) do
         
     | 
| 
       58 
48 
     | 
    
         
             
                    subject.find_collections
         
     | 
| 
       59 
     | 
    
         
            -
                     
     | 
| 
       60 
     | 
    
         
            -
                    expect(@user_collections).to be_kind_of(Array)
         
     | 
| 
      
 49 
     | 
    
         
            +
                    subject.instance_variable_get(:@user_collections)
         
     | 
| 
       61 
50 
     | 
    
         
             
                  end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  it "should only return public collections" do
         
     | 
| 
      
 53 
     | 
    
         
            +
                    expect(user_collections.map(&:id)).to match_array [@collection.id]
         
     | 
| 
       64 
54 
     | 
    
         
             
                  end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                  context "when there are more than 10" do
         
     | 
| 
      
 57 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 58 
     | 
    
         
            +
                      11.times do |i|
         
     | 
| 
      
 59 
     | 
    
         
            +
                        Collection.new(title:"Test Public #{i}").tap do |col|
         
     | 
| 
      
 60 
     | 
    
         
            +
                          col.apply_depositor_metadata(@user.user_key)
         
     | 
| 
      
 61 
     | 
    
         
            +
                          col.read_groups = ["public"]
         
     | 
| 
      
 62 
     | 
    
         
            +
                          col.save!
         
     | 
| 
      
 63 
     | 
    
         
            +
                        end
         
     | 
| 
      
 64 
     | 
    
         
            +
                      end
         
     | 
| 
      
 65 
     | 
    
         
            +
                    end
         
     | 
| 
      
 66 
     | 
    
         
            +
                    it "should return all public collections" do
         
     | 
| 
      
 67 
     | 
    
         
            +
                      expect(user_collections.count).to eq(12)
         
     | 
| 
      
 68 
     | 
    
         
            +
                    end
         
     | 
| 
       67 
69 
     | 
    
         
             
                  end
         
     | 
| 
       68 
     | 
    
         
            -
                  it "should not return non public collections" do
         
     | 
| 
       69 
     | 
    
         
            -
                    expect(@user_collections.index{|d| d.id == @collection2.id}).to be_nil
         
     | 
| 
       70 
     | 
    
         
            -
                    expect(@user_collections.index{|d| d.id == @collection3.id}).to be_nil
         
     | 
| 
       71 
     | 
    
         
            -
                    expect(@user_collections.index{|d| d.id == @collection4.id}).to be_nil
         
     | 
| 
       72 
     | 
    
         
            -
                   end
         
     | 
| 
       73 
70 
     | 
    
         
             
                end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
       74 
72 
     | 
    
         
             
                describe "Read Access" do
         
     | 
| 
       75 
73 
     | 
    
         
             
                  describe "not signed in" do
         
     | 
| 
       76 
74 
     | 
    
         
             
                    it "should error if the user is not signed in" do
         
     | 
| 
         @@ -78,45 +76,38 @@ describe SelectsCollectionsController, :type => :controller do 
     | 
|
| 
       78 
76 
     | 
    
         
             
                    end
         
     | 
| 
       79 
77 
     | 
    
         
             
                  end
         
     | 
| 
       80 
78 
     | 
    
         
             
                  describe "signed in" do
         
     | 
| 
       81 
     | 
    
         
            -
                    before  
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
      
 79 
     | 
    
         
            +
                    before { sign_in @user }
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                    let(:user_collections) do
         
     | 
| 
       83 
82 
     | 
    
         
             
                      subject.find_collections_with_read_access
         
     | 
| 
       84 
     | 
    
         
            -
                       
     | 
| 
       85 
     | 
    
         
            -
                      expect(@user_collections).to be_kind_of(Array)
         
     | 
| 
      
 83 
     | 
    
         
            +
                      subject.instance_variable_get(:@user_collections)
         
     | 
| 
       86 
84 
     | 
    
         
             
                    end
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                      expect( 
     | 
| 
       90 
     | 
    
         
            -
                      expect(@user_collections.index{|d| d.id == @collection3.id}).not_to be_nil
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                    it "should return only public and read access (edit access implies read) collections" do
         
     | 
| 
      
 87 
     | 
    
         
            +
                      expect(user_collections.map(&:id)).to match_array [@collection.id, @collection2.id, @collection3.id]
         
     | 
| 
       91 
88 
     | 
    
         
             
                    end 
         
     | 
| 
       92 
     | 
    
         
            -
                    it "should not return non public collections" do
         
     | 
| 
       93 
     | 
    
         
            -
                      expect(@user_collections.index{|d| d.id == @collection4.id}).to be_nil
         
     | 
| 
       94 
     | 
    
         
            -
                    end
         
     | 
| 
       95 
89 
     | 
    
         
             
                  end
         
     | 
| 
       96 
90 
     | 
    
         
             
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
       97 
92 
     | 
    
         
             
                describe "Edit Access" do
         
     | 
| 
       98 
93 
     | 
    
         
             
                  describe "not signed in" do
         
     | 
| 
       99 
94 
     | 
    
         
             
                    it "should error if the user is not signed in" do
         
     | 
| 
       100 
95 
     | 
    
         
             
                      expect { subject.find_collections_with_edit_access }.to raise_error
         
     | 
| 
       101 
96 
     | 
    
         
             
                    end
         
     | 
| 
       102 
97 
     | 
    
         
             
                  end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
       103 
99 
     | 
    
         
             
                  describe "signed in" do
         
     | 
| 
       104 
     | 
    
         
            -
                    before  
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
      
 100 
     | 
    
         
            +
                    before { sign_in @user }
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                    let(:user_collections) do
         
     | 
| 
       106 
103 
     | 
    
         
             
                      subject.find_collections_with_edit_access
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
                       expect(@user_collections).to be_kind_of(Array)
         
     | 
| 
       109 
     | 
    
         
            -
                     end
         
     | 
| 
       110 
     | 
    
         
            -
                    it "should return public or editable collections" do
         
     | 
| 
       111 
     | 
    
         
            -
                      expect(@user_collections.index{|d| d.id == @collection.id}).not_to be_nil
         
     | 
| 
       112 
     | 
    
         
            -
                      expect(@user_collections.index{|d| d.id == @collection3.id}).not_to be_nil
         
     | 
| 
       113 
     | 
    
         
            -
                    end 
         
     | 
| 
       114 
     | 
    
         
            -
                    it "should not return non public or editable collections" do
         
     | 
| 
       115 
     | 
    
         
            -
                      expect(@user_collections.index{|d| d.id == @collection2.id}).to be_nil
         
     | 
| 
       116 
     | 
    
         
            -
                      expect(@user_collections.index{|d| d.id == @collection4.id}).to be_nil
         
     | 
| 
      
 104 
     | 
    
         
            +
                      subject.instance_variable_get(:@user_collections)
         
     | 
| 
       117 
105 
     | 
    
         
             
                    end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                    it "should return only public or editable collections" do
         
     | 
| 
      
 108 
     | 
    
         
            +
                      expect(user_collections.map(&:id)).to match_array [@collection.id, @collection3.id]
         
     | 
| 
      
 109 
     | 
    
         
            +
                    end 
         
     | 
| 
       118 
110 
     | 
    
         
             
                  end
         
     | 
| 
       119 
111 
     | 
    
         
             
                end
         
     | 
| 
       120 
112 
     | 
    
         
             
              end
         
     | 
| 
       121 
     | 
    
         
            -
              
         
     | 
| 
       122 
113 
     | 
    
         
             
            end
         
     | 
    
        data/spec/factories.rb
    CHANGED
    
    | 
         @@ -1,17 +1,3 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Copyright © 2012 The Pennsylvania State University
         
     | 
| 
       2 
     | 
    
         
            -
            #
         
     | 
| 
       3 
     | 
    
         
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
       4 
     | 
    
         
            -
            # you may not use this file except in compliance with the License.
         
     | 
| 
       5 
     | 
    
         
            -
            # You may obtain a copy of the License at
         
     | 
| 
       6 
     | 
    
         
            -
            #
         
     | 
| 
       7 
     | 
    
         
            -
            # http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
       8 
     | 
    
         
            -
            #
         
     | 
| 
       9 
     | 
    
         
            -
            # Unless required by applicable law or agreed to in writing, software
         
     | 
| 
       10 
     | 
    
         
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 
       11 
     | 
    
         
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         
     | 
| 
       12 
     | 
    
         
            -
            # See the License for the specific language governing permissions and
         
     | 
| 
       13 
     | 
    
         
            -
            # limitations under the License.
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
1 
     | 
    
         
             
            FactoryGirl.define do
         
     | 
| 
       16 
2 
     | 
    
         
             
              factory :collection 
         
     | 
| 
       17 
3 
     | 
    
         
             
            end
         
     | 
    
        data/spec/factories/users.rb
    CHANGED
    
    | 
         @@ -1,17 +1,3 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Copyright © 2012 The Pennsylvania State University
         
     | 
| 
       2 
     | 
    
         
            -
            #
         
     | 
| 
       3 
     | 
    
         
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
       4 
     | 
    
         
            -
            # you may not use this file except in compliance with the License.
         
     | 
| 
       5 
     | 
    
         
            -
            # You may obtain a copy of the License at
         
     | 
| 
       6 
     | 
    
         
            -
            #
         
     | 
| 
       7 
     | 
    
         
            -
            # http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
       8 
     | 
    
         
            -
            #
         
     | 
| 
       9 
     | 
    
         
            -
            # Unless required by applicable law or agreed to in writing, software
         
     | 
| 
       10 
     | 
    
         
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 
       11 
     | 
    
         
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         
     | 
| 
       12 
     | 
    
         
            -
            # See the License for the specific language governing permissions and
         
     | 
| 
       13 
     | 
    
         
            -
            # limitations under the License.
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
1 
     | 
    
         
             
            FactoryGirl.define do
         
     | 
| 
       16 
2 
     | 
    
         
             
              factory :user, :class => User do |u|
         
     | 
| 
       17 
3 
     | 
    
         
             
                email 'jilluser@example.com'
         
     | 
| 
         @@ -22,17 +22,15 @@ describe CollectionsHelper, :type => :helper do 
     | 
|
| 
       22 
22 
     | 
    
         
             
                end
         
     | 
| 
       23 
23 
     | 
    
         
             
              end
         
     | 
| 
       24 
24 
     | 
    
         
             
              describe "button_for_delete_collection" do
         
     | 
| 
       25 
     | 
    
         
            -
                before  
     | 
| 
      
 25 
     | 
    
         
            +
                before do
         
     | 
| 
       26 
26 
     | 
    
         
             
                  @collection = Collection.create(title: "Test Public")
         
     | 
| 
       27 
27 
     | 
    
         
             
                end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                  @collection.delete
         
     | 
| 
       30 
     | 
    
         
            -
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       31 
29 
     | 
    
         
             
                it " should create a button to the collections delete path" do
         
     | 
| 
       32 
30 
     | 
    
         
             
                  str = button_for_delete_collection @collection
         
     | 
| 
       33 
31 
     | 
    
         
             
                  doc = Nokogiri::HTML(str)
         
     | 
| 
       34 
32 
     | 
    
         
             
                  form = doc.xpath('//form').first
         
     | 
| 
       35 
     | 
    
         
            -
                  expect(form.attr('action')).to eq 
     | 
| 
      
 33 
     | 
    
         
            +
                  expect(form.attr('action')).to eq collections.collection_path(@collection)
         
     | 
| 
       36 
34 
     | 
    
         
             
                  i = form.children.first.children[1]
         
     | 
| 
       37 
35 
     | 
    
         
             
                  expect(i.attr('type')).to eq('submit')
         
     | 
| 
       38 
36 
     | 
    
         
             
                end
         
     | 
| 
         @@ -40,7 +38,7 @@ describe CollectionsHelper, :type => :helper do 
     | 
|
| 
       40 
38 
     | 
    
         
             
                  str = button_for_delete_collection @collection, "Delete My Button"
         
     | 
| 
       41 
39 
     | 
    
         
             
                  doc = Nokogiri::HTML(str)
         
     | 
| 
       42 
40 
     | 
    
         
             
                  form = doc.xpath('//form').first
         
     | 
| 
       43 
     | 
    
         
            -
                  expect(form.attr('action')).to eq 
     | 
| 
      
 41 
     | 
    
         
            +
                  expect(form.attr('action')).to eq collections.collection_path(@collection)
         
     | 
| 
       44 
42 
     | 
    
         
             
                  i = form.children.first.children[1]
         
     | 
| 
       45 
43 
     | 
    
         
             
                  expect(i.attr('value')).to eq("Delete My Button")
         
     | 
| 
       46 
44 
     | 
    
         
             
                end
         
     | 
| 
         @@ -55,7 +53,7 @@ describe CollectionsHelper, :type => :helper do 
     | 
|
| 
       55 
53 
     | 
    
         
             
                  str = button_for_remove_from_collection item
         
     | 
| 
       56 
54 
     | 
    
         
             
                  doc = Nokogiri::HTML(str)
         
     | 
| 
       57 
55 
     | 
    
         
             
                  form = doc.xpath('//form').first
         
     | 
| 
       58 
     | 
    
         
            -
                  expect(form.attr('action')).to eq 
     | 
| 
      
 56 
     | 
    
         
            +
                  expect(form.attr('action')).to eq collections.collection_path(@collection)
         
     | 
| 
       59 
57 
     | 
    
         
             
                  expect(form.css('input#collection_members[type="hidden"][value="remove"]')).not_to be_empty
         
     | 
| 
       60 
58 
     | 
    
         
             
                  expect(form.css('input[type="hidden"][name="batch_document_ids[]"][value="changeme:123"]')).not_to be_empty
         
     | 
| 
       61 
59 
     | 
    
         
             
                end
         
     | 
| 
         @@ -77,34 +75,34 @@ describe CollectionsHelper, :type => :helper do 
     | 
|
| 
       77 
75 
     | 
    
         
             
                    str = button_for_remove_from_collection item
         
     | 
| 
       78 
76 
     | 
    
         
             
                    doc = Nokogiri::HTML(str)
         
     | 
| 
       79 
77 
     | 
    
         
             
                    form = doc.xpath('//form').first
         
     | 
| 
       80 
     | 
    
         
            -
                    expect(form.attr('action')).to eq 
     | 
| 
      
 78 
     | 
    
         
            +
                    expect(form.attr('action')).to eq collections.collection_path(@collection)
         
     | 
| 
       81 
79 
     | 
    
         
             
                    expect(form.css('input#collection_members[type="hidden"][value="remove"]')).not_to be_empty
         
     | 
| 
       82 
80 
     | 
    
         
             
                    expect(form.css('input[type="hidden"][name="batch_document_ids[]"][value="changeme:123"]')).not_to be_empty
         
     | 
| 
       83 
81 
     | 
    
         
             
                  end
         
     | 
| 
       84 
82 
     | 
    
         | 
| 
       85 
83 
     | 
    
         
             
                end
         
     | 
| 
       86 
     | 
    
         
            -
              end 
     | 
| 
      
 84 
     | 
    
         
            +
              end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
       87 
86 
     | 
    
         
             
              describe "button_for_remove_selected_from_collection" do
         
     | 
| 
       88 
     | 
    
         
            -
                before  
     | 
| 
       89 
     | 
    
         
            -
                  @collection = Collection.create title:"Test Public"
         
     | 
| 
       90 
     | 
    
         
            -
                end
         
     | 
| 
       91 
     | 
    
         
            -
                after (:all) do
         
     | 
| 
       92 
     | 
    
         
            -
                  @collection.delete
         
     | 
| 
      
 87 
     | 
    
         
            +
                before do
         
     | 
| 
      
 88 
     | 
    
         
            +
                  @collection = Collection.create title: "Test Public"
         
     | 
| 
       93 
89 
     | 
    
         
             
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
       94 
91 
     | 
    
         
             
                it " should create a button to the collections delete path" do
         
     | 
| 
       95 
92 
     | 
    
         
             
                  str = button_for_remove_selected_from_collection @collection
         
     | 
| 
       96 
93 
     | 
    
         
             
                  doc = Nokogiri::HTML(str)
         
     | 
| 
       97 
94 
     | 
    
         
             
                  form = doc.xpath('//form').first
         
     | 
| 
       98 
     | 
    
         
            -
                  expect(form.attr('action')).to eq 
     | 
| 
      
 95 
     | 
    
         
            +
                  expect(form.attr('action')).to eq collections.collection_path(@collection)
         
     | 
| 
       99 
96 
     | 
    
         
             
                  i = form.children[2]
         
     | 
| 
       100 
97 
     | 
    
         
             
                  expect(i.attr('value')).to eq("remove")
         
     | 
| 
       101 
98 
     | 
    
         
             
                  expect(i.attr('name')).to eq("collection[members]")
         
     | 
| 
       102 
99 
     | 
    
         
             
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
       103 
101 
     | 
    
         
             
                it "should create a button with my text" do
         
     | 
| 
       104 
102 
     | 
    
         
             
                  str = button_for_remove_selected_from_collection @collection, "Remove My Button"
         
     | 
| 
       105 
103 
     | 
    
         
             
                  doc = Nokogiri::HTML(str)
         
     | 
| 
       106 
104 
     | 
    
         
             
                  form = doc.css('form').first
         
     | 
| 
       107 
     | 
    
         
            -
                  expect(form.attr('action')).to eq collections.collection_path(@collection 
     | 
| 
      
 105 
     | 
    
         
            +
                  expect(form.attr('action')).to eq collections.collection_path(@collection)
         
     | 
| 
       108 
106 
     | 
    
         
             
                  expect(form.css('input[type="submit"]').attr('value').value).to eq "Remove My Button"
         
     | 
| 
       109 
107 
     | 
    
         
             
                end
         
     | 
| 
       110 
108 
     | 
    
         
             
              end
         
     | 
| 
         @@ -4,11 +4,13 @@ describe CollectionsSearchHelper, :type => :helper do 
     | 
|
| 
       4 
4 
     | 
    
         
             
              describe "collection_name" do
         
     | 
| 
       5 
5 
     | 
    
         
             
                let (:collection_without_title) { Collection.create() }
         
     | 
| 
       6 
6 
     | 
    
         
             
                let (:collection_with_title) { Collection.create(title: "Title of Collection 2") }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       7 
8 
     | 
    
         
             
                it "should return the pid if no title available" do
         
     | 
| 
       8 
     | 
    
         
            -
                  expect(collection_name(collection_without_title. 
     | 
| 
      
 9 
     | 
    
         
            +
                  expect(collection_name(collection_without_title.id)).to eq collection_without_title.id
         
     | 
| 
       9 
10 
     | 
    
         
             
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       10 
12 
     | 
    
         
             
                it "should return the title value associated with the given pid" do
         
     | 
| 
       11 
     | 
    
         
            -
                  expect(collection_name(collection_with_title. 
     | 
| 
      
 13 
     | 
    
         
            +
                  expect(collection_name(collection_with_title.id)).to eq "Title of Collection 2"
         
     | 
| 
       12 
14 
     | 
    
         
             
                end
         
     | 
| 
       13 
15 
     | 
    
         
             
              end
         
     | 
| 
       14 
16 
     | 
    
         
             
            end
         
     | 
| 
         @@ -15,17 +15,17 @@ describe Hydra::Collections::Collectible do 
     | 
|
| 
       15 
15 
     | 
    
         
             
                  @collection1.members << @collectible
         
     | 
| 
       16 
16 
     | 
    
         
             
                  @collection1.save
         
     | 
| 
       17 
17 
     | 
    
         
             
                  @collectible.collections << @collection2
         
     | 
| 
       18 
     | 
    
         
            -
                  reloaded = CollectibleThing.find(@collectible. 
     | 
| 
       19 
     | 
    
         
            -
                  expect(@collection2.reload.members).to eq 
     | 
| 
       20 
     | 
    
         
            -
                  expect(reloaded.collections).to eq 
     | 
| 
      
 18 
     | 
    
         
            +
                  reloaded = CollectibleThing.find(@collectible.id)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(@collection2.reload.members).to eq [@collectible]
         
     | 
| 
      
 20 
     | 
    
         
            +
                  expect(reloaded.collections).to eq [@collection1, @collection2]
         
     | 
| 
       21 
21 
     | 
    
         
             
                end
         
     | 
| 
       22 
22 
     | 
    
         
             
              end
         
     | 
| 
       23 
     | 
    
         
            -
              describe " 
     | 
| 
       24 
     | 
    
         
            -
                it "should add  
     | 
| 
      
 23 
     | 
    
         
            +
              describe "index_collection_ids" do
         
     | 
| 
      
 24 
     | 
    
         
            +
                it "should add ids for all associated collections" do
         
     | 
| 
       25 
25 
     | 
    
         
             
                  @collectible.save
         
     | 
| 
       26 
26 
     | 
    
         
             
                  @collectible.collections << @collection1
         
     | 
| 
       27 
27 
     | 
    
         
             
                  @collectible.collections << @collection2
         
     | 
| 
       28 
     | 
    
         
            -
                  expect(@collectible. 
     | 
| 
      
 28 
     | 
    
         
            +
                  expect(@collectible.index_collection_ids["collection_sim"]).to eq [@collection1.id, @collection2.id]
         
     | 
| 
       29 
29 
     | 
    
         
             
                end
         
     | 
| 
       30 
30 
     | 
    
         
             
              end
         
     | 
| 
       31 
     | 
    
         
            -
            end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -7,9 +7,9 @@ describe Collection, :type => :model do 
     | 
|
| 
       7 
7 
     | 
    
         
             
                  include Hydra::Collections::Collectible
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                  def to_solr(solr_doc={}, opts={})
         
     | 
| 
       10 
     | 
    
         
            -
                    super(solr_doc, opts)
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                     
     | 
| 
      
 10 
     | 
    
         
            +
                    super(solr_doc, opts).tap do |solr_doc|
         
     | 
| 
      
 11 
     | 
    
         
            +
                      solr_doc = index_collection_ids(solr_doc)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    end
         
     | 
| 
       13 
13 
     | 
    
         
             
                  end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
         @@ -18,56 +18,44 @@ describe Collection, :type => :model do 
     | 
|
| 
       18 
18 
     | 
    
         
             
                @user.destroy
         
     | 
| 
       19 
19 
     | 
    
         
             
                Object.send(:remove_const, :GenericFile)
         
     | 
| 
       20 
20 
     | 
    
         
             
              end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              before do
         
     | 
| 
       22 
23 
     | 
    
         
             
                @collection = Collection.new
         
     | 
| 
       23 
24 
     | 
    
         
             
                @collection.apply_depositor_metadata(@user.user_key)
         
     | 
| 
       24 
     | 
    
         
            -
                @collection.save
         
     | 
| 
      
 25 
     | 
    
         
            +
                @collection.save!
         
     | 
| 
       25 
26 
     | 
    
         
             
                @gf1 = GenericFile.create
         
     | 
| 
       26 
27 
     | 
    
         
             
                @gf2 = GenericFile.create
         
     | 
| 
       27 
28 
     | 
    
         
             
              end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                @collection.destroy rescue
         
     | 
| 
       30 
     | 
    
         
            -
                @gf1.destroy
         
     | 
| 
       31 
     | 
    
         
            -
                @gf2.destroy
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
       33 
30 
     | 
    
         
             
              it "should have a depositor" do
         
     | 
| 
       34 
31 
     | 
    
         
             
                expect(@collection.depositor).to eq(@user.user_key)
         
     | 
| 
       35 
32 
     | 
    
         
             
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       36 
34 
     | 
    
         
             
              it "should allow the depositor to edit and read" do
         
     | 
| 
       37 
35 
     | 
    
         
             
                ability = Ability.new(@user)
         
     | 
| 
       38 
     | 
    
         
            -
                expect(ability.can?(:read, @collection)).to 
     | 
| 
       39 
     | 
    
         
            -
                expect(ability.can?(:edit, @collection)).to 
     | 
| 
      
 36 
     | 
    
         
            +
                expect(ability.can?(:read, @collection)).to be true
         
     | 
| 
      
 37 
     | 
    
         
            +
                expect(ability.can?(:edit, @collection)).to be true
         
     | 
| 
       40 
38 
     | 
    
         
             
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
       41 
40 
     | 
    
         
             
              it "should be empty by default" do
         
     | 
| 
       42 
41 
     | 
    
         
             
                expect(@collection.members).to be_empty
         
     | 
| 
       43 
42 
     | 
    
         
             
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       44 
44 
     | 
    
         
             
              it "should have many files" do
         
     | 
| 
       45 
45 
     | 
    
         
             
                @collection.members = [@gf1, @gf2]
         
     | 
| 
       46 
46 
     | 
    
         
             
                @collection.save
         
     | 
| 
       47 
     | 
    
         
            -
                expect( 
     | 
| 
      
 47 
     | 
    
         
            +
                expect(@collection.reload.members).to match_array [@gf1, @gf2]
         
     | 
| 
       48 
48 
     | 
    
         
             
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       49 
50 
     | 
    
         
             
              it "should allow new files to be added" do
         
     | 
| 
       50 
51 
     | 
    
         
             
                @collection.members = [@gf1]
         
     | 
| 
       51 
52 
     | 
    
         
             
                @collection.save
         
     | 
| 
       52 
     | 
    
         
            -
                @collection 
     | 
| 
      
 53 
     | 
    
         
            +
                @collection.reload
         
     | 
| 
       53 
54 
     | 
    
         
             
                @collection.members << @gf2
         
     | 
| 
       54 
55 
     | 
    
         
             
                @collection.save
         
     | 
| 
       55 
     | 
    
         
            -
                expect( 
     | 
| 
      
 56 
     | 
    
         
            +
                expect(@collection.reload.members).to match_array [@gf1, @gf2]
         
     | 
| 
       56 
57 
     | 
    
         
             
              end
         
     | 
| 
       57 
     | 
    
         
            -
              it "should allow files to be removed" do
         
     | 
| 
       58 
     | 
    
         
            -
                @collection.members = [@gf1, @gf2]
         
     | 
| 
       59 
     | 
    
         
            -
                @collection.save
         
     | 
| 
       60 
58 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                expect(@gf1.collections).to eq [@collection] # This line forces the "collections" to be cached.
         
     | 
| 
       62 
     | 
    
         
            -
                # We need to ensure that deleting causes the collection to be flushed.
         
     | 
| 
       63 
     | 
    
         
            -
                solr_doc_before_remove = ActiveFedora::SolrInstanceLoader.new(ActiveFedora::Base, @gf1.pid).send(:solr_doc)
         
     | 
| 
       64 
     | 
    
         
            -
                expect(solr_doc_before_remove["collection_tesim"]).to eq([@collection.pid])
         
     | 
| 
       65 
     | 
    
         
            -
                @collection.reload.members.delete(@gf1)
         
     | 
| 
       66 
     | 
    
         
            -
                @collection.save
         
     | 
| 
       67 
     | 
    
         
            -
                expect(Collection.find(@collection.pid).members).to eq([@gf2])
         
     | 
| 
       68 
     | 
    
         
            -
                solr_doc_after_remove = ActiveFedora::SolrInstanceLoader.new(ActiveFedora::Base, @gf1.pid).send(:solr_doc)
         
     | 
| 
       69 
     | 
    
         
            -
                expect(solr_doc_after_remove["collection_tesim"]).to be_nil
         
     | 
| 
       70 
     | 
    
         
            -
              end
         
     | 
| 
       71 
59 
     | 
    
         
             
              it "should set the date uploaded on create" do
         
     | 
| 
       72 
60 
     | 
    
         
             
                @collection.save
         
     | 
| 
       73 
61 
     | 
    
         
             
                expect(@collection.date_uploaded).to be_kind_of(Date)
         
     | 
| 
         @@ -75,7 +63,7 @@ describe Collection, :type => :model do 
     | 
|
| 
       75 
63 
     | 
    
         
             
              it "should update the date modified on update" do
         
     | 
| 
       76 
64 
     | 
    
         
             
                uploaded_date = Date.today
         
     | 
| 
       77 
65 
     | 
    
         
             
                modified_date = Date.tomorrow
         
     | 
| 
       78 
     | 
    
         
            -
                 
     | 
| 
      
 66 
     | 
    
         
            +
                expect(Date).to receive(:today).twice.and_return(uploaded_date, modified_date)
         
     | 
| 
       79 
67 
     | 
    
         
             
                @collection.save
         
     | 
| 
       80 
68 
     | 
    
         
             
                expect(@collection.date_modified).to eq(uploaded_date)
         
     | 
| 
       81 
69 
     | 
    
         
             
                @collection.members = [@gf1]
         
     | 
| 
         @@ -88,33 +76,41 @@ describe Collection, :type => :model do 
     | 
|
| 
       88 
76 
     | 
    
         
             
              it "should have a title" do
         
     | 
| 
       89 
77 
     | 
    
         
             
                @collection.title = "title"
         
     | 
| 
       90 
78 
     | 
    
         
             
                @collection.save
         
     | 
| 
       91 
     | 
    
         
            -
                expect(Collection.find(@collection. 
     | 
| 
      
 79 
     | 
    
         
            +
                expect(Collection.find(@collection.id).title).to eq(@collection.title)
         
     | 
| 
       92 
80 
     | 
    
         
             
              end
         
     | 
| 
       93 
81 
     | 
    
         
             
              it "should have a description" do
         
     | 
| 
       94 
82 
     | 
    
         
             
                @collection.description = "description"
         
     | 
| 
       95 
83 
     | 
    
         
             
                @collection.save
         
     | 
| 
       96 
     | 
    
         
            -
                expect(Collection.find(@collection. 
     | 
| 
      
 84 
     | 
    
         
            +
                expect(Collection.find(@collection.id).description).to eq(@collection.description)
         
     | 
| 
       97 
85 
     | 
    
         
             
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
       98 
87 
     | 
    
         
             
              it "should have the expected display terms" do
         
     | 
| 
       99 
     | 
    
         
            -
                expect(@collection.terms_for_display).to  
     | 
| 
      
 88 
     | 
    
         
            +
                expect(@collection.terms_for_display).to include(
         
     | 
| 
      
 89 
     | 
    
         
            +
                  :part_of, :contributor, :creator, :title, :description, :publisher, 
         
     | 
| 
      
 90 
     | 
    
         
            +
                  :date_created, :date_uploaded, :date_modified, :subject, :language, :rights, 
         
     | 
| 
      
 91 
     | 
    
         
            +
                  :resource_type, :identifier, :based_near, :tag, :related_url
         
     | 
| 
      
 92 
     | 
    
         
            +
                )
         
     | 
| 
       100 
93 
     | 
    
         
             
              end
         
     | 
| 
       101 
94 
     | 
    
         
             
              it "should have the expected edit terms" do
         
     | 
| 
       102 
     | 
    
         
            -
                expect(@collection.terms_for_editing).to  
     | 
| 
      
 95 
     | 
    
         
            +
                expect(@collection.terms_for_editing).to include(
         
     | 
| 
      
 96 
     | 
    
         
            +
                  :part_of, :contributor, :creator, :title, :description, :publisher, :date_created,
         
     | 
| 
      
 97 
     | 
    
         
            +
                  :subject, :language, :rights, :resource_type, :identifier, :based_near, :tag, :related_url
         
     | 
| 
      
 98 
     | 
    
         
            +
                 )
         
     | 
| 
       103 
99 
     | 
    
         
             
              end
         
     | 
| 
       104 
100 
     | 
    
         
             
              it "should not delete member files when deleted" do
         
     | 
| 
       105 
101 
     | 
    
         
             
                @collection.members = [@gf1, @gf2]
         
     | 
| 
       106 
102 
     | 
    
         
             
                @collection.save
         
     | 
| 
       107 
103 
     | 
    
         
             
                @collection.destroy
         
     | 
| 
       108 
     | 
    
         
            -
                expect(GenericFile. 
     | 
| 
       109 
     | 
    
         
            -
                expect(GenericFile. 
     | 
| 
      
 104 
     | 
    
         
            +
                expect(GenericFile).to exist(@gf1.id)
         
     | 
| 
      
 105 
     | 
    
         
            +
                expect(GenericFile).to exist(@gf2.id)
         
     | 
| 
       110 
106 
     | 
    
         
             
              end
         
     | 
| 
       111 
107 
     | 
    
         | 
| 
       112 
108 
     | 
    
         
             
              describe "Collection by another name" do
         
     | 
| 
       113 
109 
     | 
    
         
             
                before (:all) do
         
     | 
| 
       114 
110 
     | 
    
         
             
                  class OtherCollection < ActiveFedora::Base
         
     | 
| 
       115 
111 
     | 
    
         
             
                    include Hydra::Collection
         
     | 
| 
       116 
     | 
    
         
            -
                    include Hydra::Collections::Collectible
         
     | 
| 
       117 
112 
     | 
    
         
             
                  end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
       118 
114 
     | 
    
         
             
                  class Member < ActiveFedora::Base
         
     | 
| 
       119 
115 
     | 
    
         
             
                    include Hydra::Collections::Collectible
         
     | 
| 
       120 
116 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -124,15 +120,17 @@ describe Collection, :type => :model do 
     | 
|
| 
       124 
120 
     | 
    
         
             
                  Object.send(:remove_const, :Member)
         
     | 
| 
       125 
121 
     | 
    
         
             
                end
         
     | 
| 
       126 
122 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
                 
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
      
 123 
     | 
    
         
            +
                let(:member) { Member.create }
         
     | 
| 
      
 124 
     | 
    
         
            +
                let(:collection) { OtherCollection.new }
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
                before do
         
     | 
| 
       130 
127 
     | 
    
         
             
                  collection.members << member
         
     | 
| 
       131 
128 
     | 
    
         
             
                  collection.save
         
     | 
| 
      
 129 
     | 
    
         
            +
                end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                it "have members that know about the collection" do
         
     | 
| 
       132 
132 
     | 
    
         
             
                  member.reload
         
     | 
| 
       133 
     | 
    
         
            -
                  expect(member.collections).to eq 
     | 
| 
       134 
     | 
    
         
            -
                  collection.destroy
         
     | 
| 
       135 
     | 
    
         
            -
                  member.destroy
         
     | 
| 
      
 133 
     | 
    
         
            +
                  expect(member.collections).to eq [collection]
         
     | 
| 
       136 
134 
     | 
    
         
             
                end
         
     | 
| 
       137 
135 
     | 
    
         
             
              end
         
     | 
| 
       138 
136 
     | 
    
         |