curation_concerns 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -1
- data/Gemfile +1 -0
- data/VERSION +1 -1
- data/app/controllers/concerns/curation_concerns/application_controller_behavior.rb +9 -5
- data/app/controllers/concerns/curation_concerns/catalog_controller.rb +0 -20
- data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +27 -5
- data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +7 -3
- data/app/controllers/concerns/curation_concerns/download_behavior.rb +5 -5
- data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +17 -9
- data/app/controllers/concerns/curation_concerns/parent_container.rb +4 -9
- data/app/controllers/concerns/curation_concerns/single_use_links_viewer_controller_behavior.rb +6 -2
- data/app/helpers/curation_concerns/catalog_helper.rb +2 -4
- data/app/helpers/curation_concerns/collections_helper.rb +1 -1
- data/app/helpers/curation_concerns/permissions_helper.rb +4 -3
- data/app/helpers/curation_concerns/search_paths_helper.rb +2 -2
- data/app/inputs/multifile_input.rb +1 -1
- data/app/inputs/select_with_modal_help_input.rb +1 -1
- data/app/inputs/with_help_icon.rb +3 -3
- data/app/presenters/curation_concerns/presenter_factory.rb +2 -1
- data/app/presenters/curation_concerns/version_list_presenter.rb +3 -3
- data/app/presenters/curation_concerns/version_presenter.rb +1 -1
- data/app/presenters/curation_concerns/work_show_presenter.rb +1 -1
- data/app/renderers/curation_concerns/attribute_renderer.rb +10 -7
- data/app/search_builders/curation_concerns/collection_member_search_builder.rb +5 -0
- data/app/search_builders/curation_concerns/embargo_search_builder.rb +0 -3
- data/app/search_builders/curation_concerns/file_set_search_builder.rb +10 -0
- data/app/search_builders/curation_concerns/filter_by_type.rb +29 -0
- data/app/search_builders/curation_concerns/lease_search_builder.rb +0 -3
- data/app/search_builders/curation_concerns/search_builder.rb +1 -27
- data/app/search_builders/curation_concerns/single_result.rb +13 -0
- data/app/search_builders/curation_concerns/single_use_link_search_builder.rb +6 -0
- data/app/search_builders/curation_concerns/work_search_builder.rb +5 -0
- data/app/services/curation_concerns/parent_service.rb +1 -1
- data/app/views/catalog/index.json.jbuilder +9 -0
- data/app/views/collections/_form.html.erb +3 -3
- data/app/views/collections/_search_collection_dashboard_form.html.erb +1 -1
- data/app/views/collections/_search_form.html.erb +1 -1
- data/app/views/collections/_sort_and_per_page.html.erb +1 -1
- data/app/views/shared/_site_search.html.erb +2 -2
- data/curation_concerns.gemspec +3 -5
- data/lib/curation_concerns/rails/routes.rb +1 -1
- data/lib/curation_concerns/version.rb +1 -1
- data/lib/generators/curation_concerns/install_generator.rb +2 -3
- data/lib/generators/curation_concerns/templates/catalog_controller.rb +1 -1
- data/spec/actors/curation_concerns/work_actor_spec.rb +2 -1
- data/spec/controllers/catalog_controller_spec.rb +1 -0
- data/spec/controllers/curation_concerns/generic_works_controller_spec.rb +2 -3
- data/spec/controllers/downloads_controller_spec.rb +4 -4
- data/spec/features/catalog_search_spec.rb +1 -1
- data/spec/features/collection_spec.rb +17 -1
- data/spec/helpers/catalog_helper_spec.rb +10 -1
- data/spec/helpers/render_constraints_helper_spec.rb +1 -1
- data/spec/helpers/url_helper_spec.rb +1 -1
- data/spec/models/curation_concerns/collection_behavior_spec.rb +0 -42
- data/spec/models/curation_concerns/file_set/derivatives_spec.rb +14 -0
- data/spec/search_builders/curation_concerns/file_set_search_builder_spec.rb +29 -0
- data/spec/search_builders/curation_concerns/search_builder_spec.rb +0 -19
- data/spec/services/derivative_path_spec.rb +24 -0
- data/spec/spec_helper.rb +5 -5
- data/spec/test_app_templates/Gemfile.extra +1 -0
- data/spec/views/catalog/index.html.erb_spec.rb +9 -3
- data/spec/views/collections/_sort_and_per_page.html.erb_spec.rb +2 -0
- data/spec/views/curation_concerns/base/_attributes.html.erb_spec.rb +3 -3
- data/spec/views/curation_concerns/file_sets/_file_set.html.erb_spec.rb +4 -0
- data/tasks/release.rake +1 -1
- metadata +31 -14
@@ -0,0 +1,9 @@
|
|
1
|
+
# Overriding Blacklight so that the search results can be displayed in a way compatible with
|
2
|
+
# tokenInput javascript library. This is used for suggesting "Related Works" to attach.
|
3
|
+
|
4
|
+
json.docs @presenter.documents do |solr_document|
|
5
|
+
title = solr_document['title_tesim'].first
|
6
|
+
title << " (#{solr_document['human_readable_type_tesim'].first})" if solr_document['human_readable_type_tesim'].present?
|
7
|
+
json.pid solr_document['id']
|
8
|
+
json.title title
|
9
|
+
end
|
@@ -14,10 +14,10 @@
|
|
14
14
|
<div class="row">
|
15
15
|
<div class="col-md-12 form-actions">
|
16
16
|
<%= f.submit class: 'btn btn-primary require-contributor-agreement' %>
|
17
|
-
<% if
|
18
|
-
<%= link_to 'Cancel', main_app.root_path, class: 'btn btn-link' %>
|
19
|
-
<% else %>
|
17
|
+
<% if @form.persisted? %>
|
20
18
|
<%= link_to 'Cancel', collections.collection_path(@form), class: 'btn btn-link' %>
|
19
|
+
<% else %>
|
20
|
+
<%= link_to 'Cancel', main_app.root_path, class: 'btn btn-link' %>
|
21
21
|
<% end %>
|
22
22
|
</div>
|
23
23
|
</div>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<label class="accessible-hidden">Search Collection <%= @collection.title %></label>
|
5
5
|
<%= text_field_tag :cq, params[:cq], class: "collection-query", placeholder: "Search Collection", size: '30', type: "search", id: "collection_search" %>
|
6
6
|
<%= hidden_field_tag :sort, params[:sort], id: 'collection_sort' %>
|
7
|
-
<%= render_hash_as_hidden_fields(params_for_search.except(:cq, :sort, :qt, :page)) %>
|
7
|
+
<%= render_hash_as_hidden_fields(search_state.params_for_search.except(:cq, :sort, :qt, :page)) %>
|
8
8
|
<button type="submit" class="btn btn-primary" id="collection_submit"><i class="icon-search"></i> Go</button>
|
9
9
|
<% end %>
|
10
10
|
</div>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<label class="accessible-hidden">Search Collection <%= @presenter.title %></label>
|
5
5
|
<%= text_field_tag :cq, params[:cq], class: "collection-query", placeholder: "Search Collection", size: '30', type: "search", id: "collection_search" %>
|
6
6
|
<%= hidden_field_tag :sort, params[:sort], id: 'collection_sort' %>
|
7
|
-
<%= render_hash_as_hidden_fields(params_for_search.except(:cq, :sort, :qt, :page))
|
7
|
+
<%= render_hash_as_hidden_fields(search_state.params_for_search.except(:cq, :sort, :qt, :page)) %>
|
8
8
|
<button type="submit" class="btn btn-primary" id="collection_submit"><i class="icon-search"></i> Go</button>
|
9
9
|
<% end %>
|
10
10
|
</div>
|
@@ -21,7 +21,7 @@
|
|
21
21
|
<%= label_tag :per_page do %>
|
22
22
|
Show <%= select_tag :per_page, options_for_select(['10', '20', '50', '100'], h(params[:per_page])), title: "Number of results to display per page" %> per page
|
23
23
|
<% end %>
|
24
|
-
<%= render_hash_as_hidden_fields params_for_search.except(:per_page, :sort) %>
|
24
|
+
<%= render_hash_as_hidden_fields search_state.params_for_search.except(:per_page, :sort) %>
|
25
25
|
|
26
26
|
<button class="btn btn-primary"><i class="icon-refresh"></i> Refresh</button>
|
27
27
|
<%= render 'view_type_group' %>
|
@@ -1,8 +1,8 @@
|
|
1
|
-
<%= form_tag main_app.
|
1
|
+
<%= form_tag main_app.search_catalog_path, method: :get, class: "search-form" do %>
|
2
2
|
<fieldset>
|
3
3
|
<legend class="accessible-hidden">Search <%= t('curation_concerns.product_name') %></legend>
|
4
4
|
<%= label_tag :catalog_search, t('curation_concerns.search.form.q.label'), class: "accessible-hidden" %>
|
5
|
-
<%= render_hash_as_hidden_fields(params_for_search.except(:q, :search_field, :qt, :page, :utf8)) %>
|
5
|
+
<%= render_hash_as_hidden_fields(search_state.params_for_search.except(:q, :search_field, :qt, :page, :utf8)) %>
|
6
6
|
<%= text_field_tag(:q, params[:q], class: "q search-query", id: "catalog_search",
|
7
7
|
placeholder: t('curation_concerns.search.form.q.placeholder'), tabindex: "1", type: "search") %>
|
8
8
|
<button type="submit" class="search-submit btn btn-primary" id="keyword-search-submit" tabindex="2">
|
data/curation_concerns.gemspec
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
version = File.read(File.expand_path("../VERSION",__FILE__)).strip
|
3
3
|
|
4
|
-
# lib = File.expand_path('../lib', __FILE__)
|
5
|
-
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
-
|
7
4
|
Gem::Specification.new do |spec|
|
8
5
|
spec.name = "curation_concerns"
|
9
6
|
spec.version = version
|
@@ -19,13 +16,14 @@ Gem::Specification.new do |spec|
|
|
19
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
17
|
spec.require_paths = ["lib"]
|
21
18
|
|
22
|
-
spec.add_dependency 'hydra-head', '~> 9.
|
19
|
+
spec.add_dependency 'hydra-head', '~> 9.6'
|
20
|
+
spec.add_dependency 'blacklight', '~> 6.0'
|
23
21
|
spec.add_dependency "breadcrumbs_on_rails", "~> 2.3"
|
24
22
|
spec.add_dependency "jquery-ui-rails"
|
25
23
|
spec.add_dependency "simple_form", '~> 3.1'
|
26
24
|
spec.add_dependency 'curation_concerns-models', version
|
27
25
|
spec.add_dependency 'hydra-editor', '~> 1.1'
|
28
|
-
spec.add_dependency 'blacklight_advanced_search',
|
26
|
+
spec.add_dependency 'blacklight_advanced_search', '~> 6.0'
|
29
27
|
spec.add_dependency 'rails_autolink'
|
30
28
|
|
31
29
|
spec.add_development_dependency "devise", "~> 3.0"
|
@@ -60,7 +60,7 @@ module ActionDispatch::Routing
|
|
60
60
|
private
|
61
61
|
|
62
62
|
# routing namepace arguments, for using a path other than the default
|
63
|
-
ROUTE_OPTIONS = { 'curation_concerns' => { path: :concern } }
|
63
|
+
ROUTE_OPTIONS = { 'curation_concerns' => { path: :concern } }.freeze
|
64
64
|
|
65
65
|
# Namespaces routes appropriately
|
66
66
|
# @example route_namespaced_target("curation_concerns/generic_work") is equivalent to
|
@@ -5,8 +5,7 @@ module CurationConcerns
|
|
5
5
|
source_root File.expand_path('../templates', __FILE__)
|
6
6
|
|
7
7
|
argument :model_name, type: :string, default: 'user'
|
8
|
-
desc '
|
9
|
-
This generator makes the following changes to your application:
|
8
|
+
desc 'This generator makes the following changes to your application:
|
10
9
|
1. Runs installers for blacklight & hydra-head (which also install & configure devise)
|
11
10
|
2. Runs curation_concerns:models:install
|
12
11
|
3. Adds controller behavior to the application controller
|
@@ -15,7 +14,7 @@ module CurationConcerns
|
|
15
14
|
6. Copies the catalog controller into the local app
|
16
15
|
7. Adds CurationConcerns::SolrDocumentBehavior to app/models/solr_document.rb
|
17
16
|
8. Adds config/authorities/rights.yml to the application
|
18
|
-
|
17
|
+
'
|
19
18
|
|
20
19
|
def run_required_generators
|
21
20
|
say_status('warning', '[CurationConcerns] GENERATING BLACKLIGHT', :yellow)
|
@@ -79,7 +79,7 @@ class CatalogController < ApplicationController
|
|
79
79
|
contributor_name = solr_name('contributor', :stored_searchable, type: :string)
|
80
80
|
field.solr_parameters = {
|
81
81
|
qf: "#{title_name} #{label_name} file_format_tesim #{contributor_name}",
|
82
|
-
pf:
|
82
|
+
pf: title_name.to_s
|
83
83
|
}
|
84
84
|
end
|
85
85
|
|
@@ -225,7 +225,8 @@ describe CurationConcerns::GenericWorkActor do
|
|
225
225
|
before do
|
226
226
|
curation_concern.apply_depositor_metadata(user.user_key)
|
227
227
|
curation_concern.save!
|
228
|
-
collection1.
|
228
|
+
collection1.members << curation_concern
|
229
|
+
collection1.save!
|
229
230
|
end
|
230
231
|
|
231
232
|
it 'remove from the old collection and adds to the new collection' do
|
@@ -70,6 +70,7 @@ describe CatalogController do
|
|
70
70
|
|
71
71
|
context 'when json is requested for autosuggest of related works' do
|
72
72
|
let!(:work) { FactoryGirl.create(:generic_work, user: user, title: ["All my #{srand}"]) }
|
73
|
+
render_views
|
73
74
|
it 'returns json' do
|
74
75
|
xhr :get, :index, format: :json, q: work.title
|
75
76
|
json = JSON.parse(response.body)
|
@@ -45,9 +45,8 @@ describe CurationConcerns::GenericWorksController do
|
|
45
45
|
context 'when a ObjectNotFoundError is raised' do
|
46
46
|
it 'returns 404 page' do
|
47
47
|
allow(controller).to receive(:show).and_raise(ActiveFedora::ObjectNotFoundError)
|
48
|
+
expect(controller).to receive(:render_404) { controller.render nothing: true }
|
48
49
|
get :show, id: 'abc123'
|
49
|
-
expect(response.status).to eq 404
|
50
|
-
expect(response.body).to match(/The page you were looking for doesn't exist/)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
@@ -186,7 +185,7 @@ describe CurationConcerns::GenericWorksController do
|
|
186
185
|
|
187
186
|
it 'deletes the work' do
|
188
187
|
delete :destroy, id: work_to_be_deleted
|
189
|
-
expect(response).to redirect_to main_app.
|
188
|
+
expect(response).to redirect_to main_app.search_catalog_path
|
190
189
|
expect(GenericWork).not_to exist(work_to_be_deleted.id)
|
191
190
|
end
|
192
191
|
|
@@ -6,9 +6,9 @@ describe DownloadsController do
|
|
6
6
|
let(:file_set) do
|
7
7
|
FactoryGirl.create(:file_with_work, user: user, content: File.open(fixture_file_path('files/image.png')))
|
8
8
|
end
|
9
|
-
it '
|
9
|
+
it 'calls render_404 if the object does not exist' do
|
10
|
+
expect(controller).to receive(:render_404) { controller.render nothing: true }
|
10
11
|
get :show, id: '8675309'
|
11
|
-
expect(response).to be_not_found
|
12
12
|
end
|
13
13
|
|
14
14
|
context "when user doesn't have access" do
|
@@ -61,15 +61,15 @@ describe DownloadsController do
|
|
61
61
|
|
62
62
|
context "that isn't persisted" do
|
63
63
|
it "returns 404 if the requested file does not exist" do
|
64
|
+
expect(controller).to receive(:render_404) { controller.render nothing: true }
|
64
65
|
get :show, id: file_set, file: 'thumbnail'
|
65
|
-
expect(response.status).to eq 404
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
it "returns 404 if the requested association does not exist" do
|
71
|
+
expect(controller).to receive(:render_404) { controller.render nothing: true }
|
71
72
|
get :show, id: file_set, file: 'non-existant'
|
72
|
-
expect(response.status).to eq 404
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -56,6 +56,11 @@ describe 'collection' do
|
|
56
56
|
expect(page).to have_content title
|
57
57
|
expect(page).to have_content description
|
58
58
|
end
|
59
|
+
it "fails if there's missing required fields" do
|
60
|
+
click_link 'Add a Collection'
|
61
|
+
click_button 'Create Collection'
|
62
|
+
expect(page).to have_content 'Please review the errors below'
|
63
|
+
end
|
59
64
|
end
|
60
65
|
|
61
66
|
describe 'delete collection' do
|
@@ -65,7 +70,7 @@ describe 'collection' do
|
|
65
70
|
@collection.apply_depositor_metadata(user_key)
|
66
71
|
@collection.save
|
67
72
|
sign_in user
|
68
|
-
visit main_app.
|
73
|
+
visit main_app.search_catalog_path('f[generic_type_sim][]' => 'Collection', works: 'mine')
|
69
74
|
end
|
70
75
|
|
71
76
|
it 'deletes a collection' do
|
@@ -160,6 +165,17 @@ describe 'collection' do
|
|
160
165
|
expect(page).to have_content(creators.first)
|
161
166
|
end
|
162
167
|
|
168
|
+
context "when there are errors" do
|
169
|
+
it "displays them" do
|
170
|
+
within("#document_#{@collection.id}") do
|
171
|
+
click_link('Edit Collection')
|
172
|
+
end
|
173
|
+
fill_in 'Title', with: ''
|
174
|
+
click_button 'Update Collection'
|
175
|
+
expect(page).to have_content 'review the errors'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
163
179
|
it 'removes a work from a collection from edit page' do
|
164
180
|
expect(page).to have_content(@collection.title)
|
165
181
|
within("#document_#{@collection.id}") do
|
@@ -5,11 +5,15 @@ describe CurationConcerns::CatalogHelper do
|
|
5
5
|
helper.params[:controller] = 'catalog'
|
6
6
|
allow(helper).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
|
7
7
|
allow(helper).to receive(:search_action_path) do |*args|
|
8
|
-
|
8
|
+
search_catalog_path(*args)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
describe 'all_type_tab' do
|
13
|
+
let(:search_state) { double('SearchState', remove_facet_params: {}) }
|
14
|
+
before do
|
15
|
+
allow(helper).to receive(:search_state).and_return(search_state)
|
16
|
+
end
|
13
17
|
subject { helper.all_type_tab('All') }
|
14
18
|
|
15
19
|
context 'when it is the active tab' do
|
@@ -43,6 +47,11 @@ describe CurationConcerns::CatalogHelper do
|
|
43
47
|
end
|
44
48
|
|
45
49
|
context 'when it is not the active tab' do
|
50
|
+
let(:search_state) { double('SearchState',
|
51
|
+
add_facet_params_and_redirect: { f: { generic_type_sim: ['Work'] } }) }
|
52
|
+
before do
|
53
|
+
allow(helper).to receive(:search_state).and_return(search_state)
|
54
|
+
end
|
46
55
|
it { should eq "<li><a href=\"/catalog?f%5Bgeneric_type_sim%5D%5B%5D=Work\">Works</a></li>" }
|
47
56
|
end
|
48
57
|
|
@@ -13,7 +13,7 @@ describe CurationConcernsHelper do
|
|
13
13
|
|
14
14
|
it 'removes search_field' do
|
15
15
|
node = Capybara::Node::Simple.new(subject)
|
16
|
-
expect(node).to have_link 'Remove constraint Foo: Simon', href:
|
16
|
+
expect(node).to have_link 'Remove constraint Foo: Simon', href: search_catalog_path
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -9,7 +9,7 @@ describe CurationConcerns::UrlHelper do
|
|
9
9
|
it { is_expected.to eq "/concern/generic_works/#{work.id}" }
|
10
10
|
|
11
11
|
it 'uses the curation_concern namespace' do
|
12
|
-
expect(helper.url_for_document
|
12
|
+
expect(helper.url_for_document(document)).to eq "/concern/generic_works/#{work.id}"
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'when document is a FileSet' do
|
@@ -63,48 +63,6 @@ describe CurationConcerns::CollectionBehavior do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
context '.add_member' do
|
67
|
-
let(:collectible?) { nil }
|
68
|
-
let(:proposed_collectible) { double(collections: []) }
|
69
|
-
before(:each) do
|
70
|
-
allow(proposed_collectible).to receive(:can_be_member_of_collection?).with(subject).and_return(collectible?)
|
71
|
-
# Added for solrizing interface.
|
72
|
-
allow(proposed_collectible).to receive(:pcdm_object?).and_return(true)
|
73
|
-
allow(proposed_collectible).to receive(:collection?).and_return(false)
|
74
|
-
allow(proposed_collectible).to receive(:id).and_return("1")
|
75
|
-
allow(proposed_collectible).to receive(:save).and_return(true)
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'with itself' do
|
79
|
-
it 'does not add it to the collection members' do
|
80
|
-
expect do
|
81
|
-
subject.add_member(subject)
|
82
|
-
end.to_not change { subject.members.size }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'with a non-collectible object' do
|
87
|
-
let(:collectible?) { false }
|
88
|
-
it 'does not add it to the collection\'s members' do
|
89
|
-
expect do
|
90
|
-
subject.add_member(proposed_collectible)
|
91
|
-
end.to_not change { subject.members.size }
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'with a collectible object' do
|
96
|
-
let(:collectible?) { true }
|
97
|
-
before do
|
98
|
-
allow(collection).to receive(:members).and_return([])
|
99
|
-
end
|
100
|
-
it 'adds it to the collection\'s members' do
|
101
|
-
expect do
|
102
|
-
subject.add_member(proposed_collectible)
|
103
|
-
end.to change { subject.members.size }.by(1)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
66
|
describe 'intrinsic properties' do
|
109
67
|
let(:collection1) { FactoryGirl.build(:collection) }
|
110
68
|
let(:work1) { FactoryGirl.build(:work) }
|
@@ -81,4 +81,18 @@ describe CurationConcerns::FileSet do
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
84
|
+
|
85
|
+
describe "cleanup" do
|
86
|
+
let(:mime_type) { 'image/jpg' }
|
87
|
+
it "cleans up all created derivatives" do
|
88
|
+
allow(CurationConcerns::DerivativePath).to receive(:derivatives_for_reference).with(file_set).and_return([
|
89
|
+
"tmp/1/2.jpg"
|
90
|
+
])
|
91
|
+
allow(FileUtils).to receive(:rm_f).with("tmp/1/2.jpg")
|
92
|
+
|
93
|
+
file_set.destroy
|
94
|
+
|
95
|
+
expect(FileUtils).to have_received(:rm_f).with("tmp/1/2.jpg")
|
96
|
+
end
|
97
|
+
end
|
84
98
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CurationConcerns::FileSetSearchBuilder do
|
4
|
+
let(:processor_chain) { [:filter_models] }
|
5
|
+
let(:ability) { double('ability') }
|
6
|
+
let(:context) { double('context') }
|
7
|
+
let(:user) { double('user') }
|
8
|
+
let(:solr_params) { { fq: [] } }
|
9
|
+
|
10
|
+
subject { described_class.new(context) }
|
11
|
+
describe '#only_file_sets' do
|
12
|
+
before { subject.only_file_sets(solr_params) }
|
13
|
+
|
14
|
+
it 'adds FileSet to query' do
|
15
|
+
expect(solr_params[:fq].first).to include('{!raw f=has_model_ssim}FileSet')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#find_one' do
|
20
|
+
before do
|
21
|
+
allow(subject).to receive(:blacklight_params).and_return(id: '12345')
|
22
|
+
subject.find_one(solr_params)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'adds id to query' do
|
26
|
+
expect(solr_params[:fq].first).to include('{!raw f=id}12345')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -9,25 +9,6 @@ describe CurationConcerns::SearchBuilder do
|
|
9
9
|
|
10
10
|
subject { described_class.new(processor_chain, context) }
|
11
11
|
|
12
|
-
describe '#only_file_sets' do
|
13
|
-
before { subject.only_file_sets(solr_params) }
|
14
|
-
|
15
|
-
it 'adds FileSet to query' do
|
16
|
-
expect(solr_params[:fq].first).to include('{!raw f=has_model_ssim}FileSet')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#find_one' do
|
21
|
-
before do
|
22
|
-
allow(subject).to receive(:blacklight_params).and_return(id: '12345')
|
23
|
-
subject.find_one(solr_params)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'adds id to query' do
|
27
|
-
expect(solr_params[:fq].first).to include('{!raw f=id}12345')
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
12
|
describe '#gated_discovery_filters' do
|
32
13
|
before do
|
33
14
|
allow(subject).to receive(:current_ability).and_return(ability)
|
@@ -13,4 +13,28 @@ describe CurationConcerns::DerivativePath do
|
|
13
13
|
|
14
14
|
it { is_expected.to eq 'tmp/12/3-thumbnail.jpeg' }
|
15
15
|
end
|
16
|
+
|
17
|
+
describe "#derivatives_for_reference" do
|
18
|
+
subject { described_class.derivatives_for_reference(object) }
|
19
|
+
before do
|
20
|
+
FileUtils.mkdir_p("tmp/12")
|
21
|
+
File.open("tmp/12/3-thumbnail.jpeg", 'w') do |f|
|
22
|
+
f.write "test"
|
23
|
+
end
|
24
|
+
File.open("tmp/12/4-thumbnail.jpeg", 'w') do |f|
|
25
|
+
f.write "test"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
after do
|
29
|
+
FileUtils.rm_rf("tmp/12")
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:object) { double(id: '123') }
|
33
|
+
|
34
|
+
it "lists all the paths to derivatives" do
|
35
|
+
expect(subject).to eq [
|
36
|
+
"tmp/12/3-thumbnail.jpeg"
|
37
|
+
]
|
38
|
+
end
|
39
|
+
end
|
16
40
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -52,11 +52,11 @@ RSpec.configure do |config|
|
|
52
52
|
config.fixture_path = File.expand_path('../fixtures', __FILE__)
|
53
53
|
|
54
54
|
config.before :each do
|
55
|
-
if Capybara.current_driver == :rack_test
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
DatabaseCleaner.strategy = if Capybara.current_driver == :rack_test
|
56
|
+
:transaction
|
57
|
+
else
|
58
|
+
:truncation
|
59
|
+
end
|
60
60
|
DatabaseCleaner.start
|
61
61
|
end
|
62
62
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# gem 'hydra-works', github: 'projecthydra-labs/hydra-works', branch: 'master'
|
3
3
|
# gem 'hydra-pcdm', github: 'projecthydra-labs/hydra-pcdm', branch: 'master'
|
4
4
|
# gem 'activefedora-aggregation', github: 'projecthydra-labs/activefedora-aggregation', branch: 'master'
|
5
|
+
gem 'kaminari', github: 'jcoyne/kaminari', branch: 'sufia'
|
5
6
|
|
6
7
|
group :development do
|
7
8
|
gem 'better_errors'
|
@@ -3,15 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe 'catalog/index.html.erb' do
|
4
4
|
let(:collection) { stub_model(Collection, title: 'collection1', id: 'abc123') }
|
5
5
|
let(:doc) { SolrDocument.new(collection.to_solr) }
|
6
|
+
let(:search_state) { double('SearchState', to_h: {}) }
|
7
|
+
let(:blacklight_configuration_context) do
|
8
|
+
Blacklight::Configuration::Context.new(controller)
|
9
|
+
end
|
6
10
|
|
7
11
|
before do
|
8
12
|
view.extend CurationConcerns::CollectionsHelper
|
9
13
|
view.extend CurationConcerns::CatalogHelper
|
10
|
-
allow(view).to receive(:search_action_path).and_return('/catalog')
|
11
|
-
allow(view).to receive(:has_search_parameters?).and_return(true)
|
12
14
|
|
13
|
-
allow(view).to receive(:current_users_collections).and_return([])
|
14
15
|
allow(view).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
|
16
|
+
allow(view).to receive(:blacklight_configuration_context).and_return(blacklight_configuration_context)
|
15
17
|
stub_template 'catalog/_search_sidebar.html.erb' => ''
|
16
18
|
stub_template 'catalog/_search_header.html.erb' => ''
|
17
19
|
allow(view).to receive(:render_opensearch_response_metadata).and_return('')
|
@@ -19,6 +21,8 @@ describe 'catalog/index.html.erb' do
|
|
19
21
|
allow(view).to receive(:search_session).and_return({})
|
20
22
|
allow(view).to receive(:current_search_session).and_return(nil)
|
21
23
|
allow(view).to receive(:document_counter_with_offset).and_return(5)
|
24
|
+
allow(view).to receive(:type_tab).and_return("TYPE")
|
25
|
+
allow(view).to receive(:search_state).and_return(search_state)
|
22
26
|
|
23
27
|
params[:view] = 'gallery'
|
24
28
|
|
@@ -44,8 +48,10 @@ describe 'catalog/index.html.erb' do
|
|
44
48
|
expect(page).to have_content 'List of files deposited'
|
45
49
|
end
|
46
50
|
end
|
51
|
+
|
47
52
|
context 'when user has all the permissions' do
|
48
53
|
before { allow(view).to receive(:can?).and_return(true) }
|
54
|
+
|
49
55
|
it 'appears on page without error' do
|
50
56
|
render
|
51
57
|
page = Capybara::Node::Simple.new(rendered)
|
@@ -3,8 +3,10 @@ require 'spec_helper'
|
|
3
3
|
describe 'collections/_sort_and_per_page.html.erb' do
|
4
4
|
let(:collection) { double }
|
5
5
|
let(:response) { double(response: { 'numFound' => 3 }) }
|
6
|
+
let(:search_state) { double('SearchState', params_for_search: {}) }
|
6
7
|
|
7
8
|
before do
|
9
|
+
allow(view).to receive(:search_state).and_return(search_state)
|
8
10
|
allow(view).to receive(:sort_fields).and_return(['title_sort', 'date_sort'])
|
9
11
|
allow(view).to receive(:document_index_views).and_return(list: Blacklight::Configuration::ViewConfig.new)
|
10
12
|
assign(:response, response)
|
@@ -24,9 +24,9 @@ describe 'curation_concerns/base/_attributes.html.erb' do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'has links to search for other objects with the same metadata' do
|
27
|
-
expect(rendered).to have_link(creator, href:
|
28
|
-
expect(rendered).to have_link(contributor, href:
|
29
|
-
expect(rendered).to have_link(subject, href:
|
27
|
+
expect(rendered).to have_link(creator, href: search_catalog_path(search_field: 'creator', q: creator))
|
28
|
+
expect(rendered).to have_link(contributor, href: search_catalog_path(search_field: 'contributor', q: contributor))
|
29
|
+
expect(rendered).to have_link(subject, href: search_catalog_path(search_field: 'subject', q: subject))
|
30
30
|
end
|
31
31
|
it 'shows links in the description' do
|
32
32
|
a1 = doc.xpath("//li[@class='attribute description']/span/a").text
|
@@ -11,9 +11,13 @@ describe 'curation_concerns/file_sets/_file_set.html.erb' do
|
|
11
11
|
# Ability is checked in FileSetPresenter#link_name
|
12
12
|
let(:ability) { double(can?: true) }
|
13
13
|
let(:presenter) { CurationConcerns::FileSetPresenter.new(solr_document, ability) }
|
14
|
+
let(:blacklight_configuration_context) do
|
15
|
+
Blacklight::Configuration::Context.new(controller)
|
16
|
+
end
|
14
17
|
|
15
18
|
before do
|
16
19
|
assign(:presenter, presenter)
|
20
|
+
allow(view).to receive(:blacklight_configuration_context).and_return(blacklight_configuration_context)
|
17
21
|
allow(view).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
|
18
22
|
allow(view).to receive(:current_search_session).and_return nil
|
19
23
|
allow(view).to receive(:search_session).and_return({})
|
data/tasks/release.rake
CHANGED
@@ -29,7 +29,7 @@ directory 'pkg'
|
|
29
29
|
major, minor, tiny, pre = version.split('.')
|
30
30
|
pre = pre ? pre.inspect : "nil"
|
31
31
|
|
32
|
-
ruby.gsub!(/^(\s*)VERSION = ".*?"$/, "\\1VERSION = \"#{version}\"")
|
32
|
+
ruby.gsub!(/^(\s*)VERSION = ".*?"\.freeze$/, "\\1VERSION = \"#{version}\".freeze")
|
33
33
|
raise "Could not insert VERSION in #{file}" unless $1
|
34
34
|
File.open(file, 'w') { |f| f.write ruby }
|
35
35
|
end
|