blacklight_range_limit 6.3.0 → 6.5.0
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 +5 -5
- data/.solr_wrapper.yml +1 -0
- data/.travis.yml +4 -3
- data/Gemfile +4 -0
- data/Rakefile +0 -2
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +1 -1
- data/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +9 -0
- data/app/helpers/range_limit_helper.rb +20 -2
- data/app/views/blacklight_range_limit/_range_limit_panel.html.erb +9 -10
- data/blacklight_range_limit.gemspec +7 -4
- data/lib/blacklight_range_limit.rb +1 -1
- data/lib/blacklight_range_limit/controller_override.rb +14 -0
- data/lib/blacklight_range_limit/engine.rb +1 -0
- data/lib/blacklight_range_limit/range_limit_builder.rb +21 -19
- data/lib/blacklight_range_limit/segment_calculation.rb +3 -1
- data/lib/blacklight_range_limit/view_helper_override.rb +26 -39
- data/lib/generators/blacklight_range_limit/install_generator.rb +1 -1
- data/solr/conf/schema.xml +0 -6
- data/spec/features/a_javascript_spec.rb +25 -0
- data/spec/features/blacklight_range_limit_spec.rb +20 -4
- data/spec/helpers/blacklight_range_limit_helper_spec.rb +18 -0
- data/spec/lib/blacklight_range_limit/segment_calculation_spec.rb +14 -0
- data/spec/lib/blacklight_range_limit/view_helper_override_helper_spec.rb +127 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/test_app_templates/Gemfile.extra +1 -0
- metadata +66 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 454aced55fe12cf920d7f33fc5338f40707ae450e78f3863f2d99a7721c9dc40
|
4
|
+
data.tar.gz: 19b80f76873f3a1a3e59ffaa7291c1f8d2f7af680a7979a8e3f3655adf716296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8e45fed92431f1f46db61c9c76986f4552a7c01aba77aa1f85890cae4a8fc0dee42812ef4c4de0a11473653fceb1dc1e8a4f07588ae67761ecae6fa52410bab
|
7
|
+
data.tar.gz: 2bf5fccb09e9f21de9c7a783e4f0e426d1eb5299010a0cea108619c30182d11d20e1df0ba58110d0f7ac036828fcdbd16e6dd243f50d8a1078a783f05317a049
|
data/.solr_wrapper.yml
CHANGED
data/.travis.yml
CHANGED
@@ -4,10 +4,11 @@ notifications:
|
|
4
4
|
language: ruby
|
5
5
|
sudo: false
|
6
6
|
rvm:
|
7
|
-
- 2.
|
7
|
+
- 2.5.8
|
8
|
+
- 2.6.5
|
8
9
|
|
9
10
|
before_install:
|
10
|
-
-
|
11
|
+
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
|
11
12
|
|
12
13
|
notifications:
|
13
14
|
irc: "irc.freenode.org#blacklight"
|
@@ -17,4 +18,4 @@ notifications:
|
|
17
18
|
global_env:
|
18
19
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
19
20
|
|
20
|
-
jdk:
|
21
|
+
jdk: oraclejdk9
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.
|
1
|
+
6.5.0
|
@@ -37,7 +37,7 @@ Blacklight.onLoad(function() {
|
|
37
37
|
var container = $(event.target).filter(".facet-content").find(".chart_js");
|
38
38
|
|
39
39
|
// only if it doesn't already have a canvas, it isn't already drawn
|
40
|
-
if (container && container.find("canvas").
|
40
|
+
if (container && container.find("canvas").length == 0) {
|
41
41
|
// be willing to wait up to 1100ms for container to
|
42
42
|
// have width -- right away on show.bs is too soon, but
|
43
43
|
// shown.bs is later than we want, we want to start rendering
|
@@ -44,6 +44,15 @@ $(".range_limit .profile .range.slider_js").each(function() {
|
|
44
44
|
slider_el.css("width", "100%");
|
45
45
|
}
|
46
46
|
}
|
47
|
+
|
48
|
+
// Slider change should update text input values.
|
49
|
+
var parent = $(this).parent();
|
50
|
+
var form = $(parent).closest(".limit_content").find("form.range_limit");
|
51
|
+
$(parent).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) {
|
52
|
+
var values = $(event.target).data("slider").getValue();
|
53
|
+
form.find("input.range_begin").val(values[0]);
|
54
|
+
form.find("input.range_end").val(values[1]);
|
55
|
+
});
|
47
56
|
}
|
48
57
|
|
49
58
|
begin_el.val(min);
|
@@ -62,8 +62,12 @@ module RangeLimitHelper
|
|
62
62
|
@response["stats"]["stats_fields"][solr_field] if @response["stats"] && @response["stats"]["stats_fields"]
|
63
63
|
end
|
64
64
|
|
65
|
+
def stats_for_field?(solr_field)
|
66
|
+
stats_for_field(solr_field).present?
|
67
|
+
end
|
68
|
+
|
65
69
|
def add_range_missing(solr_field, my_params = params)
|
66
|
-
my_params = Blacklight::SearchState.new(my_params, blacklight_config).to_h
|
70
|
+
my_params = Blacklight::SearchState.new(my_params.except(:page), blacklight_config).to_h
|
67
71
|
my_params["range"] ||= {}
|
68
72
|
my_params["range"][solr_field] ||= {}
|
69
73
|
my_params["range"][solr_field]["missing"] = "true"
|
@@ -77,7 +81,7 @@ module RangeLimitHelper
|
|
77
81
|
end
|
78
82
|
|
79
83
|
def add_range(solr_field, from, to, my_params = params)
|
80
|
-
my_params = Blacklight::SearchState.new(my_params, blacklight_config).to_h
|
84
|
+
my_params = Blacklight::SearchState.new(my_params.except(:page), blacklight_config).to_h
|
81
85
|
my_params["range"] ||= {}
|
82
86
|
my_params["range"][solr_field] ||= {}
|
83
87
|
|
@@ -94,4 +98,18 @@ module RangeLimitHelper
|
|
94
98
|
return my_params
|
95
99
|
end
|
96
100
|
|
101
|
+
def has_selected_range_limit?(solr_field)
|
102
|
+
params["range"] &&
|
103
|
+
params["range"][solr_field] &&
|
104
|
+
(
|
105
|
+
params["range"][solr_field]["begin"].present? ||
|
106
|
+
params["range"][solr_field]["end"].present? ||
|
107
|
+
params["range"][solr_field]["missing"]
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
def selected_missing_for_range_limit?(solr_field)
|
112
|
+
params["range"] && params["range"][solr_field] && params["range"][solr_field]["missing"]
|
113
|
+
end
|
114
|
+
|
97
115
|
end
|
@@ -7,12 +7,8 @@
|
|
7
7
|
maxlength = field_config[:maxlength]
|
8
8
|
-%>
|
9
9
|
|
10
|
-
<div class="limit_content range_limit">
|
11
|
-
<% if
|
12
|
-
params["range"][solr_field] &&
|
13
|
-
( (! params["range"][solr_field]["begin"].blank?) ||
|
14
|
-
(! params["range"][solr_field]["end"].blank?) ||
|
15
|
-
params["range"][solr_field]["missing"]) %>
|
10
|
+
<div class="limit_content range_limit">
|
11
|
+
<% if has_selected_range_limit?(solr_field) %>
|
16
12
|
<ul class="current list-unstyled facet-values">
|
17
13
|
<li class="selected">
|
18
14
|
<span class="facet-label">
|
@@ -28,9 +24,9 @@
|
|
28
24
|
|
29
25
|
<% end %>
|
30
26
|
|
31
|
-
<% unless
|
27
|
+
<% unless selected_missing_for_range_limit?(solr_field) %>
|
32
28
|
<%= form_tag search_action_path, :method => :get, class: [BlacklightRangeLimit.classes[:form], "range_#{solr_field}"].join(' ') do %>
|
33
|
-
<%= render_hash_as_hidden_fields(search_state.params_for_search) %>
|
29
|
+
<%= render_hash_as_hidden_fields(search_state.params_for_search.except(:page)) %>
|
34
30
|
|
35
31
|
<!-- we need to include a dummy search_field parameter if none exists,
|
36
32
|
to trick blacklight into displaying actual search results instead
|
@@ -46,11 +42,14 @@
|
|
46
42
|
<% end %>
|
47
43
|
|
48
44
|
<!-- no results profile if missing is selected -->
|
49
|
-
<% unless
|
45
|
+
<% unless selected_missing_for_range_limit?(solr_field) %>
|
50
46
|
<!-- you can hide this if you want, but it has to be on page if you want
|
51
47
|
JS slider and calculated facets to show up, JS sniffs it. -->
|
52
48
|
<div class="profile">
|
53
|
-
|
49
|
+
<% if stats_for_field?(solr_field) %>
|
50
|
+
<!-- No stats information found for field in search response -->
|
51
|
+
<% end %>
|
52
|
+
|
54
53
|
<% if (min = range_results_endpoint(solr_field, :min)) &&
|
55
54
|
(max = range_results_endpoint(solr_field, :max)) %>
|
56
55
|
<p class="range subsection <%= "slider_js" unless field_config[:slider_js] == false %>">
|
@@ -17,15 +17,18 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.license = 'Apache 2.0'
|
19
19
|
|
20
|
-
s.add_dependency 'rails', '>=
|
20
|
+
s.add_dependency 'rails', '>= 4.2', '< 6'
|
21
21
|
s.add_dependency 'jquery-rails' # our JS needs jquery_rails
|
22
|
-
s.add_dependency 'blacklight', '
|
22
|
+
s.add_dependency 'blacklight', '~> 6.10'
|
23
23
|
|
24
|
+
s.add_development_dependency 'chromedriver-helper'
|
24
25
|
s.add_development_dependency 'rspec', '~> 3.0'
|
25
26
|
s.add_development_dependency 'rspec-rails'
|
26
27
|
s.add_development_dependency 'capybara'
|
27
28
|
s.add_development_dependency 'sqlite3'
|
28
29
|
s.add_development_dependency 'launchy'
|
29
|
-
s.add_development_dependency '
|
30
|
-
s.add_development_dependency '
|
30
|
+
s.add_development_dependency 'selenium-webdriver'
|
31
|
+
s.add_development_dependency 'solr_wrapper', '~> 2.2'
|
32
|
+
s.add_development_dependency 'engine_cart', '~> 2.0'
|
33
|
+
s.add_development_dependency 'webdrivers'
|
31
34
|
end
|
@@ -37,7 +37,7 @@ module BlacklightRangeLimit
|
|
37
37
|
def self.range_config(blacklight_config, solr_field)
|
38
38
|
field = blacklight_config.facet_fields[solr_field.to_s]
|
39
39
|
|
40
|
-
return false unless field.range
|
40
|
+
return false unless field && field.range
|
41
41
|
|
42
42
|
config = field.range
|
43
43
|
config = { partial: field.partial } if config === true
|
@@ -9,6 +9,7 @@ module BlacklightRangeLimit
|
|
9
9
|
included do
|
10
10
|
helper BlacklightRangeLimit::ViewHelperOverride
|
11
11
|
helper RangeLimitHelper
|
12
|
+
helper_method :has_range_limit_parameters?
|
12
13
|
end
|
13
14
|
|
14
15
|
# Action method of our own!
|
@@ -28,5 +29,18 @@ module BlacklightRangeLimit
|
|
28
29
|
|
29
30
|
render('blacklight_range_limit/range_segments', :locals => {:solr_field => params[:range_field]}, :layout => !request.xhr?)
|
30
31
|
end
|
32
|
+
|
33
|
+
# over-ride, call super, but make sure our range limits count too
|
34
|
+
def has_search_parameters?
|
35
|
+
super || has_range_limit_parameters?
|
36
|
+
end
|
37
|
+
|
38
|
+
def has_range_limit_parameters?(my_params = params)
|
39
|
+
my_params[:range] &&
|
40
|
+
my_params[:range].to_unsafe_h.any? do |key, v|
|
41
|
+
v.present? && v.respond_to?(:'[]') &&
|
42
|
+
(v["begin"].present? || v["end"].present? || v["missing"].present?)
|
43
|
+
end
|
44
|
+
end
|
31
45
|
end
|
32
46
|
end
|
@@ -12,46 +12,48 @@ module BlacklightRangeLimit
|
|
12
12
|
|
13
13
|
# Method added to to fetch proper things for date ranges.
|
14
14
|
def add_range_limit_params(solr_params)
|
15
|
-
ranged_facet_configs =
|
16
|
-
blacklight_config.facet_fields.select { |key, config| config.range }
|
15
|
+
ranged_facet_configs =
|
16
|
+
blacklight_config.facet_fields.select { |key, config| config.range }
|
17
17
|
# In ruby 1.8, hash.select returns an array of pairs, in ruby 1.9
|
18
|
-
# it returns a hash. Turn it into a hash either way.
|
18
|
+
# it returns a hash. Turn it into a hash either way.
|
19
19
|
ranged_facet_configs = Hash[ ranged_facet_configs ] unless ranged_facet_configs.kind_of?(Hash)
|
20
|
-
|
20
|
+
|
21
21
|
ranged_facet_configs.each_pair do |solr_field, config|
|
22
22
|
solr_params["stats"] = "true"
|
23
23
|
solr_params["stats.field"] ||= []
|
24
|
-
solr_params["stats.field"] << solr_field
|
25
|
-
|
24
|
+
solr_params["stats.field"] << solr_field
|
25
|
+
|
26
|
+
range_config = BlacklightRangeLimit.range_config(blacklight_config, config.field)
|
27
|
+
|
26
28
|
hash = blacklight_params["range"] && blacklight_params["range"][solr_field] ?
|
27
29
|
blacklight_params["range"][solr_field] :
|
28
30
|
{}
|
29
|
-
|
31
|
+
|
30
32
|
if !hash["missing"].blank?
|
31
33
|
# missing specified in request params
|
32
34
|
solr_params[:fq] ||= []
|
33
35
|
solr_params[:fq] << "-#{solr_field}:[* TO *]"
|
34
|
-
|
36
|
+
|
35
37
|
elsif !(hash["begin"].blank? && hash["end"].blank?)
|
36
38
|
# specified in request params, begin and/or end, might just have one
|
37
39
|
start = hash["begin"].blank? ? "*" : hash["begin"]
|
38
40
|
finish = hash["end"].blank? ? "*" : hash["end"]
|
39
|
-
|
41
|
+
|
40
42
|
solr_params[:fq] ||= []
|
41
43
|
solr_params[:fq] << "#{solr_field}: [#{start} TO #{finish}]"
|
42
|
-
|
43
|
-
if (
|
44
|
+
|
45
|
+
if (range_config[:segments] != false && start != "*" && finish != "*")
|
44
46
|
# Add in our calculated segments, can only do with both boundaries.
|
45
47
|
add_range_segments_to_solr!(solr_params, solr_field, start.to_i, finish.to_i)
|
46
48
|
end
|
47
|
-
|
48
|
-
elsif (
|
49
|
-
boundaries =
|
49
|
+
|
50
|
+
elsif (range_config[:segments] != false &&
|
51
|
+
boundaries = range_config[:assumed_boundaries])
|
50
52
|
# assumed_boundaries in config
|
51
53
|
add_range_segments_to_solr!(solr_params, solr_field, boundaries[0], boundaries[1])
|
52
54
|
end
|
53
55
|
end
|
54
|
-
|
56
|
+
|
55
57
|
return solr_params
|
56
58
|
end
|
57
59
|
|
@@ -59,10 +61,10 @@ module BlacklightRangeLimit
|
|
59
61
|
# Another processing method, this one is NOT included in default processing chain,
|
60
62
|
# it is specifically swapped in *instead of* add_range_limit_params for
|
61
63
|
# certain ajax requests that only want to fetch range limit segments for
|
62
|
-
# ONE field.
|
64
|
+
# ONE field.
|
63
65
|
#
|
64
66
|
# It turns off facetting and sets rows to 0 as well, only results for
|
65
|
-
# single specified field are needed.
|
67
|
+
# single specified field are needed.
|
66
68
|
#
|
67
69
|
# Specified field and parameters are specified in incoming parameters
|
68
70
|
# range_field, range_start, range_end
|
@@ -72,13 +74,13 @@ module BlacklightRangeLimit
|
|
72
74
|
finish = blacklight_params[:range_end].to_i
|
73
75
|
|
74
76
|
add_range_segments_to_solr!(solr_params, solr_field, start, finish )
|
75
|
-
|
77
|
+
|
76
78
|
# Remove all field faceting for efficiency, we won't be using it.
|
77
79
|
solr_params.delete("facet.field")
|
78
80
|
solr_params.delete("facet.field".to_sym)
|
79
81
|
|
80
82
|
# We don't need any actual rows either
|
81
|
-
solr_params[:rows] = 0
|
83
|
+
solr_params[:rows] = 0
|
82
84
|
|
83
85
|
return solr_params
|
84
86
|
end
|
@@ -16,6 +16,8 @@ module BlacklightRangeLimit
|
|
16
16
|
|
17
17
|
field_config = BlacklightRangeLimit.range_config(blacklight_config, solr_field)
|
18
18
|
|
19
|
+
return solr_params unless field_config
|
20
|
+
|
19
21
|
solr_params[:"facet.query"] ||= []
|
20
22
|
|
21
23
|
boundaries = boundaries_for_range_facets(min, max, (field_config[:num_segments] || 10) )
|
@@ -28,7 +30,7 @@ module BlacklightRangeLimit
|
|
28
30
|
solr_params[:"facet.query"] << "#{solr_field}:[#{first} TO #{last}]"
|
29
31
|
end
|
30
32
|
|
31
|
-
|
33
|
+
solr_params
|
32
34
|
end
|
33
35
|
|
34
36
|
# returns an array of 'boundaries' for producing approx num_div
|
@@ -11,19 +11,6 @@
|
|
11
11
|
super
|
12
12
|
end
|
13
13
|
|
14
|
-
def has_range_limit_parameters?(my_params = params)
|
15
|
-
my_params[:range] &&
|
16
|
-
my_params[:range].to_unsafe_h.any? do |key, v|
|
17
|
-
v.present? && v.respond_to?(:'[]') &&
|
18
|
-
(v["begin"].present? || v["end"].present? || v["missing"].present?)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# over-ride, call super, but make sure our range limits count too
|
23
|
-
def has_search_parameters?
|
24
|
-
super || has_range_limit_parameters?
|
25
|
-
end
|
26
|
-
|
27
14
|
def query_has_constraints?(my_params = params)
|
28
15
|
super || has_range_limit_parameters?(my_params)
|
29
16
|
end
|
@@ -42,39 +29,26 @@
|
|
42
29
|
end
|
43
30
|
|
44
31
|
def render_constraints_filters(my_params = params)
|
45
|
-
content = super(my_params)
|
46
32
|
# add a constraint for ranges?
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
:escape_value => false,
|
55
|
-
:remove => remove_range_param(solr_field, my_params)
|
56
|
-
)
|
57
|
-
end
|
33
|
+
range_params(my_params).keys.each_with_object(super) do |solr_field, content|
|
34
|
+
content << render_constraint_element(
|
35
|
+
facet_field_label(solr_field),
|
36
|
+
range_display(solr_field, my_params),
|
37
|
+
escape_value: false,
|
38
|
+
remove: remove_range_param(solr_field, my_params)
|
39
|
+
)
|
58
40
|
end
|
59
|
-
return content
|
60
41
|
end
|
61
42
|
|
62
43
|
def render_search_to_s_filters(my_params)
|
63
|
-
content = super(my_params)
|
64
44
|
# add a constraint for ranges?
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
range_display(solr_field, my_params),
|
72
|
-
:escape_value => false
|
73
|
-
)
|
74
|
-
|
75
|
-
end
|
45
|
+
range_params(my_params).keys.each_with_object(super) do |solr_field, content|
|
46
|
+
content << render_search_to_s_element(
|
47
|
+
facet_field_label(solr_field),
|
48
|
+
range_display(solr_field, my_params),
|
49
|
+
escape_value: false
|
50
|
+
)
|
76
51
|
end
|
77
|
-
return content
|
78
52
|
end
|
79
53
|
|
80
54
|
def remove_range_param(solr_field, my_params = params)
|
@@ -110,4 +84,17 @@
|
|
110
84
|
BlacklightRangeLimit.range_config(blacklight_config, solr_field)
|
111
85
|
end
|
112
86
|
|
87
|
+
private
|
88
|
+
|
89
|
+
def range_params(my_params = params)
|
90
|
+
return {} unless my_params[:range].is_a?(ActionController::Parameters) || my_params[:range].is_a?(Hash)
|
91
|
+
|
92
|
+
my_params[:range].select do |_solr_field, range_options|
|
93
|
+
next unless range_options
|
94
|
+
|
95
|
+
[range_options['missing'].presence,
|
96
|
+
range_options['begin'].presence,
|
97
|
+
range_options['end'].presence].any?
|
98
|
+
end
|
99
|
+
end
|
113
100
|
end
|
@@ -9,7 +9,7 @@ module BlacklightRangeLimit
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def install_catalog_controller_mixin
|
12
|
-
|
12
|
+
inject_into_file 'app/controllers/catalog_controller.rb', after: /include Blacklight::Catalog.*$/ do
|
13
13
|
"\n include BlacklightRangeLimit::ControllerOverride\n"
|
14
14
|
end
|
15
15
|
end
|
data/solr/conf/schema.xml
CHANGED
@@ -544,12 +544,6 @@
|
|
544
544
|
-->
|
545
545
|
<uniqueKey>id</uniqueKey>
|
546
546
|
|
547
|
-
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
|
548
|
-
<defaultSearchField>text</defaultSearchField>
|
549
|
-
|
550
|
-
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
|
551
|
-
<solrQueryParser defaultOperator="OR"/>
|
552
|
-
|
553
547
|
<!-- copyField commands copy one field to another at the time a document
|
554
548
|
is added to the index. It's used either to index the same field differently,
|
555
549
|
or to add multiple fields to the same field for easier/faster searching. -->
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'JavaScript', js: true do
|
6
|
+
context 'when assumed boundaries configured' do
|
7
|
+
before do
|
8
|
+
CatalogController.blacklight_config.facet_fields['pub_date_sort'].range = {
|
9
|
+
assumed_boundaries: [1990, 2000]
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
CatalogController.blacklight_config.facet_fields['pub_date_sort'].range = true
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should show the range limit with set boundaries' do
|
18
|
+
visit '/catalog'
|
19
|
+
|
20
|
+
click_link 'Publication Date Sort'
|
21
|
+
expect(page).to have_field :range_pub_date_sort_begin, with: '1990'
|
22
|
+
expect(page).to have_field :range_pub_date_sort_end, with: '2000'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -24,7 +24,23 @@ describe "Blacklight Range Limit" do
|
|
24
24
|
click_link 'View distribution'
|
25
25
|
click_link '2000 to 2008'
|
26
26
|
|
27
|
-
|
27
|
+
within '.blacklight-pub_date_sort' do
|
28
|
+
expect(page).to have_content "2000 to 2008 [remove] 12"
|
29
|
+
end
|
30
|
+
|
31
|
+
within '#appliedParams' do
|
32
|
+
expect(page).to have_content '2000 to 2008'
|
33
|
+
end
|
34
|
+
|
35
|
+
expect(page).to have_content '1 - 10 of 12'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not include page parameter" do
|
39
|
+
visit search_catalog_path(page: 2)
|
40
|
+
click_link 'View distribution'
|
41
|
+
click_link '2000 to 2008'
|
42
|
+
click_button 'Limit'
|
43
|
+
expect(page.current_url).not_to include('page')
|
28
44
|
end
|
29
45
|
|
30
46
|
context 'when I18n translation is available' do
|
@@ -53,9 +69,9 @@ describe "Blacklight Range Limit with configured input labels" do
|
|
53
69
|
maxlength: 6
|
54
70
|
}
|
55
71
|
config.default_solr_params[:'facet.field'] = config.facet_fields.keys
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
59
75
|
it "should show the range limit facet with configured labels and maxlength" do
|
60
76
|
visit '/catalog'
|
61
77
|
expect(page).to have_selector 'label.sr-only[for="range_pub_date_sort_begin"]', :text => 'from publication date'
|
@@ -16,4 +16,22 @@ describe "Blacklight Range Limit Helper" do
|
|
16
16
|
expect(html_maxlength_6).to have_css 'input.form-control.range_begin#range_pub_date_begin[maxlength="6"]'
|
17
17
|
end
|
18
18
|
|
19
|
+
context "when building requests" do
|
20
|
+
let(:config) { Blacklight::Configuration.new }
|
21
|
+
before do
|
22
|
+
allow(helper).to receive(:blacklight_config).and_return(config)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should exclude page when adding a range" do
|
26
|
+
params = { q: '', page: '2' }
|
27
|
+
updated_params = helper.add_range('test', '1900', '1995', params)
|
28
|
+
expect(updated_params).not_to include(:page)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should exclude page when adding a missing range" do
|
32
|
+
params = { q: '', page: '2' }
|
33
|
+
updated_params = helper.add_range_missing('test', params)
|
34
|
+
expect(updated_params).not_to include(:page)
|
35
|
+
end
|
36
|
+
end
|
19
37
|
end
|
@@ -4,6 +4,10 @@ RSpec.describe BlacklightRangeLimit::SegmentCalculation do
|
|
4
4
|
let(:dummy_class) do
|
5
5
|
Class.new do
|
6
6
|
include BlacklightRangeLimit::SegmentCalculation
|
7
|
+
|
8
|
+
def blacklight_config
|
9
|
+
Blacklight::Configuration.new
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
9
13
|
|
@@ -45,5 +49,15 @@ RSpec.describe BlacklightRangeLimit::SegmentCalculation do
|
|
45
49
|
'The min date must be before the max date'
|
46
50
|
end
|
47
51
|
end
|
52
|
+
|
53
|
+
context 'when a field that does not exist is passed in' do
|
54
|
+
let(:min) { 100 }
|
55
|
+
let(:max) { 800 }
|
56
|
+
let(:solr_field) { 'i_am_not_real' }
|
57
|
+
|
58
|
+
it 'returns the original solr_params (and does not raise an error)' do
|
59
|
+
expect(subject).to eq({})
|
60
|
+
end
|
61
|
+
end
|
48
62
|
end
|
49
63
|
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe BlacklightRangeLimit::ViewHelperOverride, type: :helper do
|
4
|
+
describe '#render_constraints_filters' do
|
5
|
+
before do
|
6
|
+
allow(helper).to receive_messages(
|
7
|
+
facet_field_label: 'Date Range',
|
8
|
+
remove_range_param: '/remove'
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'does not return any content when the range parameter invalid' do
|
13
|
+
params = ActionController::Parameters.new(range: 'garbage')
|
14
|
+
|
15
|
+
expect(helper.render_constraints_filters(params)).to eq ''
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'renders a constraint for the given data in the range param' do
|
19
|
+
params = ActionController::Parameters.new(
|
20
|
+
range: { range_field: { 'begin' => 1900, 'end' => 2000 } }
|
21
|
+
)
|
22
|
+
constraints = helper.render_constraints_filters(params)
|
23
|
+
|
24
|
+
expect(constraints).to have_css(
|
25
|
+
'.constraint .filterName', text: 'Date Range'
|
26
|
+
)
|
27
|
+
expect(constraints).to have_css(
|
28
|
+
'.constraint .filterValue', text: '1900 to 2000'
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'render_search_to_s_filters' do
|
34
|
+
before do
|
35
|
+
allow(helper).to receive_messages(facet_field_label: 'Date Range')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'does not return any content when the range parameter invalid' do
|
39
|
+
params = ActionController::Parameters.new(range: 'garbage')
|
40
|
+
|
41
|
+
expect(helper.render_search_to_s_filters(params)).to eq ''
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'renders a constraint for the given data in the range param' do
|
45
|
+
params = ActionController::Parameters.new(
|
46
|
+
range: { range_field: { 'begin' => 1900, 'end' => 2000 } }
|
47
|
+
)
|
48
|
+
constraints = helper.render_search_to_s_filters(params)
|
49
|
+
|
50
|
+
expect(constraints).to have_css(
|
51
|
+
'.constraint .filterName', text: 'Date Range:'
|
52
|
+
)
|
53
|
+
expect(constraints).to have_css(
|
54
|
+
'.constraint .filterValues', text: '1900 to 2000'
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#range_params' do
|
60
|
+
it 'handles no range input' do
|
61
|
+
expect(
|
62
|
+
helper.send(:range_params, ActionController::Parameters.new(q: 'blah'))
|
63
|
+
).to eq({})
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'handles non-compliant range input' do
|
67
|
+
expect(
|
68
|
+
helper.send(:range_params, ActionController::Parameters.new(range: 'blah'))
|
69
|
+
).to eq({})
|
70
|
+
|
71
|
+
expect(
|
72
|
+
helper.send(:range_params, ActionController::Parameters.new(range: ['blah']))
|
73
|
+
).to eq({})
|
74
|
+
|
75
|
+
expect(
|
76
|
+
helper.send(:range_params, ActionController::Parameters.new(range: { 'wrong' => 'data' }))
|
77
|
+
).to eq({})
|
78
|
+
|
79
|
+
expect(
|
80
|
+
helper.send(
|
81
|
+
:range_params,
|
82
|
+
ActionController::Parameters.new(range: { field_name: { 'wrong' => 'data' } })
|
83
|
+
)
|
84
|
+
).to eq({})
|
85
|
+
|
86
|
+
expect(
|
87
|
+
helper.send(
|
88
|
+
:range_params,
|
89
|
+
ActionController::Parameters.new(range: { field_name: { 'begin' => '', 'end' => '' } })
|
90
|
+
)
|
91
|
+
).to eq({})
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'returns the range parameters that are present' do
|
95
|
+
expect(
|
96
|
+
helper.send(
|
97
|
+
:range_params,
|
98
|
+
ActionController::Parameters.new(range: { field_name: { 'missing' => true } })
|
99
|
+
).permit!.to_h
|
100
|
+
).to eq({ 'field_name' => { 'missing' => true } })
|
101
|
+
|
102
|
+
expect(
|
103
|
+
helper.send(
|
104
|
+
:range_params,
|
105
|
+
ActionController::Parameters.new(range: { field_name: { 'begin' => '1800', 'end' => '1900' } })
|
106
|
+
).permit!.to_h
|
107
|
+
).to eq({ 'field_name' => { 'begin' => '1800', 'end' => '1900' } })
|
108
|
+
|
109
|
+
expect(
|
110
|
+
helper.send(
|
111
|
+
:range_params,
|
112
|
+
ActionController::Parameters.new(
|
113
|
+
range: {
|
114
|
+
field_name: { 'begin' => '1800', 'end' => '1900' },
|
115
|
+
field_name2: { 'begin' => '1800', 'end' => '1900' }
|
116
|
+
}
|
117
|
+
)
|
118
|
+
).permit!.to_h
|
119
|
+
).to eq(
|
120
|
+
{
|
121
|
+
'field_name' => { 'begin' => '1800', 'end' => '1900' },
|
122
|
+
'field_name2' => { 'begin' => '1800', 'end' => '1900' }
|
123
|
+
}
|
124
|
+
)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,6 +5,21 @@ EngineCart.load_application!
|
|
5
5
|
|
6
6
|
require 'rspec/rails'
|
7
7
|
require 'capybara/rspec'
|
8
|
+
require 'selenium-webdriver'
|
9
|
+
require 'webdrivers'
|
10
|
+
|
11
|
+
Capybara.javascript_driver = :headless_chrome
|
12
|
+
|
13
|
+
Capybara.register_driver :headless_chrome do |app|
|
14
|
+
Capybara::Selenium::Driver.load_selenium
|
15
|
+
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
16
|
+
opts.args << '--headless'
|
17
|
+
opts.args << '--disable-gpu'
|
18
|
+
opts.args << '--no-sandbox'
|
19
|
+
opts.args << '--window-size=1280,1696'
|
20
|
+
end
|
21
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
22
|
+
end
|
8
23
|
|
9
24
|
RSpec.configure do |config|
|
10
25
|
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'sprockets', '< 4'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight_range_limit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -17,14 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '4.2'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '6'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
30
|
+
version: '4.2'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: jquery-rails
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,16 +49,30 @@ dependencies:
|
|
43
49
|
name: blacklight
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
45
51
|
requirements:
|
46
|
-
- - "
|
52
|
+
- - "~>"
|
47
53
|
- !ruby/object:Gem::Version
|
48
|
-
version: 6.
|
54
|
+
version: '6.10'
|
49
55
|
type: :runtime
|
50
56
|
prerelease: false
|
51
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '6.10'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: chromedriver-helper
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
52
65
|
requirements:
|
53
66
|
- - ">="
|
54
67
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
68
|
+
version: '0'
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
56
76
|
- !ruby/object:Gem::Dependency
|
57
77
|
name: rspec
|
58
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,34 +143,62 @@ dependencies:
|
|
123
143
|
- - ">="
|
124
144
|
- !ruby/object:Gem::Version
|
125
145
|
version: '0'
|
146
|
+
- !ruby/object:Gem::Dependency
|
147
|
+
name: selenium-webdriver
|
148
|
+
requirement: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
type: :development
|
154
|
+
prerelease: false
|
155
|
+
version_requirements: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
126
160
|
- !ruby/object:Gem::Dependency
|
127
161
|
name: solr_wrapper
|
128
162
|
requirement: !ruby/object:Gem::Requirement
|
129
163
|
requirements:
|
130
164
|
- - "~>"
|
131
165
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
166
|
+
version: '2.2'
|
133
167
|
type: :development
|
134
168
|
prerelease: false
|
135
169
|
version_requirements: !ruby/object:Gem::Requirement
|
136
170
|
requirements:
|
137
171
|
- - "~>"
|
138
172
|
- !ruby/object:Gem::Version
|
139
|
-
version: '
|
173
|
+
version: '2.2'
|
140
174
|
- !ruby/object:Gem::Dependency
|
141
175
|
name: engine_cart
|
142
176
|
requirement: !ruby/object:Gem::Requirement
|
143
177
|
requirements:
|
144
178
|
- - "~>"
|
145
179
|
- !ruby/object:Gem::Version
|
146
|
-
version: '
|
180
|
+
version: '2.0'
|
147
181
|
type: :development
|
148
182
|
prerelease: false
|
149
183
|
version_requirements: !ruby/object:Gem::Requirement
|
150
184
|
requirements:
|
151
185
|
- - "~>"
|
152
186
|
- !ruby/object:Gem::Version
|
153
|
-
version: '
|
187
|
+
version: '2.0'
|
188
|
+
- !ruby/object:Gem::Dependency
|
189
|
+
name: webdrivers
|
190
|
+
requirement: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
type: :development
|
196
|
+
prerelease: false
|
197
|
+
version_requirements: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
154
202
|
description:
|
155
203
|
email:
|
156
204
|
- blacklight-development@googlegroups.com
|
@@ -214,11 +262,14 @@ files:
|
|
214
262
|
- solr/conf/xslt/example_rss.xsl
|
215
263
|
- solr/conf/xslt/luke.xsl
|
216
264
|
- solr/sample_solr_documents.yml
|
265
|
+
- spec/features/a_javascript_spec.rb
|
217
266
|
- spec/features/blacklight_range_limit_spec.rb
|
218
267
|
- spec/fixtures/solr_documents/zero_year.yml
|
219
268
|
- spec/helpers/blacklight_range_limit_helper_spec.rb
|
220
269
|
- spec/lib/blacklight_range_limit/segment_calculation_spec.rb
|
270
|
+
- spec/lib/blacklight_range_limit/view_helper_override_helper_spec.rb
|
221
271
|
- spec/spec_helper.rb
|
272
|
+
- spec/test_app_templates/Gemfile.extra
|
222
273
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
223
274
|
- vendor/assets/javascripts/bootstrap-slider.js
|
224
275
|
- vendor/assets/javascripts/flot/excanvas.min.js
|
@@ -244,15 +295,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
295
|
- !ruby/object:Gem::Version
|
245
296
|
version: '0'
|
246
297
|
requirements: []
|
247
|
-
|
248
|
-
rubygems_version: 2.6.11
|
298
|
+
rubygems_version: 3.1.2
|
249
299
|
signing_key:
|
250
300
|
specification_version: 4
|
251
301
|
summary: Blacklight Range Limit plugin
|
252
302
|
test_files:
|
303
|
+
- spec/features/a_javascript_spec.rb
|
253
304
|
- spec/features/blacklight_range_limit_spec.rb
|
254
305
|
- spec/fixtures/solr_documents/zero_year.yml
|
255
306
|
- spec/helpers/blacklight_range_limit_helper_spec.rb
|
256
307
|
- spec/lib/blacklight_range_limit/segment_calculation_spec.rb
|
308
|
+
- spec/lib/blacklight_range_limit/view_helper_override_helper_spec.rb
|
257
309
|
- spec/spec_helper.rb
|
310
|
+
- spec/test_app_templates/Gemfile.extra
|
258
311
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|