blacklight 6.15.0 → 6.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +4 -4
- data/app/assets/javascripts/blacklight/checkbox_submit.js +0 -2
- data/app/controllers/concerns/blacklight/controller.rb +4 -0
- data/app/presenters/blacklight/index_presenter.rb +12 -4
- data/app/presenters/blacklight/show_presenter.rb +11 -2
- data/app/views/catalog/_facet_layout.html.erb +1 -1
- data/app/views/catalog/_index_default.html.erb +3 -3
- data/app/views/catalog/_per_page_widget.html.erb +1 -1
- data/app/views/catalog/_show_default.html.erb +1 -1
- data/app/views/catalog/_sort_widget.html.erb +1 -1
- data/spec/presenters/index_presenter_spec.rb +94 -62
- data/spec/presenters/show_presenter_spec.rb +113 -78
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 63001a68b4ad9bebe9b5d93dfcd5efc8b8e519353c9850d5ebfcb7c42128bab4
|
4
|
+
data.tar.gz: ffc3ded7e79c7f50a8c5147ec3cf2df3d99cb6127b3febf154c456f10a6923a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d47c5102ac6643bf0e4d566a5640409b106f94acf3b51b4a8a75005809a7fbfa6e1b15eedb99d120129e18e0afbeaf106227747b0fee194da55687e23784177
|
7
|
+
data.tar.gz: 9710b7761291373f725c866d8187e862be11053b50d84745442fb6acb9d826c0946a62f8f7fbae7cae7a8e32101b5eaf205ed7e7d2d7335257f512f2734a7e52
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.
|
1
|
+
6.16.0
|
@@ -5,13 +5,13 @@
|
|
5
5
|
//
|
6
6
|
// These javascript files are compiled in via the Rails asset pipeline:
|
7
7
|
//= require blacklight/core
|
8
|
-
//= require blacklight/
|
8
|
+
//= require blacklight/autocomplete
|
9
9
|
//= require blacklight/bookmark_toggle
|
10
|
-
//= require blacklight/ajax_modal
|
11
|
-
//= require blacklight/search_context
|
12
10
|
//= require blacklight/collapsable
|
13
11
|
//= require blacklight/facet_load
|
14
|
-
//= require blacklight/
|
12
|
+
//= require blacklight/ajax_modal
|
13
|
+
//= require blacklight/search_context
|
14
|
+
//= require blacklight/autofocus
|
15
15
|
//
|
16
16
|
//Bootstrap JS for providing collapsable tablet/mobile menu/alert boxes
|
17
17
|
//= require bootstrap/transition
|
@@ -97,7 +97,6 @@
|
|
97
97
|
data: form.serialize(),
|
98
98
|
error: function() {
|
99
99
|
alert("Error");
|
100
|
-
update_state_for(checked);
|
101
100
|
label.removeAttr("disabled");
|
102
101
|
checkbox.removeAttr("disabled");
|
103
102
|
},
|
@@ -112,7 +111,6 @@
|
|
112
111
|
options.success.call(form, checked, xhr.responseJSON);
|
113
112
|
} else {
|
114
113
|
alert("Error");
|
115
|
-
update_state_for(checked);
|
116
114
|
label.removeAttr("disabled");
|
117
115
|
checkbox.removeAttr("disabled");
|
118
116
|
}
|
@@ -133,6 +133,10 @@ module Blacklight::Controller
|
|
133
133
|
def discard_flash_if_xhr
|
134
134
|
flash.discard if request.xhr?
|
135
135
|
end
|
136
|
+
deprecation_deprecate discard_flash_if_xhr: "Discarding flash messages on XHR requests is deprecated.
|
137
|
+
If you wish to continue this behavior, add this method to your ApplicationController with an
|
138
|
+
after_action :discard_flash_if_xhr filter. To disable this behavior now and remove this warning, add
|
139
|
+
a skip_after_action :discard_flash_if_xhr to your ApplicationController."
|
136
140
|
|
137
141
|
##
|
138
142
|
#
|
@@ -48,12 +48,20 @@ module Blacklight
|
|
48
48
|
#
|
49
49
|
# Allow an extention point where information in the document
|
50
50
|
# may drive the value of the field
|
51
|
-
# @param [String]
|
51
|
+
# @param [Configuration::Field, String] field_or_name
|
52
52
|
# @param [Hash] options
|
53
53
|
# @option options [String] :value
|
54
|
-
def field_value
|
55
|
-
|
56
|
-
|
54
|
+
def field_value field_or_name, options = {}
|
55
|
+
field = case field_or_name
|
56
|
+
when String
|
57
|
+
Deprecation.warn(self, "You provided a String value to IndexPresenter#field_value " \
|
58
|
+
"Provide a Blacklight::Configuration::Field instead. field_value() will not accept " \
|
59
|
+
"strings in Blacklight 7")
|
60
|
+
field_config(field_or_name)
|
61
|
+
else
|
62
|
+
field_or_name
|
63
|
+
end
|
64
|
+
field_values(field, options)
|
57
65
|
end
|
58
66
|
|
59
67
|
# @deprecated
|
@@ -74,10 +74,19 @@ module Blacklight
|
|
74
74
|
#
|
75
75
|
# Allow an extention point where information in the document
|
76
76
|
# may drive the value of the field
|
77
|
-
# @param [String]
|
77
|
+
# @param [Configuration::Field, String] field_or_name
|
78
78
|
# @param [Hash] options
|
79
79
|
# @option options [String] :value
|
80
|
-
def field_value
|
80
|
+
def field_value field_or_name, options={}
|
81
|
+
field = case field_or_name
|
82
|
+
when String
|
83
|
+
Deprecation.warn(self, "You provided a String value to ShowPresenter#field_value " \
|
84
|
+
"Provide a Blacklight::Configuration::Field instead. field_value() will not accept " \
|
85
|
+
"strings in Blacklight 7")
|
86
|
+
field_config(field_or_name)
|
87
|
+
else
|
88
|
+
field_or_name
|
89
|
+
end
|
81
90
|
field_values(field_config(field), options)
|
82
91
|
end
|
83
92
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div class="panel panel-default facet_limit blacklight-<%= facet_field.key.parameterize %> <%= 'facet_limit-active' if facet_field_in_params?(facet_field.key) %>">
|
2
|
-
<div class="<%= "collapsed" if should_collapse_facet?(facet_field) %> collapse-toggle panel-heading" data-toggle="collapse" data-target="#<%= facet_field_id(facet_field) %>">
|
2
|
+
<div class="<%= "collapsed" if should_collapse_facet?(facet_field) %> collapse-toggle panel-heading" aria-expanded="false" data-toggle="collapse" data-target="#<%= facet_field_id(facet_field) %>">
|
3
3
|
<h3 class="panel-title facet-field-heading">
|
4
4
|
<%= link_to facet_field_label(facet_field.key), "#", :"data-turbolinks" => false, :"data-no-turbolink" => true %>
|
5
5
|
</h3>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<% doc_presenter = index_presenter(document) %>
|
1
|
+
<% doc_presenter = index_presenter(document) %>
|
2
2
|
<%# default partial to display solr document fields in catalog index view -%>
|
3
3
|
<dl class="document-metadata dl-horizontal dl-invert">
|
4
|
-
|
4
|
+
|
5
5
|
<% index_fields(document).each do |field_name, field| -%>
|
6
6
|
<% if should_render_index_field? document, field %>
|
7
7
|
<dt class="blacklight-<%= field_name.parameterize %>"><%= render_index_field_label document, field: field_name %></dt>
|
8
|
-
<dd class="blacklight-<%= field_name.parameterize %>"><%= doc_presenter.field_value
|
8
|
+
<dd class="blacklight-<%= field_name.parameterize %>"><%= doc_presenter.field_value field %></dd>
|
9
9
|
<% end -%>
|
10
10
|
<% end -%>
|
11
11
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<span class="sr-only"><%= t('blacklight.search.per_page.title') %></span>
|
4
4
|
<div id="per_page-dropdown" class="btn-group">
|
5
|
-
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
5
|
+
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
6
6
|
<%= t(:'blacklight.search.per_page.button_label', :count => current_per_page) %> <span class="caret"></span>
|
7
7
|
</button>
|
8
8
|
<ul class="dropdown-menu" role="menu">
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<% document_show_fields(document).each do |field_name, field| -%>
|
5
5
|
<% if should_render_show_field? document, field %>
|
6
6
|
<dt class="blacklight-<%= field_name.parameterize %>"><%= render_document_show_field_label document, field: field_name %></dt>
|
7
|
-
<dd class="blacklight-<%= field_name.parameterize %>"><%= doc_presenter.field_value
|
7
|
+
<dd class="blacklight-<%= field_name.parameterize %>"><%= doc_presenter.field_value field %></dd>
|
8
8
|
<% end -%>
|
9
9
|
<% end -%>
|
10
10
|
</dl>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% if show_sort_and_per_page? and active_sort_fields.many? %>
|
2
2
|
<div id="sort-dropdown" class="btn-group">
|
3
|
-
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
3
|
+
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
4
4
|
<%= t('blacklight.search.sort.label', :field =>sort_field_label(current_sort_field.key)) %> <span class="caret"></span>
|
5
5
|
</button>
|
6
6
|
|
@@ -16,103 +16,136 @@ describe Blacklight::IndexPresenter do
|
|
16
16
|
SolrDocument.new(id: 1,
|
17
17
|
'link_to_search_true' => 'x',
|
18
18
|
'link_to_search_named' => 'x',
|
19
|
-
'qwer' => 'document qwer value'
|
20
|
-
'mnbv' => 'document mnbv value')
|
19
|
+
'qwer' => 'document qwer value')
|
21
20
|
end
|
22
21
|
|
23
22
|
before do
|
24
23
|
allow(request_context).to receive(:search_state).and_return(search_state)
|
25
24
|
end
|
26
25
|
|
27
|
-
describe
|
26
|
+
describe '#field_value' do
|
27
|
+
subject { presenter.field_value field }
|
28
|
+
|
29
|
+
let(:field) { config.index_fields[field_name] }
|
30
|
+
let(:field_name) { 'asdf' }
|
28
31
|
let(:config) do
|
29
32
|
Blacklight::Configuration.new.configure do |config|
|
30
33
|
config.add_index_field 'qwer'
|
31
|
-
config.add_index_field 'asdf', :
|
32
|
-
config.add_index_field 'link_to_search_true', :
|
33
|
-
config.add_index_field 'link_to_search_named', :
|
34
|
-
config.add_index_field 'highlight', :
|
35
|
-
config.add_index_field 'solr_doc_accessor', :
|
36
|
-
config.add_index_field 'explicit_accessor', :
|
37
|
-
config.add_index_field 'explicit_accessor_with_arg', :accessor => :solr_doc_accessor_with_arg
|
34
|
+
config.add_index_field 'asdf', helper_method: :render_asdf_index_field
|
35
|
+
config.add_index_field 'link_to_search_true', link_to_search: true
|
36
|
+
config.add_index_field 'link_to_search_named', link_to_search: :some_field
|
37
|
+
config.add_index_field 'highlight', highlight: true
|
38
|
+
config.add_index_field 'solr_doc_accessor', accessor: true
|
39
|
+
config.add_index_field 'explicit_accessor', accessor: :solr_doc_accessor
|
38
40
|
config.add_index_field 'alias', field: 'qwer'
|
39
41
|
config.add_index_field 'with_default', default: 'value'
|
40
42
|
end
|
41
43
|
end
|
42
|
-
it "checks for an explicit value" do
|
43
|
-
value = subject.field_value 'asdf', :value => 'asdf'
|
44
|
-
expect(value).to eq 'asdf'
|
45
|
-
end
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
context 'when a name is provided' do
|
46
|
+
subject { presenter.field_value 'qwer' }
|
47
|
+
|
48
|
+
it 'raises a deprecation' do
|
49
|
+
expect(Deprecation).to receive(:warn)
|
50
|
+
expect(subject).to eq 'document qwer value'
|
51
|
+
end
|
51
52
|
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
expect(value).to eq 'bar'
|
54
|
+
context 'when an explicit value is provided' do
|
55
|
+
subject { presenter.field_value field, value: 'asdf' }
|
56
|
+
|
57
|
+
it { is_expected.to eq 'asdf' }
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
context 'when field has a helper method' do
|
61
|
+
before do
|
62
|
+
allow(request_context).to receive(:render_asdf_index_field).and_return('custom asdf value')
|
63
|
+
end
|
64
|
+
|
65
|
+
it { is_expected.to eq 'custom asdf value' }
|
65
66
|
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
context 'when field has link_to_search with true' do
|
69
|
+
before do
|
70
|
+
allow(request_context).to receive(:search_action_path).with('f' => { 'link_to_search_true' => ['x'] }).and_return('/foo')
|
71
|
+
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
|
72
|
+
end
|
73
|
+
|
74
|
+
let(:field_name) { 'link_to_search_true' }
|
75
|
+
|
76
|
+
it { is_expected.to eq 'bar' }
|
71
77
|
end
|
72
78
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
79
|
+
context 'when field has link_to_search with a field name' do
|
80
|
+
before do
|
81
|
+
allow(request_context).to receive(:search_action_path).with('f' => { 'some_field' => ['x'] }).and_return('/foo')
|
82
|
+
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
|
83
|
+
end
|
84
|
+
|
85
|
+
let(:field_name) { 'link_to_search_named' }
|
86
|
+
|
87
|
+
it { is_expected.to eq 'bar' }
|
78
88
|
end
|
79
89
|
|
80
|
-
|
81
|
-
|
82
|
-
|
90
|
+
context 'when no highlight field is available' do
|
91
|
+
before do
|
92
|
+
allow(document).to receive(:has_highlight_field?).and_return(false)
|
93
|
+
end
|
94
|
+
|
95
|
+
let(:field_name) { 'highlight' }
|
96
|
+
|
97
|
+
it { is_expected.to be_blank }
|
83
98
|
end
|
84
99
|
|
85
|
-
|
86
|
-
|
87
|
-
|
100
|
+
context 'when highlight field is available' do
|
101
|
+
before do
|
102
|
+
allow(document).to receive(:has_highlight_field?).and_return(true)
|
103
|
+
allow(document).to receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
|
104
|
+
end
|
105
|
+
|
106
|
+
let(:field_name) { 'highlight' }
|
107
|
+
|
108
|
+
it { is_expected.to eq '<em>highlight</em>' }
|
88
109
|
end
|
89
110
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
111
|
+
context 'when no options are provided' do
|
112
|
+
let(:field_name) { 'qwer' }
|
113
|
+
|
114
|
+
it "checks the document field value" do
|
115
|
+
expect(subject).to eq 'document qwer value'
|
116
|
+
end
|
94
117
|
end
|
95
118
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
119
|
+
context 'when accessor is true' do
|
120
|
+
before do
|
121
|
+
allow(document).to receive_messages(solr_doc_accessor: "123")
|
122
|
+
end
|
123
|
+
|
124
|
+
let(:field_name) { 'solr_doc_accessor' }
|
125
|
+
|
126
|
+
it { is_expected.to eq '123' }
|
100
127
|
end
|
101
128
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
129
|
+
context 'when accessor is set to a value' do
|
130
|
+
let(:field_name) { 'explicit_accessor' }
|
131
|
+
|
132
|
+
it 'calls the accessor with the field_name as the argument' do
|
133
|
+
expect(document).to receive(:solr_doc_accessor).with('explicit_accessor').and_return("123")
|
134
|
+
|
135
|
+
expect(subject).to eq '123'
|
136
|
+
end
|
106
137
|
end
|
107
138
|
|
108
|
-
|
109
|
-
|
110
|
-
|
139
|
+
context 'when the field is an alias' do
|
140
|
+
let(:field_name) { 'alias' }
|
141
|
+
|
142
|
+
it { is_expected.to eq 'document qwer value' }
|
111
143
|
end
|
112
144
|
|
113
|
-
|
114
|
-
|
115
|
-
|
145
|
+
context 'when the field has a default' do
|
146
|
+
let(:field_name) { 'with_default' }
|
147
|
+
|
148
|
+
it { is_expected.to eq 'value' }
|
116
149
|
end
|
117
150
|
end
|
118
151
|
|
@@ -170,4 +203,3 @@ describe Blacklight::IndexPresenter do
|
|
170
203
|
end
|
171
204
|
end
|
172
205
|
end
|
173
|
-
|
@@ -16,8 +16,7 @@ describe Blacklight::ShowPresenter do
|
|
16
16
|
SolrDocument.new(id: 1,
|
17
17
|
'link_to_search_true' => 'x',
|
18
18
|
'link_to_search_named' => 'x',
|
19
|
-
'qwer' => 'document qwer value'
|
20
|
-
'mnbv' => 'document mnbv value')
|
19
|
+
'qwer' => 'document qwer value')
|
21
20
|
end
|
22
21
|
|
23
22
|
before do
|
@@ -97,118 +96,155 @@ describe Blacklight::ShowPresenter do
|
|
97
96
|
end
|
98
97
|
end
|
99
98
|
|
100
|
-
describe
|
99
|
+
describe '#field_value' do
|
100
|
+
subject { presenter.field_value field }
|
101
|
+
|
102
|
+
let(:field) { config.show_fields[field_name] }
|
103
|
+
let(:field_name) { 'asdf' }
|
101
104
|
let(:config) do
|
102
105
|
Blacklight::Configuration.new.configure do |config|
|
103
106
|
config.add_show_field 'qwer'
|
104
|
-
config.add_show_field 'asdf', :
|
105
|
-
config.add_show_field 'link_to_search_true', :
|
106
|
-
config.add_show_field 'link_to_search_named', :
|
107
|
-
config.add_show_field 'highlight', :
|
108
|
-
config.add_show_field 'solr_doc_accessor', :
|
109
|
-
config.add_show_field 'explicit_accessor', :
|
110
|
-
config.add_show_field 'explicit_array_accessor', :
|
111
|
-
config.add_show_field 'explicit_accessor_with_arg', :accessor => :solr_doc_accessor_with_arg
|
107
|
+
config.add_show_field 'asdf', helper_method: :render_asdf_document_show_field
|
108
|
+
config.add_show_field 'link_to_search_true', link_to_search: true
|
109
|
+
config.add_show_field 'link_to_search_named', link_to_search: :some_field
|
110
|
+
config.add_show_field 'highlight', highlight: true
|
111
|
+
config.add_show_field 'solr_doc_accessor', accessor: true
|
112
|
+
config.add_show_field 'explicit_accessor', accessor: :solr_doc_accessor
|
113
|
+
config.add_show_field 'explicit_array_accessor', accessor: [:solr_doc_accessor, :some_method]
|
112
114
|
end
|
113
115
|
end
|
114
116
|
|
115
|
-
|
116
|
-
|
117
|
-
expect(value).to eq '<b>val1</b>'
|
118
|
-
end
|
117
|
+
context 'when a name is provided' do
|
118
|
+
subject { presenter.field_value 'qwer' }
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
it 'raises a deprecation' do
|
121
|
+
expect(Deprecation).to receive(:warn)
|
122
|
+
expect(subject).to eq 'document qwer value'
|
123
|
+
end
|
123
124
|
end
|
124
125
|
|
125
|
-
|
126
|
-
|
127
|
-
expect(value).to eq 'a, b, and c'
|
128
|
-
end
|
126
|
+
context 'when an explicit html value is provided' do
|
127
|
+
subject { presenter.field_value field, value: '<b>val1</b>' }
|
129
128
|
|
130
|
-
|
131
|
-
expect(request_context).to_not receive(:render_asdf_document_show_field)
|
132
|
-
value = subject.field_value 'asdf', :value => 'val1'
|
133
|
-
expect(value).to eq 'val1'
|
129
|
+
it { is_expected.to eq '<b>val1</b>' }
|
134
130
|
end
|
135
131
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
132
|
+
context 'when an explicit array value with unsafe characters is provided' do
|
133
|
+
subject { presenter.field_value field, value: ['<a', 'b'] }
|
134
|
+
|
135
|
+
it { is_expected.to eq '<a and b' }
|
140
136
|
end
|
141
137
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
expect(value).to eq 'bar'
|
138
|
+
context 'when an explicit array value is provided' do
|
139
|
+
subject { presenter.field_value field, value: %w[a b c] }
|
140
|
+
|
141
|
+
it { is_expected.to eq 'a, b, and c' }
|
147
142
|
end
|
148
143
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
expect(value).to eq 'bar'
|
144
|
+
context 'when an explicit value is provided' do
|
145
|
+
subject { presenter.field_value field, value: 'val1' }
|
146
|
+
|
147
|
+
it { is_expected.to eq 'val1' }
|
154
148
|
end
|
155
149
|
|
156
|
-
context
|
150
|
+
context 'when field has a helper method' do
|
157
151
|
before do
|
158
|
-
allow(
|
152
|
+
allow(request_context).to receive(:render_asdf_document_show_field).and_return('custom asdf value')
|
159
153
|
end
|
160
|
-
|
161
|
-
it
|
162
|
-
|
154
|
+
|
155
|
+
it { is_expected.to eq 'custom asdf value' }
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'when field has link_to_search with true' do
|
159
|
+
before do
|
160
|
+
allow(request_context).to receive(:search_action_path).with('f' => { 'link_to_search_true' => ['x'] }).and_return('/foo')
|
161
|
+
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
|
163
162
|
end
|
163
|
+
|
164
|
+
let(:field_name) { 'link_to_search_true' }
|
165
|
+
|
166
|
+
it { is_expected.to eq 'bar' }
|
164
167
|
end
|
165
168
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
169
|
+
context 'when field has link_to_search with a field name' do
|
170
|
+
before do
|
171
|
+
allow(request_context).to receive(:search_action_path).with('f' => { 'some_field' => ['x'] }).and_return('/foo')
|
172
|
+
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
|
173
|
+
end
|
174
|
+
|
175
|
+
let(:field_name) { 'link_to_search_named' }
|
176
|
+
|
177
|
+
it { is_expected.to eq 'bar' }
|
171
178
|
end
|
172
179
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
180
|
+
context 'when no highlight field is available' do
|
181
|
+
before do
|
182
|
+
allow(document).to receive(:has_highlight_field?).and_return(false)
|
183
|
+
end
|
184
|
+
|
185
|
+
let(:field_name) { 'highlight' }
|
186
|
+
|
187
|
+
it { is_expected.to be_blank }
|
178
188
|
end
|
179
189
|
|
180
|
-
|
181
|
-
|
182
|
-
|
190
|
+
context 'when highlight field is available' do
|
191
|
+
before do
|
192
|
+
allow(document).to receive(:has_highlight_field?).and_return(true)
|
193
|
+
allow(document).to receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
|
194
|
+
end
|
195
|
+
|
196
|
+
let(:field_name) { 'highlight' }
|
197
|
+
|
198
|
+
it { is_expected.to eq '<em>highlight</em>' }
|
183
199
|
end
|
184
200
|
|
185
|
-
|
186
|
-
|
187
|
-
|
201
|
+
context 'when highlight returns multiple values' do
|
202
|
+
before do
|
203
|
+
allow(document).to receive(:has_highlight_field?).and_return(true)
|
204
|
+
allow(document).to receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe, '<em>other highlight</em>'.html_safe])
|
205
|
+
end
|
206
|
+
|
207
|
+
let(:field_name) { 'highlight' }
|
208
|
+
|
209
|
+
it { is_expected.to eq '<em>highlight</em> and <em>other highlight</em>' }
|
188
210
|
end
|
189
211
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
212
|
+
context 'when no options are provided' do
|
213
|
+
let(:field_name) { 'qwer' }
|
214
|
+
|
215
|
+
it "checks the document field value" do
|
216
|
+
expect(subject).to eq 'document qwer value'
|
217
|
+
end
|
194
218
|
end
|
195
219
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
220
|
+
context 'when accessor is true' do
|
221
|
+
before do
|
222
|
+
allow(document).to receive_messages(solr_doc_accessor: "123")
|
223
|
+
end
|
224
|
+
|
225
|
+
let(:field_name) { 'solr_doc_accessor' }
|
226
|
+
|
227
|
+
it { is_expected.to eq '123' }
|
200
228
|
end
|
201
229
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
230
|
+
context 'when accessor is set to a value' do
|
231
|
+
let(:field_name) { 'explicit_accessor' }
|
232
|
+
|
233
|
+
it 'calls the accessor with the field_name as the argument' do
|
234
|
+
expect(document).to receive(:solr_doc_accessor).with('explicit_accessor').and_return("123")
|
235
|
+
|
236
|
+
expect(subject).to eq '123'
|
237
|
+
end
|
206
238
|
end
|
207
239
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
240
|
+
context 'when accessor is set to an array' do
|
241
|
+
let(:field_name) { 'explicit_array_accessor' }
|
242
|
+
|
243
|
+
it 'calls the accessors on the return of the preceeding' do
|
244
|
+
allow(document).to receive_message_chain(:solr_doc_accessor, some_method: "123")
|
245
|
+
|
246
|
+
expect(subject).to eq '123'
|
247
|
+
end
|
212
248
|
end
|
213
249
|
end
|
214
250
|
|
@@ -310,4 +346,3 @@ describe Blacklight::ShowPresenter do
|
|
310
346
|
end
|
311
347
|
end
|
312
348
|
end
|
313
|
-
|
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: 6.
|
4
|
+
version: 6.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -17,7 +17,7 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: exe
|
19
19
|
cert_chain: []
|
20
|
-
date: 2018-
|
20
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|
@@ -765,7 +765,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
765
765
|
version: '0'
|
766
766
|
requirements: []
|
767
767
|
rubyforge_project:
|
768
|
-
rubygems_version: 2.6
|
768
|
+
rubygems_version: 2.7.6
|
769
769
|
signing_key:
|
770
770
|
specification_version: 4
|
771
771
|
summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
|