blacklight_range_limit 9.0.0.beta2 → 9.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfe80b379721a4e19e01ecb97a0f1ca6335e2e85ae3914abec0f2ae9ee9546b6
4
- data.tar.gz: cdc7468b2f1e7f649f72a9f4200948cbc543d9f1e6a86bcac03b467c65b18ba2
3
+ metadata.gz: 1eb86d2b4a964fa439b38733a97efb61faa03e3db7a4a51a0ffa4daea379fe9d
4
+ data.tar.gz: 2444a4e758791ecb567d8f2f3aa0ee16a14a8cd20e3b4652a4b1b565a9511f0f
5
5
  SHA512:
6
- metadata.gz: df819d6ceb0f782c612d1eb83648a178ed2f555b599df666240cfa2cc7a75d0b3554ff29ff12ada5bdf3766bb74be88b76d054a95fd233d41309d2737bcb6cf2
7
- data.tar.gz: 269df83223ddbed2fa371c9b0aa1ebc6d5afff775d5a313a6482ba8948412456b59bbe7b1b438e51143fe2941c3e643b3ba98f5a918287ce32b4867542871c69
6
+ metadata.gz: 423928f6a8c0b71b04a8ac60a4bff7b2581aacb0a398bb4d7c933ba6c87e4b92540871e9709870e8342f7471830995552ba465e2c19357d0fa4b5637b80c5d10
7
+ data.tar.gz: 9799b189b778c9a34ca56fcb794143f328cbac9cb9ce7df829c18c23146842b6f8c961ac866c7692cc9eef31923dc0d0a012171afe658fe5778e91a5cdd18651
@@ -12,6 +12,8 @@ on:
12
12
  branches: [main]
13
13
  pull_request:
14
14
  branches: ['**']
15
+ schedule:
16
+ - cron: "0 2 * * TUE"
15
17
 
16
18
  jobs:
17
19
  test:
@@ -24,8 +26,8 @@ jobs:
24
26
  #
25
27
  # * Blacklight: 7, 8, or 9
26
28
  # * Rails: 7 or 8
27
- # * sprockets or propshaft(with cssbundling-rails sass)
28
- # * importmap-rails or esbuild (each with sprockets or importmaps)
29
+ # * sprockets or propshaft (with cssbundling-rails sass)
30
+ # * importmap-rails or esbuild (each with sprockets or importmaps)
29
31
  #
30
32
  # We should work with almost every combo of these (even though BL itself
31
33
  # doesn't officially support every one), but we don't test with every one,
@@ -42,29 +44,53 @@ jobs:
42
44
  ruby: "3.3"
43
45
  additional_name: "/ importmap-rails"
44
46
  additional_engine_cart_rails_options: "--css=bootstrap"
47
+
45
48
  - rails_version: "~> 8.0.0"
46
49
  blacklight_version: '{ "git": "https://github.com/projectblacklight/blacklight.git" }'
47
50
  ruby: "3.3"
48
51
  additional_name: "/ esbuild"
49
52
  additional_engine_cart_rails_options: "--css=bootstrap --javascript=esbuild"
50
53
 
54
+ # BLACKLIGHT 9, with beta cause that's all that's out as we write this
55
+ # and with Rails 8.0 only for simplicity
56
+ #
57
+
58
+ - rails_version: "~> 8.0.0"
59
+ blacklight_version: '~> 9.0.0.beta'
60
+ ruby: "3.4"
61
+ additional_name: "/ importmap-rails"
62
+ additional_engine_cart_rails_options: "--css=bootstrap"
63
+
64
+ - rails_version: "~> 8.0.0"
65
+ blacklight_version: '~> 9.0.0.beta'
66
+ ruby: "3.4"
67
+ additional_name: "/ esbuild"
68
+ additional_engine_cart_rails_options: "--css=bootstrap --javascript=esbuild"
51
69
 
52
70
 
53
71
  # BLACKLIGHT 8, can test with use importmaps and esbuild
54
72
  #
