hydra-collections 4.0.0 → 5.0.0
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/.rspec +1 -0
- data/.travis.yml +0 -3
- data/Gemfile +6 -1
- data/app/controllers/concerns/hydra/collections/selects_collections.rb +30 -33
- data/app/controllers/concerns/hydra/collections_controller_behavior.rb +39 -17
- data/app/models/concerns/hydra/collection.rb +5 -76
- data/app/models/concerns/hydra/collections/actions.rb +22 -0
- data/app/models/concerns/hydra/collections/metadata.rb +62 -0
- data/app/models/concerns/hydra/collections/relations.rb +8 -0
- data/app/search_builders/hydra/collections/search_builder.rb +31 -0
- data/app/views/collections/_bookmark_control.html.erb +2 -0
- data/app/views/collections/_document_list.html.erb +1 -1
- data/app/views/collections/_index_default.html.erb +2 -0
- data/app/views/collections/_index_header_default.html.erb +2 -0
- data/app/views/collections/_paginate_compact.html.erb +1 -0
- data/app/views/collections/_results_pagination.html.erb +9 -0
- data/app/views/collections/_search_results.html.erb +23 -0
- data/app/views/collections/_thumbnail_default.html.erb +2 -0
- data/app/views/collections/index.html.erb +9 -0
- data/app/views/collections/show.html.erb +3 -3
- data/app/views/layouts/collections.html.erb +48 -0
- data/config/routes.rb +3 -3
- data/hydra-collections.gemspec +3 -2
- data/lib/hydra/collections/collectible.rb +1 -0
- data/lib/hydra/collections/search_service.rb +2 -2
- data/lib/hydra/collections/version.rb +1 -1
- data/spec/controllers/collections_controller_spec.rb +37 -51
- data/spec/controllers/other_collections_controller_spec.rb +25 -57
- data/spec/controllers/selects_collections_spec.rb +14 -30
- data/spec/helpers/collections_helper_spec.rb +5 -5
- data/spec/lib/collectible_spec.rb +1 -0
- data/spec/models/collection_spec.rb +7 -34
- data/spec/spec_helper.rb +7 -11
- data/spec/test_app_templates/Gemfile.extra +1 -0
- data/spec/test_app_templates/app/controllers/other_collections_controller.rb +8 -0
- data/spec/test_app_templates/app/views/catalog/_sort_and_per_page.html.erb +3 -8
- data/spec/test_app_templates/config/blacklight.yml +22 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +17 -9
- data/spec/views/collections/_thumbnail_default.html.erb_spec.rb +25 -0
- data/spec/views/collections/show.html.erb_spec.rb +32 -0
- metadata +44 -7
@@ -1 +1 @@
|
|
1
|
-
<%= render
|
1
|
+
<%= render 'catalog/document_list', documents: documents %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= paginate paginate_compact, page_entries_info: page_entries_info(paginate_compact), theme: :blacklight_compact, route_set: collections %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% if show_pagination? and @response.total_pages > 1 %>
|
2
|
+
<div class="row record-padding">
|
3
|
+
<div class="col-md-9">
|
4
|
+
<div class="pagination">
|
5
|
+
<%= paginate @response, :outer_window => 2, :theme => 'blacklight', route_set: collections %>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<h2 class="sr-only top-content-title"><%= t('blacklight.search.search_results_header') %></h2>
|
2
|
+
|
3
|
+
<% @page_title = t('blacklight.search.title', :application_name => application_name) %>
|
4
|
+
|
5
|
+
|
6
|
+
<% content_for(:head) do -%>
|
7
|
+
<%= render_opensearch_response_metadata %>
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
|
11
|
+
<%= render 'search_header' %>
|
12
|
+
|
13
|
+
<h2 class="sr-only"><%= t('blacklight.search.search_results') %></h2>
|
14
|
+
|
15
|
+
<%- if @response.empty? %>
|
16
|
+
<%= render "zero_results" %>
|
17
|
+
<%- elsif render_grouped_response? %>
|
18
|
+
<%= render_grouped_document_index %>
|
19
|
+
<%- else %>
|
20
|
+
<%= render_document_index %>
|
21
|
+
<%- end %>
|
22
|
+
|
23
|
+
<%= render 'results_pagination' %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<h1><%=@collection.title%><h1>
|
2
2
|
<h3><%=@collection.description%> </h3>
|
3
|
-
<h3
|
4
|
-
<%= render
|
5
|
-
<%= render
|
3
|
+
<h3><u>Contained Files</u></h3>
|
4
|
+
<%= render 'search_form'%>
|
5
|
+
<%= render 'document_list', documents: @member_docs %>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en" class="no-js">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
6
|
+
|
7
|
+
<!-- Mobile viewport optimization h5bp.com/ad -->
|
8
|
+
<meta name="HandheldFriendly" content="True">
|
9
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
10
|
+
|
11
|
+
<!-- Internet Explorer use the highest version available -->
|
12
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
13
|
+
|
14
|
+
<!-- Mobile IE allows us to activate ClearType technology for smoothing fonts for easy reading -->
|
15
|
+
<!--[if IEMobile]>
|
16
|
+
<meta http-equiv="cleartype" content="on">
|
17
|
+
<![endif]-->
|
18
|
+
|
19
|
+
<title><%= render_page_title %></title>
|
20
|
+
<%= opensearch_description_tag application_name, opensearch_catalog_url(:format => 'xml') %>
|
21
|
+
<%= favicon_link_tag 'favicon.ico' %>
|
22
|
+
<%= stylesheet_link_tag "application", media: "all" %>
|
23
|
+
<%= javascript_include_tag "application" %>
|
24
|
+
<%= csrf_meta_tags %>
|
25
|
+
<%= content_for(:head) %>
|
26
|
+
|
27
|
+
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
28
|
+
<!--[if lt IE 9]>
|
29
|
+
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
30
|
+
<![endif]-->
|
31
|
+
|
32
|
+
</head>
|
33
|
+
<body class="<%= render_body_class %>">
|
34
|
+
<%= render :partial => 'shared/header_navbar' %>
|
35
|
+
|
36
|
+
<%= render partial: 'shared/ajax_modal' %>
|
37
|
+
|
38
|
+
<div id="main-container" class="container">
|
39
|
+
<%= render :partial=>'/flash_msg', layout: 'shared/flash_messages' %>
|
40
|
+
|
41
|
+
<div class="row">
|
42
|
+
<%= yield %>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<%= render :partial => 'shared/footer' %>
|
47
|
+
</body>
|
48
|
+
</html>
|
data/config/routes.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
Hydra::Collections::Engine.routes.draw do
|
2
|
-
resources :collections
|
3
|
-
end
|
1
|
+
Hydra::Collections::Engine.routes.draw do
|
2
|
+
resources :collections
|
3
|
+
end
|
data/hydra-collections.gemspec
CHANGED
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency 'hydra-head', '~> 9.
|
22
|
-
spec.add_dependency 'deprecation', '~> 0.1
|
21
|
+
spec.add_dependency 'hydra-head', '~> 9.1'
|
22
|
+
spec.add_dependency 'deprecation', '~> 0.1'
|
23
|
+
spec.add_dependency 'blacklight', '~> 5.10'
|
23
24
|
|
24
25
|
spec.add_development_dependency 'engine_cart', '~> 0.5'
|
25
26
|
spec.add_development_dependency 'rspec-rails', '~> 3.1'
|
@@ -19,6 +19,7 @@ module Hydra::Collections::Collectible
|
|
19
19
|
# return solr_doc
|
20
20
|
# end
|
21
21
|
def index_collection_ids(solr_doc={})
|
22
|
+
Deprecation.warn(Hydra::Collections::Collectible, 'index_collection_ids is deprecated and will be removed in version 5.0')
|
22
23
|
# CollectionAssociation#ids_reader loads from solr on each call, so only call it once
|
23
24
|
# see https://github.com/projecthydra/active_fedora/issues/644
|
24
25
|
ids = collection_ids
|
@@ -2,7 +2,7 @@ module Hydra
|
|
2
2
|
module Collections
|
3
3
|
class SearchService
|
4
4
|
include Blacklight::Configurable
|
5
|
-
include Blacklight::
|
5
|
+
include Blacklight::SearchHelper
|
6
6
|
|
7
7
|
def initialize(session, user_key)
|
8
8
|
@session = session
|
@@ -10,7 +10,7 @@ module Hydra
|
|
10
10
|
self.class.copy_blacklight_config_from(::CatalogController)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
self.search_params_logic << :apply_gated_search
|
14
14
|
|
15
15
|
def last_search_documents
|
16
16
|
return [] if @session[:history].blank?
|
@@ -3,6 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe CollectionsController, :type => :controller do
|
4
4
|
let(:collections) { Hydra::Collections::Engine.routes.url_helpers }
|
5
5
|
|
6
|
+
routes { Hydra::Collections::Engine.routes }
|
7
|
+
|
6
8
|
before(:all) do
|
7
9
|
CollectionsController.configure_blacklight do |config|
|
8
10
|
config.default_solr_params = {:qf => 'label_tesim'}
|
@@ -15,7 +17,6 @@ describe CollectionsController, :type => :controller do
|
|
15
17
|
|
16
18
|
def to_solr(solr_doc={})
|
17
19
|
super.tap do |solr_doc|
|
18
|
-
solr_doc = index_collection_ids(solr_doc)
|
19
20
|
solr_doc["label_tesim"] = self.title
|
20
21
|
end
|
21
22
|
end
|
@@ -26,15 +27,29 @@ describe CollectionsController, :type => :controller do
|
|
26
27
|
Object.send(:remove_const, :GenericFile)
|
27
28
|
end
|
28
29
|
|
30
|
+
let(:user) { FactoryGirl.create(:user) }
|
31
|
+
|
29
32
|
before do
|
30
33
|
allow(controller).to receive(:has_access?).and_return(true)
|
31
34
|
|
32
|
-
|
33
|
-
sign_in @user
|
35
|
+
sign_in user
|
34
36
|
allow_any_instance_of(User).to receive(:groups).and_return([])
|
35
37
|
allow(controller).to receive(:clear_session_user) ## Don't clear out the authenticated session
|
36
38
|
end
|
37
39
|
|
40
|
+
describe "#index" do
|
41
|
+
let!(:collection1) { Collection.create { |c| c.apply_depositor_metadata(user.user_key) } }
|
42
|
+
let!(:collection2) { Collection.create { |c| c.apply_depositor_metadata(user.user_key) } }
|
43
|
+
let!(:generic_file) { GenericFile.create }
|
44
|
+
|
45
|
+
it "should show a list of collections" do
|
46
|
+
get :index
|
47
|
+
expect(response).to be_successful
|
48
|
+
expect(assigns[:document_list].map(&:id)).not_to include generic_file.id
|
49
|
+
expect(assigns[:document_list].map(&:id)).to eq [collection1.id, collection2.id]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
38
53
|
describe '#new' do
|
39
54
|
it 'should assign @collection' do
|
40
55
|
get :new
|
@@ -49,7 +64,7 @@ describe CollectionsController, :type => :controller do
|
|
49
64
|
}.to change { Collection.count }.by(1)
|
50
65
|
expect(assigns[:collection].title).to eq("My First Collection ")
|
51
66
|
expect(assigns[:collection].description).to eq("The Description\r\n\r\nand more")
|
52
|
-
expect(assigns[:collection].depositor).to eq(
|
67
|
+
expect(assigns[:collection].depositor).to eq(user.user_key)
|
53
68
|
expect(response).to redirect_to collections.collection_path(assigns[:collection])
|
54
69
|
end
|
55
70
|
it "should add docs to collection if batch ids provided" do
|
@@ -90,9 +105,7 @@ describe CollectionsController, :type => :controller do
|
|
90
105
|
|
91
106
|
describe "#update" do
|
92
107
|
before do
|
93
|
-
@collection = Collection.
|
94
|
-
@collection.apply_depositor_metadata(@user.user_key)
|
95
|
-
@collection.save
|
108
|
+
@collection = Collection.create { |c| c.apply_depositor_metadata(user.user_key) }
|
96
109
|
@asset1 = GenericFile.create!
|
97
110
|
@asset2 = GenericFile.create!
|
98
111
|
@asset3 = GenericFile.create!
|
@@ -116,7 +129,7 @@ describe CollectionsController, :type => :controller do
|
|
116
129
|
it "should support adding batches of members" do
|
117
130
|
@collection.members << @asset1
|
118
131
|
@collection.save
|
119
|
-
put :update, id: @collection
|
132
|
+
put :update, id: @collection, collection: { members:"add" }, batch_document_ids: [@asset2, @asset3]
|
120
133
|
expect(response).to redirect_to collections.collection_path(@collection)
|
121
134
|
expect(assigns[:collection].members).to match_array [@asset2, @asset3, @asset1]
|
122
135
|
end
|
@@ -124,45 +137,26 @@ describe CollectionsController, :type => :controller do
|
|
124
137
|
it "should support removing batches of members" do
|
125
138
|
@collection.members = [@asset1, @asset2, @asset3]
|
126
139
|
@collection.save
|
127
|
-
put :update, id: @collection
|
140
|
+
put :update, id: @collection, collection: { members: "remove" }, batch_document_ids: [@asset1, @asset3]
|
128
141
|
expect(response).to redirect_to collections.collection_path(@collection)
|
129
142
|
expect(assigns[:collection].members).to eq([@asset2])
|
130
143
|
end
|
131
144
|
end
|
132
145
|
|
133
146
|
it "should support setting members array" do
|
134
|
-
put :update, id: @collection
|
147
|
+
put :update, id: @collection, collection: { members: "add" }, batch_document_ids: [@asset2, @asset3, @asset1]
|
135
148
|
expect(response).to redirect_to collections.collection_path(@collection)
|
136
149
|
expect(assigns[:collection].members).to match_array [@asset2, @asset3, @asset1]
|
137
150
|
end
|
138
151
|
|
139
152
|
it "should set/un-set collection on members" do
|
140
153
|
# Add to collection (sets collection on members)
|
141
|
-
put :update, id: @collection
|
154
|
+
put :update, id: @collection, collection: { members: "add" }, batch_document_ids: [@asset2, @asset3]
|
142
155
|
expect(assigns[:collection].members).to match_array [@asset2, @asset3]
|
143
156
|
|
144
|
-
## Check that member lists collection in its solr doc
|
145
|
-
@asset2.reload
|
146
|
-
expect(@asset2.to_solr[Solrizer.solr_name(:collection)]).to eq [@collection.id]
|
147
|
-
## Check that member was re-indexed with collection info
|
148
|
-
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset2.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
|
149
|
-
doc = asset_results["response"]["docs"].first
|
150
|
-
expect(doc["id"]).to eq(@asset2.id)
|
151
|
-
expect(doc[Solrizer.solr_name(:collection)]).to eq [@collection.id]
|
152
|
-
|
153
157
|
# Remove from collection (un-sets collection on members)
|
154
158
|
put :update, id: @collection, collection: { members:"remove" }, batch_document_ids: [@asset2]
|
155
159
|
expect(assigns[:collection].members).to_not include(@asset2)
|
156
|
-
|
157
|
-
## Check that member no longer lists collection in its solr doc
|
158
|
-
@asset2.reload
|
159
|
-
expect(@asset2.to_solr[Solrizer.solr_name(:collection)]).to eq([])
|
160
|
-
|
161
|
-
## Check that member was re-indexed without collection info
|
162
|
-
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset2.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
|
163
|
-
doc = asset_results["response"]["docs"].first
|
164
|
-
expect(doc["id"]).to eq(@asset2.id)
|
165
|
-
expect(doc[Solrizer.solr_name(:collection)]).to be_nil
|
166
160
|
end
|
167
161
|
|
168
162
|
context "when moving members between collections" do
|
@@ -171,14 +165,13 @@ describe CollectionsController, :type => :controller do
|
|
171
165
|
@collection.save
|
172
166
|
end
|
173
167
|
let(:collection2) do
|
174
|
-
Collection.
|
175
|
-
col.apply_depositor_metadata(
|
176
|
-
col.save
|
168
|
+
Collection.create do |col|
|
169
|
+
col.apply_depositor_metadata(user.user_key)
|
177
170
|
end
|
178
171
|
end
|
179
172
|
|
180
173
|
it "moves the members" do
|
181
|
-
put :update, id: @collection, collection: {members: "move"},
|
174
|
+
put :update, id: @collection, collection: {members: "move"},
|
182
175
|
destination_collection_id: collection2, batch_document_ids: [@asset2, @asset3]
|
183
176
|
expect(@collection.reload.members).to eq [@asset1]
|
184
177
|
expect(collection2.reload.members).to match_array [@asset2, @asset3]
|
@@ -189,20 +182,21 @@ describe CollectionsController, :type => :controller do
|
|
189
182
|
describe "#destroy" do
|
190
183
|
describe "valid collection" do
|
191
184
|
before do
|
192
|
-
@collection = Collection.
|
193
|
-
@collection.apply_depositor_metadata(@user.user_key)
|
194
|
-
@collection.save
|
185
|
+
@collection = Collection.create { |c| c.apply_depositor_metadata(user.user_key) }
|
195
186
|
expect(controller).to receive(:authorize!).and_return(true)
|
196
187
|
end
|
188
|
+
|
197
189
|
it "should delete collection" do
|
198
|
-
delete :destroy, id: @collection
|
190
|
+
delete :destroy, id: @collection
|
199
191
|
expect(response).to redirect_to Rails.application.routes.url_helpers.catalog_index_path
|
200
192
|
expect(flash[:notice]).to eq("Collection was successfully deleted.")
|
201
193
|
end
|
194
|
+
|
202
195
|
it "should after_destroy" do
|
203
196
|
expect(controller).to receive(:after_destroy).and_call_original
|
204
|
-
delete :destroy, id: @collection
|
197
|
+
delete :destroy, id: @collection
|
205
198
|
end
|
199
|
+
|
206
200
|
it "should call update members" do
|
207
201
|
@asset1 = GenericFile.create!
|
208
202
|
@collection.members << @asset1
|
@@ -210,20 +204,12 @@ describe CollectionsController, :type => :controller do
|
|
210
204
|
@asset1 = @asset1.reload
|
211
205
|
@asset1.update_index
|
212
206
|
expect(@asset1.collections).to eq [@collection]
|
213
|
-
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset1.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
|
214
|
-
expect(asset_results["response"]["numFound"]).to eq(1)
|
215
|
-
doc = asset_results["response"]["docs"].first
|
216
|
-
expect(doc[Solrizer.solr_name(:collection)]).to eq([@collection.id])
|
217
207
|
|
218
208
|
delete :destroy, id: @collection
|
219
|
-
expect(@asset1.reload.collections).to eq
|
220
|
-
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params:{fq:["id:\"#{@asset1.id}\""],fl:['id',Solrizer.solr_name(:collection)]}
|
221
|
-
expect(asset_results["response"]["numFound"]).to eq(1)
|
222
|
-
doc = asset_results["response"]["docs"].first
|
223
|
-
expect(doc[Solrizer.solr_name(:collection)]).to be_nil
|
224
|
-
@asset1.destroy
|
209
|
+
expect(@asset1.reload.collections).to eq []
|
225
210
|
end
|
226
211
|
end
|
212
|
+
|
227
213
|
it "should not delete an invalid collection" do
|
228
214
|
expect {delete :destroy, id: 'zz:-1'}.to raise_error
|
229
215
|
end
|
@@ -236,7 +222,7 @@ describe CollectionsController, :type => :controller do
|
|
236
222
|
@asset3 = GenericFile.create!(title: "Third of the Assets")
|
237
223
|
@collection = Collection.new(id:"abc123")
|
238
224
|
@collection.title = "My collection"
|
239
|
-
@collection.apply_depositor_metadata(
|
225
|
+
@collection.apply_depositor_metadata(user.user_key)
|
240
226
|
@collection.members = [@asset1, @asset2, @asset3]
|
241
227
|
@collection.save!
|
242
228
|
expect(controller).to receive(:authorize!).and_return(true)
|
@@ -248,7 +234,7 @@ describe CollectionsController, :type => :controller do
|
|
248
234
|
@asset4 = GenericFile.create!(title: "#{@asset1.id}")
|
249
235
|
@collection2 = Collection.new(id: "abc1234")
|
250
236
|
@collection2.title = "Other collection"
|
251
|
-
@collection2.apply_depositor_metadata(
|
237
|
+
@collection2.apply_depositor_metadata(user.user_key)
|
252
238
|
@collection2.members = [@asset4]
|
253
239
|
@collection2.save
|
254
240
|
end
|
@@ -1,85 +1,53 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
class OtherCollection < ActiveFedora::Base
|
14
|
-
include Hydra::Collection
|
15
|
-
include Hydra::Collections::Collectible
|
16
|
-
|
17
|
-
def to_solr(solr_doc={})
|
18
|
-
super.tap do |solr_doc|
|
19
|
-
index_collection_ids(solr_doc)
|
3
|
+
# make sure a collection by another name still assigns the @collection variable
|
4
|
+
describe OtherCollectionsController, :type => :controller do
|
5
|
+
before(:all) do
|
6
|
+
class OtherCollection < ActiveFedora::Base
|
7
|
+
include Hydra::Collection
|
8
|
+
include Hydra::Collections::Collectible
|
20
9
|
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class Member < ActiveFedora::Base
|
25
|
-
include Hydra::Collections::Collectible
|
26
|
-
attr_accessor :title
|
27
10
|
|
28
|
-
|
29
|
-
|
30
|
-
|
11
|
+
class Member < ActiveFedora::Base
|
12
|
+
include Hydra::Collections::Collectible
|
13
|
+
attr_accessor :title
|
31
14
|
end
|
32
15
|
end
|
33
16
|
|
34
|
-
end
|
35
|
-
|
36
|
-
# make sure a collection by another name still assigns the @collection variable
|
37
|
-
describe OtherCollectionsController, :type => :controller do
|
38
|
-
before(:all) do
|
39
|
-
@user = FactoryGirl.find_or_create(:user)
|
40
|
-
end
|
41
17
|
after(:all) do
|
42
|
-
@user.destroy
|
43
|
-
Member.destroy_all
|
44
|
-
OtherCollection.destroy_all
|
45
18
|
Object.send(:remove_const, :Member)
|
46
19
|
Object.send(:remove_const, :OtherCollection)
|
47
|
-
Object.send(:remove_const, :OtherCollectionsController)
|
48
|
-
|
49
20
|
end
|
50
|
-
|
21
|
+
|
22
|
+
let(:user) { FactoryGirl.find_or_create(:user) }
|
23
|
+
|
51
24
|
before do
|
52
25
|
allow(controller).to receive(:has_access?).and_return(true)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
allow_any_instance_of(User).to receive(:groups).and_return([])
|
57
|
-
allow(controller).to receive(:clear_session_user) ## Don't clear out the authenticated session
|
26
|
+
sign_in user
|
27
|
+
# allow_any_instance_of(User).to receive(:groups).and_return([])
|
28
|
+
# allow(controller).to receive(:clear_session_user) ## Don't clear out the authenticated session
|
58
29
|
end
|
59
30
|
|
60
31
|
describe "#show" do
|
61
|
-
let(:asset1) {Member.create!(title: "First of the Assets")}
|
62
|
-
let(:asset2) {Member.create!(title: "Second of the Assets")}
|
63
|
-
let(:asset3) {Member.create!(title: "Third of the Assets")}
|
64
|
-
let(:collection)
|
32
|
+
let(:asset1) { Member.create!(title: "First of the Assets") }
|
33
|
+
let(:asset2) { Member.create!(title: "Second of the Assets") }
|
34
|
+
let(:asset3) { Member.create!(title: "Third of the Assets") }
|
35
|
+
let(:collection) do
|
36
|
+
OtherCollection.create(id: 'foo123', title: "My collection",
|
37
|
+
members: [asset1, asset2, asset3]) do |collection|
|
38
|
+
collection.apply_depositor_metadata(user.user_key)
|
39
|
+
end
|
40
|
+
end
|
65
41
|
|
66
42
|
before do
|
67
|
-
collection.title = "My collection"
|
68
|
-
collection.apply_depositor_metadata(@user.user_key)
|
69
|
-
collection.members = [asset1,asset2,asset3]
|
70
|
-
collection.save
|
71
43
|
allow(controller).to receive(:apply_gated_search)
|
72
44
|
end
|
73
|
-
|
74
|
-
Rails.application.reload_routes!
|
75
|
-
end
|
45
|
+
|
76
46
|
it "should show the collections" do
|
77
|
-
routes.draw { resources :other_collections, except: :index }
|
78
47
|
get :show, id: collection
|
79
48
|
expect(assigns[:collection].title).to eq collection.title
|
80
49
|
ids = assigns[:member_docs].map(&:id)
|
81
50
|
expect(ids).to include(asset1.id, asset2.id, asset3.id)
|
82
51
|
end
|
83
52
|
end
|
84
|
-
|
85
53
|
end
|