From c9f0548f80e862e3b11ae451eebf451f4db29d8a Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sun, 22 Dec 2024 15:30:05 +0100 Subject: [PATCH] Drop EOL Ruby versions (< 3.1) (#970) --- .github/workflows/eslint.yml | 2 +- .github/workflows/javascript.yml | 2 +- .github/workflows/ruby.yml | 10 +--------- .rubocop.yml | 2 +- CHANGELOG.md | 1 + Rakefile | 2 +- client_side_validations.gemspec | 2 +- .../action_view/form_builder.rb | 4 ++-- lib/client_side_validations/action_view/form_helper.rb | 4 ++-- .../action_view/form_with_helper.rb | 4 ++-- test/action_view/cases/helper.rb | 6 +++--- 11 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index deffd736a..a2ef64b53 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Node uses: actions/setup-node@v4 with: - node-version: '18' + node-version: '22' - name: Install node dependencies run: pnpm install - name: Run JavaScript linter diff --git a/.github/workflows/javascript.yml b/.github/workflows/javascript.yml index dcd461269..8e88c8fdc 100644 --- a/.github/workflows/javascript.yml +++ b/.github/workflows/javascript.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Node uses: actions/setup-node@v4 with: - node-version: '18' + node-version: '22' - name: Install node dependencies run: pnpm install - name: Run tests diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index a3c97e5d4..82827e68e 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3'] + ruby-version: ['3.1', '3.2', '3.3'] gemfile: [rails_6.1, rails_7.0, rails_7.1, rails_7.2, rails_8.0] channel: ['stable'] @@ -40,14 +40,6 @@ jobs: channel: 'experimental' exclude: - - ruby-version: '2.7' - gemfile: rails_7.2 - - ruby-version: '2.7' - gemfile: rails_8.0 - - ruby-version: '3.0' - gemfile: rails_7.2 - - ruby-version: '3.0' - gemfile: rails_8.0 - ruby-version: '3.1' gemfile: rails_8.0 - ruby-version: '3.2' diff --git a/.rubocop.yml b/.rubocop.yml index 8abb2cfe1..dbf9da636 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,7 +7,7 @@ require: AllCops: TargetRailsVersion: 6.1 - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.1 NewCops: enable DisplayStyleGuide: true ExtraDetails: true diff --git a/CHANGELOG.md b/CHANGELOG.md index a35582580..864580373 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - `data-validate` => `data-csv-validate` * [FEATURE] Use data attributes instead of `jQuery.data()` * [FEATURE] Drop Internet Explorer and other older browsers support +* [FEATURE] Drop Ruby < 3.1 * [ENHANCEMENT] Update QUnit to 2.23.0 ## 22.3.0 / 2024-11-12 diff --git a/Rakefile b/Rakefile index d5f5d52ae..3d1965a40 100644 --- a/Rakefile +++ b/Rakefile @@ -16,7 +16,7 @@ namespace :test do desc %(Test Ruby code) Rake::TestTask.new(:ruby) do |test| test.libs << 'lib' << 'test' - test.test_files = Dir.glob("#{__dir__}/test/**/test_*.rb").sort + test.test_files = Dir.glob("#{__dir__}/test/**/test_*.rb") test.warning = false end diff --git a/client_side_validations.gemspec b/client_side_validations.gemspec index d760c32e0..7f71cfc54 100644 --- a/client_side_validations.gemspec +++ b/client_side_validations.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.platform = Gem::Platform::RUBY - spec.required_ruby_version = '>= 2.7' + spec.required_ruby_version = '>= 3.1' spec.add_dependency 'js_regex', '~> 3.7' spec.add_dependency 'rails', '>= 6.1' diff --git a/lib/client_side_validations/action_view/form_builder.rb b/lib/client_side_validations/action_view/form_builder.rb index 6ac62537d..c429b5230 100644 --- a/lib/client_side_validations/action_view/form_builder.rb +++ b/lib/client_side_validations/action_view/form_builder.rb @@ -73,7 +73,7 @@ def collection_select(method, collection, value_method, text_method, options = { super end - def fields_for(record_name, record_object = nil, fields_options = {}, &block) + def fields_for(record_name, record_object = nil, fields_options = {}, &) if record_object.is_a?(Hash) && record_object.extractable_options? fields_options = record_object record_object = nil @@ -106,7 +106,7 @@ def radio_button(method, tag_value, options = {}) super end - def select(method, choices = nil, options = {}, html_options = {}, &block) + def select(method, choices = nil, options = {}, html_options = {}, &) build_validation_options(method, html_options.merge(name: options[:name])) html_options.delete(:validate) super diff --git a/lib/client_side_validations/action_view/form_helper.rb b/lib/client_side_validations/action_view/form_helper.rb index 9d0b9d8ce..9c79f567a 100644 --- a/lib/client_side_validations/action_view/form_helper.rb +++ b/lib/client_side_validations/action_view/form_helper.rb @@ -48,10 +48,10 @@ def apply_csv_form_for_options!(record, object, options) end end - def fields_for(record_name, record_object = nil, options = {}, &block) + def fields_for(record_name, record_object = nil, options = {}, &) # Order matters here. Rails mutates the `options` object builder = instantiate_builder(record_name, record_object, options) - output = capture(builder, &block) + output = capture(builder, &) build_bound_validators! options diff --git a/lib/client_side_validations/action_view/form_with_helper.rb b/lib/client_side_validations/action_view/form_with_helper.rb index fac5b3439..720afd42c 100644 --- a/lib/client_side_validations/action_view/form_with_helper.rb +++ b/lib/client_side_validations/action_view/form_with_helper.rb @@ -31,11 +31,11 @@ def check_model(url, model, format, scope) [url, model, scope] end - def form_tag_with_validators(scope, model, options, url, &block) + def form_tag_with_validators(scope, model, options, url, &) @validators = {} builder = instantiate_builder(scope, model, options) - output = capture(builder, &block) + output = capture(builder, &) options[:multipart] ||= builder.multipart? build_bound_validators! options diff --git a/test/action_view/cases/helper.rb b/test/action_view/cases/helper.rb index 382fc8a29..748603f55 100644 --- a/test/action_view/cases/helper.rb +++ b/test/action_view/cases/helper.rb @@ -147,7 +147,7 @@ def snowman(method = nil) end def form_field(tag, id: nil, name: nil, type: nil, value: nil, multiple: false, tag_content: nil, custom_name: nil) - txt = +%(<#{tag}) + txt = %(<#{tag}) txt << %( name="#{custom_name}") if custom_name txt << %( type="#{type}") if type @@ -167,7 +167,7 @@ def form_field(tag, id: nil, name: nil, type: nil, value: nil, multiple: false, end def form_for_text(action = 'http://www.example.com', id = nil, html_class = nil, remote = nil, validators = nil, file = nil) - txt = +%(