diff --git a/.rubocop.yml b/.rubocop.yml index 2c140dc27..9f21a8ef2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -38,6 +38,8 @@ Rails/RedundantPresenceValidationOnBelongsTo: Enabled: false Style/DateTime: Enabled: true +Style/HashSyntax: + EnforcedShorthandSyntax: never Rails/TimeZone: Enabled: true Rails/UnknownEnv: diff --git a/.ruby-version b/.ruby-version index 80b0e7ef4..c877459a0 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.7.7 +ruby-3.1.3 diff --git a/CHANGELOG.md b/CHANGELOG.md index dfa0e0d79..faf32c089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog Fab-manager -- Updated ruby to 2.7 +- Updated ruby to 3.1 - Updated rails to 6.1 - Updated puma to 6.1 - Updated responders to 3.0 diff --git a/Dockerfile b/Dockerfile index c770ad17f..41cb03a50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.7.7-alpine +FROM ruby:3.1.3-alpine MAINTAINER contact@fab-manager.com # Install upgrade system packages diff --git a/Gemfile b/Gemfile index c67f0982b..72e0c57cf 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,13 @@ gem 'bootsnap' gem 'puma', '6.1.0' gem 'shakapacker', '6.5.5' +# rails 6 compatibility with ruby 3 (may not be required after upgrade to rails 7) +gem 'matrix' +gem 'net-imap', require: false +gem 'net-pop', require: false +gem 'net-smtp', require: false +gem 'psych', '< 4' + # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' gem 'jbuilder_cache_multi' @@ -52,7 +59,7 @@ group :test do gem 'minitest-reporters' gem 'pdf-reader' gem 'rubyXL' - gem 'vcr', '6.0.0' + gem 'vcr', '~> 6.1.0' gem 'webmock' end diff --git a/Gemfile.lock b/Gemfile.lock index 667641988..0ef934f8f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -42,7 +42,7 @@ GEM erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - active_record_query_trace (1.7) + active_record_query_trace (1.8) activejob (6.1.7.2) activesupport (= 6.1.7.2) globalid (>= 0.3.6) @@ -126,6 +126,7 @@ GEM safe_yaml (~> 1.0.0) crass (1.0.6) database_cleaner (1.8.3) + date (3.3.3) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) devise (4.9.0) @@ -228,6 +229,7 @@ GEM mail (2.7.1) mini_mime (>= 0.1.1) marcel (1.0.2) + matrix (0.4.2) message_format (0.0.6) twitter_cldr (~> 5.0) method_source (1.0.0) @@ -236,7 +238,6 @@ GEM rake mini_magick (4.10.1) mini_mime (1.1.2) - mini_portile2 (2.8.1) minitest (5.17.0) minitest-reporters (1.4.2) ansi @@ -247,9 +248,17 @@ GEM multi_json (1.14.1) multi_xml (0.6.0) multipart-post (2.1.1) + 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.14.2) - mini_portile2 (~> 2.8.0) + nokogiri (1.14.2-x86_64-linux) racc (~> 1.4) oauth2 (1.4.4) faraday (>= 0.8, < 2.0) @@ -291,7 +300,7 @@ GEM parallel (1.19.1) parser (3.1.2.0) ast (~> 2.4.1) - pdf-core (0.7.0) + pdf-core (0.9.0) pdf-reader (2.4.0) Ascii85 (~> 1.0.0) afm (~> 0.2.1) @@ -302,11 +311,12 @@ GEM pg_search (2.3.2) activerecord (>= 5.2) activesupport (>= 5.2) - prawn (2.2.2) - pdf-core (~> 0.7.0) - ttfunk (~> 1.5) + prawn (2.4.0) + pdf-core (~> 0.9.0) + ttfunk (~> 1.7) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) + psych (3.3.4) public_suffix (4.0.6) puma (6.1.0) nio4r (~> 2.0) @@ -433,7 +443,7 @@ GEM simplecov (0.19.0) docile (~> 1.1) simplecov-html (~> 0.11) - simplecov-html (0.12.2) + simplecov-html (0.12.3) spring (2.0.2) activesupport (>= 4.2) spring-watcher-listen (2.0.1) @@ -460,9 +470,10 @@ GEM thor (1.2.1) thread_safe (0.3.6) tilt (2.0.10) + timeout (0.3.2) tins (1.25.0) sync - ttfunk (1.5.1) + ttfunk (1.7.0) twitter_cldr (5.4.0) camertron-eprun cldr-plurals-runtime-rb (~> 1.0) @@ -479,7 +490,7 @@ GEM validate_url (1.0.13) activemodel (>= 3.0.0) public_suffix - vcr (6.0.0) + vcr (6.1.0) virtus (1.0.5) axiom-types (~> 0.1) coercible (~> 1.0) @@ -505,7 +516,7 @@ GEM zeitwerk (2.6.7) PLATFORMS - ruby + x86_64-linux DEPENDENCIES aasm @@ -539,9 +550,13 @@ DEPENDENCIES jsonpath kaminari listen (~> 3.0.5) + matrix message_format mini_magick minitest-reporters + net-imap + net-pop + net-smtp oj omniauth (~> 1.9.2) omniauth-oauth2 @@ -554,6 +569,7 @@ DEPENDENCIES pg_search prawn prawn-table + psych (< 4) puma (= 6.1.0) pundit railroady @@ -582,7 +598,7 @@ DEPENDENCIES stripe (= 5.29.0) sys-filesystem tzinfo-data - vcr (= 6.0.0) + vcr (~> 6.1.0) web-console (>= 3.3.0) webmock diff --git a/app/services/setting_service.rb b/app/services/setting_service.rb index 0e5bf728a..3f10899cb 100644 --- a/app/services/setting_service.rb +++ b/app/services/setting_service.rb @@ -114,7 +114,7 @@ class SettingService return unless (%w[openlab_app_id openlab_app_secret] & settings.map(&:name)).count.positive? && Setting.get('openlab_app_id').present? && Setting.get('openlab_app_secret').present? - Project.all.each(&:openlab_create) + Project.find_each(&:openlab_create) end # automatically validate the admins diff --git a/app/validators/closed_period_validator.rb b/app/validators/closed_period_validator.rb index 7a7a24bd2..d46ba4a18 100644 --- a/app/validators/closed_period_validator.rb +++ b/app/validators/closed_period_validator.rb @@ -9,7 +9,7 @@ class ClosedPeriodValidator < ActiveModel::Validator Time.current end - AccountingPeriod.all.each do |period| + AccountingPeriod.find_each do |period| record.errors.add(:date, I18n.t('errors.messages.in_closed_period')) if date >= period.start_at && date <= period.end_at end end diff --git a/app/validators/period_overlap_validator.rb b/app/validators/period_overlap_validator.rb index ce20e0cff..221f9259e 100644 --- a/app/validators/period_overlap_validator.rb +++ b/app/validators/period_overlap_validator.rb @@ -6,7 +6,7 @@ class PeriodOverlapValidator < ActiveModel::Validator the_end = record.end_at the_start = record.start_at - AccountingPeriod.all.each do |period| + AccountingPeriod.find_each do |period| record.errors.add(:start_at, I18n.t('errors.messages.cannot_overlap')) if the_start >= period.start_at && the_start <= period.end_at record.errors.add(:end_at, I18n.t('errors.messages.cannot_overlap')) if the_end >= period.start_at && the_end <= period.end_at record.errors.add(:end_at, I18n.t('errors.messages.cannot_encompass')) if period.start_at >= the_start && period.end_at <= the_end diff --git a/db/seeds.rb b/db/seeds.rb index 12dbac770..2e5883c0f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -141,7 +141,7 @@ if Training.count.zero? } ]) - TrainingsPricing.all.each do |p| + TrainingsPricing.find_each do |p| p.update(amount: ((rand * 50) + 5).floor * 100) end end @@ -222,7 +222,7 @@ if Machine.count.zero? } ]) - Price.all.each do |p| + Price.find_each do |p| p.update(amount: ((rand * 50) + 5).floor * 100) end end diff --git a/lib/integrity/archive_helper.rb b/lib/integrity/archive_helper.rb index a0b376982..8ae2fa315 100644 --- a/lib/integrity/archive_helper.rb +++ b/lib/integrity/archive_helper.rb @@ -6,7 +6,6 @@ module Integrity; end # Provides various helpers methods for interacting with accounting archives class Integrity::ArchiveHelper class << self - ## Checks the validity of all closed periods and raise an error otherwise def check_footprints if AccountingPeriod.count.positive? @@ -20,7 +19,7 @@ class Integrity::ArchiveHelper end else Rails.logger.info 'Checking all invoices footprints. This may take a while...' - Invoice.order(:id).all.each do |i| + Invoice.order(:id).find_each do |i| next if i.check_footprint i.debug_footprint @@ -48,7 +47,7 @@ class Integrity::ArchiveHelper ) end # 3. Delete periods from database - range_periods.each do |ap| + range_periods.each do |ap| # rubocop:disable Style/CombinableLoops execute("DELETE FROM accounting_periods WHERE ID=#{ap.id};") end periods diff --git a/test/integration/auth_providers_test.rb b/test/integration/auth_providers_test.rb index fb23c1428..9cb3e878f 100644 --- a/test/integration/auth_providers_test.rb +++ b/test/integration/auth_providers_test.rb @@ -40,7 +40,7 @@ class AuthProvidersTest < ActionDispatch::IntegrationTest db_provider&.reload assert_equal 'active', db_provider&.status assert_equal AuthProvider.active.id, db_provider&.id - User.all.each do |u| + User.find_each do |u| assert_not_nil u.auth_token end end