55
73
 
74
+ - rails_version: "~> 8.0.0"
75
+ blacklight_version: "~> 8.0"
76
+ ruby: "3.3"
77
+ additional_name: "/ importmap-rails, propshaft"
78
+ additional_engine_cart_rails_options: "-a propshaft --css=bootstrap"
79
+
56
80
  - rails_version: "7.2.1"
57
81
  blacklight_version: "~> 8.0"
58
82
  ruby: "3.3"
59
83
  additional_name: "/ importmap-rails, sprockets"
84
+
60
85
  - rails_version: "7.2.1"
61
86
  blacklight_version: "~> 8.0"
62
87
  ruby: "3.3"
63
88
  additional_name: "/ importmap-rails, propshaft"
64
89
  additional_engine_cart_rails_options: "-a propshaft --css=bootstrap"
90
+
65
91
  - rails_version: "7.2.1"
66
92
  blacklight_version: "~> 8.0"
67
- ruby: 3.3
93
+ ruby: "3.3"
68
94
  additional_engine_cart_rails_options: "-a propshaft --javascript=esbuild --css=bootstrap"
69
95
  additional_name: "/ esbuild, propshaft"
70
96
 
@@ -73,12 +99,11 @@ jobs:
73
99
  # * Blacklight 8 can't easily generate an app with Rails 7 and sprockets and esbuild
74
100
  # (the default layout won't be right), although I think it should work fine.
75
101
  #
76
- # * Can't test with unreleaed Blacklight main and esbuild because the blacklight-frontend
77
- # npm package doens't work from git checkout. So currently can't test with Rails8
102
+ # * Can't test with unreleased Blacklight main and esbuild because the blacklight-frontend
103
+ # npm package doesn't work from git checkout. So currently can't test with Rails 8
78
104
  # and esbuild.
79
105
 
80
106
 
81
-
82
107
  # BLACKLIGHT 7, only test with esbuild, not sure if it supports importmaps, it won't generate it
83
108
 
84
109
  - rails_version: "7.2.1"
@@ -86,6 +111,7 @@ jobs:
86
111
  ruby: "3.3"
87
112
  additional_engine_cart_rails_options: "--javascript=esbuild"
88
113
  additional_name: "/ esbuild, sprockets"
114
+
89
115
  - rails_version: "7.2.1"
90
116
  blacklight_version: "~> 7.0"
91
117
  ruby: "3.3"
@@ -98,15 +124,6 @@ jobs:
98
124
  additional_engine_cart_rails_options: "--javascript=esbuild"
99
125
  additional_name: "/ esbuild, sprockets"
100
126
 
101
- - rails_version: "7.0.8.4"
102
- blacklight_version: "~> 7.0"
103
- ruby: "3.1"
104
- additional_engine_cart_rails_options: "--javascript=esbuild"
105
- additional_name: "/ esbuild, sprockets"
106
-
107
-
108
-
109
-
110
127
 
111
128
  env:
112
129
  BLACKLIGHT_VERSION: ${{ matrix.blacklight_version || '~> 8.0' }}
data/README.md CHANGED
@@ -173,6 +173,8 @@ bundle exec rspec spec/features/blacklight_range_limit_spec.rb
173
173
 
174
174
  Once you are done iterating on your test you will need to stop the application server with `Ctrl-C`.
175
175
 
176
- # Publishing Javascript
176
+ # Release process
177
177
 
178
- run `npm publish` to push the javascript package to https://npmjs.org/package/blacklight-range-limit
178
+ Make sure you adjust version to match in both `VERSION` *and* `package.json` file.
179
+
180
+ Release rubygem with `bundle exec rake release` and also be sure to release npm package by running `npm publish` to push the javascript package to https://npmjs.org/package/blacklight-range-limit
data/Rakefile CHANGED
@@ -32,10 +32,11 @@ task :guard_version_match do
32
32
 
33
33
  # 9.0.0.beta1 in gem becomes 9.0.0-beta1 in npm
