blacklight 5.3.0 → 5.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +1 -0
- data/app/assets/javascripts/blacklight/collapsable.js +9 -0
- data/app/controllers/bookmarks_controller.rb +72 -9
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +15 -7
- data/app/helpers/blacklight/catalog_helper_behavior.rb +17 -9
- data/app/helpers/blacklight/configuration_helper_behavior.rb +59 -7
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -16
- data/app/helpers/blacklight/url_helper_behavior.rb +21 -2
- data/app/models/bookmark.rb +13 -4
- data/app/models/solr_document.rb +5 -0
- data/app/views/bookmarks/_tools.html.erb +10 -11
- data/app/views/catalog/_bookmark_control.html.erb +2 -2
- data/app/views/catalog/_refworks_form.html.erb +3 -2
- data/app/views/catalog/_sort_widget.html.erb +5 -5
- data/app/views/catalog/_view_type_group.html.erb +2 -2
- data/app/views/shared/_header_navbar.html.erb +1 -3
- data/config/locales/blacklight.pt-BR.yml +223 -0
- data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +8 -0
- data/gemfiles/rails4.1.gemfile +1 -1
- data/lib/blacklight.rb +5 -0
- data/lib/blacklight/catalog.rb +33 -5
- data/lib/blacklight/configuration.rb +12 -3
- data/lib/blacklight/configuration/facet_field.rb +1 -1
- data/lib/blacklight/configuration/search_field.rb +3 -2
- data/lib/blacklight/configuration/solr_field.rb +2 -1
- data/lib/blacklight/configuration/sort_field.rb +2 -1
- data/lib/blacklight/engine.rb +9 -1
- data/lib/blacklight/exceptions.rb +3 -0
- data/lib/blacklight/rails/routes.rb +12 -0
- data/lib/blacklight/request_builders.rb +19 -18
- data/lib/blacklight/search_fields.rb +0 -9
- data/lib/blacklight/solr/document.rb +15 -0
- data/lib/blacklight/solr/document/export.rb +4 -0
- data/lib/blacklight/solr_helper.rb +25 -28
- data/lib/blacklight/solr_response.rb +31 -29
- data/lib/blacklight/solr_response/response.rb +18 -0
- data/lib/blacklight/user.rb +17 -4
- data/lib/blacklight/utils.rb +30 -2
- data/lib/generators/blacklight/install_generator.rb +4 -0
- data/lib/generators/blacklight/templates/config/initializers/blacklight_initializer.rb +9 -0
- data/spec/controllers/application_controller_spec.rb +0 -1
- data/spec/controllers/bookmarks_controller_spec.rb +8 -4
- data/spec/controllers/catalog_controller_spec.rb +48 -55
- data/spec/controllers/saved_searches_controller_spec.rb +1 -4
- data/spec/controllers/search_history_controller_spec.rb +0 -1
- data/spec/features/bookmarks_spec.rb +14 -0
- data/spec/features/search_formats_spec.rb +45 -0
- data/spec/helpers/blacklight_helper_spec.rb +71 -30
- data/spec/helpers/configuration_helper_spec.rb +128 -4
- data/spec/helpers/facets_helper_spec.rb +1 -1
- data/spec/lib/blacklight/configuration_spec.rb +0 -5
- data/spec/lib/blacklight/search_fields_spec.rb +0 -22
- data/spec/lib/blacklight/solr/document_spec.rb +6 -0
- data/spec/lib/blacklight/solr_helper_spec.rb +31 -10
- data/spec/lib/blacklight/solr_response_spec.rb +8 -0
- data/spec/lib/blacklight/user_spec.rb +38 -4
- data/spec/models/bookmark_spec.rb +22 -17
- data/spec/spec_helper.rb +2 -0
- data/template.demo.rb +4 -9
- metadata +12 -6
- data/spec/data/sample_docs.yml +0 -655
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "Search Formats" do
|
6
|
+
before do
|
7
|
+
# Get all the fields from Solr, so the #index documents have the MARC field (to trigger appropriate
|
8
|
+
# export formats)
|
9
|
+
CatalogController.blacklight_config.default_solr_params[:fl] = '*'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should have an RSS XML response" do
|
13
|
+
visit "/catalog.rss?q="
|
14
|
+
expect(page).to have_content "Blacklight Search Results"
|
15
|
+
doc = Nokogiri::XML(page.body)
|
16
|
+
expect(doc.xpath("//item")).to have(10).items
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have an ATOM XML response" do
|
20
|
+
visit "/catalog.atom?q="
|
21
|
+
expect(page).to have_content "Blacklight Search Results"
|
22
|
+
doc = Nokogiri::XML(page.body)
|
23
|
+
expect(doc.xpath("//atom:entry", atom: "http://www.w3.org/2005/Atom")).to have(10).entries
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return new-line separated RIS records" do
|
27
|
+
visit "/catalog.endnote?q="
|
28
|
+
expect(page.status_code).to eq 200
|
29
|
+
rmt_regex = /^%0/
|
30
|
+
expect(page).to have_content "%A Bstan-ʼdzin-rgya-mtsho,"
|
31
|
+
expect(page).to have_content "%@ 9789573908678"
|
32
|
+
expect(page.body).to match rmt_regex
|
33
|
+
expect(page.body.scan(rmt_regex).length).to eq 10
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return new-line separated MARC records" do
|
37
|
+
visit "/catalog.refworks_marc_txt?q="
|
38
|
+
expect(page.status_code).to eq 200
|
39
|
+
rmt_regex = /LEADER .+\n(\d\d\d .. .+\n)+/
|
40
|
+
expect(page).to have_content "LEADER 01221cam a22002534a 4500001"
|
41
|
+
expect(page).to have_content "LEADER 01127cam a22002895a 4500001"
|
42
|
+
expect(page.body).to match rmt_regex
|
43
|
+
expect(page.body.scan(rmt_regex).length).to eq 10
|
44
|
+
end
|
45
|
+
end
|
@@ -122,6 +122,7 @@ describe BlacklightHelper do
|
|
122
122
|
helper.stub(:blacklight_config).and_return(@config)
|
123
123
|
helper.stub(:has_user_authentication_provider?).and_return(true)
|
124
124
|
helper.stub(:current_or_guest_user).and_return(User.new)
|
125
|
+
helper.stub(current_bookmarks: [])
|
125
126
|
end
|
126
127
|
describe "render_index_doc_actions" do
|
127
128
|
it "should render partials" do
|
@@ -136,6 +137,48 @@ describe BlacklightHelper do
|
|
136
137
|
end
|
137
138
|
end
|
138
139
|
end
|
140
|
+
|
141
|
+
describe "#should_render_index_field?" do
|
142
|
+
before do
|
143
|
+
helper.stub(should_render_field?: true, document_has_value?: true)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should be true" do
|
147
|
+
expect(helper.should_render_index_field?(double, double)).to be_true
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should be false if the document doesn't have a value for the field" do
|
151
|
+
helper.stub(document_has_value?: false)
|
152
|
+
expect(helper.should_render_index_field?(double, double)).to be_false
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should be false if the configuration has the field disabled" do
|
157
|
+
helper.stub(should_render_field?: false)
|
158
|
+
expect(helper.should_render_index_field?(double, double)).to be_false
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "#should_render_show_field?" do
|
163
|
+
before do
|
164
|
+
helper.stub(should_render_field?: true, document_has_value?: true)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should be true" do
|
168
|
+
expect(helper.should_render_show_field?(double, double)).to be_true
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should be false if the document doesn't have a value for the field" do
|
172
|
+
helper.stub(document_has_value?: false)
|
173
|
+
expect(helper.should_render_show_field?(double, double)).to be_false
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should be false if the configuration has the field disabled" do
|
178
|
+
helper.stub(should_render_field?: false)
|
179
|
+
expect(helper.should_render_show_field?(double, double)).to be_false
|
180
|
+
end
|
181
|
+
end
|
139
182
|
|
140
183
|
describe "render_index_field_value" do
|
141
184
|
before do
|
@@ -336,38 +379,13 @@ describe BlacklightHelper do
|
|
336
379
|
expect(value).to eq "123"
|
337
380
|
end
|
338
381
|
end
|
339
|
-
|
340
|
-
describe "#
|
341
|
-
it "should if the document has the field value" do
|
342
|
-
doc = double()
|
343
|
-
doc.stub(:has?).with('asdf').and_return(true)
|
344
|
-
field_config = double(:field => 'asdf')
|
345
|
-
helper.should_render_index_field?(doc, field_config).should == true
|
346
|
-
end
|
347
|
-
|
348
|
-
it "should if the document has a highlight field value" do
|
349
|
-
doc = double()
|
350
|
-
doc.stub(:has?).with('asdf').and_return(false)
|
351
|
-
doc.stub(:has_highlight_field?).with('asdf').and_return(true)
|
352
|
-
field_config = double(:field => 'asdf', :highlight => true)
|
353
|
-
helper.should_render_index_field?(doc, field_config).should == true
|
354
|
-
end
|
355
|
-
|
356
|
-
it "should if the field has a model accessor" do
|
357
|
-
doc = double()
|
358
|
-
doc.stub(:has?).with('asdf').and_return(false)
|
359
|
-
doc.stub(:has_highlight_field?).with('asdf').and_return(false)
|
360
|
-
field_config = double(:field => 'asdf', :highlight => true, :accessor => true)
|
361
|
-
helper.should_render_index_field?(doc, field_config).should == true
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
describe "#should_render_show_field?" do
|
382
|
+
|
383
|
+
describe "#document_has_value?" do
|
366
384
|
it "should if the document has the field value" do
|
367
385
|
doc = double()
|
368
386
|
doc.stub(:has?).with('asdf').and_return(true)
|
369
387
|
field_config = double(:field => 'asdf')
|
370
|
-
|
388
|
+
helper.document_has_value?(doc, field_config).should == true
|
371
389
|
end
|
372
390
|
|
373
391
|
it "should if the document has a highlight field value" do
|
@@ -375,7 +393,7 @@ describe BlacklightHelper do
|
|
375
393
|
doc.stub(:has?).with('asdf').and_return(false)
|
376
394
|
doc.stub(:has_highlight_field?).with('asdf').and_return(true)
|
377
395
|
field_config = double(:field => 'asdf', :highlight => true)
|
378
|
-
|
396
|
+
helper.document_has_value?(doc, field_config).should == true
|
379
397
|
end
|
380
398
|
|
381
399
|
it "should if the field has a model accessor" do
|
@@ -383,7 +401,7 @@ describe BlacklightHelper do
|
|
383
401
|
doc.stub(:has?).with('asdf').and_return(false)
|
384
402
|
doc.stub(:has_highlight_field?).with('asdf').and_return(false)
|
385
403
|
field_config = double(:field => 'asdf', :highlight => true, :accessor => true)
|
386
|
-
helper.
|
404
|
+
helper.document_has_value?(doc, field_config).should == true
|
387
405
|
end
|
388
406
|
end
|
389
407
|
|
@@ -552,4 +570,27 @@ describe BlacklightHelper do
|
|
552
570
|
expect(subject).to have_selector "link[href='href']", visible: false
|
553
571
|
end
|
554
572
|
end
|
573
|
+
|
574
|
+
describe "#render_document_index" do
|
575
|
+
it "should render the document index with the current view type" do
|
576
|
+
helper.stub(document_index_view_type: :current_view)
|
577
|
+
helper.should_receive(:render_document_index_with_view).with(:current_view, [], a: 1, b: 2)
|
578
|
+
helper.render_document_index [], a: 1, b: 2
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
582
|
+
describe "#render_document_index_with_view" do
|
583
|
+
it "should ignore missing templates" do
|
584
|
+
helper.stub(:render) do |options|
|
585
|
+
if options[:partial] == "document_view_type"
|
586
|
+
raise ActionView::MissingTemplate.new [], '', '', '', ''
|
587
|
+
else
|
588
|
+
options[:partial]
|
589
|
+
end
|
590
|
+
end
|
591
|
+
|
592
|
+
response = helper.render_document_index_with_view :view_type, [double, double]
|
593
|
+
expect(response).to eq "catalog/document_view_type"
|
594
|
+
end
|
595
|
+
end
|
555
596
|
end
|
@@ -17,11 +17,18 @@ describe BlacklightConfigurationHelper do
|
|
17
17
|
|
18
18
|
describe "#sort_fields" do
|
19
19
|
it "should convert the sort fields to select-ready values" do
|
20
|
-
blacklight_config.stub(sort_fields: { 'a' => double(key: 'a', label: 'a'), 'b' => double(key: 'b', label: 'b'), })
|
20
|
+
blacklight_config.stub(sort_fields: { 'a' => double(key: 'a', label: 'a'), 'b' => double(key: 'b', label: 'b'), c: double(key: 'c', if: false) })
|
21
21
|
expect(helper.sort_fields).to eq [['a', 'a'], ['b', 'b']]
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
describe "#active_sort_fields" do
|
26
|
+
it "should restrict the configured sort fields to only those that should be displayed" do
|
27
|
+
blacklight_config.stub(sort_fields: { a: double(if: false, unless: false), b: double(if:true, unless: true) })
|
28
|
+
expect(helper.active_sort_fields).to be_empty
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
25
32
|
describe "#document_show_fields" do
|
26
33
|
it "should pass through the configuration" do
|
27
34
|
blacklight_config.stub(show_fields: config_value)
|
@@ -30,9 +37,31 @@ describe BlacklightConfigurationHelper do
|
|
30
37
|
end
|
31
38
|
|
32
39
|
describe "#default_document_index_view_type" do
|
33
|
-
it "should
|
34
|
-
blacklight_config.
|
35
|
-
|
40
|
+
it "should use the first view with default set to true" do
|
41
|
+
blacklight_config.view.a
|
42
|
+
blacklight_config.view.b
|
43
|
+
blacklight_config.view.b.default = true
|
44
|
+
expect(helper.default_document_index_view_type).to eq :b
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should default to the first configured index view" do
|
48
|
+
blacklight_config.stub(view: { a: true, b: true})
|
49
|
+
expect(helper.default_document_index_view_type).to eq :a
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#document_index_views" do
|
54
|
+
before do
|
55
|
+
blacklight_config.view.abc = false
|
56
|
+
blacklight_config.view.def.if = false
|
57
|
+
blacklight_config.view.xyz.unless = true
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should filter views using :if/:unless configuration" do
|
61
|
+
helper.document_index_views.should have_key :list
|
62
|
+
helper.document_index_views.should_not have_key :abc
|
63
|
+
helper.document_index_views.should_not have_key :def
|
64
|
+
helper.document_index_views.should_not have_key :xyz
|
36
65
|
end
|
37
66
|
end
|
38
67
|
|
@@ -113,6 +142,18 @@ describe BlacklightConfigurationHelper do
|
|
113
142
|
end
|
114
143
|
end
|
115
144
|
|
145
|
+
describe "#default_sort_field" do
|
146
|
+
it "should be the configured default field" do
|
147
|
+
helper.stub(blacklight_config: double(sort_fields: { a: double(default: nil), b: double(key: 'b', default: true) }))
|
148
|
+
expect(helper.default_sort_field.key).to eq 'b'
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should be the first per-page value if a default isn't set" do
|
152
|
+
helper.stub(blacklight_config: double(sort_fields: { a: double(key: 'a', default: nil), b: double(key: 'b', default: nil) }))
|
153
|
+
expect(helper.default_sort_field.key).to eq 'a'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
116
157
|
describe "#per_page_options_for_select" do
|
117
158
|
it "should be the per-page values formatted as options_for_select" do
|
118
159
|
helper.stub(blacklight_config: double(per_page: [11, 22, 33]))
|
@@ -121,4 +162,87 @@ describe BlacklightConfigurationHelper do
|
|
121
162
|
expect(helper.per_page_options_for_select).to include ["33<span class=\"sr-only\"> per page</span>", 33]
|
122
163
|
end
|
123
164
|
end
|
165
|
+
|
166
|
+
describe "#should_render_field?" do
|
167
|
+
let(:field_config) { double('field config', if: true, unless: false) }
|
168
|
+
|
169
|
+
before do
|
170
|
+
helper.stub(document_has_value?: true)
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should be true" do
|
174
|
+
expect(helper.should_render_field?(field_config)).to be_true
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should be false if the :if condition is false" do
|
178
|
+
field_config.stub(if: false)
|
179
|
+
expect(helper.should_render_field?(field_config)).to be_false
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should be false if the :unless condition is true" do
|
183
|
+
field_config.stub(unless: true)
|
184
|
+
expect(helper.should_render_field?(field_config)).to be_false
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "#evaluate_configuration_conditional" do
|
189
|
+
it "should pass through regular values" do
|
190
|
+
val = double
|
191
|
+
expect(helper.evaluate_configuration_conditional(val)).to eq val
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should execute a helper method" do
|
195
|
+
helper.stub(:my_helper => true)
|
196
|
+
expect(helper.evaluate_configuration_conditional(:my_helper)).to be_true
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should call a helper to determine if it should render a field" do
|
200
|
+
a = double
|
201
|
+
helper.should_receive(:my_helper_with_an_arg).with(a).and_return(true)
|
202
|
+
expect(helper.evaluate_configuration_conditional(:my_helper_with_an_arg, a)).to be_true
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should evaluate a Proc to determine if it should render a field" do
|
206
|
+
one_arg_lambda = lambda { |context, a| true }
|
207
|
+
two_arg_lambda = lambda { |context, a, b| true }
|
208
|
+
expect(helper.evaluate_configuration_conditional(one_arg_lambda, 1)).to be_true
|
209
|
+
expect(helper.evaluate_configuration_conditional(two_arg_lambda, 1, 2)).to be_true
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe "#search_field_options_for_select" do
|
214
|
+
|
215
|
+
before do
|
216
|
+
|
217
|
+
@config = Blacklight::Configuration.new do |config|
|
218
|
+
config.default_solr_params = { :qt => 'search' }
|
219
|
+
|
220
|
+
config.add_search_field 'all_fields', :label => 'All Fields'
|
221
|
+
config.add_search_field 'title', :qt => 'title_search'
|
222
|
+
config.add_search_field 'author', :qt => 'author_search'
|
223
|
+
config.add_search_field 'subject', :qt => 'subject_search'
|
224
|
+
config.add_search_field 'no_display', :qt => 'something', :include_in_simple_select => false
|
225
|
+
end
|
226
|
+
|
227
|
+
helper.stub(blacklight_config: @config)
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should return proper options_for_select arguments" do
|
231
|
+
|
232
|
+
select_arguments = helper.search_field_options_for_select
|
233
|
+
|
234
|
+
select_arguments.each do |(label, key)|
|
235
|
+
config_hash = @config.search_fields[key]
|
236
|
+
|
237
|
+
expect(label).to eq config_hash.label
|
238
|
+
expect(key).to eq config_hash.key
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should not include fields in select if :display_in_simple_search=>false" do
|
243
|
+
select_arguments = helper.search_field_options_for_select
|
244
|
+
|
245
|
+
expect(select_arguments).not_to include(["No Display", "no_display"])
|
246
|
+
end
|
247
|
+
end
|
124
248
|
end
|
@@ -65,7 +65,7 @@ describe FacetsHelper do
|
|
65
65
|
|
66
66
|
it "should call a helper to determine if it should render a field" do
|
67
67
|
a = double(:items => [1,2], :name=>'helper_with_an_arg_show')
|
68
|
-
helper.should_receive(:my_helper_with_an_arg).with(a).and_return(true)
|
68
|
+
helper.should_receive(:my_helper_with_an_arg).with(@config.facet_fields['helper_with_an_arg_show'], a).and_return(true)
|
69
69
|
expect(helper.should_render_facet?(a)).to be_true
|
70
70
|
end
|
71
71
|
|
@@ -39,11 +39,6 @@ describe "Blacklight::Configuration" do
|
|
39
39
|
expect(@config.index).to be_a_kind_of OpenStruct
|
40
40
|
end
|
41
41
|
|
42
|
-
it "should introspect SolrDocument for sensible defaults for show + index" do
|
43
|
-
expect(@config.view_config(:show).title_field).to eq 'id'
|
44
|
-
expect(@config.index.title_field).to eq 'id'
|
45
|
-
end
|
46
|
-
|
47
42
|
it "should have ordered hashes for field configuration" do
|
48
43
|
expect(@config.facet_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
49
44
|
expect(@config.index_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
@@ -32,28 +32,6 @@ describe Blacklight::SearchFields do
|
|
32
32
|
it "should fill in default qt where needed" do
|
33
33
|
expect(@search_field_obj.search_field_def_for_key("all_fields").qt).to eq @config.default_solr_params[:qt]
|
34
34
|
end
|
35
|
-
|
36
|
-
it "should return proper options_for_select arguments" do
|
37
|
-
|
38
|
-
select_arguments = @search_field_obj.search_field_options_for_select
|
39
|
-
|
40
|
-
select_arguments.each_index do |index|
|
41
|
-
argument = select_arguments[index]
|
42
|
-
config_hash = @search_field_obj.search_field_list[index]
|
43
|
-
|
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
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should not include fields in select if :display_in_simple_search=>false" do
|
51
|
-
select_arguments = @search_field_obj.search_field_options_for_select
|
52
|
-
|
53
|
-
expect(select_arguments).not_to include(["No Display", "no_display"])
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
35
|
|
58
36
|
it "should lookup field definitions by key" do
|
59
37
|
expect(@search_field_obj.search_field_def_for_key("title").key).to eq "title"
|
@@ -172,6 +172,12 @@ describe "Blacklight::Solr::Document" do
|
|
172
172
|
doc.will_export_as(:marc, "application/marc")
|
173
173
|
expect(doc.export_as(:marc)).to eq "fake_marc"
|
174
174
|
end
|
175
|
+
|
176
|
+
it "should know if a document is exportable" do
|
177
|
+
doc = MockDocument.new
|
178
|
+
doc.will_export_as(:marc, "application/marc")
|
179
|
+
expect(doc.exports_as?(:marc)).to be_true
|
180
|
+
end
|
175
181
|
end
|
176
182
|
|
177
183
|
context "to_semantic_fields" do
|
@@ -254,7 +254,19 @@ describe Blacklight::SolrHelper do
|
|
254
254
|
it "should pass date-type fields through" do
|
255
255
|
blacklight_config.facet_fields.stub(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil))
|
256
256
|
|
257
|
-
expect(subject.send(:facet_value_to_fq_string, "facet_name", "2012-01-01")).to eq "facet_name:2012
|
257
|
+
expect(subject.send(:facet_value_to_fq_string, "facet_name", "2012-01-01")).to eq "facet_name:2012\\-01\\-01"
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should escape datetime-type fields" do
|
261
|
+
blacklight_config.facet_fields.stub(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil))
|
262
|
+
|
263
|
+
expect(subject.send(:facet_value_to_fq_string, "facet_name", "2003-04-09T00:00:00Z")).to eq "facet_name:2003\\-04\\-09T00\\:00\\:00Z"
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should format Date objects correctly" do
|
267
|
+
blacklight_config.facet_fields.stub(:[]).with('facet_name').and_return(double(:date => nil, :query => nil, :tag => nil))
|
268
|
+
d = DateTime.parse("2003-04-09T00:00:00")
|
269
|
+
expect(subject.send(:facet_value_to_fq_string, "facet_name", d)).to eq "facet_name:2003\\-04\\-09T00\\:00\\:00Z"
|
258
270
|
end
|
259
271
|
|
260
272
|
it "should handle range requests" do
|
@@ -463,7 +475,12 @@ describe Blacklight::SolrHelper do
|
|
463
475
|
config.add_search_field("test_field",
|
464
476
|
:display_label => "Test",
|
465
477
|
:key=>"test_field",
|
466
|
-
:solr_parameters => {
|
478
|
+
:solr_parameters => {
|
479
|
+
:qf => "fieldOne^2.3 fieldTwo fieldThree^0.4",
|
480
|
+
:pf => "",
|
481
|
+
:spellcheck => 'false',
|
482
|
+
:rows => "55",
|
483
|
+
:sort => "request_params_sort" }
|
467
484
|
)
|
468
485
|
return config
|
469
486
|
end
|
@@ -701,8 +718,10 @@ describe Blacklight::SolrHelper do
|
|
701
718
|
end
|
702
719
|
|
703
720
|
describe "get_facet_pagination", :integration => true do
|
704
|
-
before
|
705
|
-
|
721
|
+
before do
|
722
|
+
Deprecation.silence(Blacklight::SolrHelper) do
|
723
|
+
@facet_paginator = subject.get_facet_pagination(@facet_field)
|
724
|
+
end
|
706
725
|
end
|
707
726
|
it 'should return a facet paginator' do
|
708
727
|
expect(@facet_paginator).to be_a_kind_of(Blacklight::Solr::FacetPaginator)
|
@@ -1042,7 +1061,6 @@ describe Blacklight::SolrHelper do
|
|
1042
1061
|
expect(@document.id).to eq @doc_id
|
1043
1062
|
end
|
1044
1063
|
it 'should have non-nil values for required fields set in initializer' do
|
1045
|
-
expect(@document.get(blacklight_config.view_config(:show).title_field)).not_to be_nil
|
1046
1064
|
expect(@document.get(blacklight_config.view_config(:show).display_type_field)).not_to be_nil
|
1047
1065
|
end
|
1048
1066
|
end
|
@@ -1097,7 +1115,9 @@ describe Blacklight::SolrHelper do
|
|
1097
1115
|
describe "Get Document Via Search", :integration => true do
|
1098
1116
|
before do
|
1099
1117
|
@doc_row = 3
|
1100
|
-
|
1118
|
+
Deprecation.silence(Blacklight::SolrHelper) do
|
1119
|
+
@doc = subject.get_single_doc_via_search(@doc_row, :q => @all_docs_query)
|
1120
|
+
end
|
1101
1121
|
end
|
1102
1122
|
=begin
|
1103
1123
|
# can't test these here, because the method only returns the document
|
@@ -1120,13 +1140,14 @@ describe Blacklight::SolrHelper do
|
|
1120
1140
|
end
|
1121
1141
|
|
1122
1142
|
it 'should have non-nil values for required fields set in initializer' do
|
1123
|
-
expect(@doc[blacklight_config.view_config(:show).title_field]).not_to be_nil
|
1124
1143
|
expect(@doc[blacklight_config.view_config(:show).display_type_field]).not_to be_nil
|
1125
1144
|
end
|
1126
1145
|
|
1127
1146
|
it "should limit search result by facets when supplied" do
|
1128
|
-
|
1129
|
-
|
1147
|
+
Deprecation.silence(Blacklight::SolrHelper) do
|
1148
|
+
doc2 = subject.get_single_doc_via_search(@doc_row , :q => @all_docs_query, :f => @multi_facets)
|
1149
|
+
expect(doc2[:id]).not_to be_nil
|
1150
|
+
end
|
1130
1151
|
end
|
1131
1152
|
|
1132
1153
|
end
|
@@ -1239,7 +1260,7 @@ describe Blacklight::SolrHelper do
|
|
1239
1260
|
describe "#get_solr_response_for_field_values" do
|
1240
1261
|
before do
|
1241
1262
|
@mock_response = double()
|
1242
|
-
@mock_response.stub(:
|
1263
|
+
@mock_response.stub(documents: [])
|
1243
1264
|
end
|
1244
1265
|
it "should contruct a solr query based on the field and value pair" do
|
1245
1266
|
subject.should_receive(:find).with(hash_including(:q => "field_name:(value)")).and_return(@mock_response)
|