blacklight 5.5.1 → 5.5.2
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/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +8 -16
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -1
- data/app/helpers/blacklight/url_helper_behavior.rb +5 -1
- data/app/views/catalog/_view_type_group.html.erb +1 -1
- data/blacklight.gemspec +2 -1
- data/gemfiles/rails3.gemfile +1 -1
- data/gemfiles/rails4.1.gemfile +1 -1
- data/gemfiles/rails4.gemfile +1 -1
- data/lib/blacklight/catalog.rb +0 -1
- data/lib/blacklight/solr/facet_paginator.rb +22 -10
- data/lib/generators/blacklight/install_generator.rb +1 -1
- data/spec/controllers/bookmarks_controller_spec.rb +6 -6
- data/spec/controllers/catalog_controller_spec.rb +48 -48
- data/spec/features/alternate_controller_spec.rb +3 -3
- data/spec/features/record_view_spec.rb +1 -1
- data/spec/features/search_filters_spec.rb +4 -4
- data/spec/features/search_results_spec.rb +12 -12
- data/spec/helpers/blacklight_helper_spec.rb +83 -83
- data/spec/helpers/catalog_helper_spec.rb +37 -37
- data/spec/helpers/configuration_helper_spec.rb +39 -39
- data/spec/helpers/facets_helper_spec.rb +37 -37
- data/spec/helpers/render_constraints_helper_spec.rb +6 -1
- data/spec/helpers/search_history_constraints_helper_spec.rb +9 -9
- data/spec/helpers/url_helper_spec.rb +49 -39
- data/spec/lib/blacklight/configurable_spec.rb +5 -5
- data/spec/lib/blacklight/configuration_spec.rb +8 -8
- data/spec/lib/blacklight/facet_paginator_spec.rb +25 -0
- data/spec/lib/blacklight/routes_spec.rb +4 -4
- data/spec/lib/blacklight/search_fields_spec.rb +3 -3
- data/spec/lib/blacklight/solr/document_spec.rb +2 -2
- data/spec/lib/blacklight/solr_helper_spec.rb +37 -37
- data/spec/lib/blacklight/solr_response/group_response_spec.rb +1 -1
- data/spec/lib/blacklight/solr_response_spec.rb +31 -31
- data/spec/lib/document_presenter_spec.rb +41 -41
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/models/record_mailer_spec.rb +1 -1
- data/spec/models/search_spec.rb +1 -1
- data/spec/routing/catalog_routing_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/support/include_text.rb +2 -3
- data/spec/views/catalog/_constraints.html.erb_spec.rb +7 -7
- data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_facets.html.erb_spec.rb +6 -6
- data/spec/views/catalog/_index_default.erb_spec.rb +10 -10
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +5 -5
- data/spec/views/catalog/_show_default.erb_spec.rb +10 -10
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +5 -5
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +4 -4
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +5 -2
- data/spec/views/catalog/facet.html.erb_spec.rb +5 -5
- data/spec/views/catalog/index.atom.builder_spec.rb +2 -2
- data/spec/views/catalog/index.html.erb_spec.rb +5 -5
- data/spec/views/catalog/show.html.erb_spec.rb +8 -8
- data/tasks/blacklight.rake +1 -2
- metadata +18 -4
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "Alternate Controller Behaviors" do
|
4
4
|
it "should have the correct per-page form" do
|
5
5
|
visit alternate_index_path
|
6
|
-
page.
|
6
|
+
expect(page).to have_selector("form[action='#{alternate_index_url}']")
|
7
7
|
fill_in "q", :with=>"history"
|
8
8
|
click_button 'search'
|
9
9
|
expect(current_path).to match /#{alternate_index_path}/
|
@@ -15,7 +15,7 @@ describe "Alternate Controller Behaviors" do
|
|
15
15
|
|
16
16
|
it "should have the correct search field form" do
|
17
17
|
visit alternate_index_path
|
18
|
-
page.
|
18
|
+
expect(page).to have_selector("form[action='#{alternate_index_url}']")
|
19
19
|
fill_in "q", :with=>"history"
|
20
20
|
click_button 'search'
|
21
21
|
expect(current_path).to match /#{alternate_index_path}/
|
@@ -25,7 +25,7 @@ describe "Alternate Controller Behaviors" do
|
|
25
25
|
|
26
26
|
it "should display document thumbnails" do
|
27
27
|
visit alternate_index_path
|
28
|
-
page.
|
28
|
+
expect(page).to have_selector("form[action='#{alternate_index_url}']")
|
29
29
|
fill_in "q", :with=>"history"
|
30
30
|
click_button 'search'
|
31
31
|
expect(page).to have_selector ".document-thumbnail"
|
@@ -34,7 +34,7 @@ describe "Record View" do
|
|
34
34
|
end
|
35
35
|
it "should not display 404" do
|
36
36
|
visit catalog_path('this_id_does_not_exist')
|
37
|
-
page.driver.status_code.
|
37
|
+
expect(page.driver.status_code).to eq 404
|
38
38
|
expect(page).to have_content "The page you were looking for doesn't exist."
|
39
39
|
end
|
40
40
|
end
|
@@ -167,14 +167,14 @@ describe "Facets" do
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
it "should be collapsed when not selected", :js => true do
|
170
|
-
|
170
|
+
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
171
171
|
visit root_path
|
172
172
|
within(".blacklight-subject_topic_facet") do
|
173
173
|
expect(page).not_to have_selector(".panel-collapse", :visible => true)
|
174
174
|
end
|
175
175
|
end
|
176
176
|
it "should expand when the heading is clicked", :js => true do
|
177
|
-
|
177
|
+
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
178
178
|
visit root_path
|
179
179
|
within(".blacklight-subject_topic_facet") do
|
180
180
|
expect(page).not_to have_selector(".panel-collapse", :visible => true)
|
@@ -183,7 +183,7 @@ describe "Facets" do
|
|
183
183
|
end
|
184
184
|
end
|
185
185
|
it "should expand when the anchor is clicked", :js => true do
|
186
|
-
|
186
|
+
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
187
187
|
visit root_path
|
188
188
|
within(".blacklight-subject_topic_facet") do
|
189
189
|
expect(page).not_to have_selector(".panel-collapse", :visible => true)
|
@@ -192,7 +192,7 @@ describe "Facets" do
|
|
192
192
|
end
|
193
193
|
end
|
194
194
|
it "should keep selected facets expanded on page load", :js => true do
|
195
|
-
|
195
|
+
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
196
196
|
visit root_path
|
197
197
|
within(".blacklight-subject_topic_facet") do
|
198
198
|
click_link "Topic"
|
@@ -5,33 +5,33 @@ require 'spec_helper'
|
|
5
5
|
describe "Search Results" do
|
6
6
|
it "should have for an empty query" do
|
7
7
|
search_for ''
|
8
|
-
number_of_results_from_page(page).
|
9
|
-
page.
|
8
|
+
expect(number_of_results_from_page(page)).to eq 30
|
9
|
+
expect(page).to have_xpath("//a[contains(@href, #{2007020969})]")
|
10
10
|
search_for 'korea'
|
11
|
-
number_of_results_from_page(page).
|
11
|
+
expect(number_of_results_from_page(page)).to eq 4
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should find same result set with or without diacritcs" do
|
15
15
|
search_for 'inmul'
|
16
|
-
number_of_results_from_page(page).
|
17
|
-
page.
|
16
|
+
expect(number_of_results_from_page(page)).to eq 1
|
17
|
+
expect(page).to have_xpath("//a[contains(@href, #{77826928})]")
|
18
18
|
|
19
19
|
search_for 'inmül'
|
20
|
-
number_of_results_from_page(page).
|
20
|
+
expect(number_of_results_from_page(page)).to eq 1
|
21
21
|
end
|
22
22
|
it "should find same result set for a case-insensitive query " do
|
23
23
|
search_for 'inmul'
|
24
|
-
number_of_results_from_page(page).
|
25
|
-
page.
|
24
|
+
expect(number_of_results_from_page(page)).to eq 1
|
25
|
+
expect(page).to have_xpath("//a[contains(@href, #{77826928})]")
|
26
26
|
|
27
27
|
search_for 'INMUL'
|
28
|
-
number_of_results_from_page(page).
|
28
|
+
expect(number_of_results_from_page(page)).to eq 1
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should order by relevancy" do
|
32
32
|
search_for "Korea"
|
33
|
-
position_in_result_page(page, '77826928').
|
34
|
-
position_in_result_page(page, '94120425').
|
33
|
+
expect(position_in_result_page(page, '77826928')).to eq 1
|
34
|
+
expect(position_in_result_page(page, '94120425')).to eq 2
|
35
35
|
|
36
36
|
end
|
37
37
|
|
@@ -39,7 +39,7 @@ describe "Search Results" do
|
|
39
39
|
visit root_path
|
40
40
|
tmp_value = Capybara.ignore_hidden_elements
|
41
41
|
Capybara.ignore_hidden_elements = false
|
42
|
-
page.
|
42
|
+
expect(page).to have_xpath("//link[contains(@rel, 'search')]")
|
43
43
|
expect(page.find(:xpath, "//link[contains(@rel, 'search')]")[:href]).to eq "http://www.example.com/catalog/opensearch.xml"
|
44
44
|
Capybara.ignore_hidden_elements = tmp_value
|
45
45
|
end
|
@@ -12,7 +12,7 @@ describe BlacklightHelper do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
before(:each) do
|
15
|
-
helper.
|
15
|
+
allow(helper).to receive(:search_action_path) do |*args|
|
16
16
|
catalog_index_url *args
|
17
17
|
end
|
18
18
|
end
|
@@ -23,9 +23,8 @@ describe BlacklightHelper do
|
|
23
23
|
|
24
24
|
describe "#application_name", :test => true do
|
25
25
|
it "should use the Rails application config application_name if available" do
|
26
|
-
Rails.application.config.
|
27
|
-
|
28
|
-
expect(application_name).to eq 'asdf'
|
26
|
+
allow(Rails.application).to receive(:config).and_return(double(application_name: "asdf"))
|
27
|
+
expect(application_name).to eq "asdf"
|
29
28
|
end
|
30
29
|
it "should default to 'Blacklight'" do
|
31
30
|
expect(application_name).to eq "Blacklight"
|
@@ -70,7 +69,7 @@ describe BlacklightHelper do
|
|
70
69
|
@doc_id = "MOCK_ID1"
|
71
70
|
@document = MockDocumentAppHelper.new(:id => @doc_id)
|
72
71
|
render_params = {:controller => "controller", :action => "action"}
|
73
|
-
helper.
|
72
|
+
allow(helper).to receive(:params).and_return(render_params)
|
74
73
|
end
|
75
74
|
it "generates <link rel=alternate> tags" do
|
76
75
|
|
@@ -79,7 +78,7 @@ describe BlacklightHelper do
|
|
79
78
|
tmp_value = Capybara.ignore_hidden_elements
|
80
79
|
Capybara.ignore_hidden_elements = false
|
81
80
|
@document.export_formats.each_pair do |format, spec|
|
82
|
-
response.
|
81
|
+
expect(response).to have_selector("link[href$='.#{ format }']") do |matches|
|
83
82
|
expect(matches).to have(1).match
|
84
83
|
tag = matches[0]
|
85
84
|
expect(tag.attributes["rel"].value).to eq "alternate"
|
@@ -119,10 +118,10 @@ describe BlacklightHelper do
|
|
119
118
|
end
|
120
119
|
|
121
120
|
@document = SolrDocument.new('title_display' => "A Fake Document", 'id'=>'8')
|
122
|
-
helper.
|
123
|
-
helper.
|
124
|
-
helper.
|
125
|
-
helper.
|
121
|
+
allow(helper).to receive(:blacklight_config).and_return(@config)
|
122
|
+
allow(helper).to receive(:has_user_authentication_provider?).and_return(true)
|
123
|
+
allow(helper).to receive(:current_or_guest_user).and_return(User.new)
|
124
|
+
allow(helper).to receive_messages(current_bookmarks: [])
|
126
125
|
end
|
127
126
|
describe "render_index_doc_actions" do
|
128
127
|
it "should render partials" do
|
@@ -140,43 +139,43 @@ describe BlacklightHelper do
|
|
140
139
|
|
141
140
|
describe "#should_render_index_field?" do
|
142
141
|
before do
|
143
|
-
helper.
|
142
|
+
allow(helper).to receive_messages(should_render_field?: true, document_has_value?: true)
|
144
143
|
end
|
145
144
|
|
146
145
|
it "should be true" do
|
147
|
-
expect(helper.should_render_index_field?(double, double)).to
|
146
|
+
expect(helper.should_render_index_field?(double, double)).to be true
|
148
147
|
end
|
149
148
|
|
150
149
|
it "should be false if the document doesn't have a value for the field" do
|
151
|
-
helper.
|
152
|
-
expect(helper.should_render_index_field?(double, double)).to
|
150
|
+
allow(helper).to receive_messages(document_has_value?: false)
|
151
|
+
expect(helper.should_render_index_field?(double, double)).to be false
|
153
152
|
|
154
153
|
end
|
155
154
|
|
156
155
|
it "should be false if the configuration has the field disabled" do
|
157
|
-
helper.
|
158
|
-
expect(helper.should_render_index_field?(double, double)).to
|
156
|
+
allow(helper).to receive_messages(should_render_field?: false)
|
157
|
+
expect(helper.should_render_index_field?(double, double)).to be false
|
159
158
|
end
|
160
159
|
end
|
161
160
|
|
162
161
|
describe "#should_render_show_field?" do
|
163
162
|
before do
|
164
|
-
helper.
|
163
|
+
allow(helper).to receive_messages(should_render_field?: true, document_has_value?: true)
|
165
164
|
end
|
166
165
|
|
167
166
|
it "should be true" do
|
168
|
-
expect(helper.should_render_show_field?(double, double)).to
|
167
|
+
expect(helper.should_render_show_field?(double, double)).to be true
|
169
168
|
end
|
170
169
|
|
171
170
|
it "should be false if the document doesn't have a value for the field" do
|
172
|
-
helper.
|
173
|
-
expect(helper.should_render_show_field?(double, double)).to
|
171
|
+
allow(helper).to receive_messages(document_has_value?: false)
|
172
|
+
expect(helper.should_render_show_field?(double, double)).to be false
|
174
173
|
|
175
174
|
end
|
176
175
|
|
177
176
|
it "should be false if the configuration has the field disabled" do
|
178
|
-
helper.
|
179
|
-
expect(helper.should_render_show_field?(double, double)).to
|
177
|
+
allow(helper).to receive_messages(should_render_field?: false)
|
178
|
+
expect(helper.should_render_show_field?(double, double)).to be false
|
180
179
|
end
|
181
180
|
end
|
182
181
|
|
@@ -192,65 +191,65 @@ describe BlacklightHelper do
|
|
192
191
|
config.add_index_field 'explicit_accessor', :accessor => :solr_doc_accessor
|
193
192
|
config.add_index_field 'explicit_accessor_with_arg', :accessor => :solr_doc_accessor_with_arg
|
194
193
|
end
|
195
|
-
helper.
|
194
|
+
allow(helper).to receive(:blacklight_config).and_return(@config)
|
196
195
|
end
|
197
196
|
|
198
197
|
it "should check for an explicit value" do
|
199
198
|
doc = double()
|
200
|
-
doc.
|
199
|
+
expect(doc).to_not receive(:get).with('asdf', :sep => nil)
|
201
200
|
value = helper.render_index_field_value :value => 'asdf', :document => doc, :field => 'asdf'
|
202
201
|
expect(value).to eq 'asdf'
|
203
202
|
end
|
204
203
|
|
205
204
|
it "should check for a helper method to call" do
|
206
205
|
doc = double()
|
207
|
-
doc.
|
208
|
-
helper.
|
206
|
+
allow(doc).to receive(:get).with('asdf', :sep => nil)
|
207
|
+
allow(helper).to receive(:render_asdf_index_field).and_return('custom asdf value')
|
209
208
|
value = helper.render_index_field_value :document => doc, :field => 'asdf'
|
210
209
|
expect(value).to eq 'custom asdf value'
|
211
210
|
end
|
212
211
|
|
213
212
|
it "should check for a link_to_search" do
|
214
213
|
doc = double()
|
215
|
-
doc.
|
214
|
+
allow(doc).to receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
|
216
215
|
value = helper.render_index_field_value :document => doc, :field => 'link_to_search_true'
|
217
216
|
expect(value).to eq helper.link_to("x", helper.search_action_path(:f => { :link_to_search_true => ['x'] }))
|
218
217
|
end
|
219
218
|
|
220
219
|
it "should check for a link_to_search with a field name" do
|
221
220
|
doc = double()
|
222
|
-
doc.
|
221
|
+
allow(doc).to receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
|
223
222
|
value = helper.render_index_field_value :document => doc, :field => 'link_to_search_named'
|
224
223
|
expect(value).to eq helper.link_to("x", helper.search_action_path(:f => { :some_field => ['x'] }))
|
225
224
|
end
|
226
225
|
|
227
226
|
it "should gracefully handle when no highlight field is available" do
|
228
227
|
doc = double()
|
229
|
-
doc.
|
230
|
-
doc.
|
228
|
+
expect(doc).to_not receive(:get)
|
229
|
+
allow(doc).to receive(:has_highlight_field?).and_return(false)
|
231
230
|
value = helper.render_index_field_value :document => doc, :field => 'highlight'
|
232
231
|
expect(value).to be_blank
|
233
232
|
end
|
234
233
|
|
235
234
|
it "should check for a highlighted field" do
|
236
235
|
doc = double()
|
237
|
-
doc.
|
238
|
-
doc.
|
239
|
-
doc.
|
236
|
+
expect(doc).to_not receive(:get)
|
237
|
+
allow(doc).to receive(:has_highlight_field?).and_return(true)
|
238
|
+
allow(doc).to receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
|
240
239
|
value = helper.render_index_field_value :document => doc, :field => 'highlight'
|
241
240
|
expect(value).to eq '<em>highlight</em>'
|
242
241
|
end
|
243
242
|
|
244
243
|
it "should check the document field value" do
|
245
244
|
doc = double()
|
246
|
-
doc.
|
245
|
+
allow(doc).to receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
|
247
246
|
value = helper.render_index_field_value :document => doc, :field => 'qwer'
|
248
247
|
expect(value).to eq 'document qwer value'
|
249
248
|
end
|
250
249
|
|
251
250
|
it "should work with index fields that aren't explicitly defined" do
|
252
251
|
doc = double()
|
253
|
-
doc.
|
252
|
+
allow(doc).to receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
|
254
253
|
value = helper.render_index_field_value :document => doc, :field => 'mnbv'
|
255
254
|
expect(value).to eq 'document mnbv value'
|
256
255
|
end
|
@@ -289,52 +288,52 @@ describe BlacklightHelper do
|
|
289
288
|
config.add_show_field 'explicit_accessor_with_arg', :accessor => :solr_doc_accessor_with_arg
|
290
289
|
end
|
291
290
|
|
292
|
-
helper.
|
291
|
+
allow(helper).to receive(:blacklight_config).and_return(@config)
|
293
292
|
end
|
294
293
|
|
295
294
|
it "should check for an explicit value" do
|
296
295
|
doc = double()
|
297
|
-
doc.
|
298
|
-
helper.
|
296
|
+
expect(doc).to_not receive(:get).with('asdf', :sep => nil)
|
297
|
+
expect(helper).to_not receive(:render_asdf_document_show_field)
|
299
298
|
value = helper.render_document_show_field_value :value => 'asdf', :document => doc, :field => 'asdf'
|
300
299
|
expect(value).to eq 'asdf'
|
301
300
|
end
|
302
301
|
|
303
302
|
it "should check for a helper method to call" do
|
304
303
|
doc = double()
|
305
|
-
doc.
|
306
|
-
helper.
|
304
|
+
allow(doc).to receive(:get).with('asdf', :sep => nil)
|
305
|
+
allow(helper).to receive(:render_asdf_document_show_field).and_return('custom asdf value')
|
307
306
|
value = helper.render_document_show_field_value :document => doc, :field => 'asdf'
|
308
307
|
expect(value).to eq 'custom asdf value'
|
309
308
|
end
|
310
309
|
|
311
310
|
it "should check for a link_to_search" do
|
312
311
|
doc = double()
|
313
|
-
doc.
|
312
|
+
allow(doc).to receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
|
314
313
|
value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_true'
|
315
314
|
expect(value).to eq helper.link_to("x", helper.search_action_path(:f => { :link_to_search_true => ['x'] }))
|
316
315
|
end
|
317
316
|
|
318
317
|
it "should check for a link_to_search with a field name" do
|
319
318
|
doc = double()
|
320
|
-
doc.
|
319
|
+
allow(doc).to receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
|
321
320
|
value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_named'
|
322
321
|
expect(value).to eq helper.link_to("x", helper.search_action_path(:f => { :some_field => ['x'] }))
|
323
322
|
end
|
324
323
|
|
325
324
|
it "should gracefully handle when no highlight field is available" do
|
326
325
|
doc = double()
|
327
|
-
doc.
|
328
|
-
doc.
|
326
|
+
expect(doc).to_not receive(:get)
|
327
|
+
allow(doc).to receive(:has_highlight_field?).and_return(false)
|
329
328
|
value = helper.render_document_show_field_value :document => doc, :field => 'highlight'
|
330
329
|
expect(value).to be_blank
|
331
330
|
end
|
332
331
|
|
333
332
|
it "should check for a highlighted field" do
|
334
333
|
doc = double()
|
335
|
-
doc.
|
336
|
-
doc.
|
337
|
-
doc.
|
334
|
+
expect(doc).to_not receive(:get)
|
335
|
+
allow(doc).to receive(:has_highlight_field?).and_return(true)
|
336
|
+
allow(doc).to receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
|
338
337
|
value = helper.render_document_show_field_value :document => doc, :field => 'highlight'
|
339
338
|
expect(value).to eq '<em>highlight</em>'
|
340
339
|
end
|
@@ -342,14 +341,14 @@ describe BlacklightHelper do
|
|
342
341
|
|
343
342
|
it "should check the document field value" do
|
344
343
|
doc = double()
|
345
|
-
doc.
|
344
|
+
allow(doc).to receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
|
346
345
|
value = helper.render_document_show_field_value :document => doc, :field => 'qwer'
|
347
346
|
expect(value).to eq 'document qwer value'
|
348
347
|
end
|
349
348
|
|
350
349
|
it "should work with show fields that aren't explicitly defined" do
|
351
350
|
doc = double()
|
352
|
-
doc.
|
351
|
+
allow(doc).to receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
|
353
352
|
value = helper.render_document_show_field_value :document => doc, :field => 'mnbv'
|
354
353
|
expect(value).to eq 'document mnbv value'
|
355
354
|
end
|
@@ -383,38 +382,38 @@ describe BlacklightHelper do
|
|
383
382
|
describe "#document_has_value?" do
|
384
383
|
it "should if the document has the field value" do
|
385
384
|
doc = double()
|
386
|
-
doc.
|
385
|
+
allow(doc).to receive(:has?).with('asdf').and_return(true)
|
387
386
|
field_config = double(:field => 'asdf')
|
388
|
-
helper.document_has_value?(doc, field_config).
|
387
|
+
expect(helper.document_has_value?(doc, field_config)).to eq true
|
389
388
|
end
|
390
389
|
|
391
390
|
it "should if the document has a highlight field value" do
|
392
391
|
doc = double()
|
393
|
-
doc.
|
394
|
-
doc.
|
392
|
+
allow(doc).to receive(:has?).with('asdf').and_return(false)
|
393
|
+
allow(doc).to receive(:has_highlight_field?).with('asdf').and_return(true)
|
395
394
|
field_config = double(:field => 'asdf', :highlight => true)
|
396
|
-
helper.document_has_value?(doc, field_config).
|
395
|
+
expect(helper.document_has_value?(doc, field_config)).to eq true
|
397
396
|
end
|
398
397
|
|
399
398
|
it "should if the field has a model accessor" do
|
400
399
|
doc = double()
|
401
|
-
doc.
|
402
|
-
doc.
|
400
|
+
allow(doc).to receive(:has?).with('asdf').and_return(false)
|
401
|
+
allow(doc).to receive(:has_highlight_field?).with('asdf').and_return(false)
|
403
402
|
field_config = double(:field => 'asdf', :highlight => true, :accessor => true)
|
404
|
-
helper.document_has_value?(doc, field_config).
|
403
|
+
expect(helper.document_has_value?(doc, field_config)).to eq true
|
405
404
|
end
|
406
405
|
end
|
407
406
|
|
408
407
|
describe "render_grouped_response?" do
|
409
408
|
it "should check if the response ivar contains grouped data" do
|
410
409
|
assign(:response, double("SolrResponse", :grouped? => true))
|
411
|
-
expect(helper.render_grouped_response?).to
|
410
|
+
expect(helper.render_grouped_response?).to be true
|
412
411
|
end
|
413
412
|
|
414
413
|
|
415
414
|
it "should check if the response param contains grouped data" do
|
416
415
|
response = double("SolrResponse", :grouped? => true)
|
417
|
-
expect(helper.render_grouped_response?(response)).to
|
416
|
+
expect(helper.render_grouped_response?(response)).to be true
|
418
417
|
end
|
419
418
|
end
|
420
419
|
|
@@ -424,14 +423,14 @@ describe BlacklightHelper do
|
|
424
423
|
|
425
424
|
describe "render_field_value" do
|
426
425
|
before do
|
427
|
-
Deprecation.
|
426
|
+
allow(Deprecation).to receive(:warn)
|
428
427
|
end
|
429
428
|
it "should join and html-safe values" do
|
430
429
|
expect(helper.render_field_value(['a', 'b'])).to eq "a, b"
|
431
430
|
end
|
432
431
|
|
433
432
|
it "should join values using the field_value_separator" do
|
434
|
-
helper.
|
433
|
+
allow(helper).to receive(:field_value_separator).and_return(" -- ")
|
435
434
|
expect(helper.render_field_value(['a', 'b'])).to eq "a -- b"
|
436
435
|
end
|
437
436
|
|
@@ -446,40 +445,40 @@ describe BlacklightHelper do
|
|
446
445
|
|
447
446
|
describe "should_show_spellcheck_suggestions?" do
|
448
447
|
before :each do
|
449
|
-
helper.
|
448
|
+
allow(helper).to receive_messages spell_check_max: 5
|
450
449
|
end
|
451
450
|
it "should not show suggestions if there are enough results" do
|
452
451
|
response = double(total: 10)
|
453
|
-
expect(helper.should_show_spellcheck_suggestions? response).to
|
452
|
+
expect(helper.should_show_spellcheck_suggestions? response).to be false
|
454
453
|
end
|
455
454
|
|
456
455
|
it "should only show suggestions if there are very few results" do
|
457
456
|
response = double(total: 4, spelling: double(words: [1]))
|
458
|
-
expect(helper.should_show_spellcheck_suggestions? response).to
|
457
|
+
expect(helper.should_show_spellcheck_suggestions? response).to be true
|
459
458
|
end
|
460
459
|
|
461
460
|
it "should show suggestions only if there are spelling suggestions available" do
|
462
461
|
response = double(total: 4, spelling: double(words: []))
|
463
|
-
expect(helper.should_show_spellcheck_suggestions? response).to
|
462
|
+
expect(helper.should_show_spellcheck_suggestions? response).to be false
|
464
463
|
end
|
465
464
|
end
|
466
465
|
|
467
466
|
describe "#render_document_partials" do
|
468
467
|
let(:doc) { double }
|
469
468
|
before do
|
470
|
-
helper.
|
469
|
+
allow(helper).to receive_messages(document_partial_path_templates: [])
|
471
470
|
end
|
472
471
|
|
473
472
|
it "should get the document format from document_partial_name" do
|
474
|
-
helper.
|
473
|
+
allow(helper).to receive(:document_partial_name).with(doc, :xyz)
|
475
474
|
helper.render_document_partial(doc, :xyz)
|
476
475
|
end
|
477
476
|
|
478
477
|
context "with a 1-arg form of document_partial_name" do
|
479
478
|
it "should only call the 1-arg form of the document_partial_name" do
|
480
|
-
helper.
|
481
|
-
helper.
|
482
|
-
Deprecation.
|
479
|
+
allow(helper).to receive(:method).with(:document_partial_name).and_return(double(arity: 1))
|
480
|
+
allow(helper).to receive(:document_partial_name).with(doc)
|
481
|
+
allow(Deprecation).to receive(:warn)
|
483
482
|
helper.render_document_partial(doc, nil)
|
484
483
|
end
|
485
484
|
end
|
@@ -489,7 +488,7 @@ describe BlacklightHelper do
|
|
489
488
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
490
489
|
|
491
490
|
before do
|
492
|
-
helper.
|
491
|
+
allow(helper).to receive_messages(blacklight_config: blacklight_config)
|
493
492
|
end
|
494
493
|
|
495
494
|
context "with a solr document with empty fields" do
|
@@ -573,24 +572,25 @@ describe BlacklightHelper do
|
|
573
572
|
|
574
573
|
describe "#render_document_index" do
|
575
574
|
it "should render the document index with the current view type" do
|
576
|
-
helper.
|
577
|
-
helper.
|
575
|
+
allow(helper).to receive_messages(document_index_view_type: :current_view)
|
576
|
+
allow(helper).to receive(:render_document_index_with_view).with(:current_view, [], a: 1, b: 2)
|
578
577
|
helper.render_document_index [], a: 1, b: 2
|
579
578
|
end
|
580
579
|
end
|
581
580
|
|
582
581
|
describe "#render_document_index_with_view" do
|
582
|
+
let(:obj1) { SolrDocument.new }
|
583
|
+
|
584
|
+
before do
|
585
|
+
allow(helper).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
|
586
|
+
assign(:response, double("SolrResponse", grouped?: false, params: {}))
|
587
|
+
allow(helper).to receive(:link_to_document).and_return('<a/>')
|
588
|
+
allow(helper).to receive(:render_index_doc_actions).and_return('<div/>')
|
589
|
+
end
|
590
|
+
|
583
591
|
it "should ignore missing templates" do
|
584
|
-
helper.
|
585
|
-
|
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"
|
592
|
+
response = helper.render_document_index_with_view :view_type, [obj1, obj1]
|
593
|
+
expect(response).to match /<div id="documents">/
|
594
594
|
end
|
595
595
|
end
|
596
596
|
end
|