34
34
  gem_version_parts = gem_version.split(".")
35
+
35
36
  npm_version_required = [
36
37
  gem_version_parts.slice(0, 3).join("."),
37
38
  gem_version_parts.slice(3, gem_version_parts.length).join(".")
38
- ].join("-")
39
+ ].collect {|s| s if s && !s.empty? }.compact.join("-")
39
40
 
40
41
  if npm_version != npm_version_required
41
42
  raise <<~EOS
data/VERSION CHANGED
@@ -1 +1 @@
1
- 9.0.0.beta2
1
+ 9.1.0
@@ -6,7 +6,16 @@ module BlacklightRangeLimit
6
6
 
7
7
  def initialize(facet_field:, layout: nil, classes: BlacklightRangeLimit.classes)
8
8
  @facet_field = facet_field
9
- @layout = layout == false ? Blacklight::FacetFieldNoLayoutComponent : Blacklight::FacetFieldComponent
9
+ @layout = if layout == false
10
+ Blacklight::FacetFieldNoLayoutComponent
11
+ elsif layout
12
+ layout
13
+ elsif defined?(Blacklight::Facets::FacetFieldComponent)
14
+ Blacklight::Facets::FacetFieldComponent # Blacklight 9
15
+ else
16
+ Blacklight::FacetFieldComponent # Blacklight < 9
17
+ end
18
+
10
19
  @classes = classes
11
20
  end
12
21
 
@@ -39,7 +48,7 @@ module BlacklightRangeLimit
39
48
  min = @facet_field.selected_range_facet_item&.value&.begin || @facet_field.min
40
49
  max = @facet_field.selected_range_facet_item&.value&.end || @facet_field.max
41
50
 
42
- return nil unless (min && max)
51
+ return nil unless min && max
43
52
 
44
53
  range_limit_url(range_start: min, range_end: max)
45
54
  end
@@ -3,11 +3,14 @@
3
3
  module BlacklightRangeLimit
4
4
  class RangeSegmentsComponent < Blacklight::Component
5
5
  def initialize(facet_field:, facet_items: nil, item_component: nil, classes: [])
6
- super
6
+ super()
7
7
 
8
8
  @facet_field = facet_field
9
9
  @facet_items = facet_items || facet_field.try(:range_queries) || []
10
- @item_component = facet_field.facet_field.item_component || Blacklight::FacetItemComponent
10
+ # newer versions of BL9 want Blacklight::Facets::ItemComponent -- the older one is supposed
11
+ # to be deprecated, but in fact may not work so we use newer if avail.
12
+ @item_component = facet_field.facet_field.item_component ||
13
+ (defined?(Blacklight::Facets::ItemComponent) ? Blacklight::Facets::ItemComponent : Blacklight::FacetItemComponent)
11
14
  @classes = classes
12
15
  end
13
16
 
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.license = 'Apache 2.0'
19
19
 
20
20
  s.add_dependency 'blacklight', '>= 7.25.2', '< 9'
21
- s.add_dependency 'view_component', ">= 2.54", "< 4"
21
+ s.add_dependency 'view_component', ">= 2.54", "< 5"
22
22
 
23
23
  s.add_development_dependency 'rspec', '~> 3.0'
24
24
  s.add_development_dependency 'rspec-rails'
@@ -48,6 +48,12 @@ module BlacklightRangeLimit
48
48
  # range_field, range_start, range_end
49
49
  def fetch_specific_range_limit(solr_params)
50
50
  field_key = blacklight_params[:range_field] # what field to fetch for
51
+
52
+ unless blacklight_params[:range_start].present? && blacklight_params[:range_start].kind_of?(String) &&
53
+ blacklight_params[:range_end].present? && blacklight_params[:range_end].kind_of?(String)
54
+ raise BlacklightRangeLimit::InvalidRange
55
+ end
56
+
51
57
  start = blacklight_params[:range_start].to_i
52
58
  finish = blacklight_params[:range_end].to_i
53
59
 
