blacklight 5.15.0 → 5.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile +17 -8
- data/VERSION +1 -1
- data/{lib → app/controllers/concerns}/blacklight/base.rb +1 -1
- data/{lib → app/controllers/concerns}/blacklight/bookmarks.rb +0 -0
- data/{lib → app/controllers/concerns}/blacklight/catalog.rb +6 -7
- data/{lib → app/controllers/concerns}/blacklight/controller.rb +6 -0
- data/{lib/blacklight/catalog/component_configuration.rb → app/controllers/concerns/blacklight/default_component_configuration.rb} +5 -2
- data/{lib → app/controllers/concerns}/blacklight/facet.rb +0 -0
- data/{lib → app/controllers/concerns}/blacklight/request_builders.rb +0 -0
- data/{lib/blacklight/catalog → app/controllers/concerns/blacklight}/search_context.rb +1 -2
- data/{lib → app/controllers/concerns}/blacklight/search_fields.rb +0 -6
- data/{lib → app/controllers/concerns}/blacklight/search_helper.rb +4 -4
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/catalog_helper_behavior.rb +3 -3
- data/app/helpers/blacklight/facets_helper_behavior.rb +4 -5
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
- data/{lib → app/models}/blacklight/abstract_repository.rb +0 -0
- data/{lib → app/models}/blacklight/configuration.rb +2 -2
- data/{lib → app/models}/blacklight/configuration/facet_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/fields.rb +1 -1
- data/{lib → app/models}/blacklight/configuration/search_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/solr_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/sort_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/tool_config.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/view_config.rb +0 -0
- data/{lib → app/models}/blacklight/facet_paginator.rb +0 -0
- data/{lib → app/models}/blacklight/search_builder.rb +1 -1
- data/{lib → app/models}/blacklight/solr/facet_paginator.rb +0 -0
- data/{lib/blacklight/solr_repository.rb → app/models/blacklight/solr/repository.rb} +3 -3
- data/{lib → app/models}/blacklight/solr/request.rb +0 -0
- data/{lib/blacklight/solr_response.rb → app/models/blacklight/solr/response.rb} +8 -8
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/facets.rb +8 -8
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/group.rb +2 -2
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/group_response.rb +3 -3
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/more_like_this.rb +1 -1
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/pagination_methods.rb +1 -1
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/response.rb +1 -1
- data/{lib/blacklight/solr_response → app/models/blacklight/solr/response}/spelling.rb +1 -1
- data/{lib → app/models}/blacklight/solr/search_builder.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/configurable.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document.rb +7 -10
- data/{lib → app/models/concerns}/blacklight/document/active_model_shim.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/cache_key.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/dublin_core.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/email.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/export.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/extensions.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/schema_org.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/semantic_fields.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/document/sms.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document.rb +3 -8
- data/{lib → app/models/concerns}/blacklight/solr/document/dublin_core.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/email.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/export.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/extensions.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/more_like_this.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/schema_org.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/document/sms.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/solr/search_builder_behavior.rb +6 -1
- data/{lib → app/models/concerns}/blacklight/token_based_user.rb +0 -0
- data/{lib → app/models/concerns}/blacklight/user.rb +0 -0
- data/{lib → app/presenters}/blacklight/document_presenter.rb +0 -0
- data/app/views/catalog/_paginate_compact.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/lib/blacklight.rb +7 -32
- data/lib/blacklight/engine.rb +6 -0
- data/lib/blacklight/solr.rb +5 -7
- data/lib/railties/blacklight.rake +3 -1
- data/spec/{lib → controllers}/blacklight/catalog/component_configuration_spec.rb +7 -2
- data/spec/{lib → controllers}/blacklight/facet_spec.rb +0 -0
- data/spec/{lib → controllers}/blacklight/search_fields_spec.rb +2 -2
- data/spec/{lib → controllers}/blacklight/search_helper_spec.rb +3 -3
- data/spec/controllers/catalog_controller_spec.rb +34 -32
- data/spec/controllers/saved_searches_controller_spec.rb +1 -1
- data/spec/helpers/facets_helper_spec.rb +2 -2
- data/spec/helpers/search_history_constraints_helper_spec.rb +23 -3
- data/spec/lib/{utils_spec.rb → blacklight/utils_spec.rb} +0 -0
- data/spec/lib/blacklight_spec.rb +0 -1
- data/spec/{lib → models}/blacklight/configurable_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/configuration_spec.rb +1 -1
- data/spec/{lib → models}/blacklight/document/cache_key_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/document/dublin_core_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/document/email_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/document/sms_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/document_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/facet_paginator_spec.rb +7 -7
- data/spec/{lib → models}/blacklight/search_builder_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/solr/document/more_like_this_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/solr/document_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/solr/facet_paginator_spec.rb +1 -1
- data/spec/{lib/blacklight/solr_repository_spec.rb → models/blacklight/solr/repository_spec.rb} +13 -13
- data/spec/{lib → models}/blacklight/solr/request_spec.rb +0 -0
- data/spec/{lib/blacklight/solr_response → models/blacklight/solr/response}/facets_spec.rb +12 -12
- data/spec/{lib/blacklight/solr_response → models/blacklight/solr/response}/group_response_spec.rb +3 -3
- data/spec/{lib/blacklight/solr_response → models/blacklight/solr/response}/group_spec.rb +2 -2
- data/spec/{lib/blacklight/solr_response_spec.rb → models/blacklight/solr/response_spec.rb} +21 -21
- data/spec/{lib → models}/blacklight/solr/search_builder_spec.rb +0 -0
- data/spec/{lib → models}/blacklight/user_spec.rb +0 -0
- data/spec/{lib → presenters}/document_presenter_spec.rb +0 -0
- data/spec/views/catalog/_facets.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_index_default.erb_spec.rb +10 -10
- data/spec/views/catalog/_show_default.erb_spec.rb +10 -10
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +30 -33
- metadata +116 -118
- data/spec/support/include_text.rb +0 -20
@@ -224,8 +224,8 @@ describe FacetsHelper do
|
|
224
224
|
end
|
225
225
|
|
226
226
|
describe "render_facet_limit_list" do
|
227
|
-
let(:f1) { Blacklight::
|
228
|
-
let(:f2) { Blacklight::
|
227
|
+
let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }
|
228
|
+
let(:f2) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '65', value: 'Musical Score') }
|
229
229
|
let(:paginator) { Blacklight::Solr::FacetPaginator.new([f1, f2], limit: 10) }
|
230
230
|
subject { helper.render_facet_limit_list(paginator, 'type_solr_field') }
|
231
231
|
before do
|
@@ -8,6 +8,10 @@ describe SearchHistoryConstraintsHelper do
|
|
8
8
|
|
9
9
|
config.add_facet_field 'some_facet', :label => 'Some'
|
10
10
|
config.add_facet_field 'other_facet', :label => 'Other'
|
11
|
+
config.add_facet_field 'i18n_facet'
|
12
|
+
|
13
|
+
I18n.backend.store_translations(:en, blacklight: {search: {fields: {facet: {i18n_facet: 'English facet label'}}}})
|
14
|
+
I18n.backend.store_translations(:de, blacklight: {search: {fields: {facet: {i18n_facet: 'German facet label'}}}})
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
@@ -75,11 +79,27 @@ describe SearchHistoryConstraintsHelper do
|
|
75
79
|
|
76
80
|
it "should render a constraint for a selected facet not in the config" do
|
77
81
|
response = helper.render_search_to_s_filters(:f => {"undefined_facet" => ["value1", "value2"]})
|
78
|
-
expect(response).to eq("<span class=\"constraint\"><span class=\"filterName\"
|
82
|
+
expect(response).to eq("<span class=\"constraint\"><span class=\"filterName\">#{'undefined_facet'.humanize}:</span><span class=\"filterValues\"><span class=\"filterValue\">value1</span><span class=\"filterSeparator\"> and </span><span class=\"filterValue\">value2</span></span></span>")
|
79
83
|
end
|
80
|
-
end
|
81
84
|
|
82
|
-
|
85
|
+
context 'with I18n translations for selected facet' do
|
86
|
+
before do
|
87
|
+
@orig_locale = I18n.locale
|
88
|
+
end
|
89
|
+
|
90
|
+
after do
|
91
|
+
I18n.locale = @orig_locale
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should render the correct I18n label for a selected facet with I18n translations' do
|
95
|
+
{en: 'English facet label', de: 'German facet label'}.each do |locale, label|
|
96
|
+
I18n.locale = locale
|
97
|
+
response = helper.render_search_to_s_filters(f: {'i18n_facet' => ['value1', 'value2']})
|
98
|
+
expect(response).to include(label)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
83
103
|
end
|
84
104
|
|
85
105
|
end
|
File without changes
|
data/spec/lib/blacklight_spec.rb
CHANGED
File without changes
|
@@ -119,7 +119,7 @@ describe "Blacklight::Configuration" do
|
|
119
119
|
it "should return default classes" do
|
120
120
|
config_copy = @config.inheritable_copy
|
121
121
|
|
122
|
-
expect(config_copy.response_model).to eq Blacklight::
|
122
|
+
expect(config_copy.response_model).to eq Blacklight::Solr::Response
|
123
123
|
expect(config_copy.document_model).to eq SolrDocument
|
124
124
|
end
|
125
125
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,13 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Blacklight::FacetPaginator do
|
4
4
|
|
5
|
-
let(:f1) { Blacklight::
|
6
|
-
let(:f2) { Blacklight::
|
7
|
-
let(:f3) { Blacklight::
|
8
|
-
let(:f4) { Blacklight::
|
9
|
-
let(:f5) { Blacklight::
|
10
|
-
let(:f6) { Blacklight::
|
11
|
-
let(:f7) { Blacklight::
|
5
|
+
let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }
|
6
|
+
let(:f2) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '65', value: 'Musical Score') }
|
7
|
+
let(:f3) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '58', value: 'Serial') }
|
8
|
+
let(:f4) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '48', value: 'Musical Recording') }
|
9
|
+
let(:f5) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '37', value: 'Microform') }
|
10
|
+
let(:f6) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '27', value: 'Thesis') }
|
11
|
+
let(:f7) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '0') }
|
12
12
|
let(:seven_facet_values) { [f1, f2, f3, f4, f5, f6, f7] }
|
13
13
|
let(:six_facet_values) { [f1, f2, f3, f4, f5, f6] }
|
14
14
|
let(:limit) { 6 }
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Blacklight::Solr::FacetPaginator do
|
4
|
-
let(:f1) { Blacklight::
|
4
|
+
let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }
|
5
5
|
describe "#as_json" do
|
6
6
|
subject { described_class.new([f1], offset: 0, limit: nil).as_json }
|
7
7
|
it "should be well structured" do
|
data/spec/{lib/blacklight/solr_repository_spec.rb → models/blacklight/solr/repository_spec.rb}
RENAMED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Blacklight::
|
3
|
+
describe Blacklight::Solr::Repository do
|
4
4
|
|
5
5
|
let :blacklight_config do
|
6
6
|
CatalogController.blacklight_config.deep_copy
|
7
7
|
end
|
8
8
|
|
9
9
|
subject do
|
10
|
-
Blacklight::
|
10
|
+
Blacklight::Solr::Repository.new blacklight_config
|
11
11
|
end
|
12
12
|
|
13
13
|
let :mock_response do
|
@@ -23,38 +23,38 @@ describe Blacklight::SolrRepository do
|
|
23
23
|
blacklight_config.document_solr_path = 'abc'
|
24
24
|
blacklight_config.solr_path = 'xyz'
|
25
25
|
allow(subject.connection).to receive(:send_and_receive).with('abc', anything).and_return(mock_response)
|
26
|
-
expect(subject.find("123")).to be_a_kind_of Blacklight::
|
26
|
+
expect(subject.find("123")).to be_a_kind_of Blacklight::Solr::Response
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should use the default solr path" do
|
30
30
|
blacklight_config.solr_path = 'xyz'
|
31
31
|
allow(subject.connection).to receive(:send_and_receive).with('xyz', anything).and_return(mock_response)
|
32
|
-
expect(subject.find("123")).to be_a_kind_of Blacklight::
|
32
|
+
expect(subject.find("123")).to be_a_kind_of Blacklight::Solr::Response
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should use a default :qt param" do
|
36
36
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'document'})).and_return(mock_response)
|
37
|
-
expect(subject.find("123", {})).to be_a_kind_of Blacklight::
|
37
|
+
expect(subject.find("123", {})).to be_a_kind_of Blacklight::Solr::Response
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should use the provided :qt param" do
|
41
41
|
blacklight_config.document_solr_request_handler = 'xyz'
|
42
42
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'abc'})).and_return(mock_response)
|
43
|
-
expect(subject.find("123", {qt: 'abc'})).to be_a_kind_of Blacklight::
|
43
|
+
expect(subject.find("123", {qt: 'abc'})).to be_a_kind_of Blacklight::Solr::Response
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should use the :qt parameter from the default_document_solr_params" do
|
47
47
|
blacklight_config.default_document_solr_params[:qt] = 'abc'
|
48
48
|
blacklight_config.document_solr_request_handler = 'xyz'
|
49
49
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'abc'})).and_return(mock_response)
|
50
|
-
expect(subject.find("123")).to be_a_kind_of Blacklight::
|
50
|
+
expect(subject.find("123")).to be_a_kind_of Blacklight::Solr::Response
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should preserve the class of the incoming params" do
|
54
54
|
doc_params = HashWithIndifferentAccess.new
|
55
55
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
56
56
|
response = subject.find("123", doc_params)
|
57
|
-
expect(response).to be_a_kind_of Blacklight::
|
57
|
+
expect(response).to be_a_kind_of Blacklight::Solr::Response
|
58
58
|
expect(response.params).to be_a_kind_of HashWithIndifferentAccess
|
59
59
|
end
|
60
60
|
end
|
@@ -63,24 +63,24 @@ describe Blacklight::SolrRepository do
|
|
63
63
|
it "should use the search-specific solr path" do
|
64
64
|
blacklight_config.solr_path = 'xyz'
|
65
65
|
allow(subject.connection).to receive(:send_and_receive).with('xyz', anything).and_return(mock_response)
|
66
|
-
expect(subject.search({})).to be_a_kind_of Blacklight::
|
66
|
+
expect(subject.search({})).to be_a_kind_of Blacklight::Solr::Response
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should use the default solr path" do
|
70
70
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
71
|
-
expect(subject.search({})).to be_a_kind_of Blacklight::
|
71
|
+
expect(subject.search({})).to be_a_kind_of Blacklight::Solr::Response
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should use a default :qt param" do
|
75
75
|
blacklight_config.qt = 'xyz'
|
76
76
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'xyz'})).and_return(mock_response)
|
77
|
-
expect(subject.search({})).to be_a_kind_of Blacklight::
|
77
|
+
expect(subject.search({})).to be_a_kind_of Blacklight::Solr::Response
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should use the provided :qt param" do
|
81
81
|
blacklight_config.qt = 'xyz'
|
82
82
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'abc'})).and_return(mock_response)
|
83
|
-
expect(subject.search({qt: 'abc'})).to be_a_kind_of Blacklight::
|
83
|
+
expect(subject.search({qt: 'abc'})).to be_a_kind_of Blacklight::Solr::Response
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should preserve the class of the incoming params" do
|
@@ -89,7 +89,7 @@ describe Blacklight::SolrRepository do
|
|
89
89
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
90
90
|
|
91
91
|
response = subject.search(search_params)
|
92
|
-
expect(response).to be_a_kind_of Blacklight::
|
92
|
+
expect(response).to be_a_kind_of Blacklight::Solr::Response
|
93
93
|
expect(response.params).to be_a_kind_of HashWithIndifferentAccess
|
94
94
|
end
|
95
95
|
end
|
File without changes
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Blacklight::
|
4
|
-
describe Blacklight::
|
3
|
+
describe Blacklight::Solr::Response::Facets do
|
4
|
+
describe Blacklight::Solr::Response::Facets::FacetField do
|
5
5
|
|
6
6
|
describe "A field with default options" do
|
7
|
-
subject { Blacklight::
|
7
|
+
subject { Blacklight::Solr::Response::Facets::FacetField.new "my_field", [] }
|
8
8
|
|
9
9
|
its(:name) { should eq "my_field" }
|
10
10
|
its(:limit) { should eq 100 }
|
@@ -13,7 +13,7 @@ describe Blacklight::SolrResponse::Facets do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "A field with additional options" do
|
16
|
-
subject { Blacklight::
|
16
|
+
subject { Blacklight::Solr::Response::Facets::FacetField.new "my_field", [], limit: 15, sort: 'alpha', offset: 23 }
|
17
17
|
|
18
18
|
its(:name) { should eq "my_field" }
|
19
19
|
its(:limit) { should eq 15 }
|
@@ -23,7 +23,7 @@ describe Blacklight::SolrResponse::Facets do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#facets" do
|
26
|
-
subject { Blacklight::
|
26
|
+
subject { Blacklight::Solr::Response.new({}, {}) }
|
27
27
|
let(:aggregations) { { x: 1, y: 2 } }
|
28
28
|
it "should get the aggregation values" do
|
29
29
|
allow(subject).to receive(:aggregations).and_return aggregations
|
@@ -35,7 +35,7 @@ describe Blacklight::SolrResponse::Facets do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "#facet_by_field_name" do
|
38
|
-
subject { Blacklight::
|
38
|
+
subject { Blacklight::Solr::Response.new({}, {}) }
|
39
39
|
let(:aggregations) { { x: double } }
|
40
40
|
|
41
41
|
it "should pull facets out of the aggregations" do
|
@@ -51,7 +51,7 @@ describe Blacklight::SolrResponse::Facets do
|
|
51
51
|
let(:facet_field) { ['my_field', []] }
|
52
52
|
let(:response_header) { { params: request_params }}
|
53
53
|
let(:request_params) { Hash.new }
|
54
|
-
subject { Blacklight::
|
54
|
+
subject { Blacklight::Solr::Response.new({responseHeader: response_header, facet_counts: { facet_fields: [facet_field] }}.with_indifferent_access, request_params) }
|
55
55
|
|
56
56
|
describe "#limit" do
|
57
57
|
it "should extract a field-specific limit value" do
|
@@ -121,7 +121,7 @@ describe Blacklight::SolrResponse::Facets do
|
|
121
121
|
}
|
122
122
|
end
|
123
123
|
|
124
|
-
subject { Blacklight::
|
124
|
+
subject { Blacklight::Solr::Response.new(response, {}) }
|
125
125
|
|
126
126
|
it "should mark the facet.missing field with a human-readable label and fq" do
|
127
127
|
missing = subject.aggregations["some_field"].items.find { |i| i.value.nil? }
|
@@ -158,12 +158,12 @@ describe Blacklight::SolrResponse::Facets do
|
|
158
158
|
}
|
159
159
|
end
|
160
160
|
|
161
|
-
subject { Blacklight::
|
161
|
+
subject { Blacklight::Solr::Response.new(response, {}, blacklight_config: blacklight_config) }
|
162
162
|
|
163
163
|
it"should convert the query facets into a double RSolr FacetField" do
|
164
164
|
field = subject.aggregations['my_query_facet_field']
|
165
165
|
|
166
|
-
expect(field).to be_a_kind_of Blacklight::
|
166
|
+
expect(field).to be_a_kind_of Blacklight::Solr::Response::Facets::FacetField
|
167
167
|
|
168
168
|
expect(field.name).to eq'my_query_facet_field'
|
169
169
|
expect(field.items.size).to eq 2
|
@@ -200,12 +200,12 @@ describe Blacklight::SolrResponse::Facets do
|
|
200
200
|
}
|
201
201
|
end
|
202
202
|
|
203
|
-
subject { Blacklight::
|
203
|
+
subject { Blacklight::Solr::Response.new(response, {}, blacklight_config: blacklight_config) }
|
204
204
|
|
205
205
|
it "should convert the pivot facet into a double RSolr FacetField" do
|
206
206
|
field = subject.aggregations['my_pivot_facet_field']
|
207
207
|
|
208
|
-
expect(field).to be_a_kind_of Blacklight::
|
208
|
+
expect(field).to be_a_kind_of Blacklight::Solr::Response::Facets::FacetField
|
209
209
|
|
210
210
|
expect(field.name).to eq 'my_pivot_facet_field'
|
211
211
|
|
data/spec/{lib/blacklight/solr_response → models/blacklight/solr/response}/group_response_spec.rb
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Blacklight::
|
3
|
+
describe Blacklight::Solr::Response::GroupResponse do
|
4
4
|
|
5
5
|
let(:response) do
|
6
6
|
create_response(sample_response)
|
@@ -16,7 +16,7 @@ describe Blacklight::SolrResponse::GroupResponse do
|
|
16
16
|
|
17
17
|
expect(group.groups).to have(2).items
|
18
18
|
group.groups.each do |group|
|
19
|
-
expect(group).to be_a Blacklight::
|
19
|
+
expect(group).to be_a Blacklight::Solr::Response::Group
|
20
20
|
end
|
21
21
|
end
|
22
22
|
it "should include a list of SolrDocuments" do
|
@@ -61,7 +61,7 @@ describe Blacklight::SolrResponse::GroupResponse do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def create_response(response, params = {})
|
64
|
-
Blacklight::
|
64
|
+
Blacklight::Solr::Response.new(response, params)
|
65
65
|
end
|
66
66
|
|
67
67
|
def sample_response
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Blacklight::
|
3
|
+
describe Blacklight::Solr::Response::Group do
|
4
4
|
|
5
5
|
let(:response) do
|
6
6
|
create_response(sample_response)
|
@@ -53,7 +53,7 @@ describe Blacklight::SolrResponse::Group do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def create_response(response, params = {})
|
56
|
-
Blacklight::
|
56
|
+
Blacklight::Solr::Response.new(response, params)
|
57
57
|
end
|
58
58
|
|
59
59
|
def sample_response
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Blacklight::
|
3
|
+
describe Blacklight::Solr::Response do
|
4
4
|
|
5
5
|
def create_response
|
6
6
|
raw_response = eval(mock_query_response)
|
7
|
-
Blacklight::
|
7
|
+
Blacklight::Solr::Response.new(raw_response, raw_response['params'])
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:r) { create_response }
|
@@ -24,7 +24,7 @@ describe Blacklight::SolrResponse do
|
|
24
24
|
expect(r.docs).to have(11).docs
|
25
25
|
expect(r.params[:echoParams]).to eq 'EXPLICIT'
|
26
26
|
|
27
|
-
expect(r).to be_a(Blacklight::
|
27
|
+
expect(r).to be_a(Blacklight::Solr::Response::Facets)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should provide facet helpers' do
|
@@ -72,20 +72,20 @@ describe Blacklight::SolrResponse do
|
|
72
72
|
|
73
73
|
describe "FacetItem" do
|
74
74
|
it "should work with a field,value tuple" do
|
75
|
-
item = Blacklight::
|
75
|
+
item = Blacklight::Solr::Response::Facets::FacetItem.new('value', 15)
|
76
76
|
expect(item.value).to eq 'value'
|
77
77
|
expect(item.hits).to eq 15
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should work with a field,value + hash triple" do
|
81
|
-
item = Blacklight::
|
81
|
+
item = Blacklight::Solr::Response::Facets::FacetItem.new('value', 15, :a => 1, :value => 'ignored')
|
82
82
|
expect(item.value).to eq 'value'
|
83
83
|
expect(item.hits).to eq 15
|
84
84
|
expect(item.a).to eq 1
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should work like an openstruct" do
|
88
|
-
item = Blacklight::
|
88
|
+
item = Blacklight::Solr::Response::Facets::FacetItem.new(:value => 'value', :hits => 15)
|
89
89
|
|
90
90
|
expect(item.hits).to eq 15
|
91
91
|
expect(item.value).to eq 'value'
|
@@ -93,12 +93,12 @@ describe Blacklight::SolrResponse do
|
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should provide a label accessor" do
|
96
|
-
item = Blacklight::
|
96
|
+
item = Blacklight::Solr::Response::Facets::FacetItem.new('value', :hits => 15)
|
97
97
|
expect(item.label).to eq 'value'
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should use a provided label" do
|
101
|
-
item = Blacklight::
|
101
|
+
item = Blacklight::Solr::Response::Facets::FacetItem.new('value', 15, :label => 'custom label')
|
102
102
|
expect(item.label).to eq 'custom label'
|
103
103
|
|
104
104
|
end
|
@@ -114,13 +114,13 @@ describe Blacklight::SolrResponse do
|
|
114
114
|
it 'should provide the responseHeader params' do
|
115
115
|
raw_response = eval(mock_query_response)
|
116
116
|
raw_response['responseHeader']['params']['test'] = :test
|
117
|
-
r = Blacklight::
|
117
|
+
r = Blacklight::Solr::Response.new(raw_response, raw_response['params'])
|
118
118
|
expect(r.params['test']).to eq :test
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'should provide the solr-returned params and "rows" should be 11' do
|
122
122
|
raw_response = eval(mock_query_response)
|
123
|
-
r = Blacklight::
|
123
|
+
r = Blacklight::Solr::Response.new(raw_response, {})
|
124
124
|
expect(r.params[:rows].to_s).to eq '11'
|
125
125
|
expect(r.params[:sort]).to eq 'title_sort asc, pub_date_sort desc'
|
126
126
|
end
|
@@ -128,42 +128,42 @@ describe Blacklight::SolrResponse do
|
|
128
128
|
it 'should provide the ruby request params if responseHeader["params"] does not exist' do
|
129
129
|
raw_response = eval(mock_query_response)
|
130
130
|
raw_response.delete 'responseHeader'
|
131
|
-
r = Blacklight::
|
131
|
+
r = Blacklight::Solr::Response.new(raw_response, :rows => 999, :sort => 'score desc, pub_date_sort desc, title_sort asc')
|
132
132
|
expect(r.params[:rows].to_s).to eq '999'
|
133
133
|
expect(r.params[:sort]).to eq 'score desc, pub_date_sort desc, title_sort asc'
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'should provide spelling suggestions for regular spellcheck results' do
|
137
137
|
raw_response = eval(mock_response_with_spellcheck)
|
138
|
-
r = Blacklight::
|
138
|
+
r = Blacklight::Solr::Response.new(raw_response, {})
|
139
139
|
expect(r.spelling.words).to include("dell")
|
140
140
|
expect(r.spelling.words).to include("ultrasharp")
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'should provide spelling suggestions for extended spellcheck results' do
|
144
144
|
raw_response = eval(mock_response_with_spellcheck_extended)
|
145
|
-
r = Blacklight::
|
145
|
+
r = Blacklight::Solr::Response.new(raw_response, {})
|
146
146
|
expect(r.spelling.words).to include("dell")
|
147
147
|
expect(r.spelling.words).to include("ultrasharp")
|
148
148
|
end
|
149
149
|
|
150
150
|
it 'should provide no spelling suggestions when extended results and suggestion frequency is the same as original query frequency' do
|
151
151
|
raw_response = eval(mock_response_with_spellcheck_same_frequency)
|
152
|
-
r = Blacklight::
|
152
|
+
r = Blacklight::Solr::Response.new(raw_response, {})
|
153
153
|
expect(r.spelling.words).to eq []
|
154
154
|
end
|
155
155
|
|
156
156
|
context "pre solr 5 spellcheck collation syntax" do
|
157
157
|
it 'should provide spelling suggestions for a regular spellcheck results with a collation' do
|
158
158
|
raw_response = eval(mock_response_with_spellcheck_collation)
|
159
|
-
r = Blacklight::
|
159
|
+
r = Blacklight::Solr::Response.new(raw_response, {})
|
160
160
|
expect(r.spelling.words).to include("dell")
|
161
161
|
expect(r.spelling.words).to include("ultrasharp")
|
162
162
|
end
|
163
163
|
|
164
164
|
it 'should provide spelling suggestion collation' do
|
165
165
|
raw_response = eval(mock_response_with_spellcheck_collation)
|
166
|
-
r = Blacklight::
|
166
|
+
r = Blacklight::Solr::Response.new(raw_response, {})
|
167
167
|
expect(r.spelling.collation).to eq 'dell ultrasharp'
|
168
168
|
end
|
169
169
|
end
|
@@ -171,33 +171,33 @@ describe Blacklight::SolrResponse do
|
|
171
171
|
context "solr 5 spellcheck collation syntax" do
|
172
172
|
it 'should provide spelling suggestions for a regular spellcheck results with a collation' do
|
173
173
|
raw_response = eval(mock_response_with_spellcheck_collation_solr5)
|
174
|
-
r = Blacklight::
|
174
|
+
r = Blacklight::Solr::Response.new(raw_response, {})
|
175
175
|
expect(r.spelling.words).to include("dell")
|
176
176
|
expect(r.spelling.words).to include("ultrasharp")
|
177
177
|
end
|
178
178
|
|
179
179
|
it 'should provide spelling suggestion collation' do
|
180
180
|
raw_response = eval(mock_response_with_spellcheck_collation_solr5)
|
181
|
-
r = Blacklight::
|
181
|
+
r = Blacklight::Solr::Response.new(raw_response, {})
|
182
182
|
expect(r.spelling.collation).to eq 'dell ultrasharp'
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should provide MoreLikeThis suggestions" do
|
187
187
|
raw_response = eval(mock_response_with_more_like_this)
|
188
|
-
r = Blacklight::
|
188
|
+
r = Blacklight::Solr::Response.new(raw_response, {})
|
189
189
|
expect(r.more_like(double(:id => '79930185'))).to have(2).items
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should be empty when the response has no results" do
|
193
|
-
r = Blacklight::
|
193
|
+
r = Blacklight::Solr::Response.new({}, {})
|
194
194
|
allow(r).to receive_messages(:total => 0)
|
195
195
|
expect(r).to be_empty
|
196
196
|
end
|
197
197
|
|
198
198
|
describe "#export_formats" do
|
199
199
|
it "should collect the unique export formats for the current response" do
|
200
|
-
r = Blacklight::
|
200
|
+
r = Blacklight::Solr::Response.new({}, {})
|
201
201
|
allow(r).to receive_messages(documents: [double(:export_formats => { a: 1, b: 2}), double(:export_formats => { b: 1, c: 2})])
|
202
202
|
expect(r.export_formats).to include :a, :b
|
203
203
|
end
|