blacklight_range_limit 6.5.0 → 7.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.solr_wrapper.yml +0 -1
- data/.travis.yml +3 -4
- data/Gemfile +0 -4
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +3 -4
- data/app/assets/javascripts/blacklight_range_limit/range_limit_shared.js +6 -6
- data/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +0 -1
- data/app/views/blacklight_range_limit/_range_limit_panel.html.erb +31 -33
- data/blacklight_range_limit.gemspec +5 -7
- data/lib/blacklight_range_limit.rb +1 -1
- data/lib/blacklight_range_limit/controller_override.rb +1 -16
- data/lib/blacklight_range_limit/engine.rb +1 -0
- data/lib/blacklight_range_limit/range_limit_builder.rb +19 -21
- data/lib/blacklight_range_limit/segment_calculation.rb +1 -3
- data/lib/blacklight_range_limit/view_helper_override.rb +39 -26
- data/lib/generators/blacklight_range_limit/assets_generator.rb +3 -0
- data/lib/generators/blacklight_range_limit/install_generator.rb +1 -1
- data/lib/tasks/blacklight_range_limit.rake +1 -1
- data/solr/conf/schema.xml +325 -564
- data/solr/conf/solrconfig.xml +78 -294
- data/solr/sample_solr_documents.yml +30 -30
- data/spec/features/blacklight_range_limit_spec.rb +12 -20
- data/spec/fixtures/solr_documents/zero_year.yml +2 -2
- data/spec/lib/blacklight_range_limit/segment_calculation_spec.rb +0 -14
- data/spec/spec_helper.rb +0 -15
- data/spec/test_app_templates/Gemfile.extra +1 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- metadata +18 -55
- data/spec/features/a_javascript_spec.rb +0 -25
- data/spec/lib/blacklight_range_limit/view_helper_override_helper_spec.rb +0 -127
@@ -6,8 +6,8 @@ describe "Blacklight Range Limit" do
|
|
6
6
|
visit search_catalog_path
|
7
7
|
expect(page).to have_selector 'input.range_begin'
|
8
8
|
expect(page).to have_selector 'input.range_end'
|
9
|
-
expect(page).to have_selector 'label.sr-only[for="
|
10
|
-
expect(page).to have_selector 'label.sr-only[for="
|
9
|
+
expect(page).to have_selector 'label.sr-only[for="range_pub_date_si_begin"]', :text => 'Publication Date Sort range begin'
|
10
|
+
expect(page).to have_selector 'label.sr-only[for="range_pub_date_si_end"]', :text => 'Publication Date Sort range end'
|
11
11
|
expect(page).to have_button 'Limit'
|
12
12
|
end
|
13
13
|
|
@@ -24,15 +24,7 @@ describe "Blacklight Range Limit" do
|
|
24
24
|
click_link 'View distribution'
|
25
25
|
click_link '2000 to 2008'
|
26
26
|
|
27
|
-
|
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'
|
27
|
+
expect(page).to have_content "2000 to 2008 [remove] 12"
|
36
28
|
end
|
37
29
|
|
38
30
|
it "should not include page parameter" do
|
@@ -45,7 +37,7 @@ describe "Blacklight Range Limit" do
|
|
45
37
|
|
46
38
|
context 'when I18n translation is available' do
|
47
39
|
before do
|
48
|
-
I18n.backend.store_translations(:en, blacklight: {search: {fields: {facet: {
|
40
|
+
I18n.backend.store_translations(:en, blacklight: {search: {fields: {facet: {pub_date_si: 'Publication Date I18n'}}}})
|
49
41
|
end
|
50
42
|
|
51
43
|
it 'should render the I18n label' do
|
@@ -63,21 +55,21 @@ describe "Blacklight Range Limit with configured input labels" do
|
|
63
55
|
before do
|
64
56
|
CatalogController.blacklight_config = Blacklight::Configuration.new
|
65
57
|
CatalogController.configure_blacklight do |config|
|
66
|
-
config.add_facet_field '
|
58
|
+
config.add_facet_field 'pub_date_si', range: {
|
67
59
|
input_label_range_begin: 'from publication date',
|
68
60
|
input_label_range_end: 'to publication date',
|
69
61
|
maxlength: 6
|
70
62
|
}
|
71
63
|
config.default_solr_params[:'facet.field'] = config.facet_fields.keys
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
75
67
|
it "should show the range limit facet with configured labels and maxlength" do
|
76
68
|
visit '/catalog'
|
77
|
-
expect(page).to have_selector 'label.sr-only[for="
|
78
|
-
expect(page).to have_selector 'label.sr-only[for="
|
79
|
-
expect(page).to have_selector 'input#
|
80
|
-
expect(page).to have_selector 'input#
|
69
|
+
expect(page).to have_selector 'label.sr-only[for="range_pub_date_si_begin"]', :text => 'from publication date'
|
70
|
+
expect(page).to have_selector 'label.sr-only[for="range_pub_date_si_end"]', :text => 'to publication date'
|
71
|
+
expect(page).to have_selector 'input#range_pub_date_si_begin[maxlength="6"]'
|
72
|
+
expect(page).to have_selector 'input#range_pub_date_si_end[maxlength="6"]'
|
81
73
|
end
|
82
74
|
|
83
75
|
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
id: 'zero_doc_id'
|
2
|
-
|
3
|
-
|
2
|
+
title_tsim: 'Zero year doc'
|
3
|
+
pub_date_si: 1000
|
@@ -4,10 +4,6 @@ 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
|
11
7
|
end
|
12
8
|
end
|
13
9
|
|
@@ -49,15 +45,5 @@ RSpec.describe BlacklightRangeLimit::SegmentCalculation do
|
|
49
45
|
'The min date must be before the max date'
|
50
46
|
end
|
51
47
|
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
|
62
48
|
end
|
63
49
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,21 +5,6 @@ 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
|
23
8
|
|
24
9
|
RSpec.configure do |config|
|
25
10
|
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
@@ -1 +1 @@
|
|
1
|
-
gem '
|
1
|
+
gem 'blacklight', github: 'projectblacklight/blacklight', branch: 'master'
|
@@ -27,7 +27,7 @@ class TestAppGenerator < Rails::Generators::Base
|
|
27
27
|
|
28
28
|
def inject_into_catalog_controller
|
29
29
|
inject_into_file 'app/controllers/catalog_controller.rb', after: /config.add_facet_field 'format'.*$/ do
|
30
|
-
"\n config.add_facet_field '
|
30
|
+
"\n config.add_facet_field 'pub_date_si', label: 'Publication Date Sort', range: true"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
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:
|
4
|
+
version: 7.0.0.rc1
|
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: 2018-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -17,20 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
21
|
-
- - "<"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: '6'
|
20
|
+
version: '3.0'
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
27
24
|
requirements:
|
28
25
|
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
31
|
-
- - "<"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '6'
|
27
|
+
version: '3.0'
|
34
28
|
- !ruby/object:Gem::Dependency
|
35
29
|
name: jquery-rails
|
36
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -49,24 +43,24 @@ dependencies:
|
|
49
43
|
name: blacklight
|
50
44
|
requirement: !ruby/object:Gem::Requirement
|
51
45
|
requirements:
|
52
|
-
- - "
|
46
|
+
- - ">="
|
53
47
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
48
|
+
version: '0'
|
55
49
|
type: :runtime
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
52
|
requirements:
|
59
|
-
- - "
|
53
|
+
- - ">="
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
55
|
+
version: '0'
|
62
56
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
57
|
+
name: tether-rails
|
64
58
|
requirement: !ruby/object:Gem::Requirement
|
65
59
|
requirements:
|
66
60
|
- - ">="
|
67
61
|
- !ruby/object:Gem::Version
|
68
62
|
version: '0'
|
69
|
-
type: :
|
63
|
+
type: :runtime
|
70
64
|
prerelease: false
|
71
65
|
version_requirements: !ruby/object:Gem::Requirement
|
72
66
|
requirements:
|
@@ -143,62 +137,34 @@ dependencies:
|
|
143
137
|
- - ">="
|
144
138
|
- !ruby/object:Gem::Version
|
145
139
|
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'
|
160
140
|
- !ruby/object:Gem::Dependency
|
161
141
|
name: solr_wrapper
|
162
142
|
requirement: !ruby/object:Gem::Requirement
|
163
143
|
requirements:
|
164
144
|
- - "~>"
|
165
145
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
146
|
+
version: '0.14'
|
167
147
|
type: :development
|
168
148
|
prerelease: false
|
169
149
|
version_requirements: !ruby/object:Gem::Requirement
|
170
150
|
requirements:
|
171
151
|
- - "~>"
|
172
152
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
153
|
+
version: '0.14'
|
174
154
|
- !ruby/object:Gem::Dependency
|
175
155
|
name: engine_cart
|
176
156
|
requirement: !ruby/object:Gem::Requirement
|
177
157
|
requirements:
|
178
158
|
- - "~>"
|
179
159
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
160
|
+
version: '1.0'
|
181
161
|
type: :development
|
182
162
|
prerelease: false
|
183
163
|
version_requirements: !ruby/object:Gem::Requirement
|
184
164
|
requirements:
|
185
165
|
- - "~>"
|
186
166
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
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'
|
167
|
+
version: '1.0'
|
202
168
|
description:
|
203
169
|
email:
|
204
170
|
- blacklight-development@googlegroups.com
|
@@ -262,12 +228,10 @@ files:
|
|
262
228
|
- solr/conf/xslt/example_rss.xsl
|
263
229
|
- solr/conf/xslt/luke.xsl
|
264
230
|
- solr/sample_solr_documents.yml
|
265
|
-
- spec/features/a_javascript_spec.rb
|
266
231
|
- spec/features/blacklight_range_limit_spec.rb
|
267
232
|
- spec/fixtures/solr_documents/zero_year.yml
|
268
233
|
- spec/helpers/blacklight_range_limit_helper_spec.rb
|
269
234
|
- spec/lib/blacklight_range_limit/segment_calculation_spec.rb
|
270
|
-
- spec/lib/blacklight_range_limit/view_helper_override_helper_spec.rb
|
271
235
|
- spec/spec_helper.rb
|
272
236
|
- spec/test_app_templates/Gemfile.extra
|
273
237
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
@@ -291,21 +255,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
291
255
|
version: '0'
|
292
256
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
293
257
|
requirements:
|
294
|
-
- - "
|
258
|
+
- - ">"
|
295
259
|
- !ruby/object:Gem::Version
|
296
|
-
version:
|
260
|
+
version: 1.3.1
|
297
261
|
requirements: []
|
298
|
-
|
262
|
+
rubyforge_project:
|
263
|
+
rubygems_version: 2.6.11
|
299
264
|
signing_key:
|
300
265
|
specification_version: 4
|
301
266
|
summary: Blacklight Range Limit plugin
|
302
267
|
test_files:
|
303
|
-
- spec/features/a_javascript_spec.rb
|
304
268
|
- spec/features/blacklight_range_limit_spec.rb
|
305
269
|
- spec/fixtures/solr_documents/zero_year.yml
|
306
270
|
- spec/helpers/blacklight_range_limit_helper_spec.rb
|
307
271
|
- spec/lib/blacklight_range_limit/segment_calculation_spec.rb
|
308
|
-
- spec/lib/blacklight_range_limit/view_helper_override_helper_spec.rb
|
309
272
|
- spec/spec_helper.rb
|
310
273
|
- spec/test_app_templates/Gemfile.extra
|
311
274
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
@@ -1,25 +0,0 @@
|
|
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
|
@@ -1,127 +0,0 @@
|
|
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
|