hydra-collections 3.0.0.beta2 → 3.0.0.beta3
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/README.md +3 -3
- data/app/controllers/concerns/hydra/collections_controller_behavior.rb +20 -19
- data/app/helpers/collections_search_helper.rb +1 -2
- data/app/models/concerns/hydra/collection.rb +18 -82
- data/app/models/datastreams/hydra/collection_rdf_datastream.rb +54 -0
- data/app/views/collections/_search_form.html.erb +16 -0
- data/hydra-collections.gemspec +2 -3
- data/lib/hydra/collections/accepts_batches.rb +5 -5
- data/lib/hydra/collections/collectible.rb +8 -15
- data/{app/controllers/concerns → lib}/hydra/collections/selects_collections.rb +8 -3
- data/lib/hydra/collections/solr_document_behavior.rb +15 -0
- data/lib/hydra/collections/version.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +19 -5
- data/spec/controllers/collections_controller_spec.rb +154 -125
- data/spec/controllers/other_collections_controller_spec.rb +15 -13
- data/spec/controllers/selects_collections_spec.rb +48 -39
- data/spec/factories.rb +14 -0
- data/spec/factories/.gitkeep +0 -0
- data/spec/factories/users.rb +14 -0
- data/spec/helpers/collections_helper_spec.rb +16 -14
- data/spec/helpers/collections_search_helper_spec.rb +2 -4
- data/spec/lib/collectible_spec.rb +7 -7
- data/spec/models/collection_spec.rb +133 -78
- data/spec/spec_helper.rb +1 -12
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -1
- data/tasks/hydra-collections-dev.rake +1 -19
- metadata +9 -21
- data/.rspec +0 -1
@@ -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={}, opts={})
|
18
|
+
super(solr_doc, opts)
|
19
|
+
solr_doc = index_collection_pids(solr_doc)
|
20
|
+
return solr_doc
|
21
21
|
end
|
22
|
-
end
|
23
22
|
|
23
|
+
end
|
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={}, opts={})
|
29
|
+
super(solr_doc, opts)
|
30
|
+
solr_doc = index_collection_pids(solr_doc)
|
31
|
+
return solr_doc
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
@@ -75,10 +75,12 @@ 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
|
78
|
+
get :show, id: collection.id
|
79
|
+
expect(assigns[:collection].title).to eq(collection.title)
|
80
|
+
ids = assigns[:member_docs].map {|d| d.id}
|
81
|
+
expect(ids).to include asset1.pid
|
82
|
+
expect(ids).to include asset2.pid
|
83
|
+
expect(ids).to include asset3.pid
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
@@ -24,7 +24,7 @@ describe SelectsCollectionsController, :type => :controller do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "Select Collections" do
|
27
|
-
before do
|
27
|
+
before (:all) 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,34 +41,36 @@ 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
|
44
55
|
end
|
45
|
-
|
46
56
|
describe "Public Access" do
|
47
|
-
|
57
|
+
before (:each) do
|
48
58
|
subject.find_collections
|
49
|
-
subject.instance_variable_get(:@user_collections)
|
59
|
+
@user_collections = subject.instance_variable_get (:@user_collections)
|
60
|
+
expect(@user_collections).to be_kind_of(Array)
|
50
61
|
end
|
51
|
-
|
52
|
-
|
53
|
-
expect(user_collections.map(&:id)).to match_array [@collection.id]
|
62
|
+
it "should return public collections" do
|
63
|
+
expect(@user_collections.index{|d| d.id == @collection.id}).not_to be_nil
|
54
64
|
end
|
55
|
-
|
56
|
-
|
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
|
65
|
+
it "should return all public collections" do
|
66
|
+
expect(@user_collections.count).to eq(12)
|
69
67
|
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
|
70
73
|
end
|
71
|
-
|
72
74
|
describe "Read Access" do
|
73
75
|
describe "not signed in" do
|
74
76
|
it "should error if the user is not signed in" do
|
@@ -76,38 +78,45 @@ describe SelectsCollectionsController, :type => :controller do
|
|
76
78
|
end
|
77
79
|
end
|
78
80
|
describe "signed in" do
|
79
|
-
before
|
80
|
-
|
81
|
-
let(:user_collections) do
|
81
|
+
before (:each) do
|
82
|
+
sign_in @user
|
82
83
|
subject.find_collections_with_read_access
|
83
|
-
subject.instance_variable_get(:@user_collections)
|
84
|
+
@user_collections = subject.instance_variable_get (:@user_collections)
|
85
|
+
expect(@user_collections).to be_kind_of(Array)
|
84
86
|
end
|
85
|
-
|
86
|
-
|
87
|
-
expect(user_collections.
|
87
|
+
it "should return public and read access (edit access implies read) collections" do
|
88
|
+
expect(@user_collections.index{|d| d.id == @collection.id}).not_to be_nil
|
89
|
+
expect(@user_collections.index{|d| d.id == @collection2.id}).not_to be_nil
|
90
|
+
expect(@user_collections.index{|d| d.id == @collection3.id}).not_to be_nil
|
88
91
|
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
|
89
95
|
end
|
90
96
|
end
|
91
|
-
|
92
97
|
describe "Edit Access" do
|
93
98
|
describe "not signed in" do
|
94
99
|
it "should error if the user is not signed in" do
|
95
100
|
expect { subject.find_collections_with_edit_access }.to raise_error
|
96
101
|
end
|
97
102
|
end
|
98
|
-
|
99
103
|
describe "signed in" do
|
100
|
-
before
|
101
|
-
|
102
|
-
let(:user_collections) do
|
104
|
+
before (:each) do
|
105
|
+
sign_in @user
|
103
106
|
subject.find_collections_with_edit_access
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
it "should return
|
108
|
-
expect(user_collections.
|
107
|
+
@user_collections = subject.instance_variable_get (:@user_collections)
|
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
|
109
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
|
117
|
+
end
|
110
118
|
end
|
111
119
|
end
|
112
120
|
end
|
121
|
+
|
113
122
|
end
|
data/spec/factories.rb
CHANGED
@@ -1,3 +1,17 @@
|
|
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
|
+
|
1
15
|
FactoryGirl.define do
|
2
16
|
factory :collection
|
3
17
|
end
|
File without changes
|
data/spec/factories/users.rb
CHANGED
@@ -1,3 +1,17 @@
|
|
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
|
+
|
1
15
|
FactoryGirl.define do
|
2
16
|
factory :user, :class => User do |u|
|
3
17
|
email 'jilluser@example.com'
|
@@ -22,15 +22,17 @@ describe CollectionsHelper, :type => :helper do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
describe "button_for_delete_collection" do
|
25
|
-
before do
|
25
|
+
before (:all) do
|
26
26
|
@collection = Collection.create(title: "Test Public")
|
27
27
|
end
|
28
|
-
|
28
|
+
after (:all) do
|
29
|
+
@collection.delete
|
30
|
+
end
|
29
31
|
it " should create a button to the collections delete path" do
|
30
32
|
str = button_for_delete_collection @collection
|
31
33
|
doc = Nokogiri::HTML(str)
|
32
34
|
form = doc.xpath('//form').first
|
33
|
-
expect(form.attr('action')).to eq
|
35
|
+
expect(form.attr('action')).to eq("#{collections.collection_path(@collection.pid)}")
|
34
36
|
i = form.children.first.children[1]
|
35
37
|
expect(i.attr('type')).to eq('submit')
|
36
38
|
end
|
@@ -38,7 +40,7 @@ describe CollectionsHelper, :type => :helper do
|
|
38
40
|
str = button_for_delete_collection @collection, "Delete My Button"
|
39
41
|
doc = Nokogiri::HTML(str)
|
40
42
|
form = doc.xpath('//form').first
|
41
|
-
expect(form.attr('action')).to eq
|
43
|
+
expect(form.attr('action')).to eq("#{collections.collection_path(@collection.pid)}")
|
42
44
|
i = form.children.first.children[1]
|
43
45
|
expect(i.attr('value')).to eq("Delete My Button")
|
44
46
|
end
|
@@ -53,7 +55,7 @@ describe CollectionsHelper, :type => :helper do
|
|
53
55
|
str = button_for_remove_from_collection item
|
54
56
|
doc = Nokogiri::HTML(str)
|
55
57
|
form = doc.xpath('//form').first
|
56
|
-
expect(form.attr('action')).to eq
|
58
|
+
expect(form.attr('action')).to eq("#{collections.collection_path(@collection.pid)}")
|
57
59
|
expect(form.css('input#collection_members[type="hidden"][value="remove"]')).not_to be_empty
|
58
60
|
expect(form.css('input[type="hidden"][name="batch_document_ids[]"][value="changeme:123"]')).not_to be_empty
|
59
61
|
end
|
@@ -75,34 +77,34 @@ describe CollectionsHelper, :type => :helper do
|
|
75
77
|
str = button_for_remove_from_collection item
|
76
78
|
doc = Nokogiri::HTML(str)
|
77
79
|
form = doc.xpath('//form').first
|
78
|
-
expect(form.attr('action')).to eq
|
80
|
+
expect(form.attr('action')).to eq("#{collections.collection_path(@collection.pid)}")
|
79
81
|
expect(form.css('input#collection_members[type="hidden"][value="remove"]')).not_to be_empty
|
80
82
|
expect(form.css('input[type="hidden"][name="batch_document_ids[]"][value="changeme:123"]')).not_to be_empty
|
81
83
|
end
|
82
84
|
|
83
85
|
end
|
84
|
-
end
|
85
|
-
|
86
|
+
end
|
86
87
|
describe "button_for_remove_selected_from_collection" do
|
87
|
-
before do
|
88
|
-
@collection = Collection.create title:
|
88
|
+
before (:all) do
|
89
|
+
@collection = Collection.create title:"Test Public"
|
90
|
+
end
|
91
|
+
after (:all) do
|
92
|
+
@collection.delete
|
89
93
|
end
|
90
|
-
|
91
94
|
it " should create a button to the collections delete path" do
|
92
95
|
str = button_for_remove_selected_from_collection @collection
|
93
96
|
doc = Nokogiri::HTML(str)
|
94
97
|
form = doc.xpath('//form').first
|
95
|
-
expect(form.attr('action')).to eq
|
98
|
+
expect(form.attr('action')).to eq("#{collections.collection_path(@collection.pid)}")
|
96
99
|
i = form.children[2]
|
97
100
|
expect(i.attr('value')).to eq("remove")
|
98
101
|
expect(i.attr('name')).to eq("collection[members]")
|
99
102
|
end
|
100
|
-
|
101
103
|
it "should create a button with my text" do
|
102
104
|
str = button_for_remove_selected_from_collection @collection, "Remove My Button"
|
103
105
|
doc = Nokogiri::HTML(str)
|
104
106
|
form = doc.css('form').first
|
105
|
-
expect(form.attr('action')).to eq collections.collection_path(@collection)
|
107
|
+
expect(form.attr('action')).to eq collections.collection_path(@collection.id)
|
106
108
|
expect(form.css('input[type="submit"]').attr('value').value).to eq "Remove My Button"
|
107
109
|
end
|
108
110
|
end
|
@@ -4,13 +4,11 @@ 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
|
-
|
8
7
|
it "should return the pid if no title available" do
|
9
|
-
expect(collection_name(collection_without_title.
|
8
|
+
expect(collection_name(collection_without_title.pid)).to eq(collection_without_title.pid)
|
10
9
|
end
|
11
|
-
|
12
10
|
it "should return the title value associated with the given pid" do
|
13
|
-
expect(collection_name(collection_with_title.
|
11
|
+
expect(collection_name(collection_with_title.pid)).to eq("Title of Collection 2")
|
14
12
|
end
|
15
13
|
end
|
16
14
|
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.pid)
|
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_pids" do
|
24
|
+
it "should add pids 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_pids["collection_sim"]).to eq([@collection1.pid, @collection2.pid])
|
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)
|
11
|
+
solr_doc = index_collection_pids(solr_doc)
|
12
|
+
return solr_doc
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -18,120 +18,175 @@ describe Collection, :type => :model do
|
|
18
18
|
@user.destroy
|
19
19
|
Object.send(:remove_const, :GenericFile)
|
20
20
|
end
|
21
|
+
let(:gf1) { GenericFile.create }
|
22
|
+
let(:gf2) { GenericFile.create }
|
21
23
|
|
22
|
-
|
23
|
-
@collection = Collection.new
|
24
|
-
@collection.apply_depositor_metadata(@user.user_key)
|
25
|
-
@collection.save!
|
26
|
-
@gf1 = GenericFile.create
|
27
|
-
@gf2 = GenericFile.create
|
28
|
-
end
|
24
|
+
let(:user) { @user }
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
describe "#to_solr" do
|
27
|
+
let(:collection) { Collection.new(title: "A good title") }
|
28
|
+
|
29
|
+
subject { collection.to_solr }
|
33
30
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
expect(ability.can?(:edit, @collection)).to be true
|
31
|
+
it "should have title" do
|
32
|
+
expect(subject['desc_metadata__title_tesim']).to eq ['A good title']
|
33
|
+
end
|
38
34
|
end
|
39
35
|
|
40
|
-
|
41
|
-
|
36
|
+
describe "#depositor" do
|
37
|
+
before do
|
38
|
+
subject.apply_depositor_metadata(user)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have a depositor" do
|
42
|
+
expect(subject.depositor).to eq(user.user_key)
|
43
|
+
end
|
42
44
|
end
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
describe "the ability" do
|
47
|
+
let(:collection) do
|
48
|
+
Collection.new.tap do |collection|
|
49
|
+
collection.apply_depositor_metadata(user)
|
50
|
+
collection.save
|
51
|
+
end
|
52
|
+
end
|
53
|
+
subject { Ability.new(user) }
|
54
|
+
|
55
|
+
it "should allow the depositor to edit and read" do
|
56
|
+
expect(subject.can?(:read, collection)).to be true
|
57
|
+
expect(subject.can?(:edit, collection)).to be true
|
58
|
+
end
|
48
59
|
end
|
49
60
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
61
|
+
describe "#members" do
|
62
|
+
it "should be empty by default" do
|
63
|
+
expect(subject.members).to be_empty
|
64
|
+
end
|
65
|
+
|
66
|
+
context "adding members" do
|
67
|
+
context "using assignment" do
|
68
|
+
subject { Collection.create(members: [gf1, gf2]) }
|
69
|
+
|
70
|
+
it "should have many files" do
|
71
|
+
expect(subject.reload.members).to eq [gf1, gf2]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "using append" do
|
76
|
+
before do
|
77
|
+
subject.members = [gf1]
|
78
|
+
subject.save
|
79
|
+
end
|
80
|
+
it "should allow new files to be added" do
|
81
|
+
subject.reload
|
82
|
+
subject.members << gf2
|
83
|
+
subject.save
|
84
|
+
expect(subject.reload.members).to eq [gf1, gf2]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
context "removing members" do
|
91
|
+
before do
|
92
|
+
subject.members = [gf1, gf2]
|
93
|
+
subject.save
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should allow files to be removed" do
|
97
|
+
expect(gf1.collections).to eq [subject] # This line forces the "collections" to be cached.
|
98
|
+
# We need to ensure that deleting causes the collection to be flushed.
|
99
|
+
solr_doc_before_remove = ActiveFedora::SolrInstanceLoader.new(ActiveFedora::Base, gf1.pid).send(:solr_doc)
|
100
|
+
expect(solr_doc_before_remove["collection_tesim"]).to eq [subject.pid]
|
101
|
+
subject.reload.members.delete(gf1)
|
102
|
+
subject.save
|
103
|
+
expect(subject.reload.members).to eq [gf2]
|
104
|
+
solr_doc_after_remove = ActiveFedora::SolrInstanceLoader.new(ActiveFedora::Base, gf1.pid).send(:solr_doc)
|
105
|
+
expect(solr_doc_after_remove["collection_tesim"]).to be_nil
|
106
|
+
end
|
107
|
+
end
|
57
108
|
end
|
58
109
|
|
59
110
|
it "should set the date uploaded on create" do
|
60
|
-
|
61
|
-
expect(
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
111
|
+
subject.save
|
112
|
+
expect(subject.date_uploaded).to be_kind_of(Date)
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "when updating" do
|
116
|
+
let(:gf1) { GenericFile.create }
|
117
|
+
|
118
|
+
it "should update the date modified on update" do
|
119
|
+
uploaded_date = Date.today
|
120
|
+
modified_date = Date.tomorrow
|
121
|
+
subject.save
|
122
|
+
allow(Date).to receive(:today).and_return(uploaded_date, modified_date)
|
123
|
+
subject.save
|
124
|
+
expect(subject.date_modified).to eq uploaded_date
|
125
|
+
subject.members = [gf1]
|
126
|
+
subject.save
|
127
|
+
expect(subject.date_modified).to eq modified_date
|
128
|
+
expect(gf1.reload.collections).to include(subject)
|
129
|
+
expect(gf1.to_solr[Solrizer.solr_name(:collection)]).to eq [subject.id]
|
130
|
+
end
|
75
131
|
end
|
132
|
+
|
76
133
|
it "should have a title" do
|
77
|
-
|
78
|
-
|
79
|
-
expect(
|
134
|
+
subject.title = "title"
|
135
|
+
subject.save
|
136
|
+
expect(subject.title).to eq "title"
|
80
137
|
end
|
138
|
+
|
81
139
|
it "should have a description" do
|
82
|
-
|
83
|
-
|
84
|
-
expect(
|
140
|
+
subject.description = "description"
|
141
|
+
subject.save
|
142
|
+
expect(subject.reload.description).to eq "description"
|
85
143
|
end
|
86
144
|
|
87
145
|
it "should have the expected display terms" do
|
88
|
-
expect(
|
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
|
-
)
|
146
|
+
expect(subject.terms_for_display).to eq([:part_of, :contributor, :creator, :title, :description, :publisher, :date_created, :date_uploaded, :date_modified, :subject, :language, :rights, :resource_type, :identifier, :based_near, :tag, :related_url])
|
93
147
|
end
|
148
|
+
|
94
149
|
it "should have the expected edit terms" do
|
95
|
-
expect(
|
96
|
-
:part_of, :contributor, :creator, :title, :description, :publisher, :date_created,
|
97
|
-
:subject, :language, :rights, :resource_type, :identifier, :based_near, :tag, :related_url
|
98
|
-
)
|
150
|
+
expect(subject.terms_for_editing).to eq([:part_of, :contributor, :creator, :title, :description, :publisher, :date_created, :subject, :language, :rights, :resource_type, :identifier, :based_near, :tag, :related_url])
|
99
151
|
end
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
152
|
+
|
153
|
+
describe "#destroy" do
|
154
|
+
before do
|
155
|
+
subject.members = [gf1, gf2]
|
156
|
+
subject.save
|
157
|
+
subject.destroy
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should not delete member files when deleted" do
|
161
|
+
expect(GenericFile.exists?(gf1.pid)).to be true
|
162
|
+
expect(GenericFile.exists?(gf2.pid)).to be true
|
163
|
+
end
|
106
164
|
end
|
107
165
|
|
108
166
|
describe "Collection by another name" do
|
109
|
-
before
|
167
|
+
before do
|
110
168
|
class OtherCollection < ActiveFedora::Base
|
111
169
|
include Hydra::Collection
|
170
|
+
include Hydra::Collections::Collectible
|
112
171
|
end
|
113
|
-
|
114
172
|
class Member < ActiveFedora::Base
|
115
173
|
include Hydra::Collections::Collectible
|
116
174
|
end
|
117
175
|
end
|
118
|
-
after
|
176
|
+
after do
|
119
177
|
Object.send(:remove_const, :OtherCollection)
|
120
178
|
Object.send(:remove_const, :Member)
|
121
179
|
end
|
122
180
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
before do
|
181
|
+
it "have members that know about the collection" do
|
182
|
+
collection = OtherCollection.new
|
183
|
+
member = Member.create
|
127
184
|
collection.members << member
|
128
185
|
collection.save
|
129
|
-
end
|
130
|
-
|
131
|
-
it "have members that know about the collection" do
|
132
186
|
member.reload
|
133
|
-
expect(member.collections).to eq
|
187
|
+
expect(member.collections).to eq([collection])
|
188
|
+
collection.destroy
|
189
|
+
member.destroy
|
134
190
|
end
|
135
191
|
end
|
136
|
-
|
137
192
|
end
|