blacklight 5.11.0 → 5.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 306445f3c792d11626c44500a5b30d974c01f5df
4
- data.tar.gz: da7aa72df29cc2dd70ec8779d72928e8916d340a
3
+ metadata.gz: f5d4dba8182fcbbaa71a0f1e263c992b5ead7a54
4
+ data.tar.gz: a2ad75e6e2097d1881685a1f3e35414c885a70c0
5
5
  SHA512:
6
- metadata.gz: 01e02b3b3605264f5bb0517a6abeec089e4b2eb8d96e604572808e6f805e59dfd448cedd6c35a311d436e2753ef6cc780e0fdf4d3c64e86101a6bab38fae1173
7
- data.tar.gz: b95b6dc21666c74b2ba5c6103fc555300a559340efcc5e0b9315cf5f019c8de0d098e33d72cde8bfce43a0330fbab87d226697f6530783ebbd98dc1aa79ef586
6
+ metadata.gz: 2ec8a493c2c4e80ce27b9c901f6fb9de931d058d6a81f6dbc57ee2b54d4f1a321a13626d9df1342e430903cdf655ee1a380f38506f3e31b0af5708b23a5d2d96
7
+ data.tar.gz: 02343ff43095be1ffe760572b3cb1737dd14a38ab08178f5c3b9997fd46695895c627321dce537cc027f1c1059805ad37b5b268595077866cbad1b771f7212bf
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.11.0
1
+ 5.11.1
@@ -69,7 +69,7 @@ module Blacklight::RenderConstraintsHelperBehavior
69
69
 
