blacklight 7.10.0 → 7.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +56 -7
- data/.rubocop_todo.yml +113 -98
- data/.travis.yml +0 -2
- data/Gemfile +0 -7
- data/README.md +1 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +1 -2
- data/app/components/blacklight/document/bookmark_component.html.erb +16 -0
- data/app/components/blacklight/document/bookmark_component.rb +19 -0
- data/app/components/blacklight/document/citation_component.html.erb +9 -0
- data/app/components/blacklight/document/citation_component.rb +24 -0
- data/app/components/blacklight/document/more_like_this_component.html.erb +12 -0
- data/app/components/blacklight/document/more_like_this_component.rb +21 -0
- data/app/components/blacklight/document_component.html.erb +29 -0
- data/app/components/blacklight/document_component.rb +121 -0
- data/app/components/blacklight/document_metadata_component.html.erb +5 -0
- data/app/components/blacklight/document_metadata_component.rb +21 -0
- data/app/components/blacklight/facet_item_component.rb +6 -6
- data/app/components/blacklight/metadata_field_component.html.erb +8 -0
- data/app/components/blacklight/metadata_field_component.rb +31 -0
- data/app/components/blacklight/metadata_field_layout_component.html.erb +2 -0
- data/app/components/blacklight/metadata_field_layout_component.rb +16 -0
- data/app/components/blacklight/response/facet_group_component.html.erb +25 -0
- data/app/components/blacklight/response/facet_group_component.rb +19 -0
- data/app/components/blacklight/response/pagination_component.html.erb +3 -0
- data/app/components/blacklight/response/pagination_component.rb +17 -0
- data/app/components/blacklight/response/sort_component.html.erb +6 -0
- data/app/components/blacklight/response/sort_component.rb +16 -0
- data/app/components/blacklight/response/spellcheck_component.html.erb +7 -0
- data/app/components/blacklight/response/spellcheck_component.rb +20 -0
- data/app/components/blacklight/search_bar_component.html.erb +29 -0
- data/app/components/blacklight/search_bar_component.rb +45 -0
- data/app/components/blacklight/search_context_component.html.erb +10 -0
- data/app/components/blacklight/search_context_component.rb +30 -0
- data/app/components/blacklight/system/dropdown_component.html.erb +12 -0
- data/app/components/blacklight/system/dropdown_component.rb +42 -0
- data/app/components/blacklight/system/modal_component.html.erb +25 -0
- data/app/components/blacklight/system/modal_component.rb +9 -0
- data/app/controllers/concerns/blacklight/catalog.rb +5 -4
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +2 -2
- data/app/controllers/concerns/blacklight/searchable.rb +11 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -3
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/configuration_helper_behavior.rb +6 -0
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/icon_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +7 -10
- data/app/helpers/blacklight/url_helper_behavior.rb +3 -3
- data/app/javascript/blacklight/search_context.js +0 -1
- data/app/models/blacklight/icon.rb +1 -0
- data/app/models/concerns/blacklight/document.rb +1 -0
- data/app/models/record_mailer.rb +1 -1
- data/app/presenters/blacklight/document_presenter.rb +7 -1
- data/app/presenters/blacklight/field_presenter.rb +1 -0
- data/app/presenters/blacklight/rendering/microdata.rb +1 -1
- data/app/services/blacklight/field_retriever.rb +1 -0
- data/app/services/blacklight/search_service.rb +1 -0
- data/app/views/catalog/_bookmark_control.html.erb +1 -36
- data/app/views/catalog/_citation.html.erb +4 -25
- data/app/views/catalog/_did_you_mean.html.erb +1 -5
- data/app/views/catalog/_document.atom.builder +3 -3
- data/app/views/catalog/_document.html.erb +5 -5
- data/app/views/catalog/_facet_group.html.erb +5 -19
- data/app/views/catalog/_index.html.erb +1 -10
- data/app/views/catalog/_paginate_compact.html.erb +6 -6
- data/app/views/catalog/_per_page_widget.html.erb +9 -12
- data/app/views/catalog/_previous_next_doc.html.erb +1 -12
- data/app/views/catalog/_results_pagination.html.erb +1 -3
- data/app/views/catalog/_search_form.html.erb +6 -27
- data/app/views/catalog/_show.html.erb +6 -8
- data/app/views/catalog/_show_main_content.html.erb +19 -13
- data/app/views/catalog/_show_sidebar.html.erb +1 -11
- data/app/views/catalog/_sort_widget.html.erb +5 -12
- data/app/views/catalog/email.html.erb +7 -7
- data/app/views/catalog/email_success.html.erb +5 -12
- data/app/views/catalog/facet.html.erb +14 -17
- data/app/views/catalog/index.atom.builder +0 -1
- data/app/views/catalog/sms.html.erb +7 -7
- data/app/views/catalog/sms_success.html.erb +5 -12
- data/blacklight.gemspec +3 -2
- data/config/i18n-tasks.yml +3 -0
- data/config/locales/blacklight.ar.yml +2 -0
- data/config/locales/blacklight.de.yml +2 -0
- data/config/locales/blacklight.en.yml +2 -0
- data/config/locales/blacklight.es.yml +4 -2
- data/config/locales/blacklight.fr.yml +2 -0
- data/config/locales/blacklight.hu.yml +2 -0
- data/config/locales/blacklight.it.yml +2 -0
- data/config/locales/blacklight.nl.yml +2 -0
- data/config/locales/blacklight.pt-BR.yml +2 -0
- data/config/locales/blacklight.sq.yml +2 -0
- data/config/locales/blacklight.zh.yml +2 -0
- data/lib/blacklight.rb +10 -0
- data/lib/blacklight/configuration.rb +8 -3
- data/lib/blacklight/configuration/fields.rb +5 -7
- data/lib/blacklight/engine.rb +1 -1
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -0
- data/lib/blacklight/search_state.rb +21 -7
- data/lib/blacklight/solr/response.rb +1 -0
- data/lib/blacklight/solr/response/facets.rb +9 -8
- data/lib/generators/blacklight/models_generator.rb +2 -0
- data/lib/generators/blacklight/templates/config/blacklight.yml +1 -0
- data/lib/railties/blacklight.rake +18 -13
- data/package.json +1 -1
- data/spec/components/blacklight/constraint_layout_component_spec.rb +1 -0
- data/spec/components/blacklight/document_component_spec.rb +129 -0
- data/spec/components/blacklight/document_metadata_component_spec.rb +0 -0
- data/spec/components/blacklight/metadata_field_component_spec.rb +41 -0
- data/spec/controllers/blacklight/search_fields_spec.rb +2 -2
- data/spec/controllers/catalog_controller_spec.rb +20 -0
- data/spec/features/search_context_spec.rb +12 -2
- data/spec/features/search_filters_spec.rb +4 -0
- data/spec/features/search_results_spec.rb +1 -0
- data/spec/features/sitelinks_search_box.rb +1 -0
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +3 -0
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +1 -0
- data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +14 -1
- data/spec/helpers/catalog_helper_spec.rb +1 -4
- data/spec/lib/blacklight/search_state_spec.rb +32 -0
- data/spec/models/blacklight/configuration_spec.rb +5 -0
- data/spec/models/blacklight/document/cache_key_spec.rb +1 -0
- data/spec/models/blacklight/document/email_spec.rb +2 -0
- data/spec/models/blacklight/document/sms_spec.rb +2 -0
- data/spec/models/blacklight/facet_paginator_spec.rb +3 -0
- data/spec/models/blacklight/icon_spec.rb +6 -0
- data/spec/models/blacklight/solr/document_spec.rb +10 -0
- data/spec/models/blacklight/solr/response/facets_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/group_response_spec.rb +2 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +10 -0
- data/spec/models/record_mailer_spec.rb +9 -0
- data/spec/models/search_spec.rb +1 -0
- data/spec/presenters/blacklight/show_presenter_spec.rb +8 -0
- data/spec/routing/catalog_routing_spec.rb +4 -0
- data/spec/services/blacklight/search_service_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/views/catalog/_document.html.erb_spec.rb +13 -11
- data/spec/views/catalog/_facet_group.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +4 -0
- data/spec/views/catalog/index.atom.builder_spec.rb +40 -3
- data/spec/views/catalog/show.html.erb_spec.rb +14 -0
- data/tasks/blacklight.rake +7 -7
- metadata +56 -6
@@ -194,7 +194,7 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
|
|
194
194
|
}
|
195
195
|
end
|
196
196
|
|
197
|
-
it"converts the query facets into a double RSolr FacetField" do
|
197
|
+
it "converts the query facets into a double RSolr FacetField" do
|
198
198
|
field = subject.aggregations['my_query_facet_field']
|
199
199
|
|
200
200
|
expect(field).to be_a_kind_of Blacklight::Solr::Response::Facets::FacetField
|
@@ -19,6 +19,7 @@ RSpec.describe Blacklight::Solr::Response::GroupResponse, api: true do
|
|
19
19
|
expect(group).to be_a Blacklight::Solr::Response::Group
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
22
23
|
it "includes a list of SolrDocuments" do
|
23
24
|
group.groups.each do |group|
|
24
25
|
group.docs.each do |doc|
|
@@ -72,6 +73,7 @@ RSpec.describe Blacklight::Solr::Response::GroupResponse, api: true do
|
|
72
73
|
).and_return('cool group')
|
73
74
|
expect(group.entry_name(count: 2)).to eq 'cool groups'
|
74
75
|
end
|
76
|
+
|
75
77
|
it "falls back to default group key" do
|
76
78
|
expect(group.entry_name(count: 2)).to eq 'grouped results'
|
77
79
|
end
|
@@ -54,6 +54,7 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
54
54
|
expect(subject[:qf]).to eq "fieldOne^2.3 fieldTwo fieldThree^0.4"
|
55
55
|
expect(subject[:spellcheck]).to eq 'false'
|
56
56
|
end
|
57
|
+
|
57
58
|
it "merges empty string parameters from search_field definition" do
|
58
59
|
expect(subject[:pf]).to eq ""
|
59
60
|
end
|
@@ -156,9 +157,11 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
156
157
|
expect(subject[:q]).to be_nil
|
157
158
|
expect(subject["spellcheck.q"]).to be_nil
|
158
159
|
end
|
160
|
+
|
159
161
|
it 'has default rows' do
|
160
162
|
expect(subject[:rows]).to eq 10
|
161
163
|
end
|
164
|
+
|
162
165
|
it 'has default facet fields' do
|
163
166
|
# remove local params from the facet.field
|
164
167
|
expect(subject[:"facet.field"].map { |x| x.gsub(/\{![^}]+\}/, '') }).to match_array %w[format subject_ssim pub_date_ssim language_ssim lc_1letter_ssim subject_geo_ssim subject_era_ssim]
|
@@ -167,6 +170,7 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
167
170
|
it "does not have a default qt" do
|
168
171
|
expect(subject[:qt]).to be_nil
|
169
172
|
end
|
173
|
+
|
170
174
|
it "has no fq" do
|
171
175
|
expect(subject[:phrase_filters]).to be_blank
|
172
176
|
expect(subject[:fq]).to be_blank
|
@@ -266,11 +270,13 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
266
270
|
it "includes proper 'q', possibly with LocalParams" do
|
267
271
|
expect(subject[:q]).to match(/(\{[^}]+\})?wome/)
|
268
272
|
end
|
273
|
+
|
269
274
|
it "includes proper 'q' when LocalParams are used" do
|
270
275
|
if /\{[^}]+\}/.match?(subject[:q])
|
271
276
|
expect(subject[:q]).to match(/\{[^}]+\}wome/)
|
272
277
|
end
|
273
278
|
end
|
279
|
+
|
274
280
|
it "includes spellcheck.q, without LocalParams" do
|
275
281
|
expect(subject["spellcheck.q"]).to eq "wome"
|
276
282
|
end
|
@@ -278,6 +284,7 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
278
284
|
it "includes spellcheck.dictionary from field def solr_parameters" do
|
279
285
|
expect(subject[:"spellcheck.dictionary"]).to eq "subject"
|
280
286
|
end
|
287
|
+
|
281
288
|
it "adds on :solr_local_parameters using Solr LocalParams style" do
|
282
289
|
# q == "{!pf=$subject_pf $qf=subject_qf} wome", make sure
|
283
290
|
# the LocalParams are really there
|
@@ -598,12 +605,15 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
598
605
|
it 'sets rows to 0' do
|
599
606
|
expect(solr_parameters[:rows]).to eq 0
|
600
607
|
end
|
608
|
+
|
601
609
|
it 'sets facets requested to facet_field argument' do
|
602
610
|
expect(solr_parameters["facet.field".to_sym]).to eq facet_field
|
603
611
|
end
|
612
|
+
|
604
613
|
it 'defaults offset to 0' do
|
605
614
|
expect(solr_parameters[:"f.#{facet_field}.facet.offset"]).to eq 0
|
606
615
|
end
|
616
|
+
|
607
617
|
context 'when offset is manually set' do
|
608
618
|
let(:user_params) { { page_key => 2 } }
|
609
619
|
|
@@ -18,20 +18,25 @@ RSpec.describe RecordMailer do
|
|
18
18
|
it "receives the TO paramater and send the email to that address" do
|
19
19
|
expect(@email.to).to include 'test@test.com'
|
20
20
|
end
|
21
|
+
|
21
22
|
it "starts the subject w/ Item Record:" do
|
22
23
|
expect(@email.subject).to match /^Item Record:/
|
23
24
|
end
|
25
|
+
|
24
26
|
it "puts the title of the item in the subject" do
|
25
27
|
expect(@email.subject).to match /The horn/
|
26
28
|
end
|
29
|
+
|
27
30
|
it "has the correct from address (w/o the port number)" do
|
28
31
|
expect(@email.from).to include "no-reply@projectblacklight.org"
|
29
32
|
end
|
33
|
+
|
30
34
|
it "prints out the correct body" do
|
31
35
|
expect(@email.body).to match /Title: The horn/
|
32
36
|
expect(@email.body).to match /Author: Janetzky, Kurt/
|
33
37
|
expect(@email.body).to match /projectblacklight.org/
|
34
38
|
end
|
39
|
+
|
35
40
|
it "uses https URLs when protocol is set" do
|
36
41
|
details = { to: 'test@test.com', message: "This is my message" }
|
37
42
|
@https_email = described_class.email_record(@documents, details, host: 'projectblacklight.org', protocol: 'https')
|
@@ -48,17 +53,21 @@ RSpec.describe RecordMailer do
|
|
48
53
|
it "creates the correct TO address for the SMS email" do
|
49
54
|
expect(@sms.to).to include '5555555555@txt.att.net'
|
50
55
|
end
|
56
|
+
|
51
57
|
it "does not have a subject" do
|
52
58
|
expect(@sms.subject).to be_blank
|
53
59
|
end
|
60
|
+
|
54
61
|
it "has the correct from address (w/o the port number)" do
|
55
62
|
expect(@sms.from).to include "no-reply@projectblacklight.org"
|
56
63
|
end
|
64
|
+
|
57
65
|
it "prints out the correct body" do
|
58
66
|
expect(@sms.body).to match /The horn/
|
59
67
|
expect(@sms.body).to match /by Janetzky, Kurt/
|
60
68
|
expect(@sms.body).to match /projectblacklight.org:3000/
|
61
69
|
end
|
70
|
+
|
62
71
|
it "uses https URL when protocol is set" do
|
63
72
|
details = { to: '5555555555@txt.att.net' }
|
64
73
|
@https_sms = described_class.sms_record(@documents, details, host: 'projectblacklight.org', protocol: 'https')
|
data/spec/models/search_spec.rb
CHANGED
@@ -143,6 +143,14 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
|
|
143
143
|
config.show.title_field = Blacklight::Configuration::Field.new(field: 'x', values: ->(*_) { 'hardcoded' })
|
144
144
|
expect(subject.heading).to eq 'hardcoded'
|
145
145
|
end
|
146
|
+
|
147
|
+
context "when empty document" do
|
148
|
+
let(:document) { SolrDocument.new({}) }
|
149
|
+
|
150
|
+
it "returns an empty string as the heading" do
|
151
|
+
expect(subject.heading).to eq("")
|
152
|
+
end
|
153
|
+
end
|
146
154
|
end
|
147
155
|
|
148
156
|
describe "#html_title" do
|
@@ -7,15 +7,19 @@ RSpec.describe "Routing" do
|
|
7
7
|
it "has a path for showing the email form" do
|
8
8
|
expect(get: "/catalog/email").to route_to(controller: 'catalog', action: 'email')
|
9
9
|
end
|
10
|
+
|
10
11
|
it "has a path for sending the email" do
|
11
12
|
expect(post: "/catalog/email").to route_to(controller: 'catalog', action: 'email')
|
12
13
|
end
|
14
|
+
|
13
15
|
it "maps GET {:controller => 'catalog', :action => 'sms'} to /catalog/sms" do
|
14
16
|
expect(get: "/catalog/sms").to route_to(controller: 'catalog', action: 'sms')
|
15
17
|
end
|
18
|
+
|
16
19
|
it "maps POST {:controller => 'catalog', :action => 'sms'} to /catalog/sms" do
|
17
20
|
expect(post: "/catalog/sms").to route_to(controller: 'catalog', action: 'sms')
|
18
21
|
end
|
22
|
+
|
19
23
|
it "maps { :controller => 'catalog', :action => 'show', :id => 666 } to /catalog/666" do
|
20
24
|
expect(get: "/catalog/666").to route_to(controller: 'catalog', action: 'show', id: "666")
|
21
25
|
end
|
@@ -179,6 +179,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
179
179
|
it 'has more than one facet' do
|
180
180
|
expect(@facets).to have_at_least(1).facet
|
181
181
|
end
|
182
|
+
|
182
183
|
it 'has all facets specified in initializer' do
|
183
184
|
expect(@facets.keys).to include *blacklight_config.facet_fields.keys
|
184
185
|
expect(@facets.none? { |_k, v| v.nil? }).to eq true
|
@@ -189,6 +190,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
189
190
|
expect(facet.items).to have_at_least(1).hit
|
190
191
|
end
|
191
192
|
end
|
193
|
+
|
192
194
|
it 'has multiple values for at least one facet' do
|
193
195
|
has_mult_values = false
|
194
196
|
@facets.each do |_key, facet|
|
@@ -199,6 +201,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
199
201
|
end
|
200
202
|
expect(has_mult_values).to eq true
|
201
203
|
end
|
204
|
+
|
202
205
|
it 'has all value counts > 0' do
|
203
206
|
@facets.each do |_key, facet|
|
204
207
|
facet.items.each do |facet_vals|
|
@@ -217,6 +220,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
217
220
|
(solr_response,) = service.search_results
|
218
221
|
expect(solr_response.params[:start].to_i).to eq 0
|
219
222
|
end
|
223
|
+
|
220
224
|
it 'has number of results (per page) set in initializer, by default' do
|
221
225
|
(solr_response, document_list) = service.search_results
|
222
226
|
expect(solr_response.docs).to have(blacklight_config[:default_solr_params][:rows]).items
|
@@ -322,12 +326,15 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
322
326
|
it "has a non-nil result for a known id" do
|
323
327
|
expect(@document).not_to be_nil
|
324
328
|
end
|
329
|
+
|
325
330
|
it "has a single document in the response for a known id" do
|
326
331
|
expect(@response2.docs.size).to eq 1
|
327
332
|
end
|
333
|
+
|
328
334
|
it 'has the expected value in the id field' do
|
329
335
|
expect(@document.id).to eq doc_id
|
330
336
|
end
|
337
|
+
|
331
338
|
it 'has non-nil values for required fields set in initializer' do
|
332
339
|
expect(@document.fetch(blacklight_config.view_config(:show).display_type_field)).not_to be_nil
|
333
340
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -31,7 +31,7 @@ Capybara.disable_animation = true
|
|
31
31
|
# in spec/support/ and its subdirectories.
|
32
32
|
# Blacklight, again, make sure we're looking in the right place for em.
|
33
33
|
# Relative to HERE, NOT to Rails.root, which is off somewhere else.
|
34
|
-
Dir[Pathname.new(File.expand_path('support/**/*.rb', __dir__))].each { |f| require f }
|
34
|
+
Dir[Pathname.new(File.expand_path('support/**/*.rb', __dir__))].sort.each { |f| require f }
|
35
35
|
|
36
36
|
RSpec.configure do |config|
|
37
37
|
config.disable_monkey_patching!
|
@@ -7,6 +7,7 @@ RSpec.describe "catalog/_document" do
|
|
7
7
|
before do
|
8
8
|
allow(view).to receive(:render_grouped_response?).and_return(false)
|
9
9
|
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
|
10
|
+
assign(:response, instance_double(Blacklight::Solr::Response, start: 20))
|
10
11
|
end
|
11
12
|
|
12
13
|
it "renders the header, thumbnail and index by default" do
|
@@ -14,11 +15,10 @@ RSpec.describe "catalog/_document" do
|
|
14
15
|
stub_template "catalog/_thumbnail.html.erb" => "thumbnail_default"
|
15
16
|
stub_template "catalog/_index_default.html.erb" => "index_default"
|
16
17
|
render partial: "catalog/document", locals: { document: document, document_counter: 1 }
|
18
|
+
expect(rendered).to have_selector 'article.document[@data-document-counter="22"]'
|
17
19
|
expect(rendered).to match /document_header/
|
18
20
|
expect(rendered).to match /thumbnail_default/
|
19
21
|
expect(rendered).to match /index_default/
|
20
|
-
expect(rendered).to have_selector('.document[@itemscope]')
|
21
|
-
expect(rendered).to have_selector('.document[@itemtype="http://schema.org/Thing"]')
|
22
22
|
end
|
23
23
|
|
24
24
|
it "uses the index.partials parameter to determine the partials to render" do
|
@@ -32,15 +32,17 @@ RSpec.describe "catalog/_document" do
|
|
32
32
|
expect(rendered).to match /c_partial/
|
33
33
|
end
|
34
34
|
|
35
|
-
it '
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
it 'provides the rendered partials to an explicitly configured component but does not render them by default' do
|
36
|
+
blacklight_config.index.partials = %w[a]
|
37
|
+
stub_template "catalog/_a_default.html.erb" => "partial"
|
38
|
+
blacklight_config.index.document_component = Blacklight::DocumentComponent
|
39
|
+
allow(view).to receive(:search_session).and_return({})
|
40
|
+
allow(view).to receive(:current_search_session).and_return(nil)
|
41
|
+
allow(view.main_app).to receive(:track_test_path).and_return('/track')
|
42
|
+
|
43
|
+
render partial: "catalog/document", locals: { document: document, document_counter: 1 }
|
40
44
|
|
41
|
-
|
42
|
-
|
43
|
-
render partial: 'catalog/document', locals: { document: document, document_counter: 5 }
|
44
|
-
expect(rendered).to have_selector '.document[@data-document-counter="5"]'
|
45
|
+
expect(rendered).to have_selector 'article.document header', text: '22. xyz'
|
46
|
+
expect(rendered).not_to match(/partial/)
|
45
47
|
end
|
46
48
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe "catalog/_previous_next_doc.html.erb" do
|
4
|
+
before do
|
5
|
+
allow(view).to receive(:search_session).and_return({})
|
6
|
+
end
|
7
|
+
|
4
8
|
it "without next or previous does not render content" do
|
5
9
|
assign(:search_context, {})
|
6
10
|
render
|
@@ -12,20 +12,23 @@ RSpec.describe "catalog/index" do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
let(:blacklight_config) { CatalogController.blacklight_config }
|
16
|
+
|
15
17
|
before do
|
16
18
|
@response = Blacklight::Solr::Response.new({ response: { numFound: 30 } }, start: 10, rows: 10)
|
17
19
|
allow(@response).to receive(:documents).and_return(document_list)
|
18
20
|
params['content_format'] = 'some_format'
|
19
21
|
allow(view).to receive(:action_name).and_return('index')
|
20
|
-
allow(view).to receive(:blacklight_config).and_return(
|
22
|
+
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
|
21
23
|
allow(view).to receive(:search_field_options_for_select).and_return([])
|
22
|
-
render template: 'catalog/index', formats: [:atom]
|
23
24
|
end
|
24
25
|
|
25
26
|
# We need to use rexml to test certain things that have_tag wont' test
|
26
27
|
let(:response_xml) { REXML::Document.new(rendered) }
|
27
28
|
|
28
29
|
it "has contextual information" do
|
30
|
+
render template: 'catalog/index', formats: [:atom]
|
31
|
+
|
29
32
|
expect(rendered).to have_selector("link[rel=self]")
|
30
33
|
expect(rendered).to have_selector("link[rel=next]")
|
31
34
|
expect(rendered).to have_selector("link[rel=previous]")
|
@@ -36,6 +39,8 @@ RSpec.describe "catalog/index" do
|
|
36
39
|
end
|
37
40
|
|
38
41
|
it "gets paging data correctly from response" do
|
42
|
+
render template: 'catalog/index', formats: [:atom]
|
43
|
+
|
39
44
|
# Can't use have_tag for namespaced elements, sorry.
|
40
45
|
expect(response_xml.elements["/feed/opensearch:totalResults"].text).to eq "30"
|
41
46
|
expect(response_xml.elements["/feed/opensearch:startIndex"].text).to eq "10"
|
@@ -43,6 +48,8 @@ RSpec.describe "catalog/index" do
|
|
43
48
|
end
|
44
49
|
|
45
50
|
it "includes an opensearch Query role=request" do
|
51
|
+
render template: 'catalog/index', formats: [:atom]
|
52
|
+
|
46
53
|
expect(response_xml.elements.to_a("/feed/opensearch:itemsPerPage")).to have(1).item
|
47
54
|
query_el = response_xml.elements["/feed/opensearch:Query"]
|
48
55
|
expect(query_el).not_to be_nil
|
@@ -52,30 +59,55 @@ RSpec.describe "catalog/index" do
|
|
52
59
|
end
|
53
60
|
|
54
61
|
it "has ten entries" do
|
62
|
+
render template: 'catalog/index', formats: [:atom]
|
63
|
+
|
55
64
|
expect(rendered).to have_selector("entry", count: 10)
|
56
65
|
end
|
57
66
|
|
58
67
|
describe "entries" do
|
59
68
|
it "has a title" do
|
69
|
+
render template: 'catalog/index', formats: [:atom]
|
60
70
|
expect(rendered).to have_selector("entry > title")
|
61
71
|
end
|
72
|
+
|
62
73
|
it "has an updated" do
|
74
|
+
render template: 'catalog/index', formats: [:atom]
|
63
75
|
expect(rendered).to have_selector("entry > updated")
|
64
76
|
end
|
77
|
+
|
65
78
|
it "has html link" do
|
79
|
+
render template: 'catalog/index', formats: [:atom]
|
66
80
|
expect(rendered).to have_selector("entry > link[rel=alternate][type='text/html']")
|
67
81
|
end
|
82
|
+
|
68
83
|
it "has an id" do
|
84
|
+
render template: 'catalog/index', formats: [:atom]
|
69
85
|
expect(rendered).to have_selector("entry > id")
|
70
86
|
end
|
87
|
+
|
71
88
|
it "has a summary" do
|
72
|
-
|
89
|
+
stub_template "catalog/_index.html.erb" => "partial content"
|
90
|
+
render template: 'catalog/index', formats: [:atom]
|
91
|
+
expect(rendered).to have_selector("entry > summary", text: 'partial content')
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'with a custom HTML partial' do
|
95
|
+
before do
|
96
|
+
blacklight_config.view.atom.summary_partials = ['whatever']
|
97
|
+
stub_template 'catalog/_whatever_default.html.erb' => 'whatever content'
|
98
|
+
end
|
99
|
+
|
100
|
+
it "has the customized summary" do
|
101
|
+
render template: 'catalog/index', formats: [:atom]
|
102
|
+
expect(rendered).to have_selector("entry > summary", text: 'whatever content')
|
103
|
+
end
|
73
104
|
end
|
74
105
|
|
75
106
|
describe "with an author" do
|
76
107
|
let(:entry) { response_xml.elements.to_a("/feed/entry")[0] }
|
77
108
|
|
78
109
|
it "has author tag" do
|
110
|
+
render template: 'catalog/index', formats: [:atom]
|
79
111
|
expect(entry.elements["author/name"].text).to eq 'xyz'
|
80
112
|
end
|
81
113
|
end
|
@@ -84,6 +116,7 @@ RSpec.describe "catalog/index" do
|
|
84
116
|
let(:entry) { response_xml.elements.to_a("/feed/entry")[1] }
|
85
117
|
|
86
118
|
it "does not have an author tag" do
|
119
|
+
render template: 'catalog/index', formats: [:atom]
|
87
120
|
expect(entry.elements["author/name"]).to be_nil
|
88
121
|
end
|
89
122
|
end
|
@@ -94,9 +127,12 @@ RSpec.describe "catalog/index" do
|
|
94
127
|
let(:entry) { response_xml.elements.to_a("/feed/entry")[1].to_s }
|
95
128
|
|
96
129
|
it "includes a link rel tag" do
|
130
|
+
render template: 'catalog/index', formats: [:atom]
|
97
131
|
expect(entry).to have_selector("link[rel=alternate][type='application/some-format']")
|
98
132
|
end
|
133
|
+
|
99
134
|
it "has content embedded" do
|
135
|
+
render template: 'catalog/index', formats: [:atom]
|
100
136
|
expect(entry).to have_selector("content")
|
101
137
|
end
|
102
138
|
end
|
@@ -105,6 +141,7 @@ RSpec.describe "catalog/index" do
|
|
105
141
|
let(:entry) { response_xml.elements.to_a("/feed/entry")[5].to_s }
|
106
142
|
|
107
143
|
it "does not have content embedded" do
|
144
|
+
render template: 'catalog/index', formats: [:atom]
|
108
145
|
expect(entry).not_to have_selector("content[type='application/some-format']")
|
109
146
|
end
|
110
147
|
end
|
@@ -49,4 +49,18 @@ RSpec.describe "catalog/show.html.erb" do
|
|
49
49
|
expect(rendered).to match /b_partial/
|
50
50
|
expect(rendered).to match /c_partial/
|
51
51
|
end
|
52
|
+
|
53
|
+
it 'provides the rendered partials to an explicitly configured component but does not render them by default' do
|
54
|
+
blacklight_config.show.partials = %w[a]
|
55
|
+
stub_template "catalog/_a_default.html.erb" => "partial"
|
56
|
+
blacklight_config.show.document_component = Blacklight::DocumentComponent
|
57
|
+
allow(view).to receive(:search_session).and_return({})
|
58
|
+
allow(view).to receive(:current_search_session).and_return(nil)
|
59
|
+
allow(view.main_app).to receive(:track_test_path).and_return('/track')
|
60
|
+
|
61
|
+
render
|
62
|
+
|
63
|
+
expect(rendered).to have_selector 'div.document header h1', text: 'xyz'
|
64
|
+
expect(rendered).not_to match(/partial/)
|
65
|
+
end
|
52
66
|
end
|