@@ -61,6 +67,9 @@ module BlacklightRangeLimit
61
67
  solr_params[:rows] = 0
62
68
 
63
69
  return solr_params
70
+ rescue BlacklightRangeLimit::InvalidRange
71
+ # This will make Rails return a 400
72
+ raise ActionController::BadRequest, "invalid range_start (#{blacklight_params[:range_start]}) or range_end (#{blacklight_params[:range_end]})"
64
73
  end
65
74
 
66
75
  # hacky polyfill for new Blacklight behavior we need, if we don't have it yet
@@ -9,7 +9,6 @@ module BlacklightRangeLimit
9
9
  options = @defaults.merge(options)
10
10
 
11
11
  mapper.get 'range_limit', action: 'range_limit'
12
- mapper.get 'range_limit_panel/:id', action: 'range_limit_panel'
13
12
  end
14
13
  end
15
14
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blacklight-range-limit",
3
- "version": "9.0.0-beta2",
3
+ "version": "9.1.0",
4
4
  "description": "A range facet UI component plugin for blacklight",
5
5
  "type": "module",
6
6
 
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe CatalogController, type: :controller do
4
+ # Note that ActionController::BadRequest is caught by rails and turned into a 400
5
+ # response, and ActionController::RoutingError is caught by raisl and turned into 404
6
+ describe "bad params" do
7
+ let (:facet_field) { "pub_date_si" }
8
+
9
+ it "without start param present raise BadRequest " do
10
+ expect {
11
+ get :range_limit, params: {
12
+ "range_field"=> facet_field,
13
+ "range_start"=>"1931"
14
+ }
15
+ }.to raise_error(ActionController::BadRequest)
16
+ end
17
+
18
+ it "without end param raise BadRequest " do
19
+ expect {
20
+ get :range_limit, params: {
21
+ "range_field"=> facet_field,
22
+ "range_start"=>"1931"
23
+ }
24
+ }.to raise_error(ActionController::BadRequest)
25
+ end
26
+
27
+ it "without either boundary raise BadRequest" do
28
+ expect {
29
+ get :range_limit, params: {
30
+ "range_field"=> facet_field,
31
+ }
32
+ }.to raise_error(ActionController::BadRequest)
33
+ end
34
+
35
+ it "without a range_field raise RoutingError" do
36
+ expect {
37
+ get :range_limit, params: {}
38
+ }.to raise_error(ActionController::RoutingError)
39
+ end
40
+
41
+ it "with params out of order raise BadRequest" do
42
+ expect {
43
+ get :range_limit, params: {
44
+ "range_field"=> facet_field,
45
+ "range_start"=>"1940",
46
+ "range_end"=>"1930"
47
+ }
48
+ }.to raise_error(ActionController::BadRequest)
49
+ end
50
+
51
+ it "with one of the params is an array raise BadRequest" do
52
+ expect {
53
+ get :range_limit, params: {
54
+ "range_field"=> facet_field,
55
+ "range_start"=>"1931",
56
+ "range_end"=>["1940"]
57
+ }
58
+ }.to raise_error(ActionController::BadRequest)
59
+ end
60
+ end
61
+ end
data/spec/spec_helper.rb CHANGED
@@ -44,8 +44,8 @@ RSpec.configure do |config|
44
44
  config.infer_spec_type_from_file_location!
45
45
 
46
46
  config.include PresenterTestHelpers, type: :presenter
47
+ config.include ViewComponent::TestHelpers, type: :presenter
47
48
  config.include ViewComponent::TestHelpers, type: :component
48
49
 
49
50
  config.example_status_persistence_file_path = 'spec/examples.txt'
50
-
51
51
  end
@@ -2,7 +2,9 @@
2
2
 
3
3
  module PresenterTestHelpers
4
4
  def controller
