From a8def4fd5deb4199fc559a79bb49e91e92b9f3c3 Mon Sep 17 00:00:00 2001 From: Mathieu Jobin <99191+mathieujobin@users.noreply.github.com> Date: Tue, 31 Oct 2023 08:13:46 +0900 Subject: [PATCH] Support for Rails 7.1 (#111) * allow rails 7.1 * Update ci.yml * Create rails_7.1.gemfile * Update version.rb * update rubocop file * dev branch of active_attr * bye bye ruby 2.6 * updte rubocop * bye bye rails 4.2 * oups * we need this * one was missing * fix version check * ruby 3.0 only for rails 7.1 * rails 7.1 on ruby 3.1+ only * used released active_attr --- .github/workflows/ci.yml | 24 +-- .rubocop_todo.yml | 96 ++++++++-- gemfiles/rails_4.2.gemfile | 8 - gemfiles/rails_4.2.gemfile.lock | 319 -------------------------------- gemfiles/rails_7.1.gemfile | 9 + lib/webhook_system/version.rb | 2 +- spec/support/rails_seven_one.rb | 22 +++ webhook_system.gemspec | 10 +- 8 files changed, 121 insertions(+), 369 deletions(-) delete mode 100644 gemfiles/rails_4.2.gemfile delete mode 100644 gemfiles/rails_4.2.gemfile.lock create mode 100644 gemfiles/rails_7.1.gemfile create mode 100644 spec/support/rails_seven_one.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e797fab..c9a57e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,33 +17,23 @@ jobs: strategy: fail-fast: false matrix: - gemfile: ["rails_7.0"] - ruby: [2.7] + gemfile: ['rails_7.0', 'rails_7.1'] + ruby: [3.3, 3.2, 3.1] include: - gemfile: rails_7.0 - ruby: '3.1' - - gemfile: rails_6.1 - ruby: '3.1' - - gemfile: rails_7.0 - ruby: '3.0' - - gemfile: rails_6.1 ruby: '3.0' - - gemfile: rails_6.1 + - gemfile: rails_7.0 ruby: 2.7 - gemfile: rails_6.1 - ruby: 2.6 - - gemfile: rails_6.0 ruby: 2.7 - gemfile: rails_6.0 - ruby: 2.6 + ruby: 2.7 - gemfile: rails_5.2 - ruby: 2.6 + ruby: 2.7 - gemfile: rails_5.1 - ruby: 2.6 + ruby: 2.7 - gemfile: rails_5.0 - ruby: 2.6 - - gemfile: rails_4.2 - ruby: 2.6 + ruby: 2.7 env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9224e63..009c986 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,19 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 180` -# on 2023-03-31 21:57:32 UTC using RuboCop version 1.48.1. +# on 2023-10-30 03:57:18 UTC using RuboCop version 1.57.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/OrderedGems: + Exclude: + - 'gemfiles/rails_7.1.gemfile' + # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSafeAssignment. @@ -13,6 +21,12 @@ Lint/AssignmentInCondition: Exclude: - 'lib/webhook_system/subscription.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/RedundantDirGlobSort: + Exclude: + - 'spec/spec_helper.rb' + # Offense count: 1 Lint/UnreachableCode: Exclude: @@ -23,14 +37,6 @@ Lint/UnreachableCode: Metrics/MethodLength: Max: 18 -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, BlockForwardingName. -# SupportedStyles: anonymous, explicit -Naming/BlockForwarding: - Exclude: - - 'lib/webhook_system/base_event.rb' - # Offense count: 1 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to @@ -38,6 +44,13 @@ Naming/MethodParameterName: Exclude: - 'lib/webhook_system/encoder.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'spec/support/rails_seven_one.rb' + # Offense count: 9 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without @@ -68,6 +81,16 @@ RSpec/FilePath: - 'spec/event_spec.rb' - 'spec/models_spec.rb' +# Offense count: 11 +# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns. +RSpec/IndexedLet: + Exclude: + - 'spec/dispatching_events_spec.rb' + - 'spec/encoder_spec.rb' + - 'spec/event_spec.rb' + - 'spec/integration_spec.rb' + - 'spec/models_spec.rb' + # Offense count: 3 RSpec/LetSetup: Exclude: @@ -80,6 +103,20 @@ RSpec/MatchArray: Exclude: - 'spec/models_spec.rb' +# Offense count: 10 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: hash, symbol +RSpec/MetadataStyle: + Exclude: + - 'spec/dispatching_events_spec.rb' + - 'spec/encoder_spec.rb' + - 'spec/event_log_spec.rb' + - 'spec/event_spec.rb' + - 'spec/integration_spec.rb' + - 'spec/models_spec.rb' + - 'spec/spec_helper.rb' + # Offense count: 15 # Configuration parameters: AllowSubject. RSpec/MultipleMemoizedHelpers: @@ -98,10 +135,21 @@ RSpec/NestedGroups: Max: 4 # Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). RSpec/ScatteredSetup: Exclude: - 'spec/models_spec.rb' +# Offense count: 4 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Exclude: + - 'spec/encoder_spec.rb' + - 'spec/event_log_spec.rb' + - 'spec/event_spec.rb' + - 'spec/models_spec.rb' + # Offense count: 2 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: @@ -121,19 +169,21 @@ Style/Documentation: - 'lib/webhook_system.rb' - 'lib/webhook_system/encoder.rb' - 'lib/webhook_system/subscription_topic.rb' + - 'spec/support/rails_seven_one.rb' -# Offense count: 19 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent -Style/HashSyntax: +Style/MultilineIfModifier: Exclude: - - 'lib/webhook_system/encoder.rb' - - 'spec/dispatching_events_spec.rb' - - 'spec/encoder_spec.rb' - - 'spec/event_log_spec.rb' - - 'spec/event_spec.rb' + - 'spec/support/rails_seven_one.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowedCompactTypes. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + Exclude: + - 'spec/support/rails_seven_one.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -154,3 +204,11 @@ Style/RedundantFreeze: Style/RegexpLiteral: Exclude: - 'spec/dispatching_events_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'spec/support/rails_seven_one.rb' diff --git a/gemfiles/rails_4.2.gemfile b/gemfiles/rails_4.2.gemfile deleted file mode 100644 index 00f9367..0000000 --- a/gemfiles/rails_4.2.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -source "https://rubygems.org" - -gem "rails", "~> 4.2.11" -gem "sqlite3", "~> 1.3.6" - -gemspec path: "../" diff --git a/gemfiles/rails_4.2.gemfile.lock b/gemfiles/rails_4.2.gemfile.lock deleted file mode 100644 index 3188dec..0000000 --- a/gemfiles/rails_4.2.gemfile.lock +++ /dev/null @@ -1,319 +0,0 @@ -PATH - remote: .. - specs: - webhook_system (2.4.0) - activejob (> 4.2, < 7.1) - activerecord (> 4.2, < 7.1) - activesupport (> 4.2, < 7.1) - faraday (> 0.9) - faraday-encoding (>= 0.0.2, < 1.0) - ph_model - validate_url (~> 1.0) - -GEM - remote: https://rubygems.org/ - specs: - actionmailer (4.2.11.3) - actionpack (= 4.2.11.3) - actionview (= 4.2.11.3) - activejob (= 4.2.11.3) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.11.3) - actionview (= 4.2.11.3) - activesupport (= 4.2.11.3) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.11.3) - activesupport (= 4.2.11.3) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - active_attr (0.15.4) - actionpack (>= 3.0.2, < 7.1) - activemodel (>= 3.0.2, < 7.1) - activesupport (>= 3.0.2, < 7.1) - activejob (4.2.11.3) - activesupport (= 4.2.11.3) - globalid (>= 0.3.0) - activemodel (4.2.11.3) - activesupport (= 4.2.11.3) - builder (~> 3.1) - activerecord (4.2.11.3) - activemodel (= 4.2.11.3) - activesupport (= 4.2.11.3) - arel (~> 6.0) - activesupport (4.2.11.3) - i18n (~> 0.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.8.1) - public_suffix (>= 2.0.2, < 6.0) - arel (6.0.4) - ast (2.4.2) - async (1.31.0) - console (~> 1.10) - nio4r (~> 2.3) - timers (~> 4.1) - async-http (0.59.5) - async (>= 1.25) - async-io (>= 1.28) - async-pool (>= 0.2) - protocol-http (~> 0.23) - protocol-http1 (~> 0.14.0) - protocol-http2 (~> 0.14.0) - traces (>= 0.8.0) - async-http-faraday (0.11.0) - async-http (~> 0.42) - faraday - async-io (1.34.3) - async - async-pool (0.4.0) - async (>= 1.25) - builder (3.2.4) - concurrent-ruby (1.2.2) - console (1.15.3) - fiber-local - coveralls_reborn (0.27.0) - simplecov (~> 0.22.0) - term-ansicolor (~> 1.7) - thor (~> 1.2) - tins (~> 1.32) - crack (0.4.5) - rexml - crass (1.0.6) - date (3.3.3) - diff-lcs (1.5.0) - docile (1.4.0) - erubis (2.7.0) - factory_bot (5.2.0) - activesupport (>= 4.2.0) - faraday (2.7.4) - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) - faraday-encoding (0.0.5) - faraday - faraday-http-cache (2.4.1) - faraday (>= 0.8) - faraday-net_http (3.0.2) - fiber-local (1.0.0) - github_changelog_generator (1.16.4) - activesupport - async (>= 1.25.0) - async-http-faraday - faraday-http-cache - multi_json - octokit (~> 4.6) - rainbow (>= 2.2.1) - rake (>= 10.0) - globalid (0.4.2) - activesupport (>= 4.2.0) - hashdiff (1.0.1) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - io-console (0.6.0) - irb (1.6.3) - reline (>= 0.3.0) - json (2.6.3) - loofah (2.19.1) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - mini_mime (1.1.2) - mini_portile2 (2.8.1) - minitest (5.18.0) - multi_json (1.15.0) - net-imap (0.3.4) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.1) - timeout - net-smtp (0.3.3) - net-protocol - nio4r (2.5.8) - nokogiri (1.13.10) - mini_portile2 (~> 2.8.0) - racc (~> 1.4) - octokit (4.25.1) - faraday (>= 1, < 3) - sawyer (~> 0.9) - parallel (1.22.1) - parser (3.2.2.0) - ast (~> 2.4.1) - ph_model (1.1.3) - active_attr (~> 0.8) - activemodel (> 3.2) - activesupport (> 3.2) - pr_comet (0.5.1) - octokit - rainbow - protocol-hpack (1.4.2) - protocol-http (0.24.1) - protocol-http1 (0.14.6) - protocol-http (~> 0.22) - protocol-http2 (0.14.2) - protocol-hpack (~> 1.4) - protocol-http (~> 0.18) - public_suffix (5.0.1) - racc (1.6.2) - rack (1.6.13) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.11.3) - actionmailer (= 4.2.11.3) - actionpack (= 4.2.11.3) - actionview (= 4.2.11.3) - activejob (= 4.2.11.3) - activemodel (= 4.2.11.3) - activerecord (= 4.2.11.3) - activesupport (= 4.2.11.3) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.11.3) - sprockets-rails - rails-deprecated_sanitizer (1.0.4) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.9) - activesupport (>= 4.2.0, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.5.0) - loofah (~> 2.19, >= 2.19.1) - railties (4.2.11.3) - actionpack (= 4.2.11.3) - activesupport (= 4.2.11.3) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.7.0) - reline (0.3.3) - io-console (~> 0.5) - rexml (3.2.5) - rspec (3.12.0) - rspec-core (~> 3.12.0) - rspec-expectations (~> 3.12.0) - rspec-mocks (~> 3.12.0) - rspec-core (3.12.1) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.5) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-support (3.12.0) - rubocop (1.48.1) - json (~> 2.3) - parallel (~> 1.10) - parser (>= 3.2.0.0) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.26.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.28.0) - parser (>= 3.2.1.0) - rubocop-capybara (2.17.1) - rubocop (~> 1.41) - rubocop-performance (1.16.0) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.18.0) - activesupport (>= 4.2.0) - rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) - rubocop-rake (0.6.0) - rubocop (~> 1.0) - rubocop-rspec (2.19.0) - rubocop (~> 1.33) - rubocop-capybara (~> 2.17) - rubocop-thread_safety (0.5.1) - rubocop (>= 0.90.0) - rubocop_challenger (2.7.0) - pr_comet (~> 0.5.1) - rainbow - rubocop (>= 0.87) - rubocop-performance - rubocop-rails - rubocop-rake - rubocop-rspec - rubocop-thread_safety - thor - yard - ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) - rubygems-tasks (0.2.5) - irb (~> 1.0) - sawyer (0.9.2) - addressable (>= 2.3.5) - faraday (>= 0.17.3, < 3) - simplecov (0.22.0) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) - simplecov-lcov (0.8.0) - simplecov_json_formatter (0.1.4) - sprockets (4.1.1) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.2) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (>= 3.0.0) - sqlite3 (1.3.13) - sync (0.5.0) - term-ansicolor (1.7.1) - tins (~> 1.0) - thor (1.2.1) - thread_safe (0.3.6) - timeout (0.3.2) - timers (4.3.5) - tins (1.32.1) - sync - traces (0.9.1) - tzinfo (1.2.11) - thread_safe (~> 0.1) - unicode-display_width (2.4.2) - validate_url (1.0.15) - activemodel (>= 3.0.0) - public_suffix - webmock (3.18.1) - addressable (>= 2.8.0) - crack (>= 0.3.2) - hashdiff (>= 0.4.0, < 2.0.0) - webrick (1.7.0) - yard (0.9.28) - webrick (~> 1.7.0) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (> 1.17, < 2.5) - coveralls_reborn (~> 0.25) - factory_bot - github_changelog_generator (~> 1.6) - rails (~> 4.2.11) - rake - rspec (~> 3.0) - rubocop_challenger - rubygems-tasks (~> 0.2) - simplecov-lcov - sqlite3 (~> 1.3.6) - webhook_system! - webmock - -BUNDLED WITH - 1.17.3 diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile new file mode 100644 index 0000000..0f1d346 --- /dev/null +++ b/gemfiles/rails_7.1.gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "active_attr", "~> 0.16" # git: "https://github.com/mathieujobin/active_attr", branch: "rails-7.1-support" +gem "rails", "~> 7.1.1" +gem "sqlite3" + +gemspec path: "../" diff --git a/lib/webhook_system/version.rb b/lib/webhook_system/version.rb index ea04c00..fd5f19c 100644 --- a/lib/webhook_system/version.rb +++ b/lib/webhook_system/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module WebhookSystem - VERSION = '2.4.0' + VERSION = '2.4.1' end diff --git a/spec/support/rails_seven_one.rb b/spec/support/rails_seven_one.rb new file mode 100644 index 0000000..9c92360 --- /dev/null +++ b/spec/support/rails_seven_one.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require "active_support/testing/assertions" + +module ActiveSupport + module Testing + module Assertions + # Assertion that the block should not raise an exception. + # + # Passes if evaluated code in the yielded block raises no exception. + # + # assert_nothing_raised do + # perform_service(param: 'no_exception') + # end + def assert_nothing_raised + yield # .tap { debugger ; assert(true) } + rescue => error + raise Minitest::UnexpectedError.new(error) + end + end + end +end if RUBY_VERSION > '3.1' && ActiveSupport.version > '7.1' diff --git a/webhook_system.gemspec b/webhook_system.gemspec index 6611e77..b932e9b 100644 --- a/webhook_system.gemspec +++ b/webhook_system.gemspec @@ -36,16 +36,16 @@ Gem::Specification.new do |gem| ``` } - gem.required_ruby_version = '> 2.6.2' - gem.add_runtime_dependency 'activesupport', '> 4.2', '< 7.1' - gem.add_runtime_dependency 'activerecord', '> 4.2', '< 7.1' - gem.add_runtime_dependency 'activejob', '> 4.2', '< 7.1' + gem.required_ruby_version = '> 2.7.0' + gem.add_runtime_dependency 'activesupport', '> 5.0', '< 7.2' + gem.add_runtime_dependency 'activerecord', '> 5.0', '< 7.2' + gem.add_runtime_dependency 'activejob', '> 5.0', '< 7.2' gem.add_runtime_dependency 'faraday', '> 0.9' gem.add_runtime_dependency 'faraday-encoding', '>= 0.0.2', '< 1.0' gem.add_runtime_dependency 'ph_model' gem.add_runtime_dependency 'validate_url', '~> 1.0' - gem.add_development_dependency 'bundler', '> 1.17', '< 2.5' + gem.add_development_dependency 'bundler', '> 1.17', '< 2.6' gem.add_development_dependency 'coveralls_reborn', '~> 0.25' gem.add_development_dependency 'simplecov-lcov' gem.add_development_dependency 'rake'