70
70
  safe_join(values.map do |val|
71
71
  next if val.blank? # skip empty string
72
- render_constraint_element( facet_field_label(facet), facet_display_value(facet, val),
72
+ render_constraint_element( facet_field_label(facet_config.key), facet_display_value(facet, val),
73
73
  :remove => search_action_path(remove_facet_params(facet, val, localized_params)),
74
74
  :classes => ["filter", "filter-" + facet.parameterize]
75
75
  )
@@ -215,17 +215,19 @@ module Blacklight::UrlHelperBehavior
215
215
 
216
216
  facet_config = facet_configuration_for_field(field)
217
217
 
218
+ url_field = facet_config.key
219
+
218
220
  value = facet_value_for_facet_item(item)
219
221
 
220
222
  p = reset_search_params(source_params)
221
223
  p[:f] = (p[:f] || {}).dup # the command above is not deep in rails3, !@#$!@#$
222
- p[:f][field] = (p[:f][field] || []).dup
224
+ p[:f][url_field] = (p[:f][url_field] || []).dup
223
225
 
224
- if facet_config.single and not p[:f][field].empty?
225
- p[:f][field] = []
226
+ if facet_config.single and not p[:f][url_field].empty?
227
+ p[:f][url_field] = []
226
228
  end
227
229
 
228
- p[:f][field].push(value)
230
+ p[:f][url_field].push(value)
229
231
 
230
232
  if item and item.respond_to?(:fq) and item.fq
231
233
  item.fq.each do |f,v|
@@ -262,6 +264,10 @@ module Blacklight::UrlHelperBehavior
262
264
  field = item.field
263
265
  end
264
266
 
267
+ facet_config = facet_configuration_for_field(field)
268
+
269
+ url_field = facet_config.key
270
+
265
271
  value = facet_value_for_facet_item(item)
266
272
 
267
273
  p = reset_search_params(source_params)
@@ -269,9 +275,9 @@ module Blacklight::UrlHelperBehavior
269
275
  # if the values aren't dup'd, then the values
270
276
  # from the session will get remove in the show view...
271
277
  p[:f] = (p[:f] || {}).dup
272
- p[:f][field] = (p[:f][field] || []).dup
273
- p[:f][field] = p[:f][field] - [value]
274
- p[:f].delete(field) if p[:f][field].size == 0
278
+ p[:f][url_field] = (p[:f][url_field] || []).dup
279
+ p[:f][url_field] = p[:f][url_field] - [value]
280
+ p[:f].delete(url_field) if p[:f][url_field].size == 0
275
281
  p.delete(:f) if p[:f].empty?
276
282
  p
277
283
  end
@@ -343,6 +343,16 @@ describe BlacklightUrlHelper do
343
343
  expect(result_params[:f]["facet_field"]).to eq ["facet_value"]
344
344
  end
345
345
 
346
+ it "should use the facet's key in the url" do
347
+ allow(helper).to receive(:facet_configuration_for_field).with('some_field').and_return(double(single: true, field: "a_solr_field", key: "some_key"))
348
+
349
+ result_params = helper.add_facet_params('some_field', 'my_value', {})
350
+
351
+ expect(result_params[:f]['some_key']).to have(1).item
352
+ expect(result_params[:f]['some_key'].first).to eq 'my_value'
353
+ end
354
+
355
+
346
356
  it "should add a facet param to existing facet constraints" do
347
357
  allow(helper).to receive(:params).and_return(@params_existing_facets)
348
358
 
@@ -374,7 +384,7 @@ describe BlacklightUrlHelper do
374
384
  end
375
385
 
376
386
  it "should replace facets for facets configured as single" do
377
- allow(helper).to receive(:facet_configuration_for_field).with('single_value_facet_field').and_return(double(:single => true))
387
+ allow(helper).to receive(:facet_configuration_for_field).with('single_value_facet_field').and_return(double(single: true, key: "single_value_facet_field"))
378
388
  params = { :f => { 'single_value_facet_field' => 'other_value'}}
379
389
  allow(helper).to receive(:params).and_return params
380
390
 
@@ -441,6 +451,46 @@ describe BlacklightUrlHelper do
441
451
  expect(added_facet_params_from_facet_action).to eq added_facet_params.except(Blacklight::Solr::FacetPaginator.request_keys[:page], Blacklight::Solr::FacetPaginator.request_keys[:sort])
442
452
  end
443
453
  end
454
+
455
+ describe "#remove_facet_params" do
456
+ let(:query_params) { { f: facet_params }}
457
+ let(:facet_params) { { } }
458
+ it "should remove the facet / value tuple from the query parameters" do
459
+ facet_params['some_field'] = ['some_value', 'another_value']
460
+
461
+ params = helper.remove_facet_params('some_field', 'some_value', query_params)
462
+
463
+ expect(params[:f]['some_field']).not_to include 'some_value'
464
+ expect(params[:f]['some_field']).to include 'another_value'
465
+ end
466
+
467
+ it "should use the facet's key configuration" do
468
+ allow(helper).to receive(:facet_configuration_for_field).with('some_field').and_return(double(single: true, field: "a_solr_field", key: "some_key"))
469
+ facet_params['some_key'] = ['some_value', 'another_value']
470
+
471
+ params = helper.remove_facet_params('some_field', 'some_value', query_params)
472
+
473
+ expect(params[:f]['some_key']).not_to eq 'some_value'
474
+ expect(params[:f]['some_key']).to include 'another_value'
475
+ end
476
+
477
+ it "should remove the facet entirely when the last facet value is removed" do
478
+ facet_params['another_field'] = ['some_value']
479
+ facet_params['some_field'] = ['some_value']
480
+
481
+ params = helper.remove_facet_params('some_field', 'some_value', query_params)
482
+
483
+ expect(params[:f]).not_to include 'some_field'
484
+ end
485
+
486
+ it "should remove the 'f' parameter entirely when no facets remain" do
487
+ facet_params['some_field'] = ['some_value']
488
+
489
+ params = helper.remove_facet_params('some_field', 'some_value', query_params)
490
+
491
+ expect(params).not_to include :f
492
+ end
493
+ end
444
494
 
445
495
  describe "#bookmarks_export_url" do
446
496
  it "should be the bookmark url with an encrypted user token" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.11.0
4
+ version: 5.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -17,7 +17,7 @@ authors:
17
17
  autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
- date: 2015-03-17 00:00:00.000000000 Z
20
+ date: 2015-03-19 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails