blacklight 5.11.2 → 5.11.3

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: fbed788b9563305a5fdc48a4d8c24b8a96387e6b
4
- data.tar.gz: 0bd82d604396b69091d6f50fba853f2af67f06aa
3
+ metadata.gz: d66f63cc8f730572a615a21e6e02c6f2bec32a04
4
+ data.tar.gz: 0e0a72eaec2d8ac932f37c96cff9c3482e1c884d
5
5
  SHA512:
6
- metadata.gz: ef476787e4c81ac178e2ed8f2c86bcac92709d023e1a241d0581b30e39196b0d687df4979aa749077c61c9a65d97f0b2fb391e9feb8dee087a9a6fd4ef9af6e2
7
- data.tar.gz: c5e5be39ab6a4e978d550ae344a6aa543d633f65f1ca74f04310c91984b321db9f4e7a9a433ce7e8bb7325919b80106d2d6c99474212d00411ecd2670492f4ea
6
+ metadata.gz: 2cfd5cd4a3c90a7f88aace8b30f706adc7a932ae8f1b49f30464051fddaf35cc48de2259c307d6501d4e555c934c4196ed5a841cac232d97cca1322ea1c146fb
7
+ data.tar.gz: 87e32807796642701f8891a2fb8c2ae6027bc8fc1b24d9e2dc1e3fe66387c6c4710af5ae306e0ef2bf3258b3f055ceb8d915729c4b9b1d35c53c35979cb103ca
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.11.2
1
+ 5.11.3
@@ -118,7 +118,7 @@ module Blacklight::ConfigurationHelperBehavior
118
118
  # @param [Symbol] any number of additional keys
119
119
  # @param [Symbol] ...
120
120
  def field_label *i18n_keys
121
- first, *rest = i18n_keys
121
+ first, *rest = i18n_keys.compact
122
122
 
123
123
  t(first, default: rest)
124
124
  end
@@ -82,10 +82,15 @@ module Blacklight::UrlHelperBehavior
82
82
  return {}
83
83
  end
84
84
 
85
- { :data => {:'context-href' => track_solr_document_path(document, per_page: params.fetch(:per_page, search_session['per_page']), counter: counter, search_id: current_search_session.try(:id))}}
85
+ { :data => {:'context-href' => session_tracking_path(document, per_page: params.fetch(:per_page, search_session['per_page']), counter: counter, search_id: current_search_session.try(:id))}}
86
86
  end
87
87
  protected :session_tracking_params
88
88
 
89
+ ##
90
+ # Get the URL for tracking search sessions across pages using polymorphic routing
91
+ def session_tracking_path document, params = {}
92
+ polymorphic_path([:track, document], params)
93
+ end
89
94
 
90
95
  #
91
96
  # link based helpers ->
@@ -19,7 +19,7 @@
19
19
 
20
20
  </div>
21
21
  <% @documents.each do |doc| %>
22
- <%=hidden_field_tag "id[]", doc.get(:id)%>
22
+ <%=hidden_field_tag "id[]", doc.id %>
23
23
  <% end %>
24
24
  </div>
25
25
  <div class="modal-footer">
@@ -5,7 +5,7 @@ module Blacklight
5
5
 
6
6
  self.collapse = true if self.collapse.nil?
7
7
  self.show = true if self.show.nil?
8
- self.if ||= self.show
8
+ self.if = self.show if self.if.nil?
9
9
 
10
10
  super
11
11
 
@@ -1,7 +1,7 @@
1
1
  module Blacklight
2
2
  class Configuration::SearchField < Blacklight::Configuration::Field
3
3
  def normalize! blacklight_config = nil
4
- self.if ||= self.include_in_simple_select
4
+ self.if = self.include_in_simple_select if self.if.nil?
5
5
 
6
6
  super
7
7
  self.qt ||= blacklight_config.default_solr_params[:qt] if blacklight_config && blacklight_config.default_solr_params
@@ -31,7 +31,7 @@ module Blacklight::Document
31
31
  include Blacklight::Document::Extensions
32
32
  end
33
33
 
34
- attr_reader :response
34
+ attr_reader :response, :_source
35
35
  alias_method :solr_response, :response
36
36
 
37
37
  def initialize(source_doc={}, response=nil)
@@ -52,11 +52,19 @@ module Blacklight::Document
52
52
  # If a method is missing, it gets sent to @_source
53
53
  # with all of the original params and block
54
54
  def method_missing(m, *args, &b)
55
- @_source.send(m, *args, &b)
55
+ if _source and _source.respond_to? m
56
+ _source.send(m, *args, &b)
57
+ else
58
+ super
59
+ end
60
+ end
61
+
62
+ def respond_to_missing? *args
63
+ (_source && _source.respond_to?(*args)) || super
56
64
  end
57
65
 
58
66
  def [] *args
59
- @_source.send :[], *args
67
+ _source.send :[], *args
60
68
  end
61
69
 
62
70
  def _read_attribute(attr)
@@ -85,7 +93,7 @@ module Blacklight::Document
85
93
  end
86
94
 
87
95
  def key? k
88
- @_source.key? k
96
+ _source.key? k
89
97
  end
90
98
 
91
99
  # helper
@@ -116,7 +124,7 @@ module Blacklight::Document
116
124
  end
117
125
 
118
126
  def as_json(options = nil)
119
- @_source.as_json(options)
127
+ _source.as_json(options)
120
128
  end
121
129
 
122
130
  def to_partial_path
@@ -139,6 +147,12 @@ module Blacklight::Document
139
147
  nil
140
148
  end
141
149
 
150
+ ##
151
+ # Implementations that support More-Like-This should override this method
152
+ # to return an array of documents that are like this one.
153
+ def more_like_this
154
+ []
155
+ end
142
156
 
143
157
  # Certain class-level methods needed for the document-specific
144
158
  # extendability architecture
@@ -159,6 +159,13 @@ describe BlacklightConfigurationHelper do
159
159
 
160
160
  label = helper.field_label :key_a, :key_b, "default text"
161
161
  end
162
+
163
+ it "should compact nil keys (fixes rails/rails#19419)" do
164
+ allow(helper).to receive(:t).with(:key_a, default: [:key_b])
165
+
166
+ label = helper.field_label :key_a, nil, :key_b
167
+
168
+ end
162
169
  end
163
170
 
164
171
  describe "#default_per_page" do
@@ -499,4 +499,15 @@ describe BlacklightUrlHelper do
499
499
  expect(url).to eq helper.bookmarks_url(format: :html, encrypted_user_id: 'xyz')
500
500
  end
501
501
  end
502
+
503
+ describe "#session_tracking_path" do
504
+ let(:document) { SolrDocument.new(id: 1) }
505
+ it "should determine the correct route for the document class" do
506
+ expect(helper.session_tracking_path(document)).to eq helper.track_solr_document_path(document)
507
+ end
508
+
509
+ it "should pass through tracking parameters" do
510
+ expect(helper.session_tracking_path(document, x: 1)).to eq helper.track_solr_document_path(document, x: 1)
511
+ end
512
+ end
502
513
  end
@@ -213,11 +213,25 @@ describe "Blacklight::Configuration" do
213
213
  "another_field_facet" => {},
214
214
  "a_facet_field" => {},
215
215
  })
216
- expect { |b| @config.add_index_field "*_facet", &b }.to yield_control.twice
217
-
218
- expect(@config.index_fields.keys).to eq ["some_field_facet", "another_field_facet"]
216
+ expect { |b| @config.add_facet_field "*_facet", &b }.to yield_control.twice
217
+ expect(@config.facet_fields.keys).to eq ["some_field_facet", "another_field_facet"]
219
218
  end
220
219
 
220
+ describe "if/unless conditions with legacy show parameter" do
221
+ it "should be hidden if the if condition is false" do
222
+ expect(@config.add_facet_field("hidden", if: false).if).to eq false
223
+ expect(@config.add_facet_field("hidden_with_legacy", if: false, show: true).if).to eq false
224
+ end
225
+
226
+ it "should be true if the if condition is true" do
227
+ expect(@config.add_facet_field("hidden", if: true).if).to eq true
228
+ expect(@config.add_facet_field("hidden_with_legacy", if: true, show: false).if).to eq true
229
+ end
230
+
231
+ it "should be true if the if condition is missing" do
232
+ expect(@config.add_facet_field("hidden", show: true).if).to eq true
233
+ end
234
+ end
221
235
  end
222
236
 
223
237
  describe "add_index_field" do
@@ -261,7 +275,6 @@ describe "Blacklight::Configuration" do
261
275
 
262
276
  expect(@config.index_fields.keys).to eq ["some_field_display", "another_field_display"]
263
277
  end
264
-
265
278
  end
266
279
 
267
280
  describe "add_show_field" do
@@ -370,8 +383,22 @@ describe "Blacklight::Configuration" do
370
383
 
371
384
  expect(@config.search_fields["author_name"].label).to eq "Author Name"
372
385
  end
373
-
374
-
386
+
387
+ describe "if/unless conditions with legacy include_in_simple_search" do
388
+ it "should be hidden if the if condition is false" do
389
+ expect(@config.add_search_field("hidden", if: false).if).to eq false
390
+ expect(@config.add_search_field("hidden_with_legacy", if: false, include_in_simple_search: true).if).to eq false
391
+ end
392
+
393
+ it "should be true if the if condition is true" do
394
+ expect(@config.add_search_field("hidden", if: true).if).to eq true
395
+ expect(@config.add_search_field("hidden_with_legacy", if: true, include_in_simple_search: false).if).to eq true
396
+ end
397
+
398
+ it "should be true if the if condition is missing" do
399
+ expect(@config.add_search_field("hidden", include_in_simple_search: true).if).to eq true
400
+ end
401
+ end
375
402
  end
376
403
 
377
404
  describe "add_sort_field" 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.2
4
+ version: 5.11.3
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-20 00:00:00.000000000 Z
20
+ date: 2015-03-26 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails