blacklight 7.15.2 → 7.18.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 +4 -0
- data/VERSION +1 -1
- data/app/components/blacklight/advanced_search_form_component.html.erb +9 -3
- data/app/components/blacklight/advanced_search_form_component.rb +48 -35
- data/app/components/blacklight/constraints_component.html.erb +19 -3
- data/app/components/blacklight/constraints_component.rb +5 -1
- data/app/components/blacklight/content_areas_shim.rb +12 -0
- data/app/components/blacklight/document/action_component.html.erb +1 -1
- data/app/components/blacklight/document/action_component.rb +6 -1
- data/app/components/blacklight/document/actions_component.html.erb +3 -5
- data/app/components/blacklight/document/actions_component.rb +16 -2
- data/app/components/blacklight/document/thumbnail_component.html.erb +3 -3
- data/app/components/blacklight/document/thumbnail_component.rb +11 -3
- data/app/components/blacklight/document_component.html.erb +4 -7
- data/app/components/blacklight/document_component.rb +73 -73
- data/app/components/blacklight/document_metadata_component.html.erb +2 -2
- data/app/components/blacklight/document_metadata_component.rb +13 -2
- data/app/components/blacklight/document_title_component.html.erb +17 -0
- data/app/components/blacklight/document_title_component.rb +59 -0
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +2 -2
- data/app/components/blacklight/facet_field_component.rb +4 -1
- data/app/components/blacklight/facet_field_list_component.html.erb +2 -2
- data/app/components/blacklight/facet_field_no_layout_component.rb +4 -1
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_layout_component.html.erb +3 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +26 -1
- data/app/components/blacklight/response/view_type_button_component.html.erb +4 -0
- data/app/components/blacklight/response/view_type_button_component.rb +38 -0
- data/app/components/blacklight/response/view_type_component.html.erb +2 -5
- data/app/components/blacklight/response/view_type_component.rb +9 -13
- data/app/components/blacklight/search_bar_component.rb +9 -2
- data/app/components/blacklight/system/dropdown_component.html.erb +4 -7
- data/app/components/blacklight/system/dropdown_component.rb +24 -0
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/system/flash_message_component.rb +7 -1
- data/app/components/blacklight/system/modal_component.rb +7 -1
- data/app/controllers/concerns/blacklight/catalog.rb +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -4
- data/app/helpers/blacklight/catalog_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/presenters/blacklight/document_presenter.rb +8 -4
- data/app/services/blacklight/search_service.rb +1 -1
- data/app/views/bookmarks/_tools.html.erb +1 -1
- data/app/views/catalog/_citation.html.erb +1 -1
- data/app/views/catalog/_document.html.erb +2 -2
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_show_main_content.html.erb +3 -3
- data/app/views/catalog/email.html.erb +2 -2
- data/app/views/catalog/email_success.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +3 -3
- data/app/views/catalog/sms.html.erb +2 -2
- data/app/views/catalog/sms_success.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.de.yml +2 -2
- data/lib/blacklight/configuration.rb +50 -5
- data/lib/blacklight/configuration/view_config.rb +18 -5
- data/lib/blacklight/engine.rb +3 -1
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +23 -7
- data/lib/blacklight/open_struct_with_hash_access.rb +4 -0
- data/lib/blacklight/search_builder.rb +1 -0
- data/lib/blacklight/search_state.rb +2 -2
- data/lib/blacklight/solr/facet_paginator.rb +2 -0
- data/lib/blacklight/solr/request.rb +31 -0
- data/lib/blacklight/solr/response.rb +2 -16
- data/lib/blacklight/solr/response/facets.rb +76 -22
- data/lib/blacklight/solr/response/params.rb +104 -0
- data/lib/blacklight/solr/search_builder_behavior.rb +64 -28
- data/lib/generators/blacklight/assets_generator.rb +6 -2
- data/lib/generators/blacklight/user_generator.rb +1 -1
- data/spec/components/blacklight/document_component_spec.rb +3 -3
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +6 -7
- data/spec/helpers/blacklight_helper_spec.rb +2 -2
- data/spec/helpers/catalog_helper_spec.rb +1 -1
- data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +12 -0
- data/spec/models/blacklight/configuration_spec.rb +64 -0
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +4 -0
- data/spec/models/blacklight/solr/request_spec.rb +62 -29
- data/spec/models/blacklight/solr/response/facets_spec.rb +109 -0
- data/spec/models/blacklight/solr/response_spec.rb +10 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +58 -0
- data/spec/services/blacklight/search_service_spec.rb +1 -1
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +8 -9
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- metadata +10 -4
@@ -68,11 +68,15 @@ module Blacklight
|
|
68
68
|
private
|
69
69
|
|
70
70
|
def turbolinks?
|
71
|
-
@turbolinks ||=
|
71
|
+
@turbolinks ||= application_js.include?('turbolinks')
|
72
72
|
end
|
73
73
|
|
74
74
|
def has_blacklight_assets?
|
75
|
-
|
75
|
+
application_js.include?('blacklight/blacklight')
|
76
|
+
end
|
77
|
+
|
78
|
+
def application_js
|
79
|
+
IO.read(File.expand_path("app/assets/javascripts/application.js", destination_root))
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
@@ -47,7 +47,7 @@ module Blacklight
|
|
47
47
|
# Add Blacklight to the user model
|
48
48
|
def inject_blacklight_user_behavior
|
49
49
|
file_path = "app/models/#{model_name.underscore}.rb"
|
50
|
-
if File.exist?(file_path)
|
50
|
+
if File.exist?(File.expand_path(file_path, destination_root))
|
51
51
|
inject_into_class file_path, model_name.classify do
|
52
52
|
"\n # Connects this user object to Blacklights Bookmarks." \
|
53
53
|
"\n include Blacklight::User\n"
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::DocumentComponent, type: :component do
|
6
|
-
subject(:component) { described_class.new(document: document, **attr) }
|
6
|
+
subject(:component) { described_class.new(document: document, presenter: view_context.document_presenter(document), **attr) }
|
7
7
|
|
8
8
|
let(:attr) { {} }
|
9
9
|
let(:view_context) { controller.view_context }
|
@@ -47,7 +47,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
47
47
|
component.with(:embed, 'Embed')
|
48
48
|
component.with(:metadata, 'Metadata')
|
49
49
|
component.with(:thumbnail, 'Thumbnail')
|
50
|
-
component.with(:actions
|
50
|
+
component.with(:actions) { 'Actions' }
|
51
51
|
|
52
52
|
expect(rendered).to have_content 'Title'
|
53
53
|
expect(rendered).to have_content 'Embed'
|
@@ -65,7 +65,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
65
65
|
|
66
66
|
context 'with a provided body' do
|
67
67
|
it 'opts-out of normal component content' do
|
68
|
-
component.with(:body
|
68
|
+
component.with(:body) { 'Body content' }
|
69
69
|
|
70
70
|
expect(rendered).to have_content 'Body content'
|
71
71
|
expect(rendered).not_to have_selector 'header'
|
@@ -33,9 +33,8 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
33
33
|
|
34
34
|
describe "#default_document_index_view_type" do
|
35
35
|
it "uses the first view with default set to true" do
|
36
|
-
blacklight_config.view.a
|
37
|
-
blacklight_config.view.b
|
38
|
-
blacklight_config.view.b.default = true
|
36
|
+
blacklight_config.view.a({})
|
37
|
+
blacklight_config.view.b(default: true)
|
39
38
|
expect(helper.default_document_index_view_type).to eq :b
|
40
39
|
end
|
41
40
|
|
@@ -48,8 +47,8 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
48
47
|
describe "#document_index_views" do
|
49
48
|
before do
|
50
49
|
blacklight_config.view.abc = false
|
51
|
-
blacklight_config.view.def
|
52
|
-
blacklight_config.view.xyz
|
50
|
+
blacklight_config.view.def(if: false)
|
51
|
+
blacklight_config.view.xyz(unless: true)
|
53
52
|
end
|
54
53
|
|
55
54
|
it "filters views using :if/:unless configuration" do
|
@@ -62,8 +61,8 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
62
61
|
|
63
62
|
describe '#document_index_view_controls' do
|
64
63
|
before do
|
65
|
-
blacklight_config.view.a
|
66
|
-
blacklight_config.view.b
|
64
|
+
blacklight_config.view.a({})
|
65
|
+
blacklight_config.view.b(display_control: false)
|
67
66
|
end
|
68
67
|
|
69
68
|
it "filters index views to those set to display controls" do
|
@@ -127,7 +127,7 @@ RSpec.describe BlacklightHelper do
|
|
127
127
|
|
128
128
|
it "renders view type specific actions" do
|
129
129
|
allow(helper).to receive(:document_index_view_type).and_return(:custom)
|
130
|
-
config.view.custom
|
130
|
+
config.view.custom(document_actions: [])
|
131
131
|
expect(helper.render_index_doc_actions(document)).to be_blank
|
132
132
|
end
|
133
133
|
end
|
@@ -315,7 +315,7 @@ RSpec.describe BlacklightHelper do
|
|
315
315
|
end
|
316
316
|
|
317
317
|
it "ignores missing templates" do
|
318
|
-
blacklight_config.view.view_type
|
318
|
+
blacklight_config.view.view_type(partials: %w[index_header a b])
|
319
319
|
|
320
320
|
response = helper.render_document_index_with_view :view_type, [obj1, obj1]
|
321
321
|
expect(response).to have_selector "div#documents"
|
@@ -323,7 +323,7 @@ RSpec.describe CatalogHelper do
|
|
323
323
|
|
324
324
|
it "supports view-specific field configuration" do
|
325
325
|
allow(helper).to receive(:document_index_view_type).and_return(:some_view_type)
|
326
|
-
blacklight_config.view.some_view_type
|
326
|
+
blacklight_config.view.some_view_type(display_type_field: :other_type)
|
327
327
|
doc = { other_type: "document" }
|
328
328
|
expect(helper.render_document_class(doc)).to eq "blacklight-document"
|
329
329
|
end
|
@@ -9,7 +9,7 @@ RSpec.describe Blacklight::Configuration::ViewConfig do
|
|
9
9
|
describe '#display_label' do
|
10
10
|
it "looks up the label to display for the given document and field" do
|
11
11
|
allow(I18n).to receive(:t).with(:"blacklight.search.view_title.my_view", default: [:"blacklight.search.view.my_view", label, nil, "My view"]).and_return('x')
|
12
|
-
expect(subject.display_label
|
12
|
+
expect(subject.display_label).to eq 'x'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -123,6 +123,18 @@ RSpec.describe Blacklight::OpenStructWithHashAccess do
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
describe '#reverse_merge' do
|
127
|
+
before do
|
128
|
+
@h = described_class.new
|
129
|
+
@h[:a] = 1
|
130
|
+
@h[:b] = 2
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'reverse merges the object with the hash, preserving the object class' do
|
134
|
+
expect(@h.reverse_merge(b: 3, c: 4)).to have_attributes a: 1, b: 2, c: 4
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
126
138
|
describe "#to_json" do
|
127
139
|
subject { described_class.new a: 1, b: 2 }
|
128
140
|
|
@@ -557,4 +557,68 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
557
557
|
expect(config.facet_paginator_class).to eq Blacklight::Solr::FacetPaginator
|
558
558
|
end
|
559
559
|
end
|
560
|
+
|
561
|
+
describe '#view_config' do
|
562
|
+
before do
|
563
|
+
config.index.title_field = 'title_tsim'
|
564
|
+
end
|
565
|
+
|
566
|
+
context 'with a view that does not exist' do
|
567
|
+
it 'defaults to the index config' do
|
568
|
+
expect(config.view_config('this-doesnt-exist')).to have_attributes config.index.to_h
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
context 'with the :show view' do
|
573
|
+
it 'includes the show config' do
|
574
|
+
expect(config.view_config(:show)).to have_attributes config.show.to_h
|
575
|
+
end
|
576
|
+
|
577
|
+
it 'uses the show document presenter' do
|
578
|
+
expect(config.view_config(:show)).to have_attributes document_presenter_class: Blacklight::ShowPresenter
|
579
|
+
end
|
580
|
+
|
581
|
+
it 'includes index config defaults' do
|
582
|
+
expect(config.view_config(:show)).to have_attributes title_field: 'title_tsim'
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
context 'with just an action name' do
|
587
|
+
it 'includes the action config' do
|
588
|
+
expect(config.view_config(action_name: :show)).to have_attributes config.show.to_h
|
589
|
+
end
|
590
|
+
|
591
|
+
it 'includes the default action mapping configuration' do
|
592
|
+
config.action_mapping.default.whatever = :some_value
|
593
|
+
|
594
|
+
expect(config.view_config(action_name: :show)).to have_attributes whatever: :some_value
|
595
|
+
end
|
596
|
+
|
597
|
+
it 'includes the action-specific mappings' do
|
598
|
+
config.action_mapping.foo.document_presenter_class = Blacklight::DocumentPresenter
|
599
|
+
|
600
|
+
expect(config.view_config(action_name: :foo)).to have_attributes config.action_mapping.foo.to_h
|
601
|
+
end
|
602
|
+
|
603
|
+
it 'allows the action mapping to specific a parent configuration with some more defaults' do
|
604
|
+
config.action_mapping.foo.parent_config = :bar
|
605
|
+
config.action_mapping.bar.whatever = :bar_value
|
606
|
+
|
607
|
+
expect(config.view_config(action_name: :foo)).to have_attributes whatever: :bar_value
|
608
|
+
end
|
609
|
+
|
610
|
+
context 'with the :citation action' do
|
611
|
+
it 'also includes the show config' do
|
612
|
+
expect(config.view_config(action_name: :citation)).to have_attributes config.show.to_h
|
613
|
+
end
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
context 'with a view' do
|
618
|
+
it 'includes the configuration-level view parameters' do
|
619
|
+
expect(config.view_config(:atom)).to have_attributes config.index.to_h.except(:partials)
|
620
|
+
expect(config.view_config(:atom)).to have_attributes partials: [:document]
|
621
|
+
end
|
622
|
+
end
|
623
|
+
end
|
560
624
|
end
|
@@ -20,5 +20,9 @@ RSpec.describe Blacklight::Solr::FacetPaginator, api: true do
|
|
20
20
|
it 'defaults to "index" if no limit is given' do
|
21
21
|
expect(described_class.new([]).sort).to eq 'index'
|
22
22
|
end
|
23
|
+
|
24
|
+
it 'handles json facet api-style parameter sorts' do
|
25
|
+
expect(described_class.new([], sort: { count: :desc }).sort).to eq 'count'
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
@@ -1,36 +1,69 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Blacklight::Solr::Request, api: true do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
context 'with some solr parameter keys' do
|
5
|
+
before do
|
6
|
+
subject[:qt] = 'hey'
|
7
|
+
subject[:fq] = ["what's up.", "dood"]
|
8
|
+
subject['q'] = "what's"
|
9
|
+
subject[:wt] = "going"
|
10
|
+
subject[:start] = "on"
|
11
|
+
subject[:rows] = "Man"
|
12
|
+
subject['hl'] = "I"
|
13
|
+
subject['hl.fl'] = "wish"
|
14
|
+
subject['group'] = "I"
|
15
|
+
subject['defType'] = "had"
|
16
|
+
subject['spellcheck'] = "a"
|
17
|
+
subject['spellcheck.q'] = "fleece"
|
18
|
+
subject['f.title_facet.facet.limit'] = "vest"
|
19
|
+
subject['facet.field'] = []
|
20
|
+
end
|
21
|
+
|
22
|
+
it "accepts valid parameters" do
|
23
|
+
expect(subject.to_hash).to eq("defType" => "had",
|
24
|
+
"f.title_facet.facet.limit" => "vest",
|
25
|
+
"fq" => ["what's up.", "dood"],
|
26
|
+
"group" => "I",
|
27
|
+
"hl" => "I",
|
28
|
+
"hl.fl" => "wish",
|
29
|
+
"q" => "what's",
|
30
|
+
"qt" => "hey",
|
31
|
+
"rows" => "Man",
|
32
|
+
"spellcheck" => "a",
|
33
|
+
"spellcheck.q" => "fleece",
|
34
|
+
"start" => "on",
|
35
|
+
"wt" => "going")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#append_query' do
|
40
|
+
it 'populates the q parameter' do
|
41
|
+
subject.append_query 'this is my query'
|
42
|
+
expect(subject['q']).to eq 'this is my query'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'handles multiple queries by converting it to a boolean query' do
|
46
|
+
subject.append_query 'this is my query'
|
47
|
+
subject.append_query 'another:query'
|
48
|
+
expect(subject).not_to have_key 'q'
|
49
|
+
expect(subject.dig('json', 'query', 'bool', 'must')).to match_array ['this is my query', 'another:query']
|
50
|
+
end
|
19
51
|
end
|
20
52
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
53
|
+
describe '#append_boolean_query' do
|
54
|
+
it 'populates the boolean query with the queries' do
|
55
|
+
subject.append_boolean_query :must, 'required'
|
56
|
+
subject.append_boolean_query :should, 'optional'
|
57
|
+
subject.append_boolean_query :should, 'also optional'
|
58
|
+
|
59
|
+
expect(subject.dig('json', 'query', 'bool')).to include should: ['optional', 'also optional'], must: ['required']
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'converts existing q parameters to a boolean query' do
|
63
|
+
subject['q'] = 'some query'
|
64
|
+
subject.append_boolean_query :must, 'also required'
|
65
|
+
|
66
|
+
expect(subject.dig('json', 'query', 'bool', 'must')).to match_array ['some query', 'also required']
|
67
|
+
end
|
35
68
|
end
|
36
69
|
end
|
@@ -160,6 +160,12 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
|
|
160
160
|
expect(missing.label).to eq "[Missing]"
|
161
161
|
expect(missing.fq).to eq "-some_field:[* TO *]"
|
162
162
|
end
|
163
|
+
|
164
|
+
it 'extracts the missing field data to a separate facet field attribute' do
|
165
|
+
missing = subject.aggregations["some_field"].missing
|
166
|
+
|
167
|
+
expect(missing).to have_attributes(label: '[Missing]', hits: 2)
|
168
|
+
end
|
163
169
|
end
|
164
170
|
|
165
171
|
describe "query facets" do
|
@@ -278,4 +284,107 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
|
|
278
284
|
expect(field.items.first.items.first.fq).to eq('field_a' => 'a')
|
279
285
|
end
|
280
286
|
end
|
287
|
+
|
288
|
+
describe 'json facets' do
|
289
|
+
subject { Blacklight::Solr::Response.new(response, {}, blacklight_config: blacklight_config) }
|
290
|
+
|
291
|
+
let(:response) do
|
292
|
+
{
|
293
|
+
facets: {
|
294
|
+
"count": 32,
|
295
|
+
"categories": {
|
296
|
+
"buckets": [
|
297
|
+
{
|
298
|
+
"val": "electronics",
|
299
|
+
"count": 12,
|
300
|
+
"max_price": 60
|
301
|
+
},
|
302
|
+
{
|
303
|
+
"val": "currency",
|
304
|
+
"count": 4
|
305
|
+
},
|
306
|
+
{
|
307
|
+
"val": "memory",
|
308
|
+
"count": 3
|
309
|
+
}
|
310
|
+
]
|
311
|
+
}
|
312
|
+
}
|
313
|
+
}
|
314
|
+
end
|
315
|
+
let(:facet_config) do
|
316
|
+
Blacklight::Configuration::FacetField.new(key: 'categories', json: true, query: false)
|
317
|
+
end
|
318
|
+
|
319
|
+
let(:blacklight_config) { double(facet_fields: { 'categories' => facet_config }) }
|
320
|
+
let(:field) { subject.aggregations['categories'] }
|
321
|
+
|
322
|
+
it 'has access to the original response data' do
|
323
|
+
expect(field.data).to include 'buckets'
|
324
|
+
end
|
325
|
+
|
326
|
+
it 'converts buckets into facet items' do
|
327
|
+
expect(field.items.length).to eq 3
|
328
|
+
end
|
329
|
+
|
330
|
+
context 'with nested buckets' do
|
331
|
+
let(:response) do
|
332
|
+
{
|
333
|
+
facets: {
|
334
|
+
"categories": {
|
335
|
+
"buckets": [
|
336
|
+
{
|
337
|
+
"val": "electronics",
|
338
|
+
"count": 12,
|
339
|
+
"top_manufacturer": {
|
340
|
+
"buckets": [{
|
341
|
+
"val": "corsair",
|
342
|
+
"count": 3
|
343
|
+
}]
|
344
|
+
}
|
345
|
+
},
|
346
|
+
{
|
347
|
+
"val": "currency",
|
348
|
+
"count": 4,
|
349
|
+
"top_manufacturer": {
|
350
|
+
"buckets": [{
|
351
|
+
"val": "boa",
|
352
|
+
"count": 1
|
353
|
+
}]
|
354
|
+
}
|
355
|
+
}
|
356
|
+
]
|
357
|
+
}
|
358
|
+
}
|
359
|
+
}
|
360
|
+
end
|
361
|
+
|
362
|
+
it 'converts nested buckets into pivot facets' do
|
363
|
+
expect(field.items.first).to have_attributes hits: 12
|
364
|
+
expect(field.items.first.items.first).to have_attributes field: 'top_manufacturer', value: 'corsair', hits: 3, fq: { "categories" => "electronics" }
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
context 'with missing values' do
|
369
|
+
let(:response) do
|
370
|
+
{
|
371
|
+
facets: {
|
372
|
+
"categories": {
|
373
|
+
"missing" => { "count" => 13 },
|
374
|
+
"buckets" => [{ "val" => "India", "count" => 2 }, { "val" => "Iran", "count" => 2 }]
|
375
|
+
}
|
376
|
+
}
|
377
|
+
}
|
378
|
+
end
|
379
|
+
|
380
|
+
it 'converts "missing" facet data into a missing facet item' do
|
381
|
+
expect(field.items.length).to eq 2
|
382
|
+
expect(field.missing).to have_attributes(hits: 13)
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
it 'exposes any extra query function results' do
|
387
|
+
expect(field.items.first.data).to include 'max_price' => 60
|
388
|
+
end
|
389
|
+
end
|
281
390
|
end
|