5
- @controller ||= ViewComponent::Base.test_controller.constantize.new.tap { |c| c.request = request }.extend(Rails.application.routes.url_helpers)
5
+ # view_component 3+ should be just `vc_test_controller_class` when we drop VC 2 support we can
6
+ # just use that.
7
+ @controller ||= (respond_to?(:vc_test_controller_class) ? vc_test_controller_class : ApplicationController).new.tap { |c| c.request = request }.extend(Rails.application.routes.url_helpers)
6
8
  end
7
9
 
8
10
  def request
@@ -13,9 +13,13 @@ class TestAppGenerator < Rails::Generators::Base
13
13
  end
14
14
 
15
15
  def run_bl8_jsbundling_fixup
16
- # while it's named confusingly, the BL8 assets:propshaft generator has what we need
17
- # for jsbundling, I think.
18
- if File.exist?("package.json") && Blacklight::VERSION.split(".").first == "8"
16
+ # BL 8.7.0 doesn't seem to need anything, but BL8 before that the automatic BL
17
+ # install process doesn't do everything we need.
18
+ #
19
+ # By manually triggering the BL8 assets:propshaft generator, we can get what we need
20
+ # for jsbundling, even though it's named confusingly for that, it works in these
21
+ # versions.
22
+ if File.exist?("package.json") && Gem::Requirement.create("~> 8.0", "< 8.7.0").satisfied_by?(Gem::Version.new(Blacklight::VERSION))
19
23
  generate "blacklight:assets:propshaft"
20
24
  end
21
25
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight_range_limit
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.0.beta2
4
+ version: 9.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
8
8
  - Chris Beer
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-12-03 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: blacklight
@@ -40,7 +39,7 @@ dependencies:
40
39
  version: '2.54'
41
40
  - - "<"
42
41
  - !ruby/object:Gem::Version
43
- version: '4'
42
+ version: '5'
44
43
  type: :runtime
45
44
  prerelease: false
46
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -50,7 +49,7 @@ dependencies:
50
49
  version: '2.54'
51
50
  - - "<"
52
51
  - !ruby/object:Gem::Version
53
- version: '4'
52
+ version: '5'
54
53
  - !ruby/object:Gem::Dependency
55
54
  name: rspec
56
55
  requirement: !ruby/object:Gem::Requirement
@@ -177,7 +176,6 @@ dependencies:
177
176
  - - ">="
178
177
  - !ruby/object:Gem::Version
179
178
  version: 3.13.1
180
- description:
181
179
  email:
182
180
  - blacklight-development@googlegroups.com
183
181
  executables: []
@@ -250,6 +248,7 @@ files:
250
248
  - spec/components/range_facet_component_spec.rb
251
249
  - spec/components/range_form_component_spec.rb
252
250
  - spec/components/range_segments_component_spec.rb
251
+ - spec/controllers/range_limit_action_method_spec.rb
253
252
  - spec/features/blacklight_range_limit_spec.rb
254
253
  - spec/features/run_through_spec.rb
255
254
  - spec/fixtures/solr_documents/unknown_year.yml
@@ -267,7 +266,6 @@ homepage: https://github.com/projectblacklight/blacklight_range_limit
267
266
  licenses:
268
267
  - Apache 2.0
269
268
  metadata: {}
270
- post_install_message:
271
269
  rdoc_options: []
272
270
  require_paths:
273
271
  - lib
@@ -282,14 +280,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
280
  - !ruby/object:Gem::Version
283
281
  version: '0'
284
282
  requirements: []
285
- rubygems_version: 3.5.9
286
- signing_key:
283
+ rubygems_version: 3.6.9
287
284
  specification_version: 4
288
285
  summary: Blacklight Range Limit plugin
289
286
  test_files:
290
287
  - spec/components/range_facet_component_spec.rb
291
288
  - spec/components/range_form_component_spec.rb
292
289
  - spec/components/range_segments_component_spec.rb
290
+ - spec/controllers/range_limit_action_method_spec.rb
293
291
  - spec/features/blacklight_range_limit_spec.rb
294
292
  - spec/features/run_through_spec.rb
295
293
  - spec/fixtures/solr_documents/unknown_year.yml