blacklight 5.0.0.pre1 → 5.0.0.pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -4
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_bookmark.css.scss +4 -0
- data/app/assets/stylesheets/blacklight/_catalog.css.scss +9 -13
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +15 -9
- data/app/helpers/blacklight/catalog_helper_behavior.rb +8 -25
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
- data/app/views/bookmarks/index.html.erb +1 -1
- data/app/views/catalog/_did_you_mean.html.erb +1 -1
- data/app/views/catalog/_document.html.erb +4 -10
- data/app/views/catalog/{_document_header.html.erb → _index_header_default.html.erb} +6 -3
- data/app/views/catalog/_paginate_compact.html.erb +5 -0
- data/app/views/catalog/_show_header_default.html.erb +2 -0
- data/app/views/catalog/index.html.erb +1 -1
- data/app/views/catalog/show.html.erb +4 -10
- data/lib/blacklight.rb +0 -1
- data/lib/blacklight/configuration.rb +2 -2
- data/lib/blacklight/controller.rb +0 -1
- data/lib/blacklight/solr/document.rb +2 -0
- data/lib/blacklight/solr/document/schema_org.rb +7 -0
- data/lib/blacklight/solr_response.rb +4 -0
- data/lib/blacklight/user.rb +0 -6
- data/spec/controllers/application_controller_spec.rb +1 -2
- data/spec/controllers/bookmarks_controller_spec.rb +8 -9
- data/spec/controllers/catalog_controller_spec.rb +72 -73
- data/spec/controllers/saved_searches_controller_spec.rb +1 -2
- data/spec/controllers/search_history_controller_spec.rb +9 -10
- data/spec/features/search_pagination_spec.rb +1 -0
- data/spec/features/search_results_spec.rb +1 -0
- data/spec/features/search_spec.rb +1 -0
- data/spec/helpers/blacklight_helper_spec.rb +103 -93
- data/spec/helpers/catalog_helper_spec.rb +34 -21
- data/spec/helpers/facets_helper_spec.rb +41 -41
- data/spec/helpers/hash_as_hidden_fields_spec.rb +8 -9
- data/spec/helpers/render_constraints_helper_spec.rb +3 -3
- data/spec/helpers/search_history_constraints_helper_spec.rb +13 -14
- data/spec/lib/{blacklight_configurable_spec.rb → blacklight/configurable_spec.rb} +12 -14
- data/spec/lib/{blacklight_configuration_spec.rb → blacklight/configuration_spec.rb} +67 -69
- data/spec/lib/{facet_paginator_spec.rb → blacklight/facet_paginator_spec.rb} +13 -16
- data/spec/lib/{search_fields_spec.rb → blacklight/search_fields_spec.rb} +14 -15
- data/spec/lib/{blacklight_solr_document_dublin_core_spec.rb → blacklight/solr/document/dublin_core_spec.rb} +7 -8
- data/spec/lib/{blacklight_email_spec.rb → blacklight/solr/document/email_spec.rb} +5 -6
- data/spec/lib/{blacklight_solr_document_more_like_this_spec.rb → blacklight/solr/document/more_like_this_spec.rb} +5 -5
- data/spec/lib/{blacklight_sms_spec.rb → blacklight/solr/document/sms_spec.rb} +5 -6
- data/spec/lib/{blacklight_solr_document_spec.rb → blacklight/solr/document_spec.rb} +37 -39
- data/spec/lib/{solr_helper_spec.rb → blacklight/solr_helper_spec.rb} +183 -183
- data/spec/lib/{blacklight_solr_response_spec.rb → blacklight/solr_response_spec.rb} +20 -16
- data/spec/lib/{blacklight_user_spec.rb → blacklight/user_spec.rb} +3 -4
- data/spec/lib/blacklight_spec.rb +6 -7
- data/spec/lib/tasks/blacklight_task_spec.rb +2 -3
- data/spec/lib/utils_spec.rb +13 -14
- data/spec/models/bookmark_spec.rb +4 -4
- data/spec/models/record_mailer_spec.rb +15 -15
- data/spec/models/search_spec.rb +7 -7
- data/spec/models/solr_document_spec.rb +4 -4
- data/spec/routing/catalog_routing_spec.rb +12 -12
- data/spec/spec_helper.rb +1 -3
- data/spec/test_app_templates/Gemfile.extra +1 -2
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +12 -13
- data/spec/views/catalog/_document.html.erb_spec.rb +19 -2
- data/spec/views/catalog/_document_list.html.erb_spec.rb +0 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +5 -5
- data/spec/views/catalog/_index_default.erb_spec.rb +10 -11
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +45 -0
- data/spec/views/catalog/_search_header.erb_spec.rb +0 -1
- data/spec/views/catalog/_show_default.erb_spec.rb +10 -11
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +26 -27
- data/spec/views/catalog/index.html.erb_spec.rb +1 -1
- data/spec/views/catalog/show.html.erb_spec.rb +56 -0
- data/tasks/blacklight.rake +1 -1
- metadata +65 -64
- data/lib/blacklight/legacy_controller_methods.rb +0 -26
- data/spec/rcov.opts +0 -3
- data/spec/support/assert_difference.rb +0 -17
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe Blacklight::SearchFields do
|
5
4
|
|
@@ -26,12 +25,12 @@ describe Blacklight::SearchFields do
|
|
26
25
|
|
27
26
|
it "should return search field list with calculated :label when needed" do
|
28
27
|
@search_field_obj.search_field_list.each do |hash|
|
29
|
-
hash.label.
|
28
|
+
expect(hash.label).not_to be_blank
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
32
|
it "should fill in default qt where needed" do
|
34
|
-
@search_field_obj.search_field_def_for_key("all_fields").qt
|
33
|
+
expect(@search_field_obj.search_field_def_for_key("all_fields").qt).to eq @config.default_solr_params[:qt]
|
35
34
|
end
|
36
35
|
|
37
36
|
it "should return proper options_for_select arguments" do
|
@@ -42,30 +41,30 @@ describe Blacklight::SearchFields do
|
|
42
41
|
argument = select_arguments[index]
|
43
42
|
config_hash = @search_field_obj.search_field_list[index]
|
44
43
|
|
45
|
-
argument.
|
46
|
-
argument[0].
|
47
|
-
argument[1].
|
44
|
+
expect(argument).to have(2).items
|
45
|
+
expect(argument[0]).to eq config_hash.label
|
46
|
+
expect(argument[1]).to eq config_hash.key
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
50
|
it "should not include fields in select if :display_in_simple_search=>false" do
|
52
51
|
select_arguments = @search_field_obj.search_field_options_for_select
|
53
52
|
|
54
|
-
select_arguments.
|
53
|
+
expect(select_arguments).not_to include(["No Display", "no_display"])
|
55
54
|
end
|
56
55
|
|
57
56
|
|
58
57
|
|
59
58
|
it "should lookup field definitions by key" do
|
60
|
-
@search_field_obj.search_field_def_for_key("title").key.
|
59
|
+
expect(@search_field_obj.search_field_def_for_key("title").key).to eq "title"
|
61
60
|
end
|
62
61
|
|
63
62
|
it "should find label by key" do
|
64
|
-
@search_field_obj.label_for_search_field("title").
|
63
|
+
expect(@search_field_obj.label_for_search_field("title")).to eq "Title"
|
65
64
|
end
|
66
65
|
|
67
66
|
it "should supply default label for key not found" do
|
68
|
-
@search_field_obj.label_for_search_field("non_existent_key").
|
67
|
+
expect(@search_field_obj.label_for_search_field("non_existent_key")).to eq "Keyword"
|
69
68
|
end
|
70
69
|
|
71
70
|
describe "for unspecified :key" do
|
@@ -73,10 +72,10 @@ describe Blacklight::SearchFields do
|
|
73
72
|
@bad_config = MockConfig.new
|
74
73
|
end
|
75
74
|
it "should raise exception on #search_field_list" do
|
76
|
-
|
75
|
+
expect { @bad_config.stub(:blacklight_config).and_return(Blacklight::Configuration.new { |config|
|
77
76
|
config.add_search_field :label => 'All Fields', :qt => 'all_fields'
|
78
77
|
config.add_search_field 'title', :qt => 'title_search'
|
79
|
-
}) }.
|
78
|
+
}) }.to raise_error
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
@@ -85,11 +84,11 @@ describe Blacklight::SearchFields do
|
|
85
84
|
@bad_config = MockConfig.new
|
86
85
|
end
|
87
86
|
it "should raise on #search_field_list" do
|
88
|
-
|
87
|
+
expect { @bad_config.stub(:blacklight_config).and_return(Blacklight::Configuration.new { |config|
|
89
88
|
config.add_search_field 'my_key', :label => 'All Fields'
|
90
89
|
config.add_search_field 'my_key', :label => 'title'
|
91
90
|
|
92
|
-
}) }.
|
91
|
+
}) }.to raise_error
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe "Blacklight::Solr::Document::DublinCore" do
|
5
4
|
before(:all) do
|
@@ -16,27 +15,27 @@ describe "Blacklight::Solr::Document::DublinCore" do
|
|
16
15
|
|
17
16
|
it "should register all its export formats" do
|
18
17
|
document = @mock_class.new
|
19
|
-
Set.new(document.export_formats.keys).
|
18
|
+
expect(Set.new(document.export_formats.keys)).to be_superset(Set.new([:oai_dc_xml,:dc_xml, :xml]))
|
20
19
|
end
|
21
20
|
|
22
21
|
it "should export oai_dc with the proper namespaces" do
|
23
22
|
document = @mock_class.new
|
24
|
-
document.export_as_oai_dc_xml.
|
23
|
+
expect(document.export_as_oai_dc_xml).to match 'xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"'
|
25
24
|
|
26
25
|
end
|
27
26
|
|
28
27
|
it "should include 'dc:'-prefixed semantic fields" do
|
29
28
|
data = {'id'=>'123456','title_display'=>['654321'] }
|
30
29
|
document = @mock_class.new(data)
|
31
|
-
document.export_as_oai_dc_xml.
|
32
|
-
document.export_as_oai_dc_xml.
|
30
|
+
expect(document.export_as_oai_dc_xml).to match 'xmlns:dc="http://purl.org/dc/elements/1.1/"'
|
31
|
+
expect(document.export_as_oai_dc_xml).to match '<dc:title>654321</dc:title>'
|
33
32
|
end
|
34
33
|
|
35
34
|
it "should work with multi-value fields" do
|
36
35
|
data = {'id'=>'123456','title_display'=>['654321', '987'] }
|
37
36
|
document = @mock_class.new(data)
|
38
|
-
document.export_as_oai_dc_xml.
|
39
|
-
document.export_as_oai_dc_xml.
|
37
|
+
expect(document.export_as_oai_dc_xml).to match '<dc:title>654321</dc:title>'
|
38
|
+
expect(document.export_as_oai_dc_xml).to match '<dc:title>987</dc:title></oai_dc:dc>'
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe "Blacklight::Solr::Document::Email" do
|
5
4
|
before(:all) do
|
@@ -8,17 +7,17 @@ describe "Blacklight::Solr::Document::Email" do
|
|
8
7
|
it "should only return values that are available in the field semantics" do
|
9
8
|
doc = SolrDocument.new({:id=>"1234", :title_display=>"My Title"})
|
10
9
|
email_body = doc.to_email_text
|
11
|
-
email_body.
|
12
|
-
email_body.
|
10
|
+
expect(email_body).to match(/Title: My Title/)
|
11
|
+
expect(email_body).to_not match(/Author/)
|
13
12
|
end
|
14
13
|
it "should handle multi-values fields correctly" do
|
15
14
|
doc = SolrDocument.new({:id=>"1234", :title_display=>["My Title", "My Alt. Title"]})
|
16
15
|
email_body = doc.to_email_text
|
17
|
-
email_body.
|
16
|
+
expect(email_body).to match(/Title: My Title My Alt. Title/)
|
18
17
|
end
|
19
18
|
it "should return nil if there are no valid field semantics to build the email body from" do
|
20
19
|
doc = SolrDocument.new({:id=>"1234"})
|
21
|
-
doc.to_email_text.
|
20
|
+
expect(doc.to_email_text).to be_nil
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Blacklight::Solr::Document::MoreLikeThis do
|
4
4
|
before(:all) do
|
@@ -10,9 +10,9 @@ describe Blacklight::Solr::Document::MoreLikeThis do
|
|
10
10
|
it "should pluck the MoreLikeThis results from the Solr Response" do
|
11
11
|
mock_solr_response = double(:more_like => [{'id' => 'abc'}])
|
12
12
|
result = @mock_class.new({:id => '123'}, mock_solr_response).more_like_this
|
13
|
-
result.
|
14
|
-
result.first.
|
15
|
-
result.first.id.
|
16
|
-
result.first.solr_response.
|
13
|
+
expect(result).to have(1).item
|
14
|
+
expect(result.first).to be_a_kind_of(SolrDocument)
|
15
|
+
expect(result.first.id).to eq 'abc'
|
16
|
+
expect(result.first.solr_response).to eq mock_solr_response
|
17
17
|
end
|
18
18
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe "Blacklight::Solr::Document::Email" do
|
5
4
|
before(:all) do
|
@@ -8,17 +7,17 @@ describe "Blacklight::Solr::Document::Email" do
|
|
8
7
|
it "should only return values that are available in the field semantics" do
|
9
8
|
doc = SolrDocument.new({:id=>"1234", :title_display=>"My Title", :author_display=>"Joe Schmoe"})
|
10
9
|
sms_text = doc.to_sms_text
|
11
|
-
sms_text.
|
10
|
+
expect(sms_text).to match(/My Title by Joe Schmoe/)
|
12
11
|
end
|
13
12
|
it "should handle multi-values fields correctly and only take the first" do
|
14
13
|
doc = SolrDocument.new({:id=>"1234", :title_display=>["My Title", "My Alt. Title"]})
|
15
14
|
sms_text = doc.to_sms_text
|
16
|
-
sms_text.
|
17
|
-
sms_text.
|
15
|
+
expect(sms_text).to match(/My Title/)
|
16
|
+
expect(sms_text).to_not match(/My Alt\. Title/)
|
18
17
|
end
|
19
18
|
it "should return nil if there are no valid field semantics to build the email body from" do
|
20
19
|
doc = SolrDocument.new({:id=>"1234"})
|
21
|
-
doc.to_sms_text.
|
20
|
+
expect(doc.to_sms_text).to be_nil
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
|
-
require 'rubygems'
|
1
|
+
require 'spec_helper'
|
4
2
|
|
5
3
|
describe "Blacklight::Solr::Document" do
|
6
4
|
class MockDocument
|
@@ -23,13 +21,13 @@ describe "Blacklight::Solr::Document" do
|
|
23
21
|
it 'should create a doc with hashy methods' do
|
24
22
|
doc = SolrDocument.new({'id'=>'SP2514N','inStock'=>true,'manu'=>'Samsung Electronics Co. Ltd.','name'=>'Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133','popularity'=>6,'price'=>92.0,'sku'=>'SP2514N','timestamp'=>'2009-03-20T14:42:49.795Z','cat'=>['electronics','hard drive'],'spell'=>['Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133'],'features'=>['7200RPM, 8MB cache, IDE Ultra ATA-133','NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor']})
|
25
23
|
|
26
|
-
doc.has?(:cat, /^elec/).
|
27
|
-
doc.has?(:cat, 'elec').
|
28
|
-
doc.has?(:cat, 'electronics').
|
24
|
+
expect(doc.has?(:cat, /^elec/)).to eq true
|
25
|
+
expect(doc.has?(:cat, 'elec')).not_to eq true
|
26
|
+
expect(doc.has?(:cat, 'electronics')).to eq true
|
29
27
|
|
30
|
-
doc.get(:cat).
|
31
|
-
doc.get(:xyz).
|
32
|
-
doc.get(:xyz, :default=>'def').
|
28
|
+
expect(doc.get(:cat)).to eq 'electronics, hard drive'
|
29
|
+
expect(doc.get(:xyz)).to be_nil
|
30
|
+
expect(doc.get(:xyz, :default=>'def')).to eq 'def'
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
@@ -44,7 +42,7 @@ describe "Blacklight::Solr::Document" do
|
|
44
42
|
end
|
45
43
|
it "should use a configuration-defined document unique key" do
|
46
44
|
@document = MockDocument.new :id => 'asdf', :my_unique_key => '1234'
|
47
|
-
@document.id.
|
45
|
+
expect(@document.id).to eq '1234'
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
@@ -57,54 +55,54 @@ describe "Blacklight::Solr::Document" do
|
|
57
55
|
it "should let you register an extension" do
|
58
56
|
MockDocument.use_extension(MockExtension) { |doc| true }
|
59
57
|
|
60
|
-
MockDocument.registered_extensions.find {|a| a[:module_obj] == MockExtension}.
|
58
|
+
expect(MockDocument.registered_extensions.find {|a| a[:module_obj] == MockExtension}).not_to be_nil
|
61
59
|
end
|
62
60
|
it "should let you register an extension with a nil condition proc" do
|
63
61
|
MockDocument.use_extension(MockExtension) { |doc| true }
|
64
|
-
MockDocument.registered_extensions.find {|a| a[:module_obj] == MockExtension}.
|
62
|
+
expect(MockDocument.registered_extensions.find {|a| a[:module_obj] == MockExtension}).not_to be_nil
|
65
63
|
end
|
66
64
|
it "should apply an extension whose condition is met" do
|
67
65
|
MockDocument.use_extension(MockExtension) {|doc| true}
|
68
66
|
doc = MockDocument.new()
|
69
67
|
|
70
|
-
doc.methods.find {|name| name.to_s == "my_extension_method"}.
|
71
|
-
doc.my_extension_method.to_s.
|
68
|
+
expect(doc.methods.find {|name| name.to_s == "my_extension_method"}).not_to be_nil
|
69
|
+
expect(doc.my_extension_method.to_s).to eq "my_extension_results"
|
72
70
|
end
|
73
71
|
it "should apply an extension based on a Solr field" do
|
74
72
|
MockDocument.use_extension(MockExtension) {|doc| doc.key?(:required_key)}
|
75
73
|
|
76
74
|
with_extension = MockDocument.new(:required_key => "value")
|
77
|
-
with_extension.my_extension_method.to_s.
|
75
|
+
expect(with_extension.my_extension_method.to_s).to eq "my_extension_results"
|
78
76
|
|
79
77
|
without_extension = MockDocument.new(:other_key => "value")
|
80
|
-
without_extension.methods.find {|name| name.to_s == "my_extension_method"}.
|
78
|
+
expect(without_extension.methods.find {|name| name.to_s == "my_extension_method"}).to be_nil
|
81
79
|
|
82
80
|
end
|
83
81
|
it "should not apply an extension whose condition is not met" do
|
84
82
|
MockDocument.use_extension(MockExtension) {|doc| false}
|
85
83
|
doc = MockDocument.new()
|
86
84
|
|
87
|
-
doc.methods.find {|name| name.to_s == "my_extension_method"}.
|
85
|
+
expect(doc.methods.find {|name| name.to_s == "my_extension_method"}).to be_nil
|
88
86
|
end
|
89
87
|
it "should treat a nil condition as always applyable" do
|
90
88
|
MockDocument.use_extension(MockExtension)
|
91
89
|
|
92
90
|
doc = MockDocument.new()
|
93
91
|
|
94
|
-
doc.methods.find {|name | name.to_s =="my_extension_method"}.
|
95
|
-
doc.my_extension_method.
|
92
|
+
expect(doc.methods.find {|name | name.to_s =="my_extension_method"}).not_to be_nil
|
93
|
+
expect(doc.my_extension_method).to eq "my_extension_results"
|
96
94
|
end
|
97
95
|
it "should let last extension applied override earlier extensions" do
|
98
96
|
MockDocument.use_extension(MockExtension)
|
99
97
|
MockDocument.use_extension(MockSecondExtension)
|
100
98
|
|
101
|
-
MockDocument.new().my_extension_method.to_s.
|
99
|
+
expect(MockDocument.new().my_extension_method.to_s).to eq "override"
|
102
100
|
end
|
103
101
|
|
104
102
|
describe "extension_parameters class-level hash" do
|
105
103
|
it "should provide an extension_parameters hash at the class level" do
|
106
104
|
MockDocument.extension_parameters[:key] = "value"
|
107
|
-
MockDocument.extension_parameters[:key].
|
105
|
+
expect(MockDocument.extension_parameters[:key]).to eq "value"
|
108
106
|
end
|
109
107
|
|
110
108
|
it "extension_parameters should not be shared between classes" do
|
@@ -118,7 +116,7 @@ describe "Blacklight::Solr::Document" do
|
|
118
116
|
class_one.extension_parameters[:key] = "class_one_value"
|
119
117
|
class_two.extension_parameters[:key] = "class_two_value"
|
120
118
|
|
121
|
-
class_one.extension_parameters[:key].
|
119
|
+
expect(class_one.extension_parameters[:key]).to eq "class_one_value"
|
122
120
|
end
|
123
121
|
end
|
124
122
|
|
@@ -136,14 +134,14 @@ describe "Blacklight::Solr::Document" do
|
|
136
134
|
it "reports it's exportable formats properly" do
|
137
135
|
doc = MockDocument.new
|
138
136
|
doc.will_export_as(:marc, "application/marc" )
|
139
|
-
doc.export_formats.
|
140
|
-
doc.export_formats[:marc][:content_type].
|
137
|
+
expect(doc.export_formats).to have_key(:marc)
|
138
|
+
expect(doc.export_formats[:marc][:content_type]).to eq "application/marc"
|
141
139
|
end
|
142
140
|
|
143
141
|
it "looks up content-type from Mime::Type if not given in arg" do
|
144
142
|
doc = MockDocument.new
|
145
143
|
doc.will_export_as(:html)
|
146
|
-
doc.export_formats.
|
144
|
+
expect(doc.export_formats).to have_key(:html)
|
147
145
|
end
|
148
146
|
|
149
147
|
context "format not registered with Mime::Type" do
|
@@ -154,17 +152,17 @@ describe "Blacklight::Solr::Document" do
|
|
154
152
|
# registration in an after, sorry.
|
155
153
|
end
|
156
154
|
it "registers format" do
|
157
|
-
defined?("Mime::MOCK2").
|
155
|
+
expect(defined?("Mime::MOCK2")).to be_true
|
158
156
|
end
|
159
157
|
it "registers as alias only" do
|
160
|
-
Mime::Type.lookup("application/mock2").
|
158
|
+
expect(Mime::Type.lookup("application/mock2")).not_to equal Mime::Type.lookup_by_extension("mock2")
|
161
159
|
end
|
162
160
|
end
|
163
161
|
|
164
162
|
it "export_as(:format) by calling export_as_format" do
|
165
163
|
doc = MockDocument.new
|
166
164
|
doc.will_export_as(:marc, "application/marc")
|
167
|
-
doc.export_as(:marc).
|
165
|
+
expect(doc.export_as(:marc)).to eq "fake_marc"
|
168
166
|
end
|
169
167
|
end
|
170
168
|
|
@@ -183,17 +181,17 @@ describe "Blacklight::Solr::Document" do
|
|
183
181
|
end
|
184
182
|
|
185
183
|
it "should return complete dictionary based on config'd fields" do
|
186
|
-
@doc1.to_semantic_values.
|
184
|
+
expect(@doc1.to_semantic_values).to eq :title => ["doc1 title"], :something => ["val1", "val2"]
|
187
185
|
end
|
188
186
|
it "should return empty array for a key without a value" do
|
189
|
-
@doc1.to_semantic_values[:author].
|
190
|
-
@doc1.to_semantic_values[:nonexistent_token].
|
187
|
+
expect(@doc1.to_semantic_values[:author]).to be_empty
|
188
|
+
expect(@doc1.to_semantic_values[:nonexistent_token]).to be_empty
|
191
189
|
end
|
192
190
|
it "should return an array even for a single-value field" do
|
193
|
-
@doc1.to_semantic_values[:title].
|
191
|
+
expect(@doc1.to_semantic_values[:title]).to be_kind_of(Array)
|
194
192
|
end
|
195
193
|
it "should return complete array for a multi-value field" do
|
196
|
-
@doc1.to_semantic_values[:something].
|
194
|
+
expect(@doc1.to_semantic_values[:something]).to eq ["val1", "val2"]
|
197
195
|
end
|
198
196
|
|
199
197
|
end
|
@@ -207,27 +205,27 @@ describe "Blacklight::Solr::Document" do
|
|
207
205
|
|
208
206
|
describe "#has_highlight_field?" do
|
209
207
|
it "should be true if the highlight field is in the solr response" do
|
210
|
-
@document.
|
211
|
-
@document.
|
208
|
+
expect(@document).to have_highlight_field 'title_text'
|
209
|
+
expect(@document).to have_highlight_field :title_text
|
212
210
|
end
|
213
211
|
|
214
212
|
it "should be false if the highlight field isn't in the solr response" do
|
215
|
-
@document.
|
213
|
+
expect(@document).to_not have_highlight_field 'nonexisting_field'
|
216
214
|
end
|
217
215
|
end
|
218
216
|
|
219
217
|
describe "#highlight_field" do
|
220
218
|
it "should return a value" do
|
221
|
-
@document.highlight_field('title_text').
|
219
|
+
expect(@document.highlight_field('title_text')).to include('doc <em>1</em>')
|
222
220
|
end
|
223
221
|
|
224
222
|
|
225
223
|
it "should return a value that is html safe" do
|
226
|
-
@document.highlight_field('title_text').first.
|
224
|
+
expect(@document.highlight_field('title_text').first).to be_html_safe
|
227
225
|
end
|
228
226
|
|
229
227
|
it "should return nil when the field doesn't exist" do
|
230
|
-
@document.highlight_field('nonexisting_field').
|
228
|
+
expect(@document.highlight_field('nonexisting_field')).to be_nil
|
231
229
|
end
|
232
230
|
end
|
233
231
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
require
|
2
|
+
require 'spec_helper'
|
3
3
|
|
4
4
|
# check the methods that do solr requests. Note that we are not testing if
|
5
5
|
# solr gives "correct" responses, as that's out of scope (it's a part of
|
@@ -59,7 +59,7 @@ describe 'Blacklight::SolrHelper' do
|
|
59
59
|
self.solr_search_params_logic += [:add_foo_to_solr_params]
|
60
60
|
|
61
61
|
|
62
|
-
self.solr_search_params[:wt].
|
62
|
+
expect(self.solr_search_params[:wt]).to eq "TESTING"
|
63
63
|
end
|
64
64
|
|
65
65
|
|
@@ -71,23 +71,23 @@ describe 'Blacklight::SolrHelper' do
|
|
71
71
|
@produced_params = self.solr_search_params
|
72
72
|
end
|
73
73
|
it 'should not have a q param' do
|
74
|
-
@produced_params[:q].
|
75
|
-
@produced_params["spellcheck.q"].
|
74
|
+
expect(@produced_params[:q]).to be_nil
|
75
|
+
expect(@produced_params["spellcheck.q"]).to be_nil
|
76
76
|
end
|
77
77
|
it 'should have default rows' do
|
78
|
-
@produced_params[:rows].
|
78
|
+
expect(@produced_params[:rows]).to eq 10
|
79
79
|
end
|
80
80
|
it 'should have default facet fields' do
|
81
81
|
# remove local params from the facet.field
|
82
|
-
@produced_params[:"facet.field"].map { |x| x.gsub(/\{![^}]+\}/, '') }.
|
82
|
+
expect(@produced_params[:"facet.field"].map { |x| x.gsub(/\{![^}]+\}/, '') }).to eq blacklight_config.facet_fields_to_add_to_solr
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should have default qt" do
|
86
|
-
@produced_params[:qt].
|
86
|
+
expect(@produced_params[:qt]).to eq "search"
|
87
87
|
end
|
88
88
|
it "should have no fq" do
|
89
|
-
@produced_params[:phrase_filters].
|
90
|
-
@produced_params[:fq].
|
89
|
+
expect(@produced_params[:phrase_filters]).to be_blank
|
90
|
+
expect(@produced_params[:fq]).to be_blank
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -95,16 +95,16 @@ describe 'Blacklight::SolrHelper' do
|
|
95
95
|
describe "for an empty string search" do
|
96
96
|
it "should return empty string q in solr parameters" do
|
97
97
|
solr_params = solr_search_params(:q => "")
|
98
|
-
solr_params[:q].
|
99
|
-
solr_params["spellcheck.q"].
|
98
|
+
expect(solr_params[:q]).to eq ""
|
99
|
+
expect(solr_params["spellcheck.q"]).to eq ""
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
describe "for request params also passed in as argument" do
|
104
104
|
it "should only have one value for the key 'q' regardless if a symbol or string" do
|
105
105
|
solr_params = solr_search_params( :q => "some query", 'q' => 'another value' )
|
106
|
-
solr_params[:q].
|
107
|
-
solr_params['q'].
|
106
|
+
expect(solr_params[:q]).to eq 'some query'
|
107
|
+
expect(solr_params['q']).to eq 'some query'
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -114,11 +114,11 @@ describe 'Blacklight::SolrHelper' do
|
|
114
114
|
|
115
115
|
solr_params = solr_search_params(:f => @single_facet)
|
116
116
|
|
117
|
-
solr_params[:q].
|
118
|
-
solr_params["spellcheck.q"].
|
117
|
+
expect(solr_params[:q]).to be_blank
|
118
|
+
expect(solr_params["spellcheck.q"]).to be_blank
|
119
119
|
|
120
120
|
@single_facet.each_value do |value|
|
121
|
-
solr_params[:fq].
|
121
|
+
expect(solr_params[:fq]).to include("{!raw f=#{@single_facet.keys[0]}}#{value}")
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -131,7 +131,7 @@ describe 'Blacklight::SolrHelper' do
|
|
131
131
|
value_list ||= []
|
132
132
|
value_list = [value_list] unless value_list.respond_to? :each
|
133
133
|
value_list.each do |value|
|
134
|
-
solr_params[:fq].
|
134
|
+
expect(solr_params[:fq]).to include("{!raw f=#{facet_field}}#{value}" )
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -146,10 +146,10 @@ describe 'Blacklight::SolrHelper' do
|
|
146
146
|
value_list ||= []
|
147
147
|
value_list = [value_list] unless value_list.respond_to? :each
|
148
148
|
value_list.each do |value|
|
149
|
-
solr_params[:fq].
|
149
|
+
expect(solr_params[:fq]).to include("{!raw f=#{facet_field}}#{value}" )
|
150
150
|
end
|
151
151
|
end
|
152
|
-
solr_params[:q].
|
152
|
+
expect(solr_params[:q]).to eq @mult_word_query
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
@@ -160,48 +160,48 @@ describe 'Blacklight::SolrHelper' do
|
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should use the raw handler for strings" do
|
163
|
-
facet_value_to_fq_string("facet_name", "my value").
|
163
|
+
expect(facet_value_to_fq_string("facet_name", "my value")).to eq "{!raw f=facet_name}my value"
|
164
164
|
end
|
165
165
|
|
166
166
|
it "should pass booleans through" do
|
167
|
-
facet_value_to_fq_string("facet_name", true).
|
167
|
+
expect(facet_value_to_fq_string("facet_name", true)).to eq "facet_name:true"
|
168
168
|
end
|
169
169
|
|
170
170
|
it "should pass boolean-like strings through" do
|
171
|
-
facet_value_to_fq_string("facet_name", "true").
|
171
|
+
expect(facet_value_to_fq_string("facet_name", "true")).to eq "facet_name:true"
|
172
172
|
end
|
173
173
|
|
174
174
|
it "should pass integers through" do
|
175
|
-
facet_value_to_fq_string("facet_name", 1).
|
175
|
+
expect(facet_value_to_fq_string("facet_name", 1)).to eq "facet_name:1"
|
176
176
|
end
|
177
177
|
|
178
178
|
it "should pass integer-like strings through" do
|
179
|
-
facet_value_to_fq_string("facet_name", "1").
|
179
|
+
expect(facet_value_to_fq_string("facet_name", "1")).to eq "facet_name:1"
|
180
180
|
end
|
181
181
|
|
182
182
|
it "should pass floats through" do
|
183
|
-
facet_value_to_fq_string("facet_name", 1.11).
|
183
|
+
expect(facet_value_to_fq_string("facet_name", 1.11)).to eq "facet_name:1.11"
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should pass floats through" do
|
187
|
-
facet_value_to_fq_string("facet_name", "1.11").
|
187
|
+
expect(facet_value_to_fq_string("facet_name", "1.11")).to eq "facet_name:1.11"
|
188
188
|
end
|
189
189
|
|
190
190
|
it "should pass date-type fields through" do
|
191
191
|
blacklight_config.facet_fields.stub(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil))
|
192
192
|
|
193
|
-
facet_value_to_fq_string("facet_name", "2012-01-01").
|
193
|
+
expect(facet_value_to_fq_string("facet_name", "2012-01-01")).to eq "facet_name:2012-01-01"
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should handle range requests" do
|
197
|
-
facet_value_to_fq_string("facet_name", 1..5).
|
197
|
+
expect(facet_value_to_fq_string("facet_name", 1..5)).to eq "facet_name:[1 TO 5]"
|
198
198
|
end
|
199
199
|
|
200
200
|
it "should add tag local parameters" do
|
201
201
|
blacklight_config.facet_fields.stub(:[]).with('facet_name').and_return(double(:query => nil, :tag => 'asdf', :date => nil))
|
202
202
|
|
203
|
-
facet_value_to_fq_string("facet_name", true).
|
204
|
-
facet_value_to_fq_string("facet_name", "my value").
|
203
|
+
expect(facet_value_to_fq_string("facet_name", true)).to eq "{!tag=asdf}facet_name:true"
|
204
|
+
expect(facet_value_to_fq_string("facet_name", "my value")).to eq "{!raw f=facet_name tag=asdf}my value"
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
@@ -209,31 +209,31 @@ describe 'Blacklight::SolrHelper' do
|
|
209
209
|
let(:solr_params) { solr_search_params @subject_search_params }
|
210
210
|
|
211
211
|
it "should look up qt from field definition" do
|
212
|
-
solr_params[:qt].
|
212
|
+
expect(solr_params[:qt]).to eq "search"
|
213
213
|
end
|
214
214
|
it "should not include weird keys not in field definition" do
|
215
215
|
solr_params.to_hash.tap do |h|
|
216
|
-
h[:phrase_filters].
|
217
|
-
h[:fq].
|
218
|
-
h[:commit].
|
219
|
-
h[:action].
|
220
|
-
h[:controller].
|
216
|
+
expect(h[:phrase_filters]).to be_nil
|
217
|
+
expect(h[:fq]).to be_nil
|
218
|
+
expect(h[:commit]).to be_nil
|
219
|
+
expect(h[:action]).to be_nil
|
220
|
+
expect(h[:controller]).to be_nil
|
221
221
|
end
|
222
222
|
end
|
223
223
|
it "should include proper 'q', possibly with LocalParams" do
|
224
|
-
solr_params[:q].
|
224
|
+
expect(solr_params[:q]).to match(/(\{[^}]+\})?wome/)
|
225
225
|
end
|
226
226
|
it "should include proper 'q' when LocalParams are used" do
|
227
227
|
if solr_params[:q] =~ /\{[^}]+\}/
|
228
|
-
solr_params[:q].
|
228
|
+
expect(solr_params[:q]).to match(/\{[^}]+\}wome/)
|
229
229
|
end
|
230
230
|
end
|
231
231
|
it "should include spellcheck.q, without LocalParams" do
|
232
|
-
solr_params["spellcheck.q"].
|
232
|
+
expect(solr_params["spellcheck.q"]).to eq "wome"
|
233
233
|
end
|
234
234
|
|
235
235
|
it "should include spellcheck.dictionary from field def solr_parameters" do
|
236
|
-
solr_params[:"spellcheck.dictionary"].
|
236
|
+
expect(solr_params[:"spellcheck.dictionary"]).to eq "subject"
|
237
237
|
end
|
238
238
|
it "should add on :solr_local_parameters using Solr LocalParams style" do
|
239
239
|
params = solr_search_params( @subject_search_params )
|
@@ -242,8 +242,8 @@ describe 'Blacklight::SolrHelper' do
|
|
242
242
|
#the LocalParams are really there
|
243
243
|
params[:q] =~ /^\{!([^}]+)\}/
|
244
244
|
key_value_pairs = $1.split(" ")
|
245
|
-
key_value_pairs.
|
246
|
-
key_value_pairs.
|
245
|
+
expect(key_value_pairs).to include("pf=$subject_pf")
|
246
|
+
expect(key_value_pairs).to include("qf=$subject_qf")
|
247
247
|
end
|
248
248
|
end
|
249
249
|
|
@@ -253,7 +253,7 @@ describe 'Blacklight::SolrHelper' do
|
|
253
253
|
super.merge(:qt => "overridden")
|
254
254
|
end
|
255
255
|
|
256
|
-
solr_search_params[:qt].
|
256
|
+
expect(solr_search_params[:qt]).to eq "overridden"
|
257
257
|
end
|
258
258
|
end
|
259
259
|
|
@@ -263,7 +263,7 @@ describe 'Blacklight::SolrHelper' do
|
|
263
263
|
|
264
264
|
add_facet_fq_to_solr(solr_parameters, {})
|
265
265
|
|
266
|
-
solr_parameters[:fq].
|
266
|
+
expect(solr_parameters[:fq]).to be_a_kind_of Array
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
@@ -288,8 +288,8 @@ describe 'Blacklight::SolrHelper' do
|
|
288
288
|
|
289
289
|
expect(solr_parameters[:facet]).to be_true
|
290
290
|
|
291
|
-
solr_parameters[:'facet.field'].
|
292
|
-
solr_parameters[:'f.test_field.facet.sort'].
|
291
|
+
expect(solr_parameters[:'facet.field']).to include('test_field')
|
292
|
+
expect(solr_parameters[:'f.test_field.facet.sort']).to eq 'count'
|
293
293
|
end
|
294
294
|
|
295
295
|
it "should add facet exclusions" do
|
@@ -297,8 +297,8 @@ describe 'Blacklight::SolrHelper' do
|
|
297
297
|
|
298
298
|
add_facetting_to_solr(solr_parameters, {})
|
299
299
|
|
300
|
-
solr_parameters[:'facet.query'].
|
301
|
-
solr_parameters[:'facet.pivot'].
|
300
|
+
expect(solr_parameters[:'facet.query']).to include('{!ex=xyz}some:query')
|
301
|
+
expect(solr_parameters[:'facet.pivot']).to include('{!ex=xyz}a,b')
|
302
302
|
end
|
303
303
|
end
|
304
304
|
|
@@ -319,11 +319,11 @@ describe 'Blacklight::SolrHelper' do
|
|
319
319
|
it "should merge parameters from search_field definition" do
|
320
320
|
solr_params = solr_search_params
|
321
321
|
|
322
|
-
solr_params[:qf].
|
323
|
-
solr_params[:spellcheck].
|
322
|
+
expect(solr_params[:qf]).to eq "fieldOne^2.3 fieldTwo fieldThree^0.4"
|
323
|
+
expect(solr_params[:spellcheck]).to eq 'false'
|
324
324
|
end
|
325
325
|
it "should merge empty string parameters from search_field definition" do
|
326
|
-
solr_search_params[:pf].
|
326
|
+
expect(solr_search_params[:pf]).to eq ""
|
327
327
|
end
|
328
328
|
|
329
329
|
describe "should respect proper precedence of settings, " do
|
@@ -333,23 +333,23 @@ describe 'Blacklight::SolrHelper' do
|
|
333
333
|
|
334
334
|
|
335
335
|
it "should not put :search_field in produced params" do
|
336
|
-
@produced_params[:search_field].
|
336
|
+
expect(@produced_params[:search_field]).to be_nil
|
337
337
|
end
|
338
338
|
|
339
339
|
it "should fall through to BL general defaults for qt not otherwise specified " do
|
340
|
-
@produced_params[:qt].
|
340
|
+
expect(@produced_params[:qt]).to eq blacklight_config[:default_solr_params][:qt]
|
341
341
|
end
|
342
342
|
|
343
343
|
it "should take rows from search field definition where specified" do
|
344
|
-
@produced_params[:rows].
|
344
|
+
expect(@produced_params[:rows]).to eq "55"
|
345
345
|
end
|
346
346
|
|
347
347
|
it "should take q from request params" do
|
348
|
-
@produced_params[:q].
|
348
|
+
expect(@produced_params[:q]).to eq "test query"
|
349
349
|
end
|
350
350
|
|
351
351
|
it "should add in extra facet.field from params" do
|
352
|
-
@produced_params[:"facet.field"].
|
352
|
+
expect(@produced_params[:"facet.field"]).to include("extra_facet")
|
353
353
|
end
|
354
354
|
|
355
355
|
end
|
@@ -358,7 +358,7 @@ describe 'Blacklight::SolrHelper' do
|
|
358
358
|
describe "sorting" do
|
359
359
|
|
360
360
|
it "should send the default sort parameter to solr" do
|
361
|
-
solr_search_params[:sort].
|
361
|
+
expect(solr_search_params[:sort]).to eq 'score desc, pub_date_sort desc, title_sort asc'
|
362
362
|
end
|
363
363
|
|
364
364
|
it "should not send a sort parameter to solr if the sort value is blank" do
|
@@ -369,12 +369,12 @@ describe 'Blacklight::SolrHelper' do
|
|
369
369
|
end
|
370
370
|
|
371
371
|
produced_params = solr_search_params
|
372
|
-
produced_params.
|
372
|
+
expect(produced_params).not_to have_key(:sort)
|
373
373
|
end
|
374
374
|
|
375
375
|
it "should pass through user sort parameters" do
|
376
376
|
produced_params = solr_search_params( :sort => 'solr_test_field desc' )
|
377
|
-
produced_params[:sort].
|
377
|
+
expect(produced_params[:sort]).to eq 'solr_test_field desc'
|
378
378
|
end
|
379
379
|
end
|
380
380
|
|
@@ -408,35 +408,35 @@ describe 'Blacklight::SolrHelper' do
|
|
408
408
|
end
|
409
409
|
|
410
410
|
it "should pass through ordinary params" do
|
411
|
-
@result[:qt].
|
412
|
-
@result[:ps].
|
413
|
-
@result[:qf].
|
411
|
+
expect(@result[:qt]).to eq "author_qt"
|
412
|
+
expect(@result[:ps]).to eq "2"
|
413
|
+
expect(@result[:qf]).to eq "someField^1000"
|
414
414
|
end
|
415
415
|
|
416
416
|
it "should include include local params with escaping" do
|
417
|
-
@result[:q].
|
418
|
-
@result[:q].
|
419
|
-
@result[:q].
|
417
|
+
expect(@result[:q]).to include('qf=$author_qf')
|
418
|
+
expect(@result[:q]).to include('pf=\'you\\\'ll have \\" to escape this\'')
|
419
|
+
expect(@result[:q]).to include('pf2=$pf2_do_not_escape_or_quote')
|
420
420
|
end
|
421
421
|
end
|
422
422
|
|
423
423
|
describe "mapping facet.field" do
|
424
424
|
it "should add single additional facet.field from app" do
|
425
425
|
solr_params = solr_search_params( "facet.field" => "additional_facet" )
|
426
|
-
solr_params[:"facet.field"].
|
427
|
-
solr_params[:"facet.field"].
|
426
|
+
expect(solr_params[:"facet.field"]).to include("additional_facet")
|
427
|
+
expect(solr_params[:"facet.field"]).to have_at_least(2).fields
|
428
428
|
end
|
429
429
|
it "should map multiple facet.field to additional facet.field" do
|
430
430
|
solr_params = solr_search_params( "facet.field" => ["add_facet1", "add_facet2"] )
|
431
|
-
solr_params[:"facet.field"].
|
432
|
-
solr_params[:"facet.field"].
|
433
|
-
solr_params[:"facet.field"].
|
431
|
+
expect(solr_params[:"facet.field"]).to include("add_facet1")
|
432
|
+
expect(solr_params[:"facet.field"]).to include("add_facet2")
|
433
|
+
expect(solr_params[:"facet.field"]).to have_at_least(3).fields
|
434
434
|
end
|
435
435
|
it "should map facets[fields][] to additional facet.field" do
|
436
436
|
solr_params = solr_search_params( "facets" => ["add_facet1", "add_facet2"] )
|
437
|
-
solr_params[:"facet.field"].
|
438
|
-
solr_params[:"facet.field"].
|
439
|
-
solr_params[:"facet.field"].
|
437
|
+
expect(solr_params[:"facet.field"]).to include("add_facet1")
|
438
|
+
expect(solr_params[:"facet.field"]).to include("add_facet2")
|
439
|
+
expect(solr_params[:"facet.field"]).to have_at_least(3).fields
|
440
440
|
end
|
441
441
|
end
|
442
442
|
|
@@ -458,21 +458,21 @@ describe 'Blacklight::SolrHelper' do
|
|
458
458
|
end
|
459
459
|
end
|
460
460
|
it 'sets rows to 0' do
|
461
|
-
@generated_solr_facet_params[:rows].
|
461
|
+
expect(@generated_solr_facet_params[:rows]).to eq 0
|
462
462
|
end
|
463
463
|
it 'sets facets requested to facet_field argument' do
|
464
|
-
@generated_solr_facet_params["facet.field".to_sym].
|
464
|
+
expect(@generated_solr_facet_params["facet.field".to_sym]).to eq @facet_field
|
465
465
|
end
|
466
466
|
it 'defaults offset to 0' do
|
467
|
-
@generated_solr_facet_params[:"f.#{@facet_field}.facet.offset"].
|
467
|
+
expect(@generated_solr_facet_params[:"f.#{@facet_field}.facet.offset"]).to eq 0
|
468
468
|
end
|
469
469
|
it 'uses offset manually set, and converts it to an integer' do
|
470
470
|
solr_params = solr_facet_params(@facet_field, @page_key => 2)
|
471
|
-
solr_params[:"f.#{@facet_field}.facet.offset"].
|
471
|
+
expect(solr_params[:"f.#{@facet_field}.facet.offset"]).to eq 20
|
472
472
|
end
|
473
473
|
it 'defaults limit to 20' do
|
474
474
|
solr_params = solr_facet_params(@facet_field)
|
475
|
-
solr_params[:"f.#{@facet_field}.facet.limit"].
|
475
|
+
expect(solr_params[:"f.#{@facet_field}.facet.limit"]).to eq 21
|
476
476
|
end
|
477
477
|
|
478
478
|
describe 'if facet_list_limit is defined in controller' do
|
@@ -481,29 +481,29 @@ describe 'Blacklight::SolrHelper' do
|
|
481
481
|
end
|
482
482
|
it 'uses controller method for limit' do
|
483
483
|
solr_params = solr_facet_params(@facet_field)
|
484
|
-
solr_params[:"f.#{@facet_field}.facet.limit"].
|
484
|
+
expect(solr_params[:"f.#{@facet_field}.facet.limit"]).to eq 1001
|
485
485
|
end
|
486
486
|
|
487
487
|
it 'uses controller method for limit when a ordinary limit is set' do
|
488
488
|
solr_params = solr_facet_params(@facet_field)
|
489
|
-
solr_params[:"f.#{@facet_field}.facet.limit"].
|
489
|
+
expect(solr_params[:"f.#{@facet_field}.facet.limit"]).to eq 1001
|
490
490
|
end
|
491
491
|
end
|
492
492
|
|
493
493
|
it 'uses the default sort' do
|
494
494
|
solr_params = solr_facet_params(@facet_field)
|
495
|
-
solr_params[:"f.#{@facet_field}.facet.sort"].
|
495
|
+
expect(solr_params[:"f.#{@facet_field}.facet.sort"]).to be_blank
|
496
496
|
end
|
497
497
|
|
498
498
|
it "uses the field-specific sort" do
|
499
499
|
@facet_field = 'format_ordered'
|
500
500
|
solr_params = solr_facet_params(@facet_field)
|
501
|
-
solr_params[:"f.#{@facet_field}.facet.sort"].
|
501
|
+
expect(solr_params[:"f.#{@facet_field}.facet.sort"]).to eq :count
|
502
502
|
end
|
503
503
|
|
504
504
|
it 'uses sort provided in the parameters' do
|
505
505
|
solr_params = solr_facet_params(@facet_field, @sort_key => "index")
|
506
|
-
solr_params[:"f.#{@facet_field}.facet.sort"].
|
506
|
+
expect(solr_params[:"f.#{@facet_field}.facet.sort"]).to eq 'index'
|
507
507
|
end
|
508
508
|
it "comes up with the same params as #solr_search_params to constrain context for facet list" do
|
509
509
|
search_params = {:q => 'tibetan history', :f=> {:format=>'Book', :language_facet=>'Tibetan'}}
|
@@ -515,7 +515,7 @@ describe 'Blacklight::SolrHelper' do
|
|
515
515
|
# don't care about.
|
516
516
|
next if ['facets', "facet.field", 'rows', 'facet.limit', 'facet.offset', 'facet.sort'].include?(key)
|
517
517
|
# Everything else should match
|
518
|
-
solr_facet_params[key].
|
518
|
+
expect(solr_facet_params[key]).to eq value
|
519
519
|
end
|
520
520
|
|
521
521
|
end
|
@@ -531,11 +531,11 @@ describe 'Blacklight::SolrHelper' do
|
|
531
531
|
end
|
532
532
|
|
533
533
|
it "should include specifically configged facet limits +1" do
|
534
|
-
@generated_params[:"f.subject_topic_facet.facet.limit"].
|
534
|
+
expect(@generated_params[:"f.subject_topic_facet.facet.limit"]).to eq 21
|
535
535
|
end
|
536
536
|
it "should not include a facet limit for a nil key in hash" do
|
537
|
-
@generated_params.
|
538
|
-
@generated_params.
|
537
|
+
expect(@generated_params).not_to have_key(:"f.format.facet.limit")
|
538
|
+
expect(@generated_params).not_to have_key(:"facet.limit")
|
539
539
|
end
|
540
540
|
end
|
541
541
|
|
@@ -544,10 +544,10 @@ describe 'Blacklight::SolrHelper' do
|
|
544
544
|
@facet_paginator = get_facet_pagination(@facet_field)
|
545
545
|
end
|
546
546
|
it 'should return a facet paginator' do
|
547
|
-
@facet_paginator.
|
547
|
+
expect(@facet_paginator).to be_a_kind_of(Blacklight::Solr::FacetPaginator)
|
548
548
|
end
|
549
549
|
it 'with a limit set' do
|
550
|
-
@facet_paginator.limit.
|
550
|
+
expect(@facet_paginator.limit).not_to be_nil
|
551
551
|
end
|
552
552
|
end
|
553
553
|
|
@@ -563,16 +563,16 @@ describe 'Blacklight::SolrHelper' do
|
|
563
563
|
it "should use the configured request handler " do
|
564
564
|
blacklight_config.stub(:default_solr_params).and_return({:qt => 'custom_request_handler'})
|
565
565
|
Blacklight.solr.should_receive(:send_and_receive) do |path, params|
|
566
|
-
path.
|
567
|
-
params[:params][:'facet.field'].
|
568
|
-
params[:params][:"facet.query"].
|
569
|
-
params[:params].
|
566
|
+
expect(path).to eq 'select'
|
567
|
+
expect(params[:params][:'facet.field']).to eq ["format", "{!ex=pub_date_single}pub_date", "subject_topic_facet", "language_facet", "lc_1letter_facet", "subject_geo_facet", "subject_era_facet"]
|
568
|
+
expect(params[:params][:"facet.query"]).to eq ["pub_date:[#{5.years.ago.year} TO *]", "pub_date:[#{10.years.ago.year} TO *]", "pub_date:[#{25.years.ago.year} TO *]"]
|
569
|
+
expect(params[:params]).to include(:rows => 10, :qt=>"custom_request_handler", :q=>"", "spellcheck.q"=>"", :"f.subject_topic_facet.facet.limit"=>21, :sort=>"score desc, pub_date_sort desc, title_sort asc")
|
570
570
|
end.and_return({'response'=>{'docs'=>[]}})
|
571
571
|
get_search_results(:q => @all_docs_query)
|
572
572
|
end
|
573
573
|
|
574
574
|
it 'should have a @response.docs list of the same size as @document_list' do
|
575
|
-
@solr_response.docs.
|
575
|
+
expect(@solr_response.docs).to have(@document_list.length).docs
|
576
576
|
end
|
577
577
|
|
578
578
|
it 'should have @response.docs list representing same documents as SolrDocuments in @document_list' do
|
@@ -580,10 +580,10 @@ describe 'Blacklight::SolrHelper' do
|
|
580
580
|
mash = @solr_response.docs[index]
|
581
581
|
solr_document = @document_list[index]
|
582
582
|
|
583
|
-
Set.new(mash.keys).
|
583
|
+
expect(Set.new(mash.keys)).to eq Set.new(solr_document.keys)
|
584
584
|
|
585
585
|
mash.each_key do |key|
|
586
|
-
mash[key].
|
586
|
+
expect(mash[key]).to eq solr_document[key]
|
587
587
|
end
|
588
588
|
end
|
589
589
|
end
|
@@ -626,7 +626,7 @@ describe 'Blacklight::SolrHelper' do
|
|
626
626
|
describe '#query_solr' do
|
627
627
|
it 'should have results' do
|
628
628
|
solr_response = query_solr(:q => @single_word_query)
|
629
|
-
solr_response.docs.
|
629
|
+
expect(solr_response.docs).to have_at_least(1).result
|
630
630
|
end
|
631
631
|
|
632
632
|
end
|
@@ -636,8 +636,8 @@ describe 'Blacklight::SolrHelper' do
|
|
636
636
|
(solr_response, document_list) = get_search_results(:q => @all_docs_query)
|
637
637
|
result_docs = document_list
|
638
638
|
document = result_docs.first
|
639
|
-
document.get(blacklight_config.index.show_link).
|
640
|
-
document.get(blacklight_config.index.record_display_type).
|
639
|
+
expect(document.get(blacklight_config.index.show_link)).not_to be_nil
|
640
|
+
expect(document.get(blacklight_config.index.record_display_type)).not_to be_nil
|
641
641
|
end
|
642
642
|
end
|
643
643
|
|
@@ -647,13 +647,13 @@ describe 'Blacklight::SolrHelper' do
|
|
647
647
|
|
648
648
|
it 'should have results' do
|
649
649
|
solr_response = query_solr(:q => @single_word_query)
|
650
|
-
solr_response.docs.
|
650
|
+
expect(solr_response.docs).to have_at_least(1).result
|
651
651
|
end
|
652
652
|
|
653
653
|
it 'should have results' do
|
654
654
|
(solr_response, document_list) = get_search_results(:q => @single_word_query)
|
655
|
-
solr_response.docs.
|
656
|
-
solr_response.docs.
|
655
|
+
expect(solr_response.docs).to have(document_list.size).results
|
656
|
+
expect(solr_response.docs).to have_at_least(1).result
|
657
657
|
end
|
658
658
|
end
|
659
659
|
|
@@ -661,48 +661,48 @@ describe 'Blacklight::SolrHelper' do
|
|
661
661
|
it 'should have results' do
|
662
662
|
|
663
663
|
(solr_response, document_list) = get_search_results(:q => @mult_word_query)
|
664
|
-
solr_response.docs.
|
665
|
-
solr_response.docs.
|
664
|
+
expect(solr_response.docs).to have(document_list.size).results
|
665
|
+
expect(solr_response.docs).to have_at_least(1).result
|
666
666
|
end
|
667
667
|
end
|
668
668
|
|
669
669
|
describe "One Facet, No Query" do
|
670
670
|
it 'should have results' do
|
671
671
|
(solr_response, document_list) = get_search_results(:f => @single_facet)
|
672
|
-
solr_response.docs.
|
673
|
-
solr_response.docs.
|
672
|
+
expect(solr_response.docs).to have(document_list.size).results
|
673
|
+
expect(solr_response.docs).to have_at_least(1).result
|
674
674
|
end
|
675
675
|
end
|
676
676
|
|
677
677
|
describe "Mult Facets, No Query" do
|
678
678
|
it 'should have results' do
|
679
679
|
(solr_response, document_list) = get_search_results(:f => @multi_facets)
|
680
|
-
solr_response.docs.
|
681
|
-
solr_response.docs.
|
680
|
+
expect(solr_response.docs).to have(document_list.size).results
|
681
|
+
expect(solr_response.docs).to have_at_least(1).result
|
682
682
|
end
|
683
683
|
end
|
684
684
|
|
685
685
|
describe "Single Word Query with One Facet" do
|
686
686
|
it 'should have results' do
|
687
687
|
(solr_response, document_list) = get_search_results(:q => @single_word_query, :f => @single_facet)
|
688
|
-
solr_response.docs.
|
689
|
-
solr_response.docs.
|
688
|
+
expect(solr_response.docs).to have(document_list.size).results
|
689
|
+
expect(solr_response.docs).to have_at_least(1).result
|
690
690
|
end
|
691
691
|
end
|
692
692
|
|
693
693
|
describe "Multiple Words Query with Multiple Facets" do
|
694
694
|
it 'should have results' do
|
695
695
|
(solr_response, document_list) = get_search_results(:q => @mult_word_query, :f => @multi_facets)
|
696
|
-
solr_response.docs.
|
697
|
-
solr_response.docs.
|
696
|
+
expect(solr_response.docs).to have(document_list.size).results
|
697
|
+
expect(solr_response.docs).to have_at_least(1).result
|
698
698
|
end
|
699
699
|
end
|
700
700
|
|
701
701
|
describe "for All Docs Query and One Facet" do
|
702
702
|
it 'should have results' do
|
703
703
|
(solr_response, document_list) = get_search_results(:q => @all_docs_query, :f => @single_facet)
|
704
|
-
solr_response.docs.
|
705
|
-
solr_response.docs.
|
704
|
+
expect(solr_response.docs).to have(document_list.size).results
|
705
|
+
expect(solr_response.docs).to have_at_least(1).result
|
706
706
|
end
|
707
707
|
# TODO: check that number of these results < number of results for all docs query
|
708
708
|
# BUT can't: num docs isn't total, it's the num docs in the single SOLR response (e.g. 10)
|
@@ -711,24 +711,24 @@ describe 'Blacklight::SolrHelper' do
|
|
711
711
|
describe "for Query Without Results and No Facet" do
|
712
712
|
it 'should have no results and not raise error' do
|
713
713
|
(solr_response, document_list) = get_search_results(:q => @no_docs_query)
|
714
|
-
|
715
|
-
solr_response.docs.
|
714
|
+
expect(document_list).to have(0).results
|
715
|
+
expect(solr_response.docs).to have(0).results
|
716
716
|
end
|
717
717
|
end
|
718
718
|
|
719
719
|
describe "for Query Without Results and One Facet" do
|
720
720
|
it 'should have no results and not raise error' do
|
721
721
|
(solr_response, document_list) = get_search_results(:q => @no_docs_query, :f => @single_facet)
|
722
|
-
|
723
|
-
solr_response.docs.
|
722
|
+
expect(document_list).to have(0).results
|
723
|
+
expect(solr_response.docs).to have(0).results
|
724
724
|
end
|
725
725
|
end
|
726
726
|
|
727
727
|
describe "for All Docs Query and Bad Facet" do
|
728
728
|
it 'should have no results and not raise error' do
|
729
729
|
(solr_response, document_list) = get_search_results(:q => @all_docs_query, :f => @bad_facet)
|
730
|
-
|
731
|
-
solr_response.docs.
|
730
|
+
expect(document_list).to have(0).results
|
731
|
+
expect(solr_response.docs).to have(0).results
|
732
732
|
end
|
733
733
|
end
|
734
734
|
|
@@ -747,16 +747,16 @@ describe 'Blacklight::SolrHelper' do
|
|
747
747
|
end
|
748
748
|
|
749
749
|
it 'should have more than one facet' do
|
750
|
-
@facets.
|
750
|
+
expect(@facets).to have_at_least(1).facet
|
751
751
|
end
|
752
752
|
it 'should have all facets specified in initializer' do
|
753
753
|
blacklight_config.facet_fields_to_add_to_solr.each do |field|
|
754
|
-
@facets.find {|f| f.name == field}.
|
754
|
+
expect(@facets.find {|f| f.name == field}).not_to be_nil
|
755
755
|
end
|
756
756
|
end
|
757
757
|
it 'should have at least one value for each facet' do
|
758
758
|
@facets.each do |facet|
|
759
|
-
facet.items.
|
759
|
+
expect(facet.items).to have_at_least(1).hit
|
760
760
|
end
|
761
761
|
end
|
762
762
|
it 'should have multiple values for at least one facet' do
|
@@ -767,12 +767,12 @@ describe 'Blacklight::SolrHelper' do
|
|
767
767
|
break
|
768
768
|
end
|
769
769
|
end
|
770
|
-
has_mult_values.
|
770
|
+
expect(has_mult_values).to eq true
|
771
771
|
end
|
772
772
|
it 'should have all value counts > 0' do
|
773
773
|
@facets.each do |facet|
|
774
774
|
facet.items.each do |facet_vals|
|
775
|
-
facet_vals.hits > 0
|
775
|
+
expect(facet_vals.hits).to be > 0
|
776
776
|
end
|
777
777
|
end
|
778
778
|
end
|
@@ -784,58 +784,58 @@ describe 'Blacklight::SolrHelper' do
|
|
784
784
|
|
785
785
|
it 'should start with first results by default' do
|
786
786
|
(solr_response, document_list) = get_search_results(:q => @all_docs_query)
|
787
|
-
solr_response.params[:start].to_i.
|
787
|
+
expect(solr_response.params[:start].to_i).to eq 0
|
788
788
|
end
|
789
789
|
it 'should have number of results (per page) set in initializer, by default' do
|
790
790
|
(solr_response, document_list) = get_search_results(:q => @all_docs_query)
|
791
|
-
solr_response.docs.
|
792
|
-
|
791
|
+
expect(solr_response.docs).to have(blacklight_config[:default_solr_params][:rows]).items
|
792
|
+
expect(document_list).to have(blacklight_config[:default_solr_params][:rows]).items
|
793
793
|
end
|
794
794
|
|
795
795
|
it 'should get number of results per page requested' do
|
796
796
|
num_results = 3 # non-default value
|
797
797
|
(solr_response1, document_list1) = get_search_results(:q => @all_docs_query, :per_page => num_results)
|
798
|
-
|
799
|
-
solr_response1.docs.
|
798
|
+
expect(document_list1).to have(num_results).docs
|
799
|
+
expect(solr_response1.docs).to have(num_results).docs
|
800
800
|
end
|
801
801
|
|
802
802
|
it 'should get number of rows requested' do
|
803
803
|
num_results = 4 # non-default value
|
804
804
|
(solr_response1, document_list1) = get_search_results(:q => @all_docs_query, :rows => num_results)
|
805
|
-
|
806
|
-
solr_response1.docs.
|
805
|
+
expect(document_list1).to have(num_results).docs
|
806
|
+
expect(solr_response1.docs).to have(num_results).docs
|
807
807
|
end
|
808
808
|
|
809
809
|
it 'should skip appropriate number of results when requested - default per page' do
|
810
810
|
page = 3
|
811
811
|
(solr_response2, document_list2) = get_search_results(:q => @all_docs_query, :page => page)
|
812
|
-
solr_response2.params[:start].to_i.
|
812
|
+
expect(solr_response2.params[:start].to_i).to eq blacklight_config[:default_solr_params][:rows] * (page-1)
|
813
813
|
end
|
814
814
|
it 'should skip appropriate number of results when requested - non-default per page' do
|
815
815
|
page = 3
|
816
816
|
num_results = 3
|
817
817
|
(solr_response2a, document_list2a) = get_search_results(:q => @all_docs_query, :per_page => num_results, :page => page)
|
818
|
-
solr_response2a.params[:start].to_i.
|
818
|
+
expect(solr_response2a.params[:start].to_i).to eq num_results * (page-1)
|
819
819
|
end
|
820
820
|
|
821
821
|
it 'should have no results when prompted for page after last result' do
|
822
822
|
big = 5000
|
823
823
|
(solr_response3, document_list3) = get_search_results(:q => @all_docs_query, :rows => big, :page => big)
|
824
|
-
|
825
|
-
solr_response3.docs.
|
824
|
+
expect(document_list3).to have(0).docs
|
825
|
+
expect(solr_response3.docs).to have(0).docs
|
826
826
|
end
|
827
827
|
|
828
828
|
it 'should show first results when prompted for page before first result' do
|
829
829
|
# FIXME: should it show first results, or should it throw an error for view to deal w?
|
830
830
|
# Solr throws an error for a negative start value
|
831
831
|
(solr_response4, document_list4) = get_search_results(:q => @all_docs_query, :page => '-1')
|
832
|
-
solr_response4.params[:start].to_i.
|
832
|
+
expect(solr_response4.params[:start].to_i).to eq 0
|
833
833
|
end
|
834
834
|
it 'should have results available when asked for more than are in response' do
|
835
835
|
big = 5000
|
836
836
|
(solr_response5, document_list5) = get_search_results(:q => @all_docs_query, :rows => big, :page => 1)
|
837
|
-
solr_response5.docs.
|
838
|
-
solr_response5.docs.
|
837
|
+
expect(solr_response5.docs).to have(document_list5.length).docs
|
838
|
+
expect(solr_response5.docs).to have_at_least(1).doc
|
839
839
|
end
|
840
840
|
|
841
841
|
end # page specs
|
@@ -849,37 +849,37 @@ describe 'Blacklight::SolrHelper' do
|
|
849
849
|
end
|
850
850
|
|
851
851
|
it "should raise Blacklight::InvalidSolrID for an unknown id" do
|
852
|
-
|
852
|
+
expect {
|
853
853
|
get_solr_response_for_doc_id(@bad_id)
|
854
|
-
}.
|
854
|
+
}.to raise_error(Blacklight::Exceptions::InvalidSolrID)
|
855
855
|
end
|
856
856
|
|
857
857
|
it "should use a provided document request handler " do
|
858
858
|
blacklight_config.stub(:document_solr_request_handler => 'document')
|
859
859
|
Blacklight.solr.should_receive(:get).with('select', kind_of(Hash)).and_return({'response'=>{'docs'=>[]}})
|
860
|
-
|
860
|
+
expect { get_solr_response_for_doc_id(@doc_id)}.to raise_error Blacklight::Exceptions::InvalidSolrID
|
861
861
|
end
|
862
862
|
|
863
863
|
it "should have a non-nil result for a known id" do
|
864
|
-
@document.
|
864
|
+
expect(@document).not_to be_nil
|
865
865
|
end
|
866
866
|
it "should have a single document in the response for a known id" do
|
867
|
-
@response2.docs.size.
|
867
|
+
expect(@response2.docs.size).to eq 1
|
868
868
|
end
|
869
869
|
it 'should have the expected value in the id field' do
|
870
|
-
@document.id.
|
870
|
+
expect(@document.id).to eq @doc_id
|
871
871
|
end
|
872
872
|
it 'should have non-nil values for required fields set in initializer' do
|
873
|
-
@document.get(blacklight_config[:show][:html_title]).
|
874
|
-
@document.get(blacklight_config[:show][:heading]).
|
875
|
-
@document.get(blacklight_config[:show][:display_type]).
|
873
|
+
expect(@document.get(blacklight_config[:show][:html_title])).not_to be_nil
|
874
|
+
expect(@document.get(blacklight_config[:show][:heading])).not_to be_nil
|
875
|
+
expect(@document.get(blacklight_config[:show][:display_type])).not_to be_nil
|
876
876
|
end
|
877
877
|
end
|
878
878
|
|
879
879
|
describe "solr_doc_params" do
|
880
880
|
it "should default to using the 'document' requestHandler" do
|
881
881
|
doc_params = solr_doc_params('asdfg')
|
882
|
-
doc_params[:qt].
|
882
|
+
expect(doc_params[:qt]).to eq 'document'
|
883
883
|
end
|
884
884
|
|
885
885
|
|
@@ -892,8 +892,8 @@ describe 'Blacklight::SolrHelper' do
|
|
892
892
|
|
893
893
|
it "should use parameters from the controller's default_document_solr_parameters" do
|
894
894
|
doc_params = solr_doc_params('asdfg')
|
895
|
-
doc_params[:qt].
|
896
|
-
doc_params[:asdf].
|
895
|
+
expect(doc_params[:qt]).to eq 'my_custom_handler'
|
896
|
+
expect(doc_params[:asdf]).to eq '1234'
|
897
897
|
end
|
898
898
|
end
|
899
899
|
|
@@ -905,13 +905,13 @@ describe 'Blacklight::SolrHelper' do
|
|
905
905
|
it "should respect the configuration-supplied unique id" do
|
906
906
|
SolrDocument.should_receive(:unique_key).and_return("title_display")
|
907
907
|
@response, @document = @solr_helper.get_solr_response_for_doc_id('"Strong Medicine speaks"')
|
908
|
-
@document.id.
|
909
|
-
@document.get(:id).
|
908
|
+
@document.id).to eq '"Strong Medicine speaks"'
|
909
|
+
@document.get(:id)).to eq 2007020969
|
910
910
|
end
|
911
911
|
=end
|
912
912
|
it "should respect the configuration-supplied unique id" do
|
913
913
|
doc_params = solr_doc_params('"Strong Medicine speaks"')
|
914
|
-
doc_params[:id].
|
914
|
+
expect(doc_params[:id]).to eq '"Strong Medicine speaks"'
|
915
915
|
end
|
916
916
|
end
|
917
917
|
|
@@ -926,7 +926,7 @@ describe 'Blacklight::SolrHelper' do
|
|
926
926
|
=begin
|
927
927
|
# can't test these here, because the method only returns the document
|
928
928
|
it "should get a single document" do
|
929
|
-
response.docs.size.
|
929
|
+
response.docs.size).to eq 1
|
930
930
|
end
|
931
931
|
|
932
932
|
doc2 = get_single_doc_via_search(@all_docs_query, nil, @doc_row, @multi_facets)
|
@@ -935,23 +935,23 @@ describe 'Blacklight::SolrHelper' do
|
|
935
935
|
end
|
936
936
|
|
937
937
|
it "should not have facets in the response" do
|
938
|
-
response.facets.size.
|
938
|
+
response.facets.size).to eq 0
|
939
939
|
end
|
940
940
|
=end
|
941
941
|
|
942
942
|
it 'should have a doc id field' do
|
943
|
-
@doc[:id].
|
943
|
+
expect(@doc[:id]).not_to be_nil
|
944
944
|
end
|
945
945
|
|
946
946
|
it 'should have non-nil values for required fields set in initializer' do
|
947
|
-
@doc[blacklight_config.show.html_title].
|
948
|
-
@doc[blacklight_config.show.heading].
|
949
|
-
@doc[blacklight_config.show.display_type].
|
947
|
+
expect(@doc[blacklight_config.show.html_title]).not_to be_nil
|
948
|
+
expect(@doc[blacklight_config.show.heading]).not_to be_nil
|
949
|
+
expect(@doc[blacklight_config.show.display_type]).not_to be_nil
|
950
950
|
end
|
951
951
|
|
952
952
|
it "should limit search result by facets when supplied" do
|
953
953
|
doc2 = get_single_doc_via_search(@doc_row , :q => @all_docs_query, :f => @multi_facets)
|
954
|
-
doc2[:id].
|
954
|
+
expect(doc2[:id]).not_to be_nil
|
955
955
|
end
|
956
956
|
|
957
957
|
end
|
@@ -960,36 +960,36 @@ describe 'Blacklight::SolrHelper' do
|
|
960
960
|
describe "Searches should return spelling suggestions", :integration => true do
|
961
961
|
it 'search results for just-poor-enough-query term should have (multiple) spelling suggestions' do
|
962
962
|
(solr_response, document_list) = get_search_results({:q => 'boo'})
|
963
|
-
solr_response.spelling.words.
|
964
|
-
solr_response.spelling.words.
|
963
|
+
expect(solr_response.spelling.words).to include('bon')
|
964
|
+
expect(solr_response.spelling.words).to include('bod') #for multiple suggestions
|
965
965
|
end
|
966
966
|
|
967
967
|
it 'search results for just-poor-enough-query term should have multiple spelling suggestions' do
|
968
968
|
(solr_response, document_list) = get_search_results({:q => 'politica'})
|
969
|
-
solr_response.spelling.words.
|
970
|
-
solr_response.spelling.words.
|
971
|
-
solr_response.spelling.words.
|
969
|
+
expect(solr_response.spelling.words).to include('policy') # less freq
|
970
|
+
expect(solr_response.spelling.words).to include('politics') # more freq
|
971
|
+
expect(solr_response.spelling.words).to include('political') # more freq
|
972
972
|
=begin
|
973
973
|
# when we can have multiple suggestions
|
974
974
|
solr_response.spelling.words.should_not include('policy') # less freq
|
975
|
-
solr_response.spelling.words.
|
976
|
-
solr_response.spelling.words.
|
975
|
+
solr_response.spelling.words).to include('politics') # more freq
|
976
|
+
solr_response.spelling.words).to include('political') # more freq
|
977
977
|
=end
|
978
978
|
end
|
979
979
|
|
980
980
|
it "title search results for just-poor-enough query term should have spelling suggestions" do
|
981
981
|
(solr_response, document_list) = get_search_results({:q => 'yehudiyam', :qt => 'search', :"spellcheck.dictionary" => "title"})
|
982
|
-
solr_response.spelling.words.
|
982
|
+
expect(solr_response.spelling.words).to include('yehudiyim')
|
983
983
|
end
|
984
984
|
|
985
985
|
it "author search results for just-poor-enough-query term should have spelling suggestions" do
|
986
986
|
(solr_response, document_list) = get_search_results({:q => 'shirma', :qt => 'search', :"spellcheck.dictionary" => "author"})
|
987
|
-
solr_response.spelling.words.
|
987
|
+
expect(solr_response.spelling.words).to include('sharma')
|
988
988
|
end
|
989
989
|
|
990
990
|
it "subject search results for just-poor-enough-query term should have spelling suggestions" do
|
991
991
|
(solr_response, document_list) = get_search_results({:q => 'wome', :qt => 'search', :"spellcheck.dictionary" => "subject"})
|
992
|
-
solr_response.spelling.words.
|
992
|
+
expect(solr_response.spelling.words).to include('women')
|
993
993
|
end
|
994
994
|
|
995
995
|
it 'search results for multiple terms query with just-poor-enough-terms should have spelling suggestions for each term' do
|
@@ -1002,16 +1002,16 @@ describe 'Blacklight::SolrHelper' do
|
|
1002
1002
|
describe "facet_limit_for" do
|
1003
1003
|
|
1004
1004
|
it "should return specified value for facet_field specified" do
|
1005
|
-
facet_limit_for("subject_topic_facet").
|
1005
|
+
expect(facet_limit_for("subject_topic_facet")).to eq blacklight_config.facet_fields["subject_topic_facet"].limit
|
1006
1006
|
end
|
1007
1007
|
it "should generate proper solr param" do
|
1008
|
-
solr_search_params[:"f.subject_topic_facet.facet.limit"].
|
1008
|
+
expect(solr_search_params[:"f.subject_topic_facet.facet.limit"]).to eq 21
|
1009
1009
|
end
|
1010
1010
|
|
1011
1011
|
it "facet_limit_hash should return hash with key being facet_field and value being configured limit" do
|
1012
1012
|
# facet_limit_hash has been removed from solrhelper in refactor. should it go back?
|
1013
1013
|
pending "facet_limit_hash has been removed from solrhelper in refactor. should it go back?"
|
1014
|
-
facet_limit_hash.
|
1014
|
+
expect(facet_limit_hash).to eq blacklight_config[:facet][:limits]
|
1015
1015
|
end
|
1016
1016
|
it "should handle no facet_limits in config" do
|
1017
1017
|
def blacklight_config
|
@@ -1020,26 +1020,26 @@ describe 'Blacklight::SolrHelper' do
|
|
1020
1020
|
return config
|
1021
1021
|
end
|
1022
1022
|
|
1023
|
-
facet_limit_for("subject_topic_facet").
|
1023
|
+
expect(facet_limit_for("subject_topic_facet")).to be_nil
|
1024
1024
|
|
1025
|
-
solr_search_params.
|
1025
|
+
expect(solr_search_params).not_to have_key(:"f.subject_topic_facet.facet.limit")
|
1026
1026
|
|
1027
1027
|
end
|
1028
1028
|
|
1029
1029
|
describe "for 'true' configured values" do
|
1030
1030
|
it "should return nil if no @response available" do
|
1031
|
-
facet_limit_for("some_unknown_field").
|
1031
|
+
expect(facet_limit_for("some_unknown_field")).to be_nil
|
1032
1032
|
end
|
1033
1033
|
it "should get from @response facet.limit if available" do
|
1034
1034
|
# Okay, this is cheesy, since we included SolrHelper directly
|
1035
1035
|
# into our example groups, we need to set an iVar here, so it will
|
1036
1036
|
# use it.
|
1037
1037
|
@response = {"responseHeader" => {"params" => {"facet.limit" => 11}}}
|
1038
|
-
facet_limit_for("language_facet").
|
1038
|
+
expect(facet_limit_for("language_facet")).to eq 10
|
1039
1039
|
end
|
1040
1040
|
it "should get from specific field in @response if available" do
|
1041
1041
|
@response = {"responseHeader" => {"params" => {"facet.limit" => 11,"f.language_facet.facet.limit" => 16}}}
|
1042
|
-
facet_limit_for("language_facet").
|
1042
|
+
expect(facet_limit_for("language_facet")).to eq 15
|
1043
1043
|
end
|
1044
1044
|
end
|
1045
1045
|
end
|
@@ -1052,8 +1052,8 @@ describe 'Blacklight::SolrHelper' do
|
|
1052
1052
|
end
|
1053
1053
|
|
1054
1054
|
it "should enforce max_per_page against all parameters" do
|
1055
|
-
blacklight_config.max_per_page.
|
1056
|
-
solr_search_params(:per_page => 98765)[:rows].
|
1055
|
+
expect(blacklight_config.max_per_page).to eq 123
|
1056
|
+
expect(solr_search_params(:per_page => 98765)[:rows]).to eq 123
|
1057
1057
|
end
|
1058
1058
|
end
|
1059
1059
|
|
@@ -1129,14 +1129,14 @@ describe 'Blacklight::SolrHelper' do
|
|
1129
1129
|
it "should return only the next document if the counter is 0" do
|
1130
1130
|
response, docs = get_previous_and_next_documents_for_search(0, :q => '')
|
1131
1131
|
|
1132
|
-
expect(docs.first).to
|
1132
|
+
expect(docs.first).to be_nil
|
1133
1133
|
expect(docs.last.id).to eq @all_docs[1].id
|
1134
1134
|
end
|
1135
1135
|
|
1136
1136
|
it "should return only the previous document if the counter is the total number of documents" do
|
1137
1137
|
response, docs = get_previous_and_next_documents_for_search(@full_response.total - 1, :q => '')
|
1138
1138
|
expect(docs.first.id).to eq @all_docs.slice(-2).id
|
1139
|
-
expect(docs.last).to
|
1139
|
+
expect(docs.last).to be_nil
|
1140
1140
|
end
|
1141
1141
|
|
1142
1142
|
it "should return an array of nil values if there is only one result" do
|