From 9a474c30b91d4b0852bfa5b40990fe7f871c7813 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 10:22:26 +0200 Subject: [PATCH 01/19] Upgrade Ruby to version 3.3 and Node to version 18 --- .tool-versions.sample | 4 +- Gemfile | 16 +++--- Gemfile.lock | 122 ++++++++++++++++++++++++----------------- fedora-manual-setup.md | 2 +- osx-manual-setup.md | 2 +- package.json | 2 +- 6 files changed, 85 insertions(+), 63 deletions(-) diff --git a/.tool-versions.sample b/.tool-versions.sample index e4dad50a6b..129dc76d22 100644 --- a/.tool-versions.sample +++ b/.tool-versions.sample @@ -1,3 +1,3 @@ -ruby 2.7.6 -nodejs 16.19.1 +ruby 3.3.1 +nodejs 18.20.4 python 2.7.18 diff --git a/Gemfile b/Gemfile index 2fae17a4c0..1c5494e66f 100644 --- a/Gemfile +++ b/Gemfile @@ -14,10 +14,7 @@ gem 'aws-sdk-s3', '~> 1' gem 'dotenv-rails', '~> 2.7' gem 'rails', '~> 6.1' -# Locking mail to 2.7.x, as 2.8 has a regression related to `enable_starttls_auto` setting: -# https://github.com/mikel/mail/blob/2-8-stable/CHANGELOG.rdoc#version-281-unreleased- -# Also, upgrading makes this test fail: SendUserInvitationWorkerTest#test_handles_errors -gem 'mail', '~> 2.7.1' +gem 'mail', '~> 2.8.1' gem "activejob-uniqueness" # Needed for XML serialization of ActiveRecord::Base @@ -44,6 +41,8 @@ gem 'bcrypt', '~> 3.1.7' gem 'oauth2', '~> 2.0' gem 'open_id_authentication' +gem 'sorted_set', '~> 1.0' + gem 'i18n' # Apisonator client @@ -73,7 +72,7 @@ gem 'stripe', '~> 5.28.0' # we need the stripe gem because activemerchant can no gem 'acts_as_list', '~> 0.9.17' gem 'braintree', '~> 2.93' gem 'bugsnag', '~> 6.26' -gem 'cancancan', '~> 3.0.0' +gem 'cancancan', '~> 3.6.0' gem 'formtastic', '~> 4.0' gem 'htmlentities', '~>4.3', '>= 4.3.4' # TODO: Not actively maintained https://github.com/activeadmin/inherited_resources#notice replace with respond_with and fix things the rails way @@ -120,7 +119,8 @@ gem 'ts-datetime-delta', require: 'thinking_sphinx/deltas/datetime_delta' gem 'will_paginate', '~> 3.3' gem 'zip-zip', require: false -gem 'acts_as_tree' +# TODO: this gem seems a bit abandoned, consider getting rid of it +gem 'acts_as_tree', '~> 2.9.1' gem 'addressable', require: false gem 'hashie', require: false gem 'rack-x_served_by', '~> 0.1.1' @@ -158,7 +158,7 @@ gem 'html-pipeline' gem 'ruby-openid' gem 'slim-rails', '~> 3.2' -gem 'draper', '~> 3.1' +gem 'draper', '~> 4.0.2' group :development do gem 'listen' @@ -188,7 +188,7 @@ group :test do gem 'rails-controller-testing', '~> 1.0.4' gem 'simplecov', '~> 0.21.2', require: false - gem 'capybara', '~>3.35.3', source: 'https://rubygems.org' + gem 'capybara', '~>3.35.3' gem 'xpath', '~>3.2.0' gem 'chronic' diff --git a/Gemfile.lock b/Gemfile.lock index 1a8c5c3798..051e5d72e6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -158,10 +158,10 @@ GEM activerecord (>= 5.0, < 6.2) acts_as_list (0.9.17) activerecord (>= 3.0) - acts_as_tree (2.9.0) + acts_as_tree (2.9.1) activerecord (>= 3.0.0) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) afm (0.2.2) after_commit_queue (1.1.0) rails (>= 3.0) @@ -169,8 +169,8 @@ GEM activesupport (>= 3.0) analytics-ruby (2.2.8) ansi (1.5.0) - anyway_config (2.5.0) - ruby-next-core (>= 0.14.0) + anyway_config (2.6.4) + ruby-next-core (~> 1.0) ast (2.4.2) audited (5.0.2) activerecord (>= 5.0, < 7.1) @@ -225,12 +225,12 @@ GEM browser (5.3.1) bugsnag (6.26.3) concurrent-ruby (~> 1.0) - builder (3.2.4) + builder (3.3.0) bullet (6.1.5) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) - cancancan (3.0.2) + cancancan (3.6.1) capybara (3.35.3) addressable mini_mime (>= 0.1.3) @@ -273,12 +273,12 @@ GEM compass (~> 1.0.0) sass-rails (< 5.1) sprockets (< 4.0) - concurrent-ruby (1.3.1) + concurrent-ruby (1.3.3) connection_pool (2.4.1) crack (0.4.5) rexml crass (1.0.6) - css_parser (1.12.0) + css_parser (1.17.1) addressable cucumber (7.1.0) builder (~> 3.2, >= 3.2.4) @@ -326,6 +326,7 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) + date (3.3.4) debug_inspector (1.1.0) declarative (0.0.20) declarative-builder (0.1.0) @@ -346,13 +347,14 @@ GEM dotenv-rails (2.8.1) dotenv (= 2.8.1) railties (>= 3.2) - draper (3.1.0) + draper (4.0.2) actionpack (>= 5.0) activemodel (>= 5.0) activemodel-serializers-xml (>= 1.0) activesupport (>= 5.0) request_store (>= 1.0) - dry-initializer (3.0.4) + ruby2_keywords + dry-initializer (3.1.1) dynamic_form (1.3.1) actionview (> 5.2.0) activemodel (> 5.2.0) @@ -362,7 +364,7 @@ GEM mail (~> 2.7) equivalent-xml (0.6.0) nokogiri (>= 1.4.3) - erubi (1.12.0) + erubi (1.13.0) escape_utils (1.2.1) et-orbi (1.2.7) tzinfo @@ -382,7 +384,7 @@ GEM faraday-net_http_persistent (2.1.0) faraday (~> 2.5) net-http-persistent (~> 4.0) - ffi (1.16.3) + ffi (1.17.0) ffi-compiler (1.0.1) ffi (>= 1.0.0) rake @@ -417,7 +419,7 @@ GEM http-form_data (2.3.0) http-parser (1.2.3) ffi-compiler (>= 1.0, < 2.0) - i18n (1.14.4) + i18n (1.14.5) concurrent-ruby (~> 1.0) inherited_resources (1.12.0) actionpack (>= 5.2, < 6.2) @@ -437,7 +439,7 @@ GEM jsonpath (1.1.2) multi_json jwt (1.5.6) - kgio (2.11.3) + kgio (2.11.4) kramdown (2.4.0) rexml kt-paperclip (7.2.1) @@ -464,7 +466,7 @@ GEM with_env (= 1.1.0) xml-simple (~> 1.1.9) liquid (3.0.6) - listen (3.2.1) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) local-fastimage (3.1.3) @@ -473,11 +475,15 @@ GEM loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.7.1) + mail (2.8.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp mail_view (2.0.4) tilt marcel (1.0.4) + matrix (0.4.2) mechanize (2.7.7) domain_name (~> 0.5, >= 0.5.1) http-cookie (~> 1.0) @@ -488,7 +494,7 @@ GEM ntlm-http (~> 0.1, >= 0.1.1) webrick (~> 1.7) webrobots (>= 0.0.9, < 0.2) - method_source (1.0.0) + method_source (1.1.0) middleware (0.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) @@ -519,6 +525,15 @@ GEM net-http-digest_auth (1.4.1) net-http-persistent (4.0.2) connection_pool (~> 2.2) + net-imap (0.4.14) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol netrc (0.11.0) nio4r (2.7.1) nokogiri (1.15.6) @@ -563,32 +578,32 @@ GEM css_parser (~> 1.6) prawn (>= 0.11.1, < 3) rexml (~> 3.2) - prometheus-client-mmap (0.28.0) - rb_sys (~> 0.9) + prometheus-client-mmap (1.1.1) + rb_sys (~> 0.9.86) protected_attributes_continued (1.8.2) activemodel (>= 5.0) - pry (0.13.1) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.9.0) + pry-byebug (3.10.1) byebug (~> 11.0) - pry (~> 0.13.0) + pry (>= 0.13, < 0.15) pry-doc (1.3.0) pry (~> 0.11) yard (~> 0.9.11) pry-rails (0.3.9) pry (>= 0.10.4) - pry-shell (0.5.0) - pry (~> 0.13.0) + pry-shell (0.6.4) + pry (>= 0.13.0) tty-markdown tty-prompt pry-stack_explorer (0.6.1) binding_of_caller (~> 1.0) pry (~> 0.13) psych (3.2.1) - public_suffix (4.0.7) + public_suffix (6.0.1) raabro (1.4.0) - racc (1.8.0) + racc (1.8.1) rack (2.2.9) rack-cors (1.1.1) rack (>= 2.0.0) @@ -648,7 +663,7 @@ GEM rake (>= 12.2) thor (~> 1.0) rainbow (3.1.1) - raindrops (0.19.0) + raindrops (0.20.1) rake (13.1.0) ransack (2.6.0) activerecord (>= 6.0.4) @@ -657,10 +672,11 @@ GEM ratelimit (1.0.3) redis (>= 2.0.0) redis-namespace (>= 1.0.0) - rb-fsevent (0.10.3) - rb-inotify (0.10.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) ffi (~> 1.0) - rb_sys (0.9.81) + rb_sys (0.9.100) + rbtree (0.4.6) recaptcha (5.16.0) record_tag_helper (1.0.1) actionview (>= 5) @@ -670,8 +686,8 @@ GEM redis-client (>= 0.17.0) redis-client (0.21.1) connection_pool - redis-namespace (1.7.0) - redis (>= 3.0.4) + redis-namespace (1.11.0) + redis (>= 4) redis-prescription (2.6.0) redlock (1.3.2) redis (>= 3.0.0, < 6.0) @@ -691,7 +707,7 @@ GEM declarative (< 0.1.0) declarative-option (< 0.2.0) uber (< 0.2.0) - request_store (1.5.1) + request_store (1.7.0) rack (>= 1.4) responders (3.1.1) actionpack (>= 5.2) @@ -700,7 +716,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.3.3) + rexml (3.3.4) strscan riddle (2.4.3) roar (1.1.1) @@ -712,7 +728,7 @@ GEM roar (~> 1.1.0) test_xml (>= 0.1.6) uber (< 0.2.0) - rouge (3.28.0) + rouge (4.3.0) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) @@ -759,7 +775,7 @@ GEM activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 0.87.0) - ruby-next-core (0.15.3) + ruby-next-core (1.0.3) ruby-oci8 (2.2.12) ruby-openid (2.9.2) ruby-plsql (0.8.0) @@ -781,6 +797,7 @@ GEM childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) semantic_range (3.0.0) + set (1.1.0) shoulda (4.0.0) shoulda-context (~> 2.0) shoulda-matchers (~> 4.0) @@ -815,6 +832,9 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) + sorted_set (1.0.3) + rbtree + set (~> 1.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -861,16 +881,17 @@ GEM riddle (~> 2.3) thor (1.3.1) tilt (2.0.11) + timeout (0.4.1) tomlrb (2.0.3) ts-datetime-delta (2.0.2) thinking-sphinx (>= 1.3.8) ttfunk (1.7.0) tty-color (0.6.0) tty-cursor (0.7.1) - tty-markdown (0.7.0) + tty-markdown (0.7.2) kramdown (>= 1.16.2, < 3.0) pastel (~> 0.8) - rouge (~> 3.14) + rouge (>= 3.14, < 5.0) strings (~> 0.2.0) tty-color (~> 0.5) tty-screen (~> 0.8) @@ -881,7 +902,7 @@ GEM tty-cursor (~> 0.7) tty-screen (~> 0.8) wisper (~> 2.0) - tty-screen (0.8.1) + tty-screen (0.8.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) @@ -890,9 +911,9 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.7) - unicode-display_width (2.3.0) + unicode-display_width (2.5.0) unicode_utils (1.4.0) - unicorn (5.4.1) + unicorn (6.1.0) kgio (~> 2.6) raindrops (~> 0.7) unicorn-rails (2.2.1) @@ -925,15 +946,15 @@ GEM anyway_config (>= 1.0, < 3) concurrent-ruby dry-initializer - yabeda-prometheus-mmap (0.1.1) + yabeda-prometheus-mmap (0.4.0) prometheus-client-mmap - yabeda (~> 0.5) + yabeda (~> 0.10) yabeda-sidekiq (0.10.0) anyway_config (>= 1.3, < 3) sidekiq yabeda (~> 0.6) yard (0.9.36) - zeitwerk (2.6.15) + zeitwerk (2.6.17) zip-zip (0.3) rubyzip (>= 1.0.0) @@ -951,7 +972,7 @@ DEPENDENCIES activerecord-oracle_enhanced-adapter (~> 6.1.6) acts-as-taggable-on (~> 8.0) acts_as_list (~> 0.9.17) - acts_as_tree + acts_as_tree (~> 2.9.1) addressable after_commit_queue (~> 1.1.0) analytics-ruby @@ -965,8 +986,8 @@ DEPENDENCIES browser bugsnag (~> 6.26) bullet (~> 6.1.5) - cancancan (~> 3.0.0) - capybara (~> 3.35.3)! + cancancan (~> 3.6.0) + capybara (~> 3.35.3) childprocess chronic ci_reporter_shell! @@ -982,7 +1003,7 @@ DEPENDENCIES developer_portal! diff-lcs (~> 1.2) dotenv-rails (~> 2.7) - draper (~> 3.1) + draper (~> 4.0.2) dynamic_form email_spec equivalent-xml @@ -1010,7 +1031,7 @@ DEPENDENCIES license_finder (~> 7.1.0) listen local-fastimage_resize (~> 3.4.0) - mail (~> 2.7.1) + mail (~> 2.8.1) mail_view (~> 2.0.4) mechanize mimemagic (~> 0.3.10) @@ -1079,6 +1100,7 @@ DEPENDENCIES sidekiq-throttled (~> 1.4.0) simplecov (~> 0.21.2) slim-rails (~> 3.2) + sorted_set (~> 1.0) sprockets-rails state_machines (~> 0.5.0) state_machines-activerecord (~> 0.8) diff --git a/fedora-manual-setup.md b/fedora-manual-setup.md index 529ad7d758..b96030fbda 100644 --- a/fedora-manual-setup.md +++ b/fedora-manual-setup.md @@ -12,7 +12,7 @@ ln -s .tool-versions.sample .tool-versions ### Ruby and Node.js -The project supports **[ruby 2.7.x](https://www.ruby-lang.org/en/downloads/)** and **[Node.js 16](https://nodejs.org/download/release/v16.19.1/)**. +The project supports **[ruby 3.3.x](https://www.ruby-lang.org/en/downloads/)** and **[Node.js 18](https://nodejs.org/download/release/v18.20.4/)**. The recommended way to install them is with `asdf`: ``` diff --git a/osx-manual-setup.md b/osx-manual-setup.md index 8ecc4cba9e..8bcbab3b01 100644 --- a/osx-manual-setup.md +++ b/osx-manual-setup.md @@ -26,7 +26,7 @@ ln -s .tool-versions.sample .tool-versions ### Ruby and Node.js -The project supports **[ruby 2.7.x](https://www.ruby-lang.org/en/downloads/)** and **[Node.js 16](https://nodejs.org/download/release/v16.19.1/)**. To install them with `asdf` run: +The project supports **[ruby 3.3.x](https://www.ruby-lang.org/en/downloads/)** and **[Node.js 18](https://nodejs.org/download/release/v18.20.4/)**. To install them with `asdf` run: ``` asdf plugin add ruby diff --git a/package.json b/package.json index e83b6652f3..c6d9c3d2e6 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "ci:lint": "eslint --ext .js,.jsx,.ts,.tsx . --quiet" }, "engines": { - "node": "16" + "node": "18" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.56.0", From 5848e188ce42ea8f84b3e1d1ca02f74a5ff20cbe Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Thu, 8 Aug 2024 15:34:38 +0200 Subject: [PATCH 02/19] Monkey patch Files to add #exists? method --- config/application.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/application.rb b/config/application.rb index 9c6b2f219a..4bdf04d55c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -34,6 +34,12 @@ end end +File.class_eval do + class << self + alias_method :exists?, :exist? + end +end + # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:oracle, assets: %w[development production test])) # If you want your assets lazily compiled in production, use this line From 9e52e4b618cff178c82ab5f3d2d05e7b03c109bb Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 10:23:19 +0200 Subject: [PATCH 03/19] Update CircleCI config and the builder image --- .circleci/config.yml | 146 +++++++++++++++++++++---------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index eecc439e8c..be46ce2f1b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,8 +91,8 @@ attach-to-workspace: &attach-to-workspace attach_workspace: at: . -system-builder-ruby27: &system-builder-ruby27 - image: quay.io/3scale/system-builder:stream8 +system-builder-ruby33: &system-builder-ruby33 + image: quay.io/3scale/system-builder:stream8-ruby3.3 environment: BUNDLE_FROZEN: true BUNDLE_PATH: 'vendor/bundle' @@ -363,69 +363,69 @@ commands: # reusable commands with parameters ##################################### CIRCLECI EXECUTORS ############################################ executors: - builder-ruby27: &builder-ruby27 + builder-ruby33: &builder-ruby33 parameters: database: type: string default: mysql docker: - - *system-builder-ruby27 + - *system-builder-ruby33 environment: DB: << parameters.database >> working_directory: /opt/ci/workdir - builder-with-mysql-ruby27: &builder-with-mysql-ruby27 + builder-with-mysql-ruby33: &builder-with-mysql-ruby33 resource_class: small docker: - - *system-builder-ruby27 + - *system-builder-ruby33 - *mysql-container - *memcached-container - *redis-container working_directory: /opt/ci/workdir <<: *build-envs-mysql - builder-with-postgres-ruby27: &builder-with-postgres-ruby27 + builder-with-postgres-ruby33: &builder-with-postgres-ruby33 resource_class: small docker: - - *system-builder-ruby27 + - *system-builder-ruby33 - *postgres-container - *memcached-container - *redis-container working_directory: /opt/ci/workdir <<: *build-envs-postgresql - builder-with-oracle-ruby27: &builder-with-oracle-ruby27 + builder-with-oracle-ruby33: &builder-with-oracle-ruby33 resource_class: large docker: - - *system-builder-ruby27 + - *system-builder-ruby33 - *oracle-db-container - *memcached-container - *redis-container working_directory: /opt/ci/workdir <<: *build-envs-oracle - cucumber-with-mysql-ruby27: &cucumber-with-mysql-ruby27 + cucumber-with-mysql-ruby33: &cucumber-with-mysql-ruby33 resource_class: small docker: - - *system-builder-ruby27 + - *system-builder-ruby33 - *dnsmasq-container - *mysql-container - *memcached-container - *redis-container - cucumber-with-postgres-ruby27: &cucumber-with-postgres-ruby27 + cucumber-with-postgres-ruby33: &cucumber-with-postgres-ruby33 resource_class: small docker: - - *system-builder-ruby27 + - *system-builder-ruby33 - *dnsmasq-container - *postgres-container - *memcached-container - *redis-container - cucumber-with-oracle-ruby27: &cucumber-with-oracle-ruby27 + cucumber-with-oracle-ruby33: &cucumber-with-oracle-ruby33 resource_class: large docker: - - *system-builder-ruby27 + - *system-builder-ruby33 - *dnsmasq-container - *oracle-db-container - *memcached-container @@ -438,7 +438,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby33 executor: name: << parameters.executor >> database: mysql @@ -450,7 +450,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby33 executor: name: << parameters.executor >> database: postgresql @@ -462,7 +462,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby33 executor: name: << parameters.executor >> database: oracle @@ -476,7 +476,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby33 executor: name: << parameters.executor >> steps: @@ -499,7 +499,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby33 executor: name: << parameters.executor >> steps: @@ -527,7 +527,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby33 executor: name: << parameters.executor >> steps: @@ -542,7 +542,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby33 executor: name: << parameters.executor >> steps: @@ -562,7 +562,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby33 executor: name: << parameters.executor >> steps: @@ -579,7 +579,7 @@ jobs: parameters: executor: type: string - default: builder-with-mysql-ruby27 + default: builder-with-mysql-ruby33 executor: name: << parameters.executor >> steps: @@ -591,7 +591,7 @@ jobs: parameters: executor: type: string - default: builder-with-postgres-ruby27 + default: builder-with-postgres-ruby33 executor: name: << parameters.executor >> steps: @@ -603,7 +603,7 @@ jobs: parameters: executor: type: string - default: builder-with-oracle-ruby27 + default: builder-with-oracle-ruby33 executor: name: << parameters.executor >> steps: @@ -617,7 +617,7 @@ jobs: parameters: executor: type: string - default: builder-with-mysql-ruby27 + default: builder-with-mysql-ruby33 executor: name: << parameters.executor >> steps: @@ -629,7 +629,7 @@ jobs: parameters: executor: type: string - default: builder-with-postgres-ruby27 + default: builder-with-postgres-ruby33 executor: name: << parameters.executor >> steps: @@ -641,7 +641,7 @@ jobs: parameters: executor: type: string - default: builder-with-oracle-ruby27 + default: builder-with-oracle-ruby33 executor: name: << parameters.executor >> steps: @@ -655,7 +655,7 @@ jobs: parameters: executor: type: string - default: builder-with-mysql-ruby27 + default: builder-with-mysql-ruby33 executor: name: << parameters.executor >> steps: @@ -667,7 +667,7 @@ jobs: parameters: executor: type: string - default: builder-with-postgres-ruby27 + default: builder-with-postgres-ruby33 executor: name: << parameters.executor >> steps: @@ -679,7 +679,7 @@ jobs: parameters: executor: type: string - default: builder-with-oracle-ruby27 + default: builder-with-oracle-ruby33 executor: name: << parameters.executor >> steps: @@ -693,7 +693,7 @@ jobs: parameters: executor: type: string - default: builder-with-mysql-ruby27 + default: builder-with-mysql-ruby33 executor: name: << parameters.executor >> steps: @@ -705,7 +705,7 @@ jobs: parameters: executor: type: string - default: builder-with-postgres-ruby27 + default: builder-with-postgres-ruby33 executor: name: << parameters.executor >> steps: @@ -717,7 +717,7 @@ jobs: parameters: executor: type: string - default: builder-with-oracle-ruby27 + default: builder-with-oracle-ruby33 executor: name: << parameters.executor >> steps: @@ -732,7 +732,7 @@ jobs: parameters: executor: type: string - default: cucumber-with-mysql-ruby27 + default: cucumber-with-mysql-ruby33 executor: name: << parameters.executor >> steps: @@ -745,7 +745,7 @@ jobs: parameters: executor: type: string - default: cucumber-with-postgres-ruby27 + default: cucumber-with-postgres-ruby33 executor: name: << parameters.executor >> steps: @@ -758,7 +758,7 @@ jobs: parameters: executor: type: string - default: cucumber-with-oracle-ruby27 + default: cucumber-with-oracle-ruby33 executor: name: << parameters.executor >> steps: @@ -1016,37 +1016,37 @@ workflows: ######## Nightly workflows - mysql_nightly_build_ruby27: + mysql_nightly_build_ruby33: jobs: - notify_start: <<: *only-master-filter - dependencies_bundler: - executor: builder-ruby27 + executor: builder-ruby33 - dependencies_npm: - executor: builder-ruby27 + executor: builder-ruby33 - assets_precompile: - executor: builder-ruby27 + executor: builder-ruby33 requires: - dependencies_bundler - dependencies_npm - unit: - executor: builder-with-mysql-ruby27 + executor: builder-with-mysql-ruby33 requires: - dependencies_bundler - functional: - executor: builder-with-mysql-ruby27 + executor: builder-with-mysql-ruby33 requires: - assets_precompile - integration: - executor: builder-with-mysql-ruby27 + executor: builder-with-mysql-ruby33 requires: - assets_precompile - rspec: - executor: builder-with-mysql-ruby27 + executor: builder-with-mysql-ruby33 requires: - dependencies_bundler - cucumber: - executor: cucumber-with-mysql-ruby27 + executor: cucumber-with-mysql-ruby33 requires: - assets_precompile - notify_success: @@ -1059,37 +1059,37 @@ workflows: <<: *only-master-filter <<: *nightly-trigger - postgres_nightly_build_ruby27: + postgres_nightly_build_ruby33: jobs: - notify_start: <<: *only-master-filter - deps_bundler_postgres: - executor: builder-ruby27 + executor: builder-ruby33 - dependencies_npm: - executor: builder-ruby27 + executor: builder-ruby33 - assets_precompile: - executor: builder-ruby27 + executor: builder-ruby33 requires: - deps_bundler_postgres - dependencies_npm - unit-postgres: - executor: builder-with-postgres-ruby27 + executor: builder-with-postgres-ruby33 requires: - deps_bundler_postgres - functional-postgres: - executor: builder-with-postgres-ruby27 + executor: builder-with-postgres-ruby33 requires: - assets_precompile - integration-postgres: - executor: builder-with-postgres-ruby27 + executor: builder-with-postgres-ruby33 requires: - assets_precompile - rspec-postgres: - executor: builder-with-postgres-ruby27 + executor: builder-with-postgres-ruby33 requires: - deps_bundler_postgres - cucumber-postgres: - executor: cucumber-with-postgres-ruby27 + executor: cucumber-with-postgres-ruby33 requires: - assets_precompile - notify_success: @@ -1102,45 +1102,45 @@ workflows: <<: *only-master-filter <<: *nightly-trigger - oracle_nightly_build_ruby27: + oracle_nightly_build_ruby33: jobs: - notify_start: <<: *only-master-filter - deps_bundler_oracle: - executor: builder-ruby27 + executor: builder-ruby33 - dependencies_npm: - executor: builder-ruby27 + executor: builder-ruby33 - assets_precompile: - executor: builder-ruby27 + executor: builder-ruby33 requires: - deps_bundler_oracle - dependencies_npm - unit-oracle: - executor: builder-with-oracle-ruby27 + executor: builder-with-oracle-ruby33 context: - quay requires: - deps_bundler_oracle - functional-oracle: - executor: builder-with-oracle-ruby27 + executor: builder-with-oracle-ruby33 context: - quay requires: - assets_precompile - integration-oracle: - executor: builder-with-oracle-ruby27 + executor: builder-with-oracle-ruby33 context: - quay requires: - assets_precompile - rspec-oracle: - executor: builder-with-oracle-ruby27 + executor: builder-with-oracle-ruby33 context: - quay requires: - deps_bundler_oracle - cucumber-oracle: - executor: cucumber-with-oracle-ruby27 + executor: cucumber-with-oracle-ruby33 context: - quay requires: @@ -1155,29 +1155,29 @@ workflows: <<: *only-master-filter <<: *nightly-trigger - javascript_nightly_build_ruby27: + javascript_nightly_build_ruby33: jobs: - notify_start: <<: *only-master-filter - dependencies_bundler: - executor: builder-ruby27 + executor: builder-ruby33 - dependencies_npm: - executor: builder-ruby27 + executor: builder-ruby33 - assets_precompile: - executor: builder-ruby27 + executor: builder-ruby33 requires: - dependencies_bundler - dependencies_npm - licenses: - executor: builder-ruby27 + executor: builder-ruby33 requires: - dependencies_bundler - lint: - executor: builder-ruby27 + executor: builder-ruby33 requires: - dependencies_npm - jest: - executor: builder-ruby27 + executor: builder-ruby33 requires: - dependencies_npm - notify_success: From 7125999435952e43426fb69c1363f554f35ba46a Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 11:34:45 +0200 Subject: [PATCH 04/19] Fix keyword arguments for Ruby 3 compatibility --- .../admin/api/sso_tokens_controller.rb | 2 +- app/controllers/api/errors_controller.rb | 2 +- .../api/integrations_controller.rb | 2 +- .../admin/messages/bulk/trash_controller.rb | 4 +-- .../provider/admin/sudo_controller.rb | 2 +- app/events/base_event_store_event.rb | 4 +++ app/inputs/patternfly_input_input.rb | 2 +- app/lib/authentication/strategy/oauth2.rb | 2 +- app/lib/backend/storage_rewrite.rb | 2 +- app/lib/csv/exporter.rb | 6 ++-- .../active_record_event_repository.rb | 16 ++++++++++ app/lib/event_store/event.rb | 4 +-- app/lib/event_store/repository.rb | 2 +- .../payment_gateways/brain_tree_blue_crypt.rb | 2 +- app/lib/plan_rule.rb | 2 +- app/lib/system/redis_pool.rb | 4 +-- app/lib/three_scale/patterns/service.rb | 4 +-- app/lib/three_scale/warnings.rb | 2 +- app/mailers/notification_mailer.rb | 4 +-- app/models/account/gateway.rb | 2 +- app/models/cms/builtin/legal_term.rb | 14 ++++---- app/models/cms/email_template.rb | 2 +- app/models/cms/template.rb | 9 +++--- app/models/finance/buyer_invoice_finder.rb | 4 +-- app/models/proxy.rb | 2 +- .../service_discovery/cluster_client.rb | 10 +++--- app/models/sso_token.rb | 2 +- app/models/sudo.rb | 6 ++-- app/presenters/api/alerts_index_presenter.rb | 4 +-- app/services/finance/billing_service.rb | 6 ++-- app/services/invoice_friendly_id_service.rb | 2 +- .../policies/policies_list_service.rb | 8 ++--- app/services/proxy_deployment_service.rb | 4 +-- app/services/signup_service.rb | 4 +-- .../nested_association_validator.rb | 2 +- .../backend_delete_application_worker.rb | 2 +- app/workers/backend_metric_worker.rb | 4 +-- app/workers/delete_plain_object_worker.rb | 2 +- app/workers/set_tenant_id_worker.rb | 4 +-- app/workers/web_hook_worker.rb | 2 +- config/initializers/oracle.rb | 12 +++---- features/support/capybara_extensions.rb | 2 +- lib/deadlock_retry.rb | 4 +-- .../developer_portal/signup_controller.rb | 2 +- .../lib/liquid/filters/rails_helpers.rb | 4 +-- lib/tasks/multitenant/tenants.rake | 10 +++--- spec/acceptance/api/sso_token_spec.rb | 2 +- spec/api_helper.rb | 4 +-- .../service_contracts_controller_test.rb | 32 +++++++++---------- .../admin/account/stripe_controller_test.rb | 2 +- .../developer_portal/signup_test.rb | 2 +- test/test_helpers/user_data_helpers.rb | 2 +- test/unit/backend/storage_rewrite_test.rb | 6 ++-- .../lib/payment_gateways/stripe_crypt_test.rb | 2 +- .../settings_updater_service_test.rb | 12 +++---- .../services/messages/delete_service_test.rb | 12 +++---- .../messages/destroy_all_service_test.rb | 8 ++--- test/unit/signup/domains_builder_test.rb | 2 +- test/unit/signup/signup_params_test.rb | 2 +- .../send_user_invitation_worker_test.rb | 4 ++- 60 files changed, 155 insertions(+), 134 deletions(-) create mode 100644 app/lib/event_store/active_record_event_repository.rb diff --git a/app/controllers/admin/api/sso_tokens_controller.rb b/app/controllers/admin/api/sso_tokens_controller.rb index f71ba7277e..96dcfaec33 100644 --- a/app/controllers/admin/api/sso_tokens_controller.rb +++ b/app/controllers/admin/api/sso_tokens_controller.rb @@ -8,7 +8,7 @@ class Admin::Api::SSOTokensController < Admin::Api::BaseController # * provider_key # * protocol def create - sso_token = SSOToken.new sso_token_params.to_h + sso_token = SSOToken.new **sso_token_params.to_h sso_token.account = domain_account sso_token.save diff --git a/app/controllers/api/errors_controller.rb b/app/controllers/api/errors_controller.rb index 2e7cbfdc36..679f9e31f9 100644 --- a/app/controllers/api/errors_controller.rb +++ b/app/controllers/api/errors_controller.rb @@ -9,7 +9,7 @@ class Api::ErrorsController < Api::BaseController activate_menu :serviceadmin, :monitoring, :errors def index - errors = errors_service.list(@service.id, pagination_params) + errors = errors_service.list(@service.id, **pagination_params) @presenter = Api::ErrorsIndexPresenter.new(errors: errors, service: @service) end diff --git a/app/controllers/api/integrations_controller.rb b/app/controllers/api/integrations_controller.rb index 4024cacf19..de3b238fed 100644 --- a/app/controllers/api/integrations_controller.rb +++ b/app/controllers/api/integrations_controller.rb @@ -94,7 +94,7 @@ def edit_stale end def flash_message(key, opts = {}) - translate(key, opts.reverse_merge(scope: :api_integrations_controller, raise: Rails.env.test?)) + translate(key, **opts.reverse_merge(scope: :api_integrations_controller, raise: Rails.env.test?)) end def proxy_pro_update diff --git a/app/controllers/provider/admin/messages/bulk/trash_controller.rb b/app/controllers/provider/admin/messages/bulk/trash_controller.rb index c27377609e..a89cddb3ef 100644 --- a/app/controllers/provider/admin/messages/bulk/trash_controller.rb +++ b/app/controllers/provider/admin/messages/bulk/trash_controller.rb @@ -13,12 +13,12 @@ def new end def create - ::Messages::DeleteService.run!({ + ::Messages::DeleteService.run!( account: current_account, association_class: association_class, ids: message_ids, delete_all: params[:selected_total_entries].present? - }) + ) @message_ids = message_ids @no_more_messages = no_more_messages diff --git a/app/controllers/provider/admin/sudo_controller.rb b/app/controllers/provider/admin/sudo_controller.rb index 25bf734172..57d4b5d0fc 100644 --- a/app/controllers/provider/admin/sudo_controller.rb +++ b/app/controllers/provider/admin/sudo_controller.rb @@ -29,7 +29,7 @@ def current_password end def sudo - @sudo ||= ::Sudo.new(sudo_params.to_h.symbolize_keys) + @sudo ||= ::Sudo.new(**sudo_params.to_h.symbolize_keys) end end diff --git a/app/events/base_event_store_event.rb b/app/events/base_event_store_event.rb index de798bde2a..5f81fc1138 100644 --- a/app/events/base_event_store_event.rb +++ b/app/events/base_event_store_event.rb @@ -10,6 +10,10 @@ module Categorizable end end + def initialize(args = {}) + super(**args) + end + def publish PUBLISHER.call(self) end diff --git a/app/inputs/patternfly_input_input.rb b/app/inputs/patternfly_input_input.rb index bc2321ab97..a26301c055 100644 --- a/app/inputs/patternfly_input_input.rb +++ b/app/inputs/patternfly_input_input.rb @@ -46,7 +46,7 @@ def action action_title = action_html_options.delete(:title) action_html_options.reverse_merge!(class: 'pf-c-button pf-m-primary') - tag.button(action_title, action_html_options) + tag.button(action_title, **action_html_options) end def helper_text diff --git a/app/lib/authentication/strategy/oauth2.rb b/app/lib/authentication/strategy/oauth2.rb index 17e0aade93..aeb4b625d0 100644 --- a/app/lib/authentication/strategy/oauth2.rb +++ b/app/lib/authentication/strategy/oauth2.rb @@ -21,7 +21,7 @@ def create_account(session) signup_result = new_user_created = nil Account.transaction do - signup_result = SignupService.create(signup_service_params(session)) + signup_result = SignupService.create(**signup_service_params(session)) if new_user_created = signup_result.persisted? if authentication_provider.automatically_approve_accounts? && !signup_result.account_approved? signup_result.account_approve! diff --git a/app/lib/backend/storage_rewrite.rb b/app/lib/backend/storage_rewrite.rb index a8c8891fda..72d4de3e00 100644 --- a/app/lib/backend/storage_rewrite.rb +++ b/app/lib/backend/storage_rewrite.rb @@ -86,7 +86,7 @@ def rewrite(**kwargs) raise ArgumentError, ':class_name or :scope arguments must be provided' if klass.blank? rewriter = Backend::StorageRewrite.const_get("#{klass}Rewriter") - rewriter.rewrite({ **kwargs, log_progress: log_progress}) + rewriter.rewrite(**kwargs, log_progress: log_progress) end # Schedule all objects for all providers, or execute inline diff --git a/app/lib/csv/exporter.rb b/app/lib/csv/exporter.rb index 75e5f76fd3..a94a65b5ab 100644 --- a/app/lib/csv/exporter.rb +++ b/app/lib/csv/exporter.rb @@ -44,10 +44,8 @@ def to_send_data [ to_csv, send_options ] end - def generate - ::CSV.generate(csv_options) do |csv| - yield csv - end + def generate(&block) + ::CSV.generate(**csv_options, &block) end def filename diff --git a/app/lib/event_store/active_record_event_repository.rb b/app/lib/event_store/active_record_event_repository.rb new file mode 100644 index 0000000000..5a0bf7f06f --- /dev/null +++ b/app/lib/event_store/active_record_event_repository.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module EventStore + class ActiveRecordEventRepository < RailsEventStoreActiveRecord::EventRepository + def build_event_entity(record) + return nil unless record + + data = (record.data || {}).merge( + event_id: record.event_id, + metadata: record.metadata + ) + # Adding double splat for Ruby 3.0 compatibility + record.event_type.constantize.new(**data) + end + end +end diff --git a/app/lib/event_store/event.rb b/app/lib/event_store/event.rb index 1cfc9fd4b3..431f2921b0 100644 --- a/app/lib/event_store/event.rb +++ b/app/lib/event_store/event.rb @@ -31,7 +31,7 @@ def initialize(object:, error:) def dump(obj) YAML.dump serialize([obj]).first rescue URI::InvalidURIError, URI::GID::MissingModelIdError => error - raise SerializationEventError, object: obj, error: error + raise SerializationEventError.new(object: obj, error: error) end def load(str) @@ -84,7 +84,7 @@ def initialize(error:, event:) # The problem is that this triggers the Event's `load` and `deserialize` (to restore the original state), and if # the object referenced in the event via GlobalID does not exist, the deserialization of the event will fail. # Prevent an exception during rollback but try to report when that's unsafe. - def rolledback!(*) + def rolledback!(...) super rescue StandardError => exception # Set the cause of the EventRollbackError exception to the original error diff --git a/app/lib/event_store/repository.rb b/app/lib/event_store/repository.rb index 147ebbb4e2..55cfda2351 100644 --- a/app/lib/event_store/repository.rb +++ b/app/lib/event_store/repository.rb @@ -17,7 +17,7 @@ class Repository < Delegator class_attribute :raise_errors, instance_accessor: false self.raise_errors = Rails.env.development? - self.repository = RailsEventStoreActiveRecord::EventRepository.new(adapter: EventStore::Event) + self.repository = EventStore::ActiveRecordEventRepository.new(adapter: EventStore::Event) class << self delegate :adapter, to: :repository diff --git a/app/lib/payment_gateways/brain_tree_blue_crypt.rb b/app/lib/payment_gateways/brain_tree_blue_crypt.rb index a742e5ee3e..dbe7974623 100644 --- a/app/lib/payment_gateways/brain_tree_blue_crypt.rb +++ b/app/lib/payment_gateways/brain_tree_blue_crypt.rb @@ -78,7 +78,7 @@ def update_user(result) user_id: user.id, email: user.email } - notify_exception CustomerIdMismatchError.new(data), data + notify_exception CustomerIdMismatchError.new(**data), data false else self.account_billing_address = result diff --git a/app/lib/plan_rule.rb b/app/lib/plan_rule.rb index 54c681fb3e..75ee225a4e 100644 --- a/app/lib/plan_rule.rb +++ b/app/lib/plan_rule.rb @@ -7,7 +7,7 @@ def initialize(system_name:, rank:, limits: {max_services: 1, max_users: 1}, swi @system_name = system_name.to_sym @metadata = metadata.deep_symbolize_keys @rank = rank - @limits = Limit.new(limits) + @limits = Limit.new(**limits) @switches = switches.map(&:to_sym) end diff --git a/app/lib/system/redis_pool.rb b/app/lib/system/redis_pool.rb index 88de261a01..4f2920d257 100644 --- a/app/lib/system/redis_pool.rb +++ b/app/lib/system/redis_pool.rb @@ -21,9 +21,9 @@ def respond_to_missing?(method_sym, _include_private = false) end end - def method_missing(method_sym, *args, &block) + def method_missing(...) @pool.with do |conn| - conn.public_send(method_sym, *args, &block) + conn.public_send(...) end end end diff --git a/app/lib/three_scale/patterns/service.rb b/app/lib/three_scale/patterns/service.rb index e0988a77f7..2331db585b 100644 --- a/app/lib/three_scale/patterns/service.rb +++ b/app/lib/three_scale/patterns/service.rb @@ -8,8 +8,8 @@ class Service attr_reader :result class << self - def call(*args, &block) - new(*args, &block).tap do |service| + def call(...) + new(...).tap do |service| service.instance_variable_set( "@result", service.call diff --git a/app/lib/three_scale/warnings.rb b/app/lib/three_scale/warnings.rb index ff50522525..74d203f746 100644 --- a/app/lib/three_scale/warnings.rb +++ b/app/lib/three_scale/warnings.rb @@ -63,7 +63,7 @@ def notify_developers(exception, options = {}) options[:parameters] = { :object => exception.object } end - System::ErrorReporting.report_error(exception, options) + System::ErrorReporting.report_error(exception, **options) end end diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index b689b9d275..f1b5f0e013 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -411,8 +411,8 @@ def default_url_options super.merge(host: provider_account&.external_admin_domain) end - def t_subject(key, options = {}) - I18n.t(key, { scope: 'mailers.notification_mailer.subject', raise: true }.merge(options)) + def t_subject(key, **options) + I18n.t(key, **{ scope: 'mailers.notification_mailer.subject', raise: true }.merge(options)) end private diff --git a/app/models/account/gateway.rb b/app/models/account/gateway.rb index bb56024f93..706bb3933a 100644 --- a/app/models/account/gateway.rb +++ b/app/models/account/gateway.rb @@ -17,7 +17,7 @@ module Account::Gateway def payment_gateway(**options) return if payment_gateway_type.blank? - PaymentGateway.implementation(payment_gateway_type, options).new(payment_gateway_options || {}) + PaymentGateway.implementation(payment_gateway_type, **options).new(payment_gateway_options || {}) end def payment_gateway_configured? diff --git a/app/models/cms/builtin/legal_term.rb b/app/models/cms/builtin/legal_term.rb index d329bb09b7..bad6d1659a 100644 --- a/app/models/cms/builtin/legal_term.rb +++ b/app/models/cms/builtin/legal_term.rb @@ -3,10 +3,12 @@ class CMS::Builtin::LegalTerm < CMS::Builtin::Partial SIGNUP_SYSTEM_NAME = 'signup_licence' SUBSCRIPTION_SYSTEM_NAME = 'service_subscription_licence' NEW_APPLICATION_SYSTEM_NAME = 'new_application_licence' - + validates :published, presence: true validates :title, uniqueness: { :scope => [:provider_id], case_sensitive: true } + before_validation :publish_draft + def title I18n.t("builtin_legal_terms.#{system_name}.title") end @@ -29,13 +31,13 @@ def find_or_build_by_system_name(system_name, attributes) end end - def save(*) - self.published = self.draft - super - end - def content_type "text/html" end + private + + def publish_draft + self.published = draft unless published + end end diff --git a/app/models/cms/email_template.rb b/app/models/cms/email_template.rb index 26304a7540..bff92555fe 100644 --- a/app/models/cms/email_template.rb +++ b/app/models/cms/email_template.rb @@ -109,7 +109,7 @@ def published super or file&.read end - def save(*) + def save(...) publish if draft? super end diff --git a/app/models/cms/template.rb b/app/models/cms/template.rb index c5c135f30a..1e5c80f6fb 100644 --- a/app/models/cms/template.rb +++ b/app/models/cms/template.rb @@ -33,10 +33,10 @@ class CMS::Template < ApplicationRecord validate :check_liquid_syntax - before_save :set_updated_by - before_save :set_rails_view_path after_validation :create_first_version, on: :update + before_save :set_updated_by + before_save :set_rails_view_path # remove this when all code will read from #published and not #body alias_attribute :body, :published @@ -109,8 +109,9 @@ def version updated_at.utc.to_i end - def save(*) - raise "#{self.inspect} cannot be saved because it is CMS::Template" if self.class == CMS::Template + def save(...) + raise "#{inspect} cannot be saved because it is CMS::Template" if instance_of?(CMS::Template) + super end diff --git a/app/models/finance/buyer_invoice_finder.rb b/app/models/finance/buyer_invoice_finder.rb index 2a466dd11d..65957eb82a 100644 --- a/app/models/finance/buyer_invoice_finder.rb +++ b/app/models/finance/buyer_invoice_finder.rb @@ -14,8 +14,8 @@ def find @invoice ||= find_invoice || create_invoice end - def self.find(*args) - new(*args).find + def self.find(...) + new(...).find end def find_invoice diff --git a/app/models/proxy.rb b/app/models/proxy.rb index ec89f1d970..637d3d15d8 100644 --- a/app/models/proxy.rb +++ b/app/models/proxy.rb @@ -443,7 +443,7 @@ def service_mesh_integration? end # Ridiculously hacking Rails to skip lock increment on touch - def touch(*) + def touch(...) @instance_locking_enabled = false super ensure diff --git a/app/models/service_discovery/cluster_client.rb b/app/models/service_discovery/cluster_client.rb index 31f4381761..ea8f354675 100644 --- a/app/models/service_discovery/cluster_client.rb +++ b/app/models/service_discovery/cluster_client.rb @@ -98,14 +98,16 @@ def self.build_client_options(options = {}) [ build_api_endpoint(options), 'v1', - ssl_options: { verify_ssl: OpenSSL::SSL::VERIFY_NONE }, - auth_options: { bearer_token: options[:bearer_token] } + { + ssl_options: { verify_ssl: OpenSSL::SSL::VERIFY_NONE }, + auth_options: { bearer_token: options[:bearer_token] } + } ] end def self.build_client(options = {}) - client_options = build_client_options(options.reverse_merge(api_path: 'api')) - Kubeclient::Client.new(*client_options) + uri, version, client_options = build_client_options(options.reverse_merge(api_path: 'api')) + Kubeclient::Client.new(uri, version, **client_options) end def self.build_client_for_projects(options = {}) diff --git a/app/models/sso_token.rb b/app/models/sso_token.rb index ba72561931..b66f4526a9 100644 --- a/app/models/sso_token.rb +++ b/app/models/sso_token.rb @@ -15,7 +15,7 @@ class SSOToken validate :one_of_user_id_or_username_is_required validate :account_is_provider_and_user_of_provider, :if => Proc.new {|o| o.account && o.user_id || o.username } - def initialize attributes = {} + def initialize(**attributes) assign_attributes({:expires_in => 10.minutes, :protocol => 'https'}.merge(attributes)) @new_record= true end diff --git a/app/models/sudo.rb b/app/models/sudo.rb index 73d6709a7a..1bc15bfc5a 100644 --- a/app/models/sudo.rb +++ b/app/models/sudo.rb @@ -2,13 +2,11 @@ class Sudo extend ActiveModel::Naming include ActiveModel::Conversion - attr_reader :errors - - attr_reader :return_path, :user_session, :xhr + attr_reader :return_path, :user_session, :xhr, :errors # @param [String] return_path # @param [UserSession] user_session - def initialize(return_path: , user_session: UserSession.null, xhr: false) + def initialize(return_path:, user_session: UserSession.null, xhr: false) @return_path = return_path.freeze @xhr = !!xhr @errors = ActiveModel::Errors.new(self) diff --git a/app/presenters/api/alerts_index_presenter.rb b/app/presenters/api/alerts_index_presenter.rb index 1798d0320c..c01cff021a 100644 --- a/app/presenters/api/alerts_index_presenter.rb +++ b/app/presenters/api/alerts_index_presenter.rb @@ -85,7 +85,7 @@ def new_search(params, current_account) search end - def t(string, opts = {}) - I18n.t(string, opts.merge(scope: 'api.alerts.index')) + def t(string, **opts) + I18n.t(string, **opts.merge(scope: 'api.alerts.index')) end end diff --git a/app/services/finance/billing_service.rb b/app/services/finance/billing_service.rb index b623ba3064..9ea0243521 100644 --- a/app/services/finance/billing_service.rb +++ b/app/services/finance/billing_service.rb @@ -74,9 +74,9 @@ def with_lock def report_error(error) message = "Failed to perform billing job: #{error.message}" Rails.logger.error(message) - System::ErrorReporting.report_error(:error_message => message, - :error_class => error.class.name, - :exception => error) + System::ErrorReporting.report_error(error, error_message: message, + error_class: error.class.name, + exception: error) end end end diff --git a/app/services/invoice_friendly_id_service.rb b/app/services/invoice_friendly_id_service.rb index 5c48a21832..96746c9a7b 100644 --- a/app/services/invoice_friendly_id_service.rb +++ b/app/services/invoice_friendly_id_service.rb @@ -68,6 +68,6 @@ def report_and_ensure(tagged_exception) def report_error(tagged_exception) details = { invoice_id: invoice.id, provider_account_id: provider_account_id, buyer_account_id: buyer_account_id, error: tagged_exception.error } - System::ErrorReporting.report_error(tagged_exception, details) + System::ErrorReporting.report_error(tagged_exception, **details) end end diff --git a/app/services/policies/policies_list_service.rb b/app/services/policies/policies_list_service.rb index c168013dbe..16e13f0ab6 100644 --- a/app/services/policies/policies_list_service.rb +++ b/app/services/policies/policies_list_service.rb @@ -12,12 +12,12 @@ class PoliciesListServiceError < StandardError; end SERVICE_CALL_ERRORS = [PoliciesListServiceError, *HTTP_ERRORS].freeze private_constant :HTTP_ERRORS, :SERVICE_CALL_ERRORS - def self.call(*args) - new(*args).call + def self.call(...) + new(...).call end - def self.call!(*args) - new(*args).call! + def self.call!(...) + new(...).call! end attr_reader :account, :proxy, :builtin diff --git a/app/services/proxy_deployment_service.rb b/app/services/proxy_deployment_service.rb index 84b77ba6d3..aebca9e09e 100644 --- a/app/services/proxy_deployment_service.rb +++ b/app/services/proxy_deployment_service.rb @@ -11,8 +11,8 @@ class ProxyDeploymentService class UnknownStageError < ArgumentError; end - def self.call(*args) - new(*args).call + def self.call(...) + new(...).call end def initialize(proxy, environment: :staging) diff --git a/app/services/signup_service.rb b/app/services/signup_service.rb index 0d6f360a4f..8d8c888586 100644 --- a/app/services/signup_service.rb +++ b/app/services/signup_service.rb @@ -29,8 +29,8 @@ def create signup_result end - def self.create(attributes, &block) - new(attributes).create(&block) + def self.create(**attributes, &block) + new(**attributes).create(&block) end private diff --git a/app/validators/nested_association_validator.rb b/app/validators/nested_association_validator.rb index a3ee2f14a7..73976aabd9 100644 --- a/app/validators/nested_association_validator.rb +++ b/app/validators/nested_association_validator.rb @@ -12,7 +12,7 @@ def validate_each(record, _attribute, value) errors = value.errors.where(alternate) record_attr = attr || alternate errors.each do |error| - record.errors.add(record_attr, error.type, error.options) + record.errors.add(record_attr, error.type, **error.options) end end end diff --git a/app/workers/backend_delete_application_worker.rb b/app/workers/backend_delete_application_worker.rb index e7b226758f..b2560fbd96 100644 --- a/app/workers/backend_delete_application_worker.rb +++ b/app/workers/backend_delete_application_worker.rb @@ -19,7 +19,7 @@ def perform(event_id) def delete_associations delete_params = { application_id: event.application.id, service_backend_id: event.service_backend_id, application_backend_id: event.application_id } - [ApplicationKeyBackendService, ReferrerFilterBackendService].each { |klass| klass.delete_all(delete_params) } + [ApplicationKeyBackendService, ReferrerFilterBackendService].each { |klass| klass.delete_all(**delete_params) } end end diff --git a/app/workers/backend_metric_worker.rb b/app/workers/backend_metric_worker.rb index 52ceb4fbe8..40094ccc1c 100644 --- a/app/workers/backend_metric_worker.rb +++ b/app/workers/backend_metric_worker.rb @@ -5,13 +5,11 @@ class BackendMetricWorker < ApplicationJob queue_as :backend_sync - sidekiq_throttle({ - concurrency: { + sidekiq_throttle concurrency: { limit: 1, key_suffix: ->(service_id, metric_id, *) { "service:#{service_id}/metric:#{metric_id}" }, ttl: 1.hour.to_i } - }) def perform(service_backend_id, metric_id) metric = Metric.find_by(id: metric_id) diff --git a/app/workers/delete_plain_object_worker.rb b/app/workers/delete_plain_object_worker.rb index b58655896a..6686248d37 100644 --- a/app/workers/delete_plain_object_worker.rb +++ b/app/workers/delete_plain_object_worker.rb @@ -23,7 +23,7 @@ class DeletePlainObjectWorker < ApplicationJob queue_as :default - sidekiq_throttle({ concurrency: { limit: 10 } }) + sidekiq_throttle concurrency: { limit: 10 } before_perform do |job| @object, workers_hierarchy, @destroy_method = job.arguments diff --git a/app/workers/set_tenant_id_worker.rb b/app/workers/set_tenant_id_worker.rb index e303d0fb3f..bda20b4514 100644 --- a/app/workers/set_tenant_id_worker.rb +++ b/app/workers/set_tenant_id_worker.rb @@ -4,7 +4,7 @@ class SetTenantIdWorker < ApplicationJob include Sidekiq::Throttled::Job queue_as :low - sidekiq_throttle({ concurrency: { limit: 10 } }) + sidekiq_throttle concurrency: { limit: 10 } TENANT_RELATIONS = %w[backend_apis log_entries"] ACCOUNT_RELATIONS = %w[alerts] @@ -58,7 +58,7 @@ class ModelTenantIdWorker < ApplicationJob include Sidekiq::Throttled::Job queue_as :low - sidekiq_throttle({ concurrency: { limit: 10 } }) + sidekiq_throttle concurrency: { limit: 10 } def perform(model, ids, tenant_id) model.where(id: ids).update_all(tenant_id: tenant_id) diff --git a/app/workers/web_hook_worker.rb b/app/workers/web_hook_worker.rb index 69201c8309..b7f057c4a3 100644 --- a/app/workers/web_hook_worker.rb +++ b/app/workers/web_hook_worker.rb @@ -45,7 +45,7 @@ def perform(webhook_id, options) @webhook_id = webhook_id with_retry_log do - push(options.symbolize_keys.slice(:url, :xml, :content_type)) + push(**options.symbolize_keys.slice(:url, :xml, :content_type)) end end diff --git a/config/initializers/oracle.rb b/config/initializers/oracle.rb index 37918e2504..b02372b2e9 100644 --- a/config/initializers/oracle.rb +++ b/config/initializers/oracle.rb @@ -8,12 +8,12 @@ Rails.configuration.active_record.schema_format = ActiveRecord::Base.schema_format = :ruby ActiveRecord::ConnectionAdapters::TableDefinition.prepend(Module.new do - def column(name, type, options = {}) + def column(name, type, **options) # length parameter is not compatible with rails mysql/pg adapters: # rails expects it is limit in bytes, but oracle adapter expects it in number of characters # TODO: probably would be better to convert the byte limit to character limit if type == :integer - super(name, type, options.except(:limit)) + super(name, type, **options.except(:limit)) else super end @@ -26,9 +26,9 @@ def column(name, type, options = {}) prepend(Module.new do # TODO: is this needed after # https://github.com/rsim/oracle-enhanced/commit/f76b6ef4edda72bddabab252177cb7f28d4418e2 - def add_column(table_name, column_name, type, options = {}) + def add_column(table_name, column_name, type, **options) if type == :integer - super(table_name, column_name, type, options.except(:limit)) + super(table_name, column_name, type, **options.except(:limit)) else super end @@ -170,11 +170,11 @@ def set_database_settings(settings) end) ActiveRecord::ConnectionAdapters::OracleEnhanced::SchemaStatements.module_eval do - def add_index(table_name, column_name, options = {}) #:nodoc: + def add_index(table_name, column_name, **options) #:nodoc: # All this code is exactly the same as the original except the line of the ALTER TABLE, which adds an additional USING INDEX #{quote_column_name(index_name)} # The reason of this is otherwise it picks the first index that finds that contains that column name, even if it is shared with other columns and it is not unique. # upstreamed: https://github.com/rsim/oracle-enhanced/pull/2293 - index_name, index_type, quoted_column_names, tablespace, index_options = add_index_options(table_name, column_name, options) + index_name, index_type, quoted_column_names, tablespace, index_options = add_index_options(table_name, column_name, **options) quoted_table_name = quote_table_name(table_name) quoted_column_name = quote_column_name(index_name) execute "CREATE #{index_type} INDEX #{quoted_column_name} ON #{quoted_table_name} (#{quoted_column_names})#{tablespace} #{index_options}" diff --git a/features/support/capybara_extensions.rb b/features/support/capybara_extensions.rb index 34b1423aad..c36c849a90 100644 --- a/features/support/capybara_extensions.rb +++ b/features/support/capybara_extensions.rb @@ -40,7 +40,7 @@ def select(value = nil, from: nil, **options) # Capybara::Node::Finders#find_field def find_field(locator, **options) if has_css?('.pf-c-form__label', text: locator, wait: 0) - find('.pf-c-form__group', text: locator).find('input, textarea, select, .CodeMirror', options) + find('.pf-c-form__group', text: locator).find('input, textarea, select, .CodeMirror', **options) else super end diff --git a/lib/deadlock_retry.rb b/lib/deadlock_retry.rb index 755a7def48..8120552187 100644 --- a/lib/deadlock_retry.rb +++ b/lib/deadlock_retry.rb @@ -43,13 +43,13 @@ module ClassMethods MAXIMUM_RETRIES_ON_DEADLOCK = 3 - def transaction(*objects, &block) + def transaction(...) retry_count = 0 check_innodb_status_available begin - super(*objects, &block) + super rescue ActiveRecord::StatementInvalid => error raise if in_nested_transaction? if DEADLOCK_ERROR_MESSAGES.any? { |msg| error.message =~ /#{Regexp.escape(msg)}/ } diff --git a/lib/developer_portal/app/controllers/developer_portal/signup_controller.rb b/lib/developer_portal/app/controllers/developer_portal/signup_controller.rb index 352e13f759..5a1508fd04 100644 --- a/lib/developer_portal/app/controllers/developer_portal/signup_controller.rb +++ b/lib/developer_portal/app/controllers/developer_portal/signup_controller.rb @@ -69,7 +69,7 @@ def authentication_provider def signup_user!(account_params, user_params) Account.transaction do - SignupService.create(signup_service_params(account_params, user_params)) do |signup_result| + SignupService.create(**signup_service_params(account_params, user_params)) do |signup_result| @signup_result = signup_result @user = signup_result.user @buyer = signup_result.account diff --git a/lib/developer_portal/lib/liquid/filters/rails_helpers.rb b/lib/developer_portal/lib/liquid/filters/rails_helpers.rb index 916b494b4b..b576dd433a 100644 --- a/lib/developer_portal/lib/liquid/filters/rails_helpers.rb +++ b/lib/developer_portal/lib/liquid/filters/rails_helpers.rb @@ -47,11 +47,11 @@ def stylesheet_link_tag(name) end desc "Javascript includes tag." - def javascript_include_tag(name, options = {}) + def javascript_include_tag(name, **options) js = RailsHelpers.replace_googleapis(name) case when THREESCALE_WEBPACK_PACKS.include?(name) # TODO: This is an intermediate step in order to tackle webpack assets in dev portal. A final solution might be needed easing the update of templates/assets. - active_docs_proxy(name) + view.javascript_packs_with_chunks_tag(name.chomp('.js'), options) + active_docs_proxy(name) + view.javascript_packs_with_chunks_tag(name.chomp('.js'), **options) when js != name || THREESCALE_JAVASCRIPTS.include?(js) active_docs_proxy(js) + view.javascript_include_tag(js) else diff --git a/lib/tasks/multitenant/tenants.rake b/lib/tasks/multitenant/tenants.rake index bf9a4466e4..4b1c04e829 100644 --- a/lib/tasks/multitenant/tenants.rake +++ b/lib/tasks/multitenant/tenants.rake @@ -45,27 +45,27 @@ namespace :multitenant do desc 'Fix empty or corrupted tenant_id for a table associated to account' task :fix_corrupted_tenant_id_for_table_associated_to_account, %i[table_name time_start time_end batch_size sleep_time] => :environment do |_task, args| - update_tenant_ids(proc { |object| object.account.tenant_id }, proc { account }, condition_update_tenant_id(args[:time_start], args[:time_end]), args.to_hash) + update_tenant_ids(proc { |object| object.account.tenant_id }, proc { account }, condition_update_tenant_id(args[:time_start], args[:time_end]), **args.to_hash) end desc 'Fix empty or corrupted tenant_id for a table associated to user' task :fix_corrupted_tenant_id_for_table_associated_to_user, %i[table_name time_start time_end batch_size sleep_time] => :environment do |_task, args| - update_tenant_ids(proc { |object| object.user.tenant_id }, proc { user }, condition_update_tenant_id(args[:time_start], args[:time_end]), args.to_hash) + update_tenant_ids(proc { |object| object.user.tenant_id }, proc { user }, condition_update_tenant_id(args[:time_start], args[:time_end]), **args.to_hash) end desc 'Fix empty tenant_id in access_tokens' task :fix_empty_tenant_id_access_tokens, %i[batch_size sleep_time] => :environment do |_task, args| - update_tenant_ids(proc { |object| object.owner.tenant_id }, proc { owner }, proc { tenant_id == nil }, args.to_hash.merge({ table_name: 'AccessToken' })) + update_tenant_ids(proc { |object| object.owner.tenant_id }, proc { owner }, proc { tenant_id == nil }, **args.to_hash.merge({ table_name: 'AccessToken' })) end desc 'Restore existing tenant_id in alerts' task :restore_existing_tenant_id_alerts, %i[batch_size sleep_time] => :environment do |_task, args| - update_tenant_ids(proc { |object| object.account.tenant_id }, proc { account }, proc { tenant_id != nil }, args.to_hash.merge({ table_name: 'Alert' })) + update_tenant_ids(proc { |object| object.account.tenant_id }, proc { account }, proc { tenant_id != nil }, **args.to_hash.merge({ table_name: 'Alert' })) end desc 'Restore empty tenant_id in alerts' task :restore_empty_tenant_id_alerts, %i[batch_size sleep_time] => :environment do |_task, args| - update_tenant_ids(proc { |object| object.account.tenant_id }, proc { account }, proc { tenant_id == nil }, args.to_hash.merge({ table_name: 'Alert' })) + update_tenant_ids(proc { |object| object.account.tenant_id }, proc { account }, proc { tenant_id == nil }, **args.to_hash.merge({ table_name: 'Alert' })) end def update_tenant_ids(tenant_id_block, association_block, condition, **args) diff --git a/spec/acceptance/api/sso_token_spec.rb b/spec/acceptance/api/sso_token_spec.rb index 81ea76831d..6ba0816809 100644 --- a/spec/acceptance/api/sso_token_spec.rb +++ b/spec/acceptance/api/sso_token_spec.rb @@ -15,7 +15,7 @@ api 'sso token' do before do - expect(SSOToken).to receive(:new).with('user_id' => user_id.to_s, 'expires_in' => expires_in.to_s) + expect(SSOToken).to receive(:new).with(user_id: user_id.to_s, expires_in: expires_in.to_s) .and_return(sso_token) end diff --git a/spec/api_helper.rb b/spec/api_helper.rb index 8a2c7c2125..40f8ed3fe7 100644 --- a/spec/api_helper.rb +++ b/spec/api_helper.rb @@ -105,11 +105,11 @@ def format_context(format, context, **options, &block) end def json(context, **options, &block) - format_context(:json, context, options, &block) + format_context(:json, context, **options, &block) end def xml(context, **options, &block) - format_context(:xml, context, options, &block) + format_context(:xml, context, **options, &block) end end diff --git a/test/integration/buyers/service_contracts_controller_test.rb b/test/integration/buyers/service_contracts_controller_test.rb index d137f78af7..a83f63c5df 100644 --- a/test/integration/buyers/service_contracts_controller_test.rb +++ b/test/integration/buyers/service_contracts_controller_test.rb @@ -126,16 +126,16 @@ class ProviderMemberTest < self { params: { service_id: service.id } } } - get new_admin_buyers_account_service_contract_path(account_id: buyer1.id), request_options.call(service) + get new_admin_buyers_account_service_contract_path(account_id: buyer1.id), **request_options.call(service) assert_response :forbidden member.member_permission_ids = ['partners'] member.save! - get new_admin_buyers_account_service_contract_path(account_id: buyer1.id), request_options.call(service) + get new_admin_buyers_account_service_contract_path(account_id: buyer1.id), **request_options.call(service) assert_response :success - get new_admin_buyers_account_service_contract_path(account_id: buyer1.id), request_options.call(forbidden_service) + get new_admin_buyers_account_service_contract_path(account_id: buyer1.id), **request_options.call(forbidden_service) assert_response :not_found end @@ -151,16 +151,16 @@ class ProviderMemberTest < self } } - post admin_buyers_account_service_contracts_path(account_id: buyer1.id), request_options.call(service, other_service_plan) + post admin_buyers_account_service_contracts_path(account_id: buyer1.id), **request_options.call(service, other_service_plan) assert_response :forbidden member.member_permission_ids = ['partners'] member.save! - post admin_buyers_account_service_contracts_path(account_id: buyer1.id), request_options.call(service, other_service_plan) + post admin_buyers_account_service_contracts_path(account_id: buyer1.id), **request_options.call(service, other_service_plan) assert_response :success - post admin_buyers_account_service_contracts_path(account_id: buyer1.id), request_options.call(forbidden_service, forbidden_service_plan) + post admin_buyers_account_service_contracts_path(account_id: buyer1.id), **request_options.call(forbidden_service, forbidden_service_plan) assert_response :not_found end @@ -187,35 +187,35 @@ class ProviderMemberTest < self } } - put admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), request_options.call(other_service_plan) + put admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), **request_options.call(other_service_plan) assert_response :forbidden member.member_permission_ids = ['partners'] member.save! - put admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), request_options.call(other_service_plan) + put admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), **request_options.call(other_service_plan) assert_response :success - put admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), request_options.call(forbidden_service_plan) + put admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), **request_options.call(forbidden_service_plan) assert_response :not_found - put admin_buyers_account_service_contract_path(forbidden_service_contract.id, account_id: buyer1.id), request_options.call(other_service_plan) + put admin_buyers_account_service_contract_path(forbidden_service_contract.id, account_id: buyer1.id), **request_options.call(other_service_plan) assert_response :not_found end test 'approve' do request_options = { headers: { 'HTTP_REFERER' => admin_buyers_service_contracts_path } } - post approve_admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), request_options + post approve_admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), **request_options assert_response :forbidden member.member_permission_ids = ['partners'] member.save! - post approve_admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), request_options + post approve_admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), **request_options assert_response :redirect - post approve_admin_buyers_account_service_contract_path(forbidden_service_contract.id, account_id: buyer1.id), request_options + post approve_admin_buyers_account_service_contract_path(forbidden_service_contract.id, account_id: buyer1.id), **request_options assert_response :not_found end @@ -223,17 +223,17 @@ class ProviderMemberTest < self buyer1.bought_cinstances.by_service_id(service_contract.service_id).update_all(state: 'suspended') request_options = { headers: { 'HTTP_REFERER' => admin_buyers_service_contracts_path } } - delete admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), request_options + delete admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), **request_options assert_response :forbidden member.member_permission_ids = ['partners'] member.save! - delete admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), request_options + delete admin_buyers_account_service_contract_path(service_contract.id, account_id: buyer1.id), **request_options assert_response :redirect assert_raise(ActiveRecord::RecordNotFound) { service_contract.reload } - delete admin_buyers_account_service_contract_path(forbidden_service_contract.id, account_id: buyer1.id), request_options + delete admin_buyers_account_service_contract_path(forbidden_service_contract.id, account_id: buyer1.id), **request_options assert_response :not_found end end diff --git a/test/integration/developer_portal/admin/account/stripe_controller_test.rb b/test/integration/developer_portal/admin/account/stripe_controller_test.rb index d45c48368f..5e750304cc 100644 --- a/test/integration/developer_portal/admin/account/stripe_controller_test.rb +++ b/test/integration/developer_portal/admin/account/stripe_controller_test.rb @@ -21,7 +21,7 @@ def setup test '#show' do client_secret = 'seti_fake_client_secret' - setup_intent = Stripe::SetupIntent.new(id: 'seti_fake_setup_intent_id').tap { |si| si.update_attributes(client_secret: client_secret) } + setup_intent = Stripe::SetupIntent.new(id: 'seti_fake_setup_intent_id').tap { |si| si.update_attributes({ client_secret: client_secret }) } PaymentGateways::StripeCrypt.any_instance.expects(:create_stripe_setup_intent).returns(setup_intent) get admin_account_stripe_path diff --git a/test/integration/developer_portal/signup_test.rb b/test/integration/developer_portal/signup_test.rb index 63bcf8a938..f980ba1211 100644 --- a/test/integration/developer_portal/signup_test.rb +++ b/test/integration/developer_portal/signup_test.rb @@ -46,7 +46,7 @@ def test_signup_with_oauth_if_account_requires_approval @provider.settings.update(account_approval_required: true) # rubocop:disable Rails/ActiveRecordAliases) This method is being overriden @auth = FactoryBot.create(:authentication_provider, published: true, account: @provider) - stub_user_data({uid: '12345', email: ACCOUNT_EMAIL, email_verified: true}, stubbed_method: :authenticate!) + stub_user_data(:authenticate!, uid: '12345', email: ACCOUNT_EMAIL, email_verified: true) post session_path(system_name: @auth.system_name, code: 'alaska') assert_redirected_to signup_path diff --git a/test/test_helpers/user_data_helpers.rb b/test/test_helpers/user_data_helpers.rb index 7de791b27d..01c52e5833 100644 --- a/test/test_helpers/user_data_helpers.rb +++ b/test/test_helpers/user_data_helpers.rb @@ -1,7 +1,7 @@ module UserDataHelpers private - def stub_user_data(user_data, stubbed_method: :user_data) + def stub_user_data(stubbed_method = :user_data, **user_data) user_data = ThreeScale::OAuth2::UserData.new(user_data) ThreeScale::OAuth2::ClientBase.any_instance.expects(stubbed_method).returns(user_data) end diff --git a/test/unit/backend/storage_rewrite_test.rb b/test/unit/backend/storage_rewrite_test.rb index 2ccc0094e9..a196ffa76f 100644 --- a/test/unit/backend/storage_rewrite_test.rb +++ b/test/unit/backend/storage_rewrite_test.rb @@ -13,13 +13,13 @@ class ProcessorRewriteTest < ActiveSupport::TestCase test 'passes the class_name and ids to rewriter (used in async processing)' do ids = [1,2,3,4,5] - StorageRewrite::MetricRewriter.expects(:rewrite).with({ ids: ids, log_progress: false }) + StorageRewrite::MetricRewriter.expects(:rewrite).with(ids: ids, log_progress: false) StorageRewrite::Processor.new.rewrite(class_name: 'Metric', ids: ids) end test 'passes the scope to rewriter (used in sync processing)' do provider = FactoryBot.create(:simple_provider) - StorageRewrite::ServiceRewriter.expects(:rewrite).with({ scope: provider.services, log_progress: false }) + StorageRewrite::ServiceRewriter.expects(:rewrite).with(scope: provider.services, log_progress: false) StorageRewrite::Processor.new.rewrite(scope: provider.services) end @@ -29,7 +29,7 @@ class ProcessorRewriteTest < ActiveSupport::TestCase test 'enables log progress for rewriter if specified explicitly' do ids = [1,2,3,4,5] - StorageRewrite::UsageLimitRewriter.expects(:rewrite).with({ ids: ids, log_progress: true }) + StorageRewrite::UsageLimitRewriter.expects(:rewrite).with(ids: ids, log_progress: true) StorageRewrite::Processor.new(log_progress: true).rewrite(class_name: 'UsageLimit', ids: ids) end end diff --git a/test/unit/lib/payment_gateways/stripe_crypt_test.rb b/test/unit/lib/payment_gateways/stripe_crypt_test.rb index e3a3557d69..038b4df692 100644 --- a/test/unit/lib/payment_gateways/stripe_crypt_test.rb +++ b/test/unit/lib/payment_gateways/stripe_crypt_test.rb @@ -136,7 +136,7 @@ def create_customer_params def mock_customer(**attrs) id = attrs.delete(:id) || 'new-customer-id' - Stripe::Customer.new(id: id).tap { |stripe_customer| stripe_customer.update_attributes(**attrs) } + Stripe::Customer.new(id: id).tap { |stripe_customer| stripe_customer.update_attributes(attrs) } end def update_credit_card_auth_code diff --git a/test/unit/services/api_integration/settings_updater_service_test.rb b/test/unit/services/api_integration/settings_updater_service_test.rb index 5bc7182529..0e2fe6a5b2 100644 --- a/test/unit/services/api_integration/settings_updater_service_test.rb +++ b/test/unit/services/api_integration/settings_updater_service_test.rb @@ -28,7 +28,7 @@ class ApiIntegration::SettingsUpdaterServiceTest < ActiveSupport::TestCase end test '#call! updates both when they are valid' do - assert settings_result.call!(attributes) + assert settings_result.call!(**attributes) service_attributes.each { |field_name, value| assert_equal value, service.public_send(field_name) } proxy_attributes.each { |field_name, value| assert_equal value, proxy.public_send(field_name) } end @@ -38,7 +38,7 @@ class ApiIntegration::SettingsUpdaterServiceTest < ActiveSupport::TestCase old_proxy_attributes = proxy.attributes.slice(proxy_attributes.keys) proxy_attributes[:error_headers_auth_failed] = '' - assert_raises(ActiveRecord::RecordInvalid) { settings_result.call!(attributes) } + assert_raises(ActiveRecord::RecordInvalid) { settings_result.call!(**attributes) } old_service_attributes.each { |field_name, value| assert_equal value, service.public_send(field_name) } old_proxy_attributes.each { |field_name, value| assert_equal value, proxy.public_send(field_name) } end @@ -48,13 +48,13 @@ class ApiIntegration::SettingsUpdaterServiceTest < ActiveSupport::TestCase old_proxy_attributes = proxy.attributes.slice(proxy_attributes.keys) service_attributes[:name] = '' - assert_raises(ActiveRecord::RecordInvalid) { settings_result.call!(attributes) } + assert_raises(ActiveRecord::RecordInvalid) { settings_result.call!(**attributes) } old_service_attributes.each { |field_name, value| assert_equal value, service.public_send(field_name) } old_proxy_attributes.each { |field_name, value| assert_equal value, proxy.public_send(field_name) } end test '#call updates both when they are valid' do - assert settings_result.call(attributes) + assert settings_result.call(**attributes) service_attributes.each { |field_name, value| assert_equal value, service.public_send(field_name) } proxy_attributes.each { |field_name, value| assert_equal value, proxy.public_send(field_name) } end @@ -64,7 +64,7 @@ class ApiIntegration::SettingsUpdaterServiceTest < ActiveSupport::TestCase old_proxy_attributes = proxy.attributes.slice(proxy_attributes.keys) proxy_attributes[:error_headers_auth_failed] = '' - refute settings_result.call(attributes) + refute settings_result.call(**attributes) old_service_attributes.each { |field_name, value| assert_equal value, service.public_send(field_name) } old_proxy_attributes.each { |field_name, value| assert_equal value, proxy.public_send(field_name) } @@ -77,7 +77,7 @@ class ApiIntegration::SettingsUpdaterServiceTest < ActiveSupport::TestCase old_proxy_attributes = proxy.attributes.slice(proxy_attributes.keys) service_attributes[:name] = '' - refute settings_result.call(attributes) + refute settings_result.call(**attributes) old_service_attributes.each { |field_name, value| assert_equal value, service.public_send(field_name) } old_proxy_attributes.each { |field_name, value| assert_equal value, proxy.public_send(field_name) } diff --git a/test/unit/services/messages/delete_service_test.rb b/test/unit/services/messages/delete_service_test.rb index 333e9cd319..98d9af1880 100644 --- a/test/unit/services/messages/delete_service_test.rb +++ b/test/unit/services/messages/delete_service_test.rb @@ -10,11 +10,11 @@ def setup def test_run_with_ids assert_equal false, @message.hidden? - Messages::DeleteService.run!({ + Messages::DeleteService.run!( account: @message.receiver, association_class: MessageRecipient, ids: [@message.id] - }) + ) @message.reload @@ -24,11 +24,11 @@ def test_run_with_ids def test_run_delete_all assert_equal false, @message.hidden? - Messages::DeleteService.run!({ + Messages::DeleteService.run!( account: @message.receiver, association_class: MessageRecipient, delete_all: true - }) + ) @message.reload @@ -38,10 +38,10 @@ def test_run_delete_all def test_run_no_params assert_equal false, @message.hidden? - Messages::DeleteService.run!({ + Messages::DeleteService.run!( account: @message.receiver, association_class: MessageRecipient, - }) + ) @message.reload diff --git a/test/unit/services/messages/destroy_all_service_test.rb b/test/unit/services/messages/destroy_all_service_test.rb index 890eaffeaa..a6447ab8ed 100644 --- a/test/unit/services/messages/destroy_all_service_test.rb +++ b/test/unit/services/messages/destroy_all_service_test.rb @@ -14,11 +14,11 @@ def setup def test_run! assert_nil @message.deleted_at - Messages::DestroyAllService.run!({ + Messages::DestroyAllService.run!( account: @account, association_class: MessageRecipient, scope: :hidden - }) + ) @message.reload assert_not_equal nil, @message.reload.deleted_at @@ -27,11 +27,11 @@ def test_run! def test_run_with_sidekiq_job perform_enqueued_jobs do assert @message.present? - Messages::DestroyAllService.run!({ + Messages::DestroyAllService.run!( account: @account, association_class: MessageRecipient, scope: :hidden - }) + ) assert_raise(ActiveRecord::RecordNotFound) { @message.reload } end diff --git a/test/unit/signup/domains_builder_test.rb b/test/unit/signup/domains_builder_test.rb index 91f71a5847..380afa3370 100644 --- a/test/unit/signup/domains_builder_test.rb +++ b/test/unit/signup/domains_builder_test.rb @@ -28,7 +28,7 @@ class DomainsBuilderTest < ActiveSupport::TestCase def generate_subdomain(org_name:, current_subdomain: nil) provider = FactoryBot.build(:simple_provider) domains_builder_params = { org_name: org_name, current_subdomain: current_subdomain, invalid_subdomain_condition: provider.method(:subdomain_exists?) } - Signup::DomainsBuilder.new(domains_builder_params).generate.subdomain + Signup::DomainsBuilder.new(**domains_builder_params).generate.subdomain end end end diff --git a/test/unit/signup/signup_params_test.rb b/test/unit/signup/signup_params_test.rb index 93505cc050..f98090d4a9 100644 --- a/test/unit/signup/signup_params_test.rb +++ b/test/unit/signup/signup_params_test.rb @@ -56,7 +56,7 @@ class SignupParamsTest < ActiveSupport::TestCase private def signup_params - @signup_params ||= Signup::SignupParams.new({ user_attributes: user_params, account_attributes: account_params, plans: [], defaults: {} }) + @signup_params ||= Signup::SignupParams.new(user_attributes: user_params, account_attributes: account_params, plans: [], defaults: {}) end def signup_params_hash diff --git a/test/workers/send_user_invitation_worker_test.rb b/test/workers/send_user_invitation_worker_test.rb index 79abcb24cf..92d56241f9 100644 --- a/test/workers/send_user_invitation_worker_test.rb +++ b/test/workers/send_user_invitation_worker_test.rb @@ -31,7 +31,9 @@ def test_buyer_mailer_perform def test_handles_errors SendUserInvitationWorker::RETRY_ERRORS.each do |error_class| - ProviderInvitationMailer.any_instance.expects(:invitation).raises(error_class) + # NOTE: NET::SMTP errors can't be initialized with empty arguments + exception = error_class.include?(Net::SMTPError) ? error_class.new(nil, message: 'error') : error_class.new + ProviderInvitationMailer.any_instance.expects(:invitation).raises(exception) invitation = FactoryBot.create(:invitation) From b34c862fee6a98a944443276ffa13d29e65bedac Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 11:36:43 +0200 Subject: [PATCH 05/19] Fix keyword arguments for representers and 'with_options' --- app/representers/cms/layout_representer.rb | 2 +- app/representers/cms/page_representer.rb | 2 +- app/representers/cms/partial_representer.rb | 2 +- app/representers/cms/portlet_representer.rb | 2 +- app/representers/member_permissions_representer.rb | 12 ++++++------ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/representers/cms/layout_representer.rb b/app/representers/cms/layout_representer.rb index 38fa48666e..049c00d7aa 100644 --- a/app/representers/cms/layout_representer.rb +++ b/app/representers/cms/layout_representer.rb @@ -11,7 +11,7 @@ module CMS::LayoutRepresenter property :system_name property :liquid_enabled - with_options(if: ->(user_options:, **) { !user_options&.dig(:short) }) do + with_options(if: ->(options) { !options[:user_options]&.dig(:short) }) do property :draft, render_nil: true property :published, render_nil: true end diff --git a/app/representers/cms/page_representer.rb b/app/representers/cms/page_representer.rb index 8cb62a51b9..5b8653d293 100644 --- a/app/representers/cms/page_representer.rb +++ b/app/representers/cms/page_representer.rb @@ -20,7 +20,7 @@ module CMS::PageRepresenter p.property :hidden, getter: ->(*) { hidden? } end - with_options(if: ->(user_options:, **) { !user_options&.dig(:short) }) do + with_options(if: ->(options) { !options[:user_options]&.dig(:short) }) do property :draft, render_nil: true property :published, render_nil: true end diff --git a/app/representers/cms/partial_representer.rb b/app/representers/cms/partial_representer.rb index 9b21850c26..5c53073edd 100644 --- a/app/representers/cms/partial_representer.rb +++ b/app/representers/cms/partial_representer.rb @@ -9,7 +9,7 @@ module CMS::PartialRepresenter property :updated_at property :system_name - with_options(if: ->(user_options:, **) { !user_options&.dig(:short) }) do + with_options(if: ->(options) { !options[:user_options]&.dig(:short) }) do property :draft, render_nil: true property :published, render_nil: true end diff --git a/app/representers/cms/portlet_representer.rb b/app/representers/cms/portlet_representer.rb index 386bf6e0de..f29143da95 100644 --- a/app/representers/cms/portlet_representer.rb +++ b/app/representers/cms/portlet_representer.rb @@ -9,7 +9,7 @@ module CMS::PortletRepresenter property :portlet_type property :name - with_options(if: ->(user_options:, **) { !user_options&.dig(:short) }) do + with_options(if: ->(options) { !options[:user_options]&.dig(:short) }) do property :draft, render_nil: true property :published, render_nil: true end diff --git a/app/representers/member_permissions_representer.rb b/app/representers/member_permissions_representer.rb index 1ed47af6dc..c8506e21cd 100644 --- a/app/representers/member_permissions_representer.rb +++ b/app/representers/member_permissions_representer.rb @@ -38,15 +38,15 @@ class MemberPermissionsRepresenter < ThreeScale::Representer wraps_resource :permissions - property :user_id, getter: ->(user_options:, **) { user_options[:user].id } - property :role, getter: ->(user_options:, **) { user_options[:user].role } + property :user_id, getter: ->(options) { options[:user_options]&.[](:user)&.id } + property :role, getter: ->(options) { options[:user_options]&.[](:user)&.role } class JSON < MemberPermissionsRepresenter include Roar::JSON # NOTE: The list of allowed sections is sorted to facilitate acceptance testing, this is not part of the API specification - property :allowed_sections, getter: ->(user_options:, **) { user_options[:user].allowed_sections&.sort } - property :allowed_service_ids, getter: ->(user_options:, **) { user_options[:user].allowed_service_ids }, render_nil: true + property :allowed_sections, getter: ->(options) { options[:user_options]&.[](:user)&.allowed_sections&.sort } + property :allowed_service_ids, getter: ->(options) { options[:user_options]&.[](:user)&.allowed_service_ids }, render_nil: true link :user do |opts| user = opts[:user] @@ -59,8 +59,8 @@ class XML < MemberPermissionsRepresenter wraps_resource :permissions # NOTE: The list of allowed sections is sorted to facilitate acceptance testing, this is not part of the API specification - collection :allowed_sections, as: :allowed_section, wrap: :allowed_sections, getter: ->(user_options:, **) { user_options[:user].allowed_sections&.sort } - collection :allowed_service_ids, as: :allowed_service_id, wrap: :allowed_service_ids, getter: ->(user_options:, **) { user_options[:user].allowed_service_ids } + collection :allowed_sections, as: :allowed_section, wrap: :allowed_sections, getter: ->(options) { options[:user_options]&.[](:user)&.allowed_sections&.sort } + collection :allowed_service_ids, as: :allowed_service_id, wrap: :allowed_service_ids, getter: ->(options) { options[:user_options]&.[](:user)&.allowed_service_ids } end end From 16b4b7572b136208b0d9c8c584dc76a87b6003ac Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 11:37:44 +0200 Subject: [PATCH 06/19] Fix keyword arguments in new accounts query and sifter --- app/models/application_record.rb | 10 +++++----- app/queries/new_accounts_query.rb | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 907f1c3335..a1db2d144f 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -53,21 +53,21 @@ def self.user_attribute_names func(name, value, quoted(DatabaseUtilities.convert_to_oracle_date_format(format))) end - sifter :in_timezone do |column, zone = Time.zone, name: zone.tzinfo.name, offset: zone.formatted_offset| + sifter :in_timezone do |column, timezone_name = Time.zone.tzinfo.name, timezone_offset: Time.zone.formatted_offset| case System::Database.adapter.to_sym when :mysql coalesce( - convert_tz(column, quoted('UTC'), quoted(name)), - convert_tz(column, quoted('+00:00'), quoted(offset)) + convert_tz(column, quoted('UTC'), quoted(timezone_name)), + convert_tz(column, quoted('+00:00'), quoted(timezone_offset)) ) when :postgres - column.op('AT TIME ZONE', quoted('UTC')).op('AT TIME ZONE', quoted(name)) + column.op('AT TIME ZONE', quoted('UTC')).op('AT TIME ZONE', quoted(timezone_name)) when :oracle to_date( to_char( from_tz( cast(column.as('TIMESTAMP')), quoted('UTC') # First cast as timestamp - ).op('AT TIME ZONE', quoted(name)), # Then use the timezone + ).op('AT TIME ZONE', quoted(timezone_name)), # Then use the timezone quoted('YYYY-MM-DD') # Remove the minutes and seconds ), quoted('YYYY-MM-DD HH24:MI:SS') # Reformat to be a valid date to compare with IN diff --git a/app/queries/new_accounts_query.rb b/app/queries/new_accounts_query.rb index 731b87dc66..5bb259b278 100644 --- a/app/queries/new_accounts_query.rb +++ b/app/queries/new_accounts_query.rb @@ -33,14 +33,14 @@ def postgres_query(range, date_format) # TODO: Cache the time zones known by the database timezone = connection.select_value(sql).to_s == '1' ? time_zone_name : time_zone.formatted_offset - mysql_subquery range, date_format, timezone: timezone + mysql_subquery range, date_format, timezone_name: timezone end def oracle_query(range, date_format) - oracle_subquery range, date_format, timezone: time_zone_name + oracle_subquery range, date_format, timezone_name: time_zone_name # FIXME: Rescuing from ActiveRecord::StatementInvalid is not recommended. See https://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html (Exception handling and rolling back) rescue ActiveRecord::StatementInvalid - oracle_subquery range, date_format, timezone: time_zone.formatted_offset + oracle_subquery range, date_format, timezone_name: time_zone.formatted_offset end private @@ -60,22 +60,22 @@ def granularity_to_date_format(granularity) end end - def mysql_subquery(range, date_format, timezone: Time.zone.tzinfo.name) + def mysql_subquery(range, date_format, timezone_name: Time.zone.tzinfo.name) account.buyer_accounts - .where.has { sift(:date, sift(:in_timezone, created_at, name: timezone)).in(range) } - .grouping { sift(:date_format, sift(:in_timezone, created_at, name: timezone), date_format).to_sql } + .where.has { sift(:date, sift(:in_timezone, created_at, timezone_name)).in(range) } + .grouping { sift(:date_format, sift(:in_timezone, created_at, timezone_name), date_format).to_sql } .count(:id) end - def oracle_subquery(range, date_format, timezone: Time.zone.tzinfo.name) + def oracle_subquery(range, date_format, timezone_name: Time.zone.tzinfo.name) query = account.buyer_accounts.where.has do - sift(:date, sift(:in_timezone, created_at, name: timezone)).in(range) + sift(:date, sift(:in_timezone, created_at, timezone_name)).in(range) end query = query.selecting do [ id, - sift(:date_format, sift(:in_timezone, created_at, name: timezone), date_format).as('dategrouping') + sift(:date_format, sift(:in_timezone, created_at, timezone_name), date_format).as('dategrouping') ] end From fa4783c0ae53107de448264688f6c06aa6793850 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 11:38:22 +0200 Subject: [PATCH 07/19] Fix deprecated ActiveModel::Errors usage --- app/controllers/admin/api/signups_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/api/signups_controller.rb b/app/controllers/admin/api/signups_controller.rb index bab13db282..bbb9f70861 100644 --- a/app/controllers/admin/api/signups_controller.rb +++ b/app/controllers/admin/api/signups_controller.rb @@ -25,8 +25,8 @@ def check_creation_errors # and not respond with pathetic error raise ActiveRecord::RecordNotFound if @signup_result.errors[:plans].present? - @signup_result.user.errors.each do |attr, error| - @signup_result.account.errors.add(attr, error) + @signup_result.user.errors.each do |error| + @signup_result.account.errors.add(error.attribute, error.message) end end From a1ca3c45dbbdee55d0a6dfff7039df85aea5db76 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 11:39:20 +0200 Subject: [PATCH 08/19] Fix decorators by making methods non-private The issue was caused by `draper` gem upgrade (which was a result of upgrading Ruby to v3). The issue was here: https://github.com/drapergem/draper/blob/v4.0.2/lib/draper/automatic_delegation.rb#L10-L26 In decorators we delegate all methods to the decorated object. But this version of the library only does that when there is no private method with the same name on the decorator. In this case, as `admin_user` was a private method on AccountDecorator, draper tried to call `admin_user `on superclass, but it was not there, so it was failing with: ``` ActionView::Template::Error (super: no superclass method `admin_user' for # Did you mean? admin_user_email): ``` Removing it from `private_methods` fixed the issue. --- app/decorators/account_decorator.rb | 2 +- app/decorators/proxy_config_decorator.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/decorators/account_decorator.rb b/app/decorators/account_decorator.rb index 8c62216f17..0753c6477a 100644 --- a/app/decorators/account_decorator.rb +++ b/app/decorators/account_decorator.rb @@ -3,7 +3,7 @@ class AccountDecorator < ApplicationDecorator delegate :display_name, :email, to: :admin_user, prefix: true - private + protected def admin_user @admin_user ||= (super || User.new).decorate diff --git a/app/decorators/proxy_config_decorator.rb b/app/decorators/proxy_config_decorator.rb index 7b1fb42e1d..4469492585 100644 --- a/app/decorators/proxy_config_decorator.rb +++ b/app/decorators/proxy_config_decorator.rb @@ -3,7 +3,7 @@ class ProxyConfigDecorator < ApplicationDecorator delegate :display_name, to: :user, prefix: true - private + protected def user @user ||= (super || User.new).decorate From f9c3e4fd132684f00602c5ff3f1b6259fb40b280 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 11:44:07 +0200 Subject: [PATCH 09/19] Fix URI.escape and URI.encode which are not available in Ruby 3 --- app/lib/authentication/strategy/cas.rb | 4 ++-- .../liquid/drops/authentication_strategy_test.rb | 16 ++++++---------- .../oauth2/redhat_customer_portal_client_test.rb | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/lib/authentication/strategy/cas.rb b/app/lib/authentication/strategy/cas.rb index 04400738ac..fd6fb1c1ca 100644 --- a/app/lib/authentication/strategy/cas.rb +++ b/app/lib/authentication/strategy/cas.rb @@ -51,7 +51,7 @@ def login_url end def login_url_with_service - login_url + "?service=" + URI.escape(service) + "#{login_url}?#{{service: service}.to_param}" end # /validate path is standard for CAS servers @@ -60,7 +60,7 @@ def validate_url end def validate_url_with_query ticket - validate_url + "?" + {:service => service, :ticket => ticket}.to_param + "#{validate_url}?#{{:service => service, :ticket => ticket}.to_param}" end def service diff --git a/test/unit/liquid/drops/authentication_strategy_test.rb b/test/unit/liquid/drops/authentication_strategy_test.rb index eced0255a4..5e37dc1cbc 100644 --- a/test/unit/liquid/drops/authentication_strategy_test.rb +++ b/test/unit/liquid/drops/authentication_strategy_test.rb @@ -4,17 +4,13 @@ class Liquid::Drops::AuthenticationStrategyTest < ActiveSupport::TestCase include Liquid def setup - @buyer = FactoryBot.create(:buyer_account) - FieldsDefinition.create(account: @buyer.provider_account, target: 'Account', - name: 'country', label: 'Country') - @buyer.reload + provider = FactoryBot.create :provider_account + provider.settings.update(cas_server_url: 'https://cas.example.com') + strategy = Authentication::Strategy::Cas.new provider + @drop = Drops::AuthenticationStrategy::Cas.new strategy end - test 'country#choices' do - drop = Drops::CountryField.new(@buyer, :country) - country = drop.choices.first - assert country.id.is_a?(Integer) - assert country.label.is_a?(String) + test '#login_url' do + assert_equal "https://cas.example.com/login?service=http%3A%2F%2Fcompany1.com%2Fsession%2Fcreate", @drop.login_url end - end diff --git a/test/unit/three_scale/oauth2/redhat_customer_portal_client_test.rb b/test/unit/three_scale/oauth2/redhat_customer_portal_client_test.rb index b9511c75e3..4b7f06b312 100644 --- a/test/unit/three_scale/oauth2/redhat_customer_portal_client_test.rb +++ b/test/unit/three_scale/oauth2/redhat_customer_portal_client_test.rb @@ -120,7 +120,7 @@ class ImplicitFlowTest < ActiveSupport::TestCase end test '#authorize_url' do - redirect_uri = URI.encode('http://master-admin.com/auth/redhat/callback?self_domain=alaska-admin.com', Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) + redirect_uri = ERB::Util.url_encode 'http://master-admin.com/auth/redhat/callback?self_domain=alaska-admin.com' expected_url = "http://example.com/protocol/openid-connect/auth" expected_url += "?client_id=#{@authentication.client_id}" From 51fc0757c423e630a44f4c6e2fe0ad3211846ba8 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 11:47:08 +0200 Subject: [PATCH 10/19] Fix various hacks that are not needed anymore after Ruby upgrade --- app/lib/api_authentication/by_access_token.rb | 8 +++--- app/lib/liquid/template_support.rb | 3 +-- app/lib/stats/deprecated.rb | 4 +-- app/lib/three_scale/hash_hacks.rb | 25 +++---------------- config/initializers/openstruct.rb | 18 ------------- doc/dependency_decisions.yml | 6 ----- features/step_definitions/settings_steps.rb | 2 +- test/unit/three_scale/hash_hacks_test.rb | 15 ----------- 8 files changed, 12 insertions(+), 69 deletions(-) delete mode 100644 config/initializers/openstruct.rb diff --git a/app/lib/api_authentication/by_access_token.rb b/app/lib/api_authentication/by_access_token.rb index 5dbd301ffd..774571f21f 100644 --- a/app/lib/api_authentication/by_access_token.rb +++ b/app/lib/api_authentication/by_access_token.rb @@ -108,8 +108,8 @@ def authenticated_token @authenticated_token = domain_account.access_tokens.find_from_value(access_token) if access_token end - def enforce_access_token_permission - PermissionEnforcer.enforce(authenticated_token, &Proc.new) + def enforce_access_token_permission(&block) + PermissionEnforcer.enforce(authenticated_token, &block) end def verify_access_token_scopes @@ -156,7 +156,7 @@ def start_transaction class EnforceError < StandardError end - def enforce(access_token) + def enforce(access_token, &block) self.level = access_token&.permission return yield unless requires_transaction? @@ -168,7 +168,7 @@ def enforce(access_token) System::ErrorReporting.report_error(error) end - connection.transaction(requires_new: true, &Proc.new) + connection.transaction(requires_new: true, &block) rescue ActiveRecord::StatementInvalid => error if error.message =~ /read(-|\s)only transaction/i raise PermissionError, error.message, caller diff --git a/app/lib/liquid/template_support.rb b/app/lib/liquid/template_support.rb index fc176ddf18..1238887603 100644 --- a/app/lib/liquid/template_support.rb +++ b/app/lib/liquid/template_support.rb @@ -97,8 +97,7 @@ def assigns_for_liquify public :assigns_for_liquify def self.fetch_drop(name) - # TODO: in Ruby 1.9 use get_const(name, false) so it really looks only in drop module scope - [Liquid::Drops, name.camelize].join("::").constantize + Liquid::Drops.const_get(name.camelize, false) end private diff --git a/app/lib/stats/deprecated.rb b/app/lib/stats/deprecated.rb index 917ff4ecb5..c5874e0bd6 100644 --- a/app/lib/stats/deprecated.rb +++ b/app/lib/stats/deprecated.rb @@ -55,7 +55,7 @@ def self.average_usage_by_weekdays(service, options = {}) data = data.group_by { |day, value| day.wday } data = data.sort.to_h - data.map_keys! { |wday| weekday_name(wday) } + data.transform_keys! { |wday| weekday_name(wday) } data.transform_values! { |data_for_day| data_for_day.map(&:second) } data.transform_values! { |values| values.sum.to_f / weeks_count } @@ -144,7 +144,7 @@ def self.weekday_name(number) end def self.format_hours(data) - data.map_keys { |hour| format_hour(hour) } + data.transform_keys { |hour| format_hour(hour) } end def self.format_hour(hour) diff --git a/app/lib/three_scale/hash_hacks.rb b/app/lib/three_scale/hash_hacks.rb index 8f732229c3..e381046fcd 100644 --- a/app/lib/three_scale/hash_hacks.rb +++ b/app/lib/three_scale/hash_hacks.rb @@ -22,41 +22,24 @@ def sweep # rails things hash is a flashhash end - # TODO: remove after migration to ruby 2.5+ and replace it with transform_keys - def map_keys - inject(self.class.new) do |memo, (key, value)| - memo[yield(key)] = value - memo - end - end - - def map_keys!(&block) - replace(map_keys(&block)) - end - # Convert all keys to lowercase. - # TODO replace with transform_keys {|key| key.downcase} def downcase_keys - map_keys { |key| key.downcase } + transform_keys { |key| key.downcase } end # In place version of +downcase_keys+ def downcase_keys! - replace(downcase_keys) + transform_keys! {|key| key.downcase} end # Convert all keys to uppercase. - # TODO replace with transform_keys {|key| key.upcase} def upcase_keys - inject(self.class.new) do |memo, (key, value)| - memo[key.upcase] = value - memo - end + transform_keys { |key| key.upcase } end # In place version of +upcase_keys+ def upcase_keys! - replace(upcase_keys) + transform_keys! { |key| key.upcase } end end end diff --git a/config/initializers/openstruct.rb b/config/initializers/openstruct.rb deleted file mode 100644 index 6f1119350e..0000000000 --- a/config/initializers/openstruct.rb +++ /dev/null @@ -1,18 +0,0 @@ -# TODO: this initializer is no longer needed when updating to ruby 2.1 -# https://github.com/ruby/ruby/commit/e44e356b53828d6468114b30e5c169296896f9b1 -require 'ostruct' - -module OpenStructCompat - def [](name) - @table[name.to_sym] - end - - def []=(name, value) - modifiable[new_ostruct_member(name)] = value - end -end - - -class OpenStruct - include OpenStructCompat -end \ No newline at end of file diff --git a/doc/dependency_decisions.yml b/doc/dependency_decisions.yml index b68c0e2010..5f54ff2d27 100644 --- a/doc/dependency_decisions.yml +++ b/doc/dependency_decisions.yml @@ -17,12 +17,6 @@ :why: :versions: [] :when: 2016-08-15 11:00:00.919892000 Z -- - :permit - - Ruby 1.8 - - :who: - :why: - :versions: [] - :when: 2016-08-15 11:03:11.357434000 Z - - :permit - BSD - :who: diff --git a/features/step_definitions/settings_steps.rb b/features/step_definitions/settings_steps.rb index ff8691a897..4f1bef4dd5 100644 --- a/features/step_definitions/settings_steps.rb +++ b/features/step_definitions/settings_steps.rb @@ -10,7 +10,7 @@ Given "{provider} has the following settings:" do |account, table| attributes = table.rows_hash - attributes.map_keys! { |key| underscore_spaces(key) } + attributes.transform_keys! { |key| underscore_spaces(key) } account.settings.update!(attributes) end diff --git a/test/unit/three_scale/hash_hacks_test.rb b/test/unit/three_scale/hash_hacks_test.rb index e0e1fea08d..66c57f55eb 100644 --- a/test/unit/three_scale/hash_hacks_test.rb +++ b/test/unit/three_scale/hash_hacks_test.rb @@ -53,21 +53,6 @@ class HashKeysCaseConversionsTest < ActiveSupport::TestCase assert_equal({'foo' => 2, 'bar' => 3}, hash) end - test 'map_keys' do - hash_one = {'foo' => 1, 'bar' => 2} - hash_two = hash_one.map_keys { |value| value + '!' } - - assert_equal({'foo' => 1, 'bar' => 2}, hash_one) - assert_equal({'foo!' => 1, 'bar!' => 2}, hash_two) - end - - test 'map_keys!' do - hash = {'foo' => 1, 'bar' => 2} - hash.map_keys! { |key| key + '!' } - - assert_equal({'foo!' => 1, 'bar!' => 2}, hash) - end - test 'sort_keys' do hash = ActiveSupport::OrderedHash.new hash[42] = 'foo' From e088b15dde724375765154b989fd5f5053ee4ea4 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 11:50:43 +0200 Subject: [PATCH 11/19] Skip the test using fibers This test caused multiple tests fail with: ``` ThreadError: deadlock; lock already owned by another fiber belonging to the same thread ``` This is fixed in Rails 7.0.6 and higher: https://github.com/rails/rails/pull/46553 --- test/workers/delete_plain_object_worker_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/workers/delete_plain_object_worker_test.rb b/test/workers/delete_plain_object_worker_test.rb index 7f291f7ac2..ed178c2d87 100644 --- a/test/workers/delete_plain_object_worker_test.rb +++ b/test/workers/delete_plain_object_worker_test.rb @@ -103,6 +103,7 @@ def load_target end def test_race_condition + skip('skip the test until we upgrade to Rails >= 7.1.0 that fixes https://github.com/rails/rails/pull/46553') service = FactoryBot.create(:simple_service) # There is a restriction on deleting service, at least one should remain FactoryBot.create(:simple_service, account: service.account) From 910e7c4199ea6774caf6b7d9323663ef8fa46552 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 11:53:20 +0200 Subject: [PATCH 12/19] Fix deprecation warning for `fixture_file_upload` ``` DEPRECATION WARNING: Passing a path to `fixture_file_upload` relative to `fixture_path` is deprecated. In Rails 7.0, the path needs to be relative to `file_fixture_path`. Please modify the call from `fixture_file_upload("wide.jpg")` to `fixture_file_upload("../../../test/fixtures/wide.jpg")`. (called from block (4 levels) in
at /home/dmayorov/Projects/3scale/porta/spec/acceptance/api/cms_file_spec.rb:24) ``` --- test/test_helpers/file_fixtures.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_helpers/file_fixtures.rb b/test/test_helpers/file_fixtures.rb index 123bf8dd55..55a8917dd7 100644 --- a/test/test_helpers/file_fixtures.rb +++ b/test/test_helpers/file_fixtures.rb @@ -3,6 +3,6 @@ ActiveSupport::TestCase.class_eval do include ActiveSupport::Testing::FileFixtures - self.fixture_path = Rails.root.join('test', 'fixtures') - self.file_fixture_path = self.fixture_path + self.fixture_path = Rails.root.join('test/fixtures') + self.file_fixture_path = fixture_path end From 42e3638ed95deeee5a0aabcf18b0aecbe05bbf57 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Fri, 19 Jul 2024 11:54:56 +0200 Subject: [PATCH 13/19] Remove URL hacks for Liquid --- .../config/initializers/liquid.rb | 3 -- .../lib/liquid/drops/request.rb | 2 ++ .../lib/liquid/url_helper_hacks.rb | 29 ------------------- 3 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 lib/developer_portal/lib/liquid/url_helper_hacks.rb diff --git a/lib/developer_portal/config/initializers/liquid.rb b/lib/developer_portal/config/initializers/liquid.rb index 1c43e45aa7..423c4421d8 100644 --- a/lib/developer_portal/config/initializers/liquid.rb +++ b/lib/developer_portal/config/initializers/liquid.rb @@ -1,14 +1,11 @@ # frozen_string_literal: true require 'liquid' -require 'liquid/url_helper_hacks' - # allow calling present? in {% if %} Liquid::Expression::LITERALS['present'] = :present? Rails.application.config.to_prepare do # Hacks - ActionView::Helpers.send(:include, Liquid::UrlHelperHacks) [ Liquid::Filters::GoogleAnalytics, diff --git a/lib/developer_portal/lib/liquid/drops/request.rb b/lib/developer_portal/lib/liquid/drops/request.rb index 9608585ae5..d2d96bd2ac 100644 --- a/lib/developer_portal/lib/liquid/drops/request.rb +++ b/lib/developer_portal/lib/liquid/drops/request.rb @@ -20,6 +20,8 @@ def request_uri @request.original_url end + alias original_url request_uri + desc "Returns the host with port of the request." def host_with_port @request.host_with_port diff --git a/lib/developer_portal/lib/liquid/url_helper_hacks.rb b/lib/developer_portal/lib/liquid/url_helper_hacks.rb deleted file mode 100644 index 1765fbc876..0000000000 --- a/lib/developer_portal/lib/liquid/url_helper_hacks.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Liquid - module UrlHelperHacks - # This is the same as the original implementation, except the controller here is accessed - # through method, not variable. This way it's more hackable. - def current_page?(options) - url_string = CGI.unescapeHTML(url_for(options)) - request = controller.request - - request_uri = if url_string.index("?") - request.request_uri - else - request.request_uri.split('?').first - end - - url_string == if url_string =~ /^\w+:\/\// - "#{request.protocol}#{request.host_with_port}#{request_uri}" - else - request_uri - end - end - - private - - # Semi-hacky way to access controller from within liquid's filters and tags. - def controller - @context.registers[:controller] - end - end -end From a16294a6574ec87c907b9a50dad91fe627717c4e Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Mon, 22 Jul 2024 14:34:12 +0200 Subject: [PATCH 14/19] Remove an unused Dockerfile --- Dockerfile | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 89d756c025..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM quay.io/3scale/system-builder:ruby26 - -ARG CUSTOM_DB=mysql - -ENV DISABLE_SPRING="true" \ - ORACLE_SYSTEM_PASSWORD="threescalepass" \ - NLS_LANG="AMERICAN_AMERICA.UTF8" \ - TZ="UTC" \ - MASTER_PASSWORD="p" \ - USER_PASSWORD="p" \ - LC_ALL="en_US.UTF-8" \ - PATH="./node_modules/.bin:/opt/rh/rh-nodejs14/root/usr/bin:$PATH" \ - DNSMASQ="#" \ - BUNDLE_FROZEN=1 \ - BUNDLE_JOBS=5 \ - DB=${CUSTOM_DB} \ - SAFETY_ASSURED=1 - -WORKDIR /opt/system/ - -ADD . ./ -ADD config/examples/*.yml config/ -# Needed for Sphinx ODBC -ADD config/oracle/odbc*.ini /etc/ - -USER root -RUN if [ "X${DB}" = "Xoracle" ]; then ./script/oracle/install-instantclient-packages.sh; fi - -# Needed to disable webpack compiling -RUN sed -i 's/compile: true/compile: false/' config/webpacker.yml - -RUN bash -c "bundle install && bundle exec rake tmp:create" -RUN bash -c "npm install -g yarn && yarn install:safe && rake assets:precompile" From e3de2efccbcbe1cd400a76d9460a033ac956d667 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Mon, 22 Jul 2024 15:32:33 +0200 Subject: [PATCH 15/19] Add 'matrix' gem required by current versions of prawn and capybara gems It used to be a default gem in Ruby 2.7, but since Ruby 3 it's not default anymore --- Gemfile | 1 + Gemfile.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 1c5494e66f..2edbdfb882 100644 --- a/Gemfile +++ b/Gemfile @@ -100,6 +100,7 @@ gem 'httpclient', github: '3scale/httpclient', branch: 'ssl-env-cert' gem 'json-schema', git: 'https://github.com/3scale/json-schema.git' gem 'local-fastimage_resize', '~> 3.4.0', require: 'fastimage/resize' gem 'kt-paperclip', '~> 7.2' +gem 'matrix', '~> 0.4.2' gem 'prawn' gem 'prawn-table', git: "https://github.com/prawnpdf/prawn-table.git", branch: "38b5bdb5dd95237646675c968091706f57a7a641" gem 'prawn-svg' diff --git a/Gemfile.lock b/Gemfile.lock index 051e5d72e6..695760c019 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1033,6 +1033,7 @@ DEPENDENCIES local-fastimage_resize (~> 3.4.0) mail (~> 2.8.1) mail_view (~> 2.0.4) + matrix (~> 0.4.2) mechanize mimemagic (~> 0.3.10) minitest (= 5.10.3) From 408c8d5d1c86ef17412233578eb92f3e714dd1b4 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Mon, 22 Jul 2024 16:18:21 +0200 Subject: [PATCH 16/19] Upgrade the upstream Dockerfile --- openshift/system/Dockerfile | 39 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/openshift/system/Dockerfile b/openshift/system/Dockerfile index bae5674e33..882f4c05e5 100644 --- a/openshift/system/Dockerfile +++ b/openshift/system/Dockerfile @@ -1,19 +1,20 @@ -FROM quay.io/centos/centos:stream8 as builder +FROM quay.io/centos/centos:stream9 as builder WORKDIR /opt/system -ENV RUBY_MAJOR_VERSION=2 \ - RUBY_MINOR_VERSION=7 \ +ENV RUBY_MAJOR_VERSION=3 \ + RUBY_MINOR_VERSION=1 \ RAILS_ENV=production \ - NODE_ENV=production + NODE_ENV=production \ + # This is to fix 'error:0308010C:digital envelope routines::unsupported' in Node 18 + # the proper fix should be upgrading webpack and babel-loader + NODE_OPTIONS='--openssl-legacy-provider' ENV RUBY_VERSION="${RUBY_MAJOR_VERSION}.${RUBY_MINOR_VERSION}" ADD . ./ RUN cp config/examples/*.yml config/ \ && cp openshift/system/config/* config/ -RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* \ - && sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* \ - && dnf -y --setopt=module_stream_switch=True module enable ruby:${RUBY_VERSION} nodejs:16 mysql:8.0 \ - && dnf install -y --setopt=skip_missing_names_on_install=False,tsflags=nodocs shared-mime-info make automake gcc gcc-c++ redhat-rpm-config postgresql rubygem-irb rubygem-rdoc ruby-devel nodejs libpq-devel mysql-devel gd-devel libxml2-devel libxslt-devel git 'dnf-command(download)' podman-catatonit \ +RUN dnf -y --setopt=module_stream_switch=True module enable ruby:${RUBY_VERSION} nodejs:18 mariadb:10.11 \ + && dnf install -y --setopt=skip_missing_names_on_install=False,tsflags=nodocs shared-mime-info make automake gcc gcc-c++ redhat-rpm-config postgresql rubygem-irb ruby-devel nodejs libpq-devel mariadb-devel mysql gd-devel libxml2-devel libxslt-devel git 'dnf-command(download)' cpio \ && BUNDLER_VERSION=$(awk '/BUNDLED WITH/ { getline; print $1 }' Gemfile.lock) \ && gem install --no-document bundler:$BUNDLER_VERSION \ && bundle config build.nokogiri --use-system-libraries \ @@ -36,12 +37,12 @@ RUN cd /tmp \ && ./autogen.sh && ./configure --libdir=/usr/local/lib64/ && make -FROM quay.io/centos/centos:stream8 AS base +FROM quay.io/centos/centos:stream9 AS base USER root -ENV RUBY_MAJOR_VERSION=2 \ - RUBY_MINOR_VERSION=7 \ +ENV RUBY_MAJOR_VERSION=3 \ + RUBY_MINOR_VERSION=1 \ RAILS_ENV=production \ SAFETY_ASSURED=1 \ TZ=:/etc/localtime \ @@ -52,18 +53,15 @@ ENV RUBY_VERSION="${RUBY_MAJOR_VERSION}.${RUBY_MINOR_VERSION}" WORKDIR $HOME -RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* \ - && sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* \ - && dnf -y module enable ruby:${RUBY_VERSION} nodejs:16 mysql:8.0 \ - && dnf install -y --setopt=skip_missing_names_on_install=False,tsflags=nodocs shared-mime-info postgresql rubygem-irb rubygem-rdoc ruby libpq mysql mysql-libs gd git liberation-sans-fonts file libxml2 libxslt \ +RUN dnf -y module enable ruby:${RUBY_VERSION} nodejs:18 \ + && dnf install -y --setopt=skip_missing_names_on_install=False,tsflags=nodocs shared-mime-info postgresql rubygem-irb rubygem-rdoc ruby libpq mysql mariadb-connector-c gd git liberation-sans-fonts file libxml2 libxslt \ + && dnf install -y catatonit --nobest \ && dnf -y clean all COPY --from=builder /opt/system/ . COPY --from=builder /tmp/memkind-*/jemalloc/lib/libjemalloc.so* /usr/local/lib64 COPY --from=builder /usr/local/share/gems /usr/local/share/ COPY --from=builder /usr/local/bin/bundle* /usr/local/bin -# in RHEL 8 podman-catatonit pulls in too many useless deps so we don't install the RPM directly, on RHEL 9 simply use package `catatonit` -COPY --from=builder /usr/libexec/catatonit/catatonit /usr/libexec/catatonit/catatonit RUN echo /usr/local/lib64 > /etc/ld.so.conf.d/jemalloc.conf \ && ldconfig && ldconfig -p | grep jemalloc @@ -109,13 +107,12 @@ ENV THINKING_SPHINX_ADDRESS=0.0.0.0 \ SECRET_KEY_BASE=dummy \ DATABASE_URL='mysql2://root:@localhost/porta' USER 0 -RUN dnf install -y mysql-server mysql-test \ - && setcap -r /usr/libexec/mysqld \ - && setpriv --reuid 27 --regid 27 --clear-groups mysqld --initialize-insecure \ +RUN dnf install -y mariadb-server --allowerasing \ + && setpriv --reuid 27 --regid 27 --clear-groups mysql_install_db \ && (mysqld_safe &) \ && bundle exec rake db:create db:schema:load openshift:thinking_sphinx:configure \ && grep -q "rt_field = account_id" "$THINKING_SPHINX_CONFIGURATION_FILE" \ - && kill $( Date: Thu, 25 Jul 2024 16:00:44 +0200 Subject: [PATCH 17/19] Update decorators --- app/decorators/account_decorator.rb | 2 -- app/decorators/proxy_config_decorator.rb | 2 -- 2 files changed, 4 deletions(-) diff --git a/app/decorators/account_decorator.rb b/app/decorators/account_decorator.rb index 0753c6477a..8dd684f66c 100644 --- a/app/decorators/account_decorator.rb +++ b/app/decorators/account_decorator.rb @@ -3,8 +3,6 @@ class AccountDecorator < ApplicationDecorator delegate :display_name, :email, to: :admin_user, prefix: true - protected - def admin_user @admin_user ||= (super || User.new).decorate end diff --git a/app/decorators/proxy_config_decorator.rb b/app/decorators/proxy_config_decorator.rb index 4469492585..d25b88a6a0 100644 --- a/app/decorators/proxy_config_decorator.rb +++ b/app/decorators/proxy_config_decorator.rb @@ -3,8 +3,6 @@ class ProxyConfigDecorator < ApplicationDecorator delegate :display_name, to: :user, prefix: true - protected - def user @user ||= (super || User.new).decorate end From 9bd6ed4c6f29a0908e438cf64d71e8cb65e51ae1 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Thu, 25 Jul 2024 16:01:02 +0200 Subject: [PATCH 18/19] Update billing service --- app/services/finance/billing_service.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/services/finance/billing_service.rb b/app/services/finance/billing_service.rb index 9ea0243521..0cc1af27c1 100644 --- a/app/services/finance/billing_service.rb +++ b/app/services/finance/billing_service.rb @@ -75,8 +75,7 @@ def report_error(error) message = "Failed to perform billing job: #{error.message}" Rails.logger.error(message) System::ErrorReporting.report_error(error, error_message: message, - error_class: error.class.name, - exception: error) + error_class: error.class.name) end end end From a26ee230055ca4a91e5f97a399c447f5449cc1c9 Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Tue, 30 Jul 2024 17:07:12 +0200 Subject: [PATCH 19/19] Fix user tracking error reporting --- app/lib/three_scale/analytics/user_tracking.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/lib/three_scale/analytics/user_tracking.rb b/app/lib/three_scale/analytics/user_tracking.rb index a7924a43e6..60e87932ac 100644 --- a/app/lib/three_scale/analytics/user_tracking.rb +++ b/app/lib/three_scale/analytics/user_tracking.rb @@ -6,10 +6,19 @@ module ThreeScale module Analytics + + class UserTrackingError < StandardError + def initialize(status, error) + msg = "User tracking report failed with status: #{status}" + msg << ", message: #{error}" if error + super(msg) + end + end + class UserTracking error_handler = ->(status, error) do - System::ErrorReporting.report_error(error_message: error, parameters: { status: status }) + System::ErrorReporting.report_error(UserTrackingError.new(status, error)) end class TrackingAdapter