blacklight 7.11.1 → 7.12.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 +8 -0
- data/.solr_wrapper.yml +5 -0
- data/VERSION +1 -1
- data/app/builders/blacklight/action_builder.rb +6 -0
- data/app/components/blacklight/constraint_component.html.erb +5 -0
- data/app/components/blacklight/constraint_component.rb +13 -0
- data/app/components/blacklight/constraint_layout_component.rb +2 -1
- data/app/components/blacklight/constraints_component.html.erb +10 -0
- data/app/components/blacklight/constraints_component.rb +65 -0
- data/app/components/blacklight/document/action_component.html.erb +9 -0
- data/app/components/blacklight/document/action_component.rb +38 -0
- data/app/components/blacklight/document/actions_component.html.erb +13 -0
- data/app/components/blacklight/document/actions_component.rb +26 -0
- data/app/components/blacklight/document/bookmark_component.html.erb +1 -1
- data/app/components/blacklight/document/bookmark_component.rb +8 -0
- data/app/components/blacklight/document/citation_component.html.erb +4 -2
- data/app/components/blacklight/document/citation_component.rb +8 -1
- data/app/components/blacklight/document/group_component.html.erb +9 -0
- data/app/components/blacklight/document/group_component.rb +26 -0
- data/app/components/blacklight/document/more_like_this_component.rb +2 -0
- data/app/components/blacklight/document/thumbnail_component.html.erb +12 -0
- data/app/components/blacklight/document/thumbnail_component.rb +25 -0
- data/app/components/blacklight/document_component.rb +27 -26
- data/app/components/blacklight/facet_field_filter_component.html.erb +12 -0
- data/app/components/blacklight/facet_field_filter_component.rb +25 -0
- data/app/components/blacklight/facet_field_pagination_component.html.erb +19 -0
- data/app/components/blacklight/facet_field_pagination_component.rb +21 -0
- data/app/components/blacklight/facet_item_component.rb +4 -8
- data/app/components/blacklight/response/facet_group_component.html.erb +3 -1
- data/app/components/blacklight/response/facet_group_component.rb +8 -1
- data/app/components/blacklight/response/pagination_component.rb +3 -0
- data/app/components/blacklight/response/sort_component.html.erb +1 -1
- data/app/components/blacklight/response/spellcheck_component.rb +9 -2
- data/app/components/blacklight/response/view_type_component.html.erb +11 -0
- data/app/components/blacklight/response/view_type_component.rb +36 -0
- data/app/components/blacklight/search_bar_component.html.erb +1 -1
- data/app/components/blacklight/search_bar_component.rb +6 -0
- data/app/components/blacklight/search_context_component.rb +6 -2
- data/app/components/blacklight/system/dropdown_component.html.erb +1 -1
- data/app/components/blacklight/system/flash_message_component.html.erb +4 -0
- data/app/components/blacklight/system/flash_message_component.rb +24 -0
- data/app/controllers/concerns/blacklight/catalog.rb +7 -1
- data/app/controllers/concerns/blacklight/controller.rb +12 -3
- data/app/controllers/concerns/blacklight/facet.rb +19 -5
- data/app/controllers/concerns/blacklight/search_fields.rb +7 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +127 -17
- data/app/helpers/blacklight/catalog_helper_behavior.rb +36 -5
- data/app/helpers/blacklight/component_helper_behavior.rb +36 -6
- data/app/helpers/blacklight/configuration_helper_behavior.rb +32 -4
- data/app/helpers/blacklight/facets_helper_behavior.rb +31 -8
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +5 -0
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +28 -11
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +8 -3
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +4 -2
- data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +23 -3
- data/app/models/blacklight/icon.rb +0 -1
- data/app/models/concerns/blacklight/document.rb +1 -1
- data/app/models/concerns/blacklight/suggest/response.rb +1 -1
- data/app/models/record_mailer.rb +1 -1
- data/app/presenters/blacklight/document_presenter.rb +42 -1
- data/app/presenters/blacklight/facet_field_presenter.rb +3 -1
- data/app/presenters/blacklight/facet_item_presenter.rb +8 -0
- data/app/presenters/blacklight/field_presenter.rb +9 -6
- data/app/presenters/blacklight/json_presenter.rb +3 -1
- data/app/presenters/blacklight/show_presenter.rb +4 -30
- data/app/presenters/blacklight/thumbnail_presenter.rb +5 -1
- data/app/services/blacklight/document_factory.rb +3 -0
- data/app/services/blacklight/field_retriever.rb +18 -4
- data/app/services/blacklight/search_service.rb +0 -1
- data/app/views/bookmarks/_tools.html.erb +12 -7
- data/app/views/catalog/_bookmark_control.html.erb +1 -1
- data/app/views/catalog/_constraints.html.erb +12 -7
- data/app/views/catalog/_document.atom.builder +9 -6
- data/app/views/catalog/_document.rss.builder +4 -2
- data/app/views/catalog/_facet_index_navigation.html.erb +1 -10
- data/app/views/catalog/_facet_pagination.html.erb +1 -19
- data/app/views/catalog/_facets.html.erb +1 -1
- data/app/views/catalog/_group.html.erb +1 -9
- data/app/views/catalog/_index.html.erb +1 -1
- data/app/views/catalog/_search_results.html.erb +1 -1
- data/app/views/catalog/_show.html.erb +1 -1
- data/app/views/catalog/_show_header.html.erb +1 -1
- data/app/views/catalog/_show_main_content.html.erb +2 -2
- data/app/views/catalog/_show_tools.html.erb +12 -8
- data/app/views/catalog/_start_over.html.erb +1 -1
- data/app/views/catalog/_thumbnail.html.erb +1 -5
- data/app/views/catalog/_view_type_group.html.erb +5 -13
- data/app/views/catalog/index.json.jbuilder +8 -6
- data/app/views/catalog/show.json.jbuilder +1 -1
- data/app/views/shared/_flash_msg.html.erb +1 -15
- data/blacklight.gemspec +1 -0
- data/config/locales/blacklight.ca.yml +241 -0
- data/lib/blacklight/abstract_repository.rb +13 -4
- data/lib/blacklight/configuration.rb +11 -5
- data/lib/blacklight/configuration/display_field.rb +50 -0
- data/lib/blacklight/configuration/facet_field.rb +58 -1
- data/lib/blacklight/configuration/field.rb +13 -0
- data/lib/blacklight/configuration/index_field.rb +5 -0
- data/lib/blacklight/configuration/search_field.rb +3 -0
- data/lib/blacklight/configuration/show_field.rb +5 -0
- data/lib/blacklight/configuration/sort_field.rb +3 -0
- data/lib/blacklight/configuration/tool_config.rb +1 -0
- data/lib/blacklight/configuration/view_config.rb +25 -0
- data/lib/blacklight/search_state.rb +4 -2
- data/lib/blacklight/solr/repository.rb +1 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +8 -7
- data/spec/components/blacklight/document/action_component_spec.rb +43 -0
- data/spec/components/blacklight/document/group_component_spec.rb +45 -0
- data/spec/components/blacklight/document_component_spec.rb +8 -0
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +0 -1
- data/spec/components/blacklight/system/flash_message_component_spec.rb +54 -0
- data/spec/controllers/blacklight/search_fields_spec.rb +2 -0
- data/spec/controllers/catalog_controller_spec.rb +2 -0
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +6 -1
- data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +3 -1
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight_helper_spec.rb +10 -0
- data/spec/helpers/catalog_helper_spec.rb +4 -4
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +17 -0
- data/spec/models/blacklight/search_builder_spec.rb +1 -1
- data/spec/models/blacklight/solr/search_builder_spec.rb +8 -0
- data/spec/presenters/blacklight/field_presenter_spec.rb +30 -5
- data/spec/services/blacklight/search_service_spec.rb +1 -5
- data/spec/views/catalog/_constraints.html.erb_spec.rb +2 -1
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -2
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
- data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -0
- data/tasks/blacklight.rake +27 -12
- metadata +47 -2
@@ -87,6 +87,14 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
87
87
|
expect(rendered).to have_selector 'header', text: '5. Title'
|
88
88
|
end
|
89
89
|
|
90
|
+
context 'with a document rendered as part of a collection' do
|
91
|
+
let(:attr) { { document_counter: 10, counter_offset: 100 } }
|
92
|
+
|
93
|
+
it 'renders a counter with the title' do
|
94
|
+
expect(rendered).to have_selector 'header', text: '111. Title'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
90
98
|
it 'renders actions' do
|
91
99
|
expect(rendered).to have_selector '.index-document-functions'
|
92
100
|
end
|
@@ -36,7 +36,6 @@ RSpec.describe Blacklight::FacetItemPivotComponent, type: :component do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'has the facet hierarchy' do
|
39
|
-
puts render
|
40
39
|
expect(rendered).to have_selector 'li ul.pivot-facet'
|
41
40
|
expect(rendered).to have_link 'x:1', href: /f%5Bz%5D%5B%5D=x%3A1/
|
42
41
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
|
6
|
+
subject(:component) { described_class.new(message: message, type: type) }
|
7
|
+
|
8
|
+
let(:view_context) { controller.view_context }
|
9
|
+
let(:render) do
|
10
|
+
component.render_in(view_context)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:rendered) do
|
14
|
+
Capybara::Node::Simple.new(render)
|
15
|
+
end
|
16
|
+
let(:message) { 'This is an important message' }
|
17
|
+
let(:type) { 'whatever' }
|
18
|
+
|
19
|
+
it 'renders a message inside an alert' do
|
20
|
+
expect(rendered).to have_selector 'div.alert.alert-whatever', text: message
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with a success message' do
|
24
|
+
let(:type) { 'success' }
|
25
|
+
|
26
|
+
it 'adds some styling' do
|
27
|
+
expect(rendered).to have_selector 'div.alert-success'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with a notice message' do
|
32
|
+
let(:type) { 'notice' }
|
33
|
+
|
34
|
+
it 'adds some styling' do
|
35
|
+
expect(rendered).to have_selector 'div.alert-info'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with an alert message' do
|
40
|
+
let(:type) { 'alert' }
|
41
|
+
|
42
|
+
it 'adds some styling' do
|
43
|
+
expect(rendered).to have_selector 'div.alert-warning'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with an error message' do
|
48
|
+
let(:type) { 'error' }
|
49
|
+
|
50
|
+
it 'adds some styling' do
|
51
|
+
expect(rendered).to have_selector 'div.alert-danger'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe CatalogController, api: true do
|
4
|
+
around { |test| Deprecation.silence(Blacklight::Catalog) { test.call } }
|
5
|
+
|
4
6
|
let(:doc_id) { '2007020969' }
|
5
7
|
let(:mock_response) { instance_double(Blacklight::Solr::Response) }
|
6
8
|
let(:mock_document) { instance_double(SolrDocument, export_formats: {}) }
|
@@ -3,6 +3,8 @@
|
|
3
3
|
RSpec.describe Blacklight::FacetsHelperBehavior do
|
4
4
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
5
5
|
|
6
|
+
around { |test| Deprecation.silence(described_class) { test.call } }
|
7
|
+
|
6
8
|
before do
|
7
9
|
allow(helper).to receive(:blacklight_config).and_return blacklight_config
|
8
10
|
end
|
@@ -103,6 +105,8 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
103
105
|
end
|
104
106
|
|
105
107
|
describe "facet_by_field_name" do
|
108
|
+
around { |test| Deprecation.silence(Blacklight::Facet) { test.call } }
|
109
|
+
|
106
110
|
it "retrieves the facet from the response given a string" do
|
107
111
|
facet_config = double(query: nil, field: 'b', key: 'a')
|
108
112
|
facet_field = double
|
@@ -133,7 +137,6 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
133
137
|
expect(helper).to receive(:render_facet_limit).with(a, {})
|
134
138
|
expect(helper).to receive(:render_facet_limit).with(b, {})
|
135
139
|
helper.render_facet_partials
|
136
|
-
expect(Deprecation).to have_received(:warn).twice
|
137
140
|
end
|
138
141
|
end
|
139
142
|
|
@@ -233,6 +236,8 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
233
236
|
allow(helper).to receive(:render_facet_item).and_return('<a class="facet-select">Book</a>'.html_safe, nil)
|
234
237
|
end
|
235
238
|
|
239
|
+
around { |test| Deprecation.silence(Blacklight::FacetItemComponent) { test.call } }
|
240
|
+
|
236
241
|
it "draws a list of elements" do
|
237
242
|
expect(subject).to have_selector 'li', count: 1
|
238
243
|
expect(subject).to have_selector 'li:first-child a.facet-select', text: 'Book'
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Blacklight::RenderPartialsHelperBehavior do
|
4
|
+
around { |test| Deprecation.silence(described_class) { test.call } }
|
5
|
+
|
4
6
|
describe "#type_field_to_partial_name" do
|
5
7
|
subject { helper.send(:type_field_to_partial_name, document, value) }
|
6
8
|
|
@@ -49,7 +51,7 @@ RSpec.describe Blacklight::RenderPartialsHelperBehavior do
|
|
49
51
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
50
52
|
|
51
53
|
before do
|
52
|
-
allow(helper).to receive_messages(blacklight_config: blacklight_config)
|
54
|
+
allow(helper).to receive_messages(blacklight_config: blacklight_config, action_name: 'show')
|
53
55
|
end
|
54
56
|
|
55
57
|
context "with a solr document with empty fields" do
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Blacklight::UrlHelperBehavior do
|
4
|
+
around { |test| Deprecation.silence(described_class) { test.call } }
|
5
|
+
|
4
6
|
let(:blacklight_config) do
|
5
7
|
Blacklight::Configuration.new.configure do |config|
|
6
8
|
config.index.title_field = 'title_tsim'
|
@@ -213,6 +213,8 @@ RSpec.describe BlacklightHelper do
|
|
213
213
|
end
|
214
214
|
|
215
215
|
describe '#render_index_field_label' do
|
216
|
+
around { |test| Deprecation.silence(Blacklight::BlacklightHelperBehavior) { test.call } }
|
217
|
+
|
216
218
|
let(:doc) { SolrDocument.new({}) }
|
217
219
|
|
218
220
|
before do
|
@@ -246,6 +248,8 @@ RSpec.describe BlacklightHelper do
|
|
246
248
|
end
|
247
249
|
|
248
250
|
describe "should_show_spellcheck_suggestions?" do
|
251
|
+
around { |test| Deprecation.silence(Blacklight::BlacklightHelperBehavior) { test.call } }
|
252
|
+
|
249
253
|
before do
|
250
254
|
allow(helper).to receive_messages spell_check_max: 5
|
251
255
|
end
|
@@ -366,6 +370,8 @@ RSpec.describe BlacklightHelper do
|
|
366
370
|
let(:presenter_class) { double }
|
367
371
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
368
372
|
|
373
|
+
around { |test| Deprecation.silence(Blacklight::BlacklightHelperBehavior) { test.call } }
|
374
|
+
|
369
375
|
before do
|
370
376
|
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
371
377
|
end
|
@@ -394,6 +400,8 @@ RSpec.describe BlacklightHelper do
|
|
394
400
|
end
|
395
401
|
|
396
402
|
describe "#render_document_heading" do
|
403
|
+
around { |test| Deprecation.silence(Blacklight::BlacklightHelperBehavior) { test.call } }
|
404
|
+
|
397
405
|
let(:document) { double }
|
398
406
|
|
399
407
|
before do
|
@@ -420,6 +428,8 @@ RSpec.describe BlacklightHelper do
|
|
420
428
|
end
|
421
429
|
|
422
430
|
describe "#presenter" do
|
431
|
+
around { |test| Deprecation.silence(Blacklight::BlacklightHelperBehavior) { test.call } }
|
432
|
+
|
423
433
|
let(:document) { double }
|
424
434
|
|
425
435
|
before do
|
@@ -166,7 +166,7 @@ RSpec.describe CatalogHelper do
|
|
166
166
|
|
167
167
|
describe "should_autofocus_on_search_box?" do
|
168
168
|
before do
|
169
|
-
|
169
|
+
allow(Deprecation).to receive(:warn)
|
170
170
|
end
|
171
171
|
|
172
172
|
it "is focused if we're on a catalog-like index page without query or facet parameters" do
|
@@ -192,7 +192,7 @@ RSpec.describe CatalogHelper do
|
|
192
192
|
|
193
193
|
describe "has_thumbnail?" do
|
194
194
|
before do
|
195
|
-
|
195
|
+
allow(Deprecation).to receive(:warn)
|
196
196
|
end
|
197
197
|
|
198
198
|
let(:document) { SolrDocument.new(data) }
|
@@ -231,7 +231,7 @@ RSpec.describe CatalogHelper do
|
|
231
231
|
let(:thumbnail_presenter) { instance_double(Blacklight::ThumbnailPresenter) }
|
232
232
|
|
233
233
|
before do
|
234
|
-
|
234
|
+
allow(Deprecation).to receive(:warn)
|
235
235
|
allow(helper).to receive(:index_presenter).with(document).and_return(index_presenter)
|
236
236
|
end
|
237
237
|
|
@@ -250,7 +250,7 @@ RSpec.describe CatalogHelper do
|
|
250
250
|
|
251
251
|
describe "thumbnail_url" do
|
252
252
|
before do
|
253
|
-
|
253
|
+
allow(Deprecation).to receive(:warn)
|
254
254
|
end
|
255
255
|
|
256
256
|
it "pulls the configured thumbnail field out of the document" do
|
@@ -10,4 +10,21 @@ RSpec.describe Blacklight::Configuration::FacetField do
|
|
10
10
|
expect(subject.link_to_facet).to eq true
|
11
11
|
end
|
12
12
|
end
|
13
|
+
|
14
|
+
describe '#normalize!' do
|
15
|
+
it 'preserves existing properties' do
|
16
|
+
expected = double
|
17
|
+
subject.presenter = expected
|
18
|
+
|
19
|
+
subject.normalize!
|
20
|
+
|
21
|
+
expect(subject.presenter).to eq expected
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'adds a default presenter' do
|
25
|
+
subject.normalize!
|
26
|
+
|
27
|
+
expect(subject.presenter).to eq Blacklight::FacetFieldPresenter
|
28
|
+
end
|
29
|
+
end
|
13
30
|
end
|
@@ -183,7 +183,7 @@ RSpec.describe Blacklight::SearchBuilder, api: true do
|
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
context "when the user provides
|
186
|
+
context "when the user provides a sort parameter" do
|
187
187
|
subject(:sort) { builder_with_param.send(:sort) }
|
188
188
|
|
189
189
|
let(:builder_with_param) { builder.with(sort: 'x') }
|
@@ -331,6 +331,14 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
331
331
|
end
|
332
332
|
end
|
333
333
|
|
334
|
+
context "when the user provides a valid customized sort parmeter" do
|
335
|
+
let(:user_params) { { sort: 'year-desc' } }
|
336
|
+
|
337
|
+
it "passes solr sort paramters through" do
|
338
|
+
expect(subject[:sort]).to eq 'pub_date_si desc, title_si asc'
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
334
342
|
context "when the user provides an invalid sort parameter" do
|
335
343
|
let(:user_params) { { sort: 'bad' } }
|
336
344
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
RSpec.describe Blacklight::FieldPresenter, api: true do
|
4
4
|
subject(:presenter) { described_class.new(request_context, document, field_config, options) }
|
5
5
|
|
6
|
-
let(:request_context) { double('View context', search_state: search_state, should_render_field?: true, blacklight_config: config) }
|
6
|
+
let(:request_context) { double('View context', params: { x: '1' }, search_state: search_state, should_render_field?: true, blacklight_config: config) }
|
7
7
|
let(:document) do
|
8
8
|
SolrDocument.new(id: 1,
|
9
9
|
'link_to_facet_true' => 'x',
|
@@ -18,6 +18,14 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
|
|
18
18
|
|
19
19
|
let(:field_config) { config.index_fields[field_name] }
|
20
20
|
let(:field_name) { 'asdf' }
|
21
|
+
|
22
|
+
let(:custom_step) do
|
23
|
+
Class.new(Blacklight::Rendering::AbstractStep) do
|
24
|
+
def render
|
25
|
+
'Static step'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
21
29
|
let(:config) do
|
22
30
|
Blacklight::Configuration.new.configure do |config|
|
23
31
|
config.add_index_field 'qwer'
|
@@ -29,8 +37,10 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
|
|
29
37
|
config.add_index_field 'explicit_accessor', accessor: :solr_doc_accessor
|
30
38
|
config.add_index_field 'explicit_array_accessor', accessor: [:solr_doc_accessor, :some_method]
|
31
39
|
config.add_index_field 'explicit_values', values: ->(_config, _doc) { ['some-value'] }
|
40
|
+
config.add_index_field 'explicit_values_with_context', values: ->(_config, _doc, view_context) { [view_context.params[:x]] }
|
32
41
|
config.add_index_field 'alias', field: 'qwer'
|
33
42
|
config.add_index_field 'with_default', default: 'value'
|
43
|
+
config.add_index_field 'with_steps', steps: [custom_step]
|
34
44
|
end
|
35
45
|
end
|
36
46
|
|
@@ -154,10 +164,19 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
|
|
154
164
|
let(:field_name) { 'explicit_values' }
|
155
165
|
|
156
166
|
it 'calls the accessors on the return of the preceeding' do
|
167
|
+
allow(Deprecation).to receive(:warn)
|
157
168
|
expect(subject).to eq 'some-value'
|
158
169
|
end
|
159
170
|
end
|
160
171
|
|
172
|
+
context 'when the values lambda is provided and accepts the view contexts' do
|
173
|
+
let(:field_name) { 'explicit_values_with_context' }
|
174
|
+
|
175
|
+
it 'calls the accessors on the return of the preceeding' do
|
176
|
+
expect(subject).to eq '1'
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
161
180
|
context 'when the field is an alias' do
|
162
181
|
let(:field_name) { 'alias' }
|
163
182
|
|
@@ -170,6 +189,12 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
|
|
170
189
|
it { is_expected.to eq 'value' }
|
171
190
|
end
|
172
191
|
|
192
|
+
context 'with steps' do
|
193
|
+
let(:field_name) { 'with_steps' }
|
194
|
+
|
195
|
+
it { is_expected.to eq 'Static step' }
|
196
|
+
end
|
197
|
+
|
173
198
|
context 'for a field with the helper_method option' do
|
174
199
|
let(:field_name) { 'field_with_helper' }
|
175
200
|
let(:field_config) { config.add_facet_field 'field_with_helper', helper_method: 'render_field_with_helper' }
|
@@ -212,7 +237,7 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
|
|
212
237
|
describe '#render_field?' do
|
213
238
|
subject { presenter.render_field? }
|
214
239
|
|
215
|
-
let(:field_config) { double('field config', if: true, unless: false) }
|
240
|
+
let(:field_config) { double('field config', if: true, unless: false, except_operations: nil) }
|
216
241
|
|
217
242
|
before do
|
218
243
|
allow(presenter).to receive_messages(document_has_value?: true)
|
@@ -235,7 +260,7 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
|
|
235
260
|
subject { presenter.any? }
|
236
261
|
|
237
262
|
context 'when the document has the field value' do
|
238
|
-
let(:field_config) { double(field: 'asdf', highlight: false, accessor: nil, default: nil, values: nil) }
|
263
|
+
let(:field_config) { double(field: 'asdf', highlight: false, accessor: nil, default: nil, values: nil, except_operations: nil) }
|
239
264
|
|
240
265
|
before do
|
241
266
|
allow(document).to receive(:fetch).with('asdf', nil).and_return(['value'])
|
@@ -245,7 +270,7 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
|
|
245
270
|
end
|
246
271
|
|
247
272
|
context 'when the document has a highlight field value' do
|
248
|
-
let(:field_config) { double(field: 'asdf', highlight: true) }
|
273
|
+
let(:field_config) { double(field: 'asdf', highlight: true, except_operations: nil) }
|
249
274
|
|
250
275
|
before do
|
251
276
|
allow(document).to receive(:has_highlight_field?).with('asdf').and_return(true)
|
@@ -256,7 +281,7 @@ RSpec.describe Blacklight::FieldPresenter, api: true do
|
|
256
281
|
end
|
257
282
|
|
258
283
|
context 'when the field is a model accessor' do
|
259
|
-
let(:field_config) { double(field: 'asdf', highlight: false, accessor: true) }
|
284
|
+
let(:field_config) { double(field: 'asdf', highlight: false, accessor: true, except_operations: nil) }
|
260
285
|
|
261
286
|
before do
|
262
287
|
allow(document).to receive(:send).with('asdf').and_return(['value'])
|
@@ -131,7 +131,7 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
131
131
|
expect(solr_response.docs).to have_at_least(1).result
|
132
132
|
end
|
133
133
|
# TODO: check that number of these results < number of results for all docs query
|
134
|
-
# BUT can't: num docs isn't total, it's the num docs in the single
|
134
|
+
# BUT can't: num docs isn't total, it's the num docs in the single Solr response (e.g. 10)
|
135
135
|
end
|
136
136
|
|
137
137
|
describe "for Query Without Results and No Facet" do
|
@@ -334,10 +334,6 @@ RSpec.describe Blacklight::SearchService, api: true do
|
|
334
334
|
it 'has the expected value in the id field' do
|
335
335
|
expect(@document.id).to eq doc_id
|
336
336
|
end
|
337
|
-
|
338
|
-
it 'has non-nil values for required fields set in initializer' do
|
339
|
-
expect(@document.fetch(blacklight_config.view_config(:show).display_type_field)).not_to be_nil
|
340
|
-
end
|
341
337
|
end
|
342
338
|
|
343
339
|
describe 'Get multiple documents By Id', integration: true do
|
@@ -9,8 +9,9 @@ RSpec.describe "catalog/constraints" do
|
|
9
9
|
|
10
10
|
it "renders nothing if no constraints are set" do
|
11
11
|
allow(view).to receive_messages(query_has_constraints?: false)
|
12
|
+
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
|
12
13
|
render partial: "catalog/constraints"
|
13
|
-
expect(rendered).to be_empty
|
14
|
+
expect(rendered.strip).to be_empty
|
14
15
|
end
|
15
16
|
|
16
17
|
it "renders a start over link" do
|
@@ -3,12 +3,14 @@
|
|
3
3
|
RSpec.describe 'catalog/_facet_index_navigation.html.erb', type: :view do
|
4
4
|
let(:pagination) { Blacklight::Solr::FacetPaginator.new([]) }
|
5
5
|
let(:facet) { Blacklight::Configuration::FacetField.new(index_range: '0'..'9') }
|
6
|
+
let(:display_facet) { double(items: [], offset: 0, prefix: '', sort: 'index') }
|
6
7
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
7
8
|
|
8
9
|
before do
|
9
|
-
assign(:
|
10
|
+
assign(:display_facet, display_facet)
|
10
11
|
assign(:facet, facet)
|
11
12
|
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
|
13
|
+
allow(view).to receive(:facet_limit_for).and_return(10)
|
12
14
|
controller.request.path_parameters[:action] = 'index'
|
13
15
|
end
|
14
16
|
|
@@ -27,7 +29,7 @@ RSpec.describe 'catalog/_facet_index_navigation.html.erb', type: :view do
|
|
27
29
|
end
|
28
30
|
|
29
31
|
context 'with a selected index' do
|
30
|
-
let(:
|
32
|
+
let(:display_facet) { double(items: [], offset: 0, prefix: '5', sort: 'index') }
|
31
33
|
|
32
34
|
it 'highlights the selected index' do
|
33
35
|
render
|