diff --git a/.circleci/config.yml b/.circleci/config.yml index eecc439e8c..001a8149fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,9 +28,9 @@ store-log-artifacts: &store-log-artifacts path: log destination: log -npm-cache-key: &npm-cache-key stream8-{{ .Environment.CACHE_VERSION }}-node-modules-{{ checksum "yarn.lock" }} -bundle-cache-key: &bundle-cache-key stream8-{{ .Environment.CACHE_VERSION }}-bundler-gems-{{ arch }}-{{ checksum "Gemfile.lock" }}-{{ checksum "/tmp/db" }} -assets-cache-key: &assets-cache-key stream8-{{ .Environment.CACHE_VERSION }}-asset-cache-{{ checksum "tmp/assets_related_checksums" }} +npm-cache-key: &npm-cache-key stream9-{{ .Environment.CACHE_VERSION }}-node-modules-{{ checksum "yarn.lock" }} +bundle-cache-key: &bundle-cache-key stream9-{{ .Environment.CACHE_VERSION }}-bundler-gems-{{ arch }}-{{ checksum "Gemfile.lock" }}-{{ checksum "/tmp/db" }} +assets-cache-key: &assets-cache-key stream9-{{ .Environment.CACHE_VERSION }}-asset-cache-{{ checksum "tmp/assets_related_checksums" }} oracle-libs-cache-key: &oracle-libs-cache-key ora1-{{ .Environment.CACHE_VERSION }}-oracle-libs-cache-{{ checksum "script/oracle/install-instantclient-packages.sh" }} restore-npm-cache: &restore-npm-cache @@ -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-ruby31: &system-builder-ruby31 + image: quay.io/3scale/system-builder:stream9-ruby3.1-chrome126 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-ruby31: &builder-ruby31 parameters: database: type: string default: mysql docker: - - *system-builder-ruby27 + - *system-builder-ruby31 environment: DB: << parameters.database >> working_directory: /opt/ci/workdir - builder-with-mysql-ruby27: &builder-with-mysql-ruby27 + builder-with-mysql-ruby31: &builder-with-mysql-ruby31 resource_class: small docker: - - *system-builder-ruby27 + - *system-builder-ruby31 - *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-ruby31: &builder-with-postgres-ruby31 resource_class: small docker: - - *system-builder-ruby27 + - *system-builder-ruby31 - *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-ruby31: &builder-with-oracle-ruby31 resource_class: large docker: - - *system-builder-ruby27 + - *system-builder-ruby31 - *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-ruby31: &cucumber-with-mysql-ruby31 resource_class: small docker: - - *system-builder-ruby27 + - *system-builder-ruby31 - *dnsmasq-container - *mysql-container - *memcached-container - *redis-container - cucumber-with-postgres-ruby27: &cucumber-with-postgres-ruby27 + cucumber-with-postgres-ruby31: &cucumber-with-postgres-ruby31 resource_class: small docker: - - *system-builder-ruby27 + - *system-builder-ruby31 - *dnsmasq-container - *postgres-container - *memcached-container - *redis-container - cucumber-with-oracle-ruby27: &cucumber-with-oracle-ruby27 + cucumber-with-oracle-ruby31: &cucumber-with-oracle-ruby31 resource_class: large docker: - - *system-builder-ruby27 + - *system-builder-ruby31 - *dnsmasq-container - *oracle-db-container - *memcached-container @@ -438,7 +438,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby31 executor: name: << parameters.executor >> database: mysql @@ -450,7 +450,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby31 executor: name: << parameters.executor >> database: postgresql @@ -462,7 +462,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby31 executor: name: << parameters.executor >> database: oracle @@ -476,7 +476,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby31 executor: name: << parameters.executor >> steps: @@ -499,7 +499,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby31 executor: name: << parameters.executor >> steps: @@ -527,7 +527,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby31 executor: name: << parameters.executor >> steps: @@ -542,7 +542,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby31 executor: name: << parameters.executor >> steps: @@ -562,7 +562,7 @@ jobs: parameters: executor: type: string - default: builder-ruby27 + default: builder-ruby31 executor: name: << parameters.executor >> steps: @@ -579,7 +579,7 @@ jobs: parameters: executor: type: string - default: builder-with-mysql-ruby27 + default: builder-with-mysql-ruby31 executor: name: << parameters.executor >> steps: @@ -591,7 +591,7 @@ jobs: parameters: executor: type: string - default: builder-with-postgres-ruby27 + default: builder-with-postgres-ruby31 executor: name: << parameters.executor >> steps: @@ -603,7 +603,7 @@ jobs: parameters: executor: type: string - default: builder-with-oracle-ruby27 + default: builder-with-oracle-ruby31 executor: name: << parameters.executor >> steps: @@ -617,7 +617,7 @@ jobs: parameters: executor: type: string - default: builder-with-mysql-ruby27 + default: builder-with-mysql-ruby31 executor: name: << parameters.executor >> steps: @@ -629,7 +629,7 @@ jobs: parameters: executor: type: string - default: builder-with-postgres-ruby27 + default: builder-with-postgres-ruby31 executor: name: << parameters.executor >> steps: @@ -641,7 +641,7 @@ jobs: parameters: executor: type: string - default: builder-with-oracle-ruby27 + default: builder-with-oracle-ruby31 executor: name: << parameters.executor >> steps: @@ -655,7 +655,7 @@ jobs: parameters: executor: type: string - default: builder-with-mysql-ruby27 + default: builder-with-mysql-ruby31 executor: name: << parameters.executor >> steps: @@ -667,7 +667,7 @@ jobs: parameters: executor: type: string - default: builder-with-postgres-ruby27 + default: builder-with-postgres-ruby31 executor: name: << parameters.executor >> steps: @@ -679,7 +679,7 @@ jobs: parameters: executor: type: string - default: builder-with-oracle-ruby27 + default: builder-with-oracle-ruby31 executor: name: << parameters.executor >> steps: @@ -693,7 +693,7 @@ jobs: parameters: executor: type: string - default: builder-with-mysql-ruby27 + default: builder-with-mysql-ruby31 executor: name: << parameters.executor >> steps: @@ -705,7 +705,7 @@ jobs: parameters: executor: type: string - default: builder-with-postgres-ruby27 + default: builder-with-postgres-ruby31 executor: name: << parameters.executor >> steps: @@ -717,7 +717,7 @@ jobs: parameters: executor: type: string - default: builder-with-oracle-ruby27 + default: builder-with-oracle-ruby31 executor: name: << parameters.executor >> steps: @@ -732,7 +732,7 @@ jobs: parameters: executor: type: string - default: cucumber-with-mysql-ruby27 + default: cucumber-with-mysql-ruby31 executor: name: << parameters.executor >> steps: @@ -745,7 +745,7 @@ jobs: parameters: executor: type: string - default: cucumber-with-postgres-ruby27 + default: cucumber-with-postgres-ruby31 executor: name: << parameters.executor >> steps: @@ -758,7 +758,7 @@ jobs: parameters: executor: type: string - default: cucumber-with-oracle-ruby27 + default: cucumber-with-oracle-ruby31 executor: name: << parameters.executor >> steps: @@ -1016,37 +1016,37 @@ workflows: ######## Nightly workflows - mysql_nightly_build_ruby27: + mysql_nightly_build_ruby31: jobs: - notify_start: <<: *only-master-filter - dependencies_bundler: - executor: builder-ruby27 + executor: builder-ruby31 - dependencies_npm: - executor: builder-ruby27 + executor: builder-ruby31 - assets_precompile: - executor: builder-ruby27 + executor: builder-ruby31 requires: - dependencies_bundler - dependencies_npm - unit: - executor: builder-with-mysql-ruby27 + executor: builder-with-mysql-ruby31 requires: - dependencies_bundler - functional: - executor: builder-with-mysql-ruby27 + executor: builder-with-mysql-ruby31 requires: - assets_precompile - integration: - executor: builder-with-mysql-ruby27 + executor: builder-with-mysql-ruby31 requires: - assets_precompile - rspec: - executor: builder-with-mysql-ruby27 + executor: builder-with-mysql-ruby31 requires: - dependencies_bundler - cucumber: - executor: cucumber-with-mysql-ruby27 + executor: cucumber-with-mysql-ruby31 requires: - assets_precompile - notify_success: @@ -1059,37 +1059,37 @@ workflows: <<: *only-master-filter <<: *nightly-trigger - postgres_nightly_build_ruby27: + postgres_nightly_build_ruby31: jobs: - notify_start: <<: *only-master-filter - deps_bundler_postgres: - executor: builder-ruby27 + executor: builder-ruby31 - dependencies_npm: - executor: builder-ruby27 + executor: builder-ruby31 - assets_precompile: - executor: builder-ruby27 + executor: builder-ruby31 requires: - deps_bundler_postgres - dependencies_npm - unit-postgres: - executor: builder-with-postgres-ruby27 + executor: builder-with-postgres-ruby31 requires: - deps_bundler_postgres - functional-postgres: - executor: builder-with-postgres-ruby27 + executor: builder-with-postgres-ruby31 requires: - assets_precompile - integration-postgres: - executor: builder-with-postgres-ruby27 + executor: builder-with-postgres-ruby31 requires: - assets_precompile - rspec-postgres: - executor: builder-with-postgres-ruby27 + executor: builder-with-postgres-ruby31 requires: - deps_bundler_postgres - cucumber-postgres: - executor: cucumber-with-postgres-ruby27 + executor: cucumber-with-postgres-ruby31 requires: - assets_precompile - notify_success: @@ -1102,45 +1102,45 @@ workflows: <<: *only-master-filter <<: *nightly-trigger - oracle_nightly_build_ruby27: + oracle_nightly_build_ruby31: jobs: - notify_start: <<: *only-master-filter - deps_bundler_oracle: - executor: builder-ruby27 + executor: builder-ruby31 - dependencies_npm: - executor: builder-ruby27 + executor: builder-ruby31 - assets_precompile: - executor: builder-ruby27 + executor: builder-ruby31 requires: - deps_bundler_oracle - dependencies_npm - unit-oracle: - executor: builder-with-oracle-ruby27 + executor: builder-with-oracle-ruby31 context: - quay requires: - deps_bundler_oracle - functional-oracle: - executor: builder-with-oracle-ruby27 + executor: builder-with-oracle-ruby31 context: - quay requires: - assets_precompile - integration-oracle: - executor: builder-with-oracle-ruby27 + executor: builder-with-oracle-ruby31 context: - quay requires: - assets_precompile - rspec-oracle: - executor: builder-with-oracle-ruby27 + executor: builder-with-oracle-ruby31 context: - quay requires: - deps_bundler_oracle - cucumber-oracle: - executor: cucumber-with-oracle-ruby27 + executor: cucumber-with-oracle-ruby31 context: - quay requires: @@ -1155,29 +1155,29 @@ workflows: <<: *only-master-filter <<: *nightly-trigger - javascript_nightly_build_ruby27: + javascript_nightly_build_ruby31: jobs: - notify_start: <<: *only-master-filter - dependencies_bundler: - executor: builder-ruby27 + executor: builder-ruby31 - dependencies_npm: - executor: builder-ruby27 + executor: builder-ruby31 - assets_precompile: - executor: builder-ruby27 + executor: builder-ruby31 requires: - dependencies_bundler - dependencies_npm - licenses: - executor: builder-ruby27 + executor: builder-ruby31 requires: - dependencies_bundler - lint: - executor: builder-ruby27 + executor: builder-ruby31 requires: - dependencies_npm - jest: - executor: builder-ruby27 + executor: builder-ruby31 requires: - dependencies_npm - notify_success: diff --git a/.tool-versions.sample b/.tool-versions.sample index e4dad50a6b..888d6aa8da 100644 --- a/.tool-versions.sample +++ b/.tool-versions.sample @@ -1,3 +1,3 @@ -ruby 2.7.6 -nodejs 16.19.1 +ruby 3.1.5 +nodejs 18.20.4 python 2.7.18 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" diff --git a/Gemfile b/Gemfile index 2fae17a4c0..cee4cae292 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 @@ -101,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' # needed only until we upgrade capybara and prawn that list it as a dependency gem 'prawn' gem 'prawn-table', git: "https://github.com/prawnpdf/prawn-table.git", branch: "38b5bdb5dd95237646675c968091706f57a7a641" gem 'prawn-svg' @@ -120,7 +120,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 +159,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' @@ -182,13 +183,12 @@ gem 'dynamic_form' gem 'record_tag_helper', '~> 1.0' group :test do - # To remove once migrated all functional tests - gem 'codecov', :require => false gem 'rack-no_animations', '~> 1.0.3' gem 'rails-controller-testing', '~> 1.0.4' - gem 'simplecov', '~> 0.21.2', require: false + gem 'simplecov', '~> 0.22.0', require: false + gem 'simplecov-cobertura', '~> 2.1' - 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..943ac670d6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -158,7 +158,7 @@ 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) @@ -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) @@ -245,8 +245,6 @@ GEM ci_reporter (2.0.0) builder (>= 2.1.2) climate_control (0.2.0) - codecov (0.4.3) - simplecov (>= 0.15, < 0.22) coderay (1.1.3) coffee-rails (5.0.0) coffee-script (>= 2.2.0) @@ -273,7 +271,7 @@ 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 @@ -326,6 +324,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) @@ -339,19 +338,20 @@ GEM declarative-option (< 0.2.0) representable (>= 2.4.0, <= 3.1.0) uber (< 0.2.0) - docile (1.3.5) + docile (1.4.1) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) dotenv (2.8.1) 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) + ruby2_keywords dry-initializer (3.0.4) dynamic_form (1.3.1) actionview (> 5.2.0) @@ -362,7 +362,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 +382,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 +417,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 +437,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 +464,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 +473,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) @@ -519,6 +523,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) @@ -588,7 +601,7 @@ GEM psych (3.2.1) public_suffix (4.0.7) 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 +661,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 +670,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) + rbtree (0.4.6) recaptcha (5.16.0) record_tag_helper (1.0.1) actionview (>= 5) @@ -670,8 +684,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 +705,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) @@ -781,6 +795,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) @@ -799,12 +814,15 @@ GEM concurrent-ruby (>= 1.2.0) redis-prescription (~> 2.2) sidekiq (>= 6.5) - simplecov (0.21.2) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) + simplecov-cobertura (2.1.0) + rexml + simplecov (~> 0.19) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.2) + simplecov_json_formatter (0.1.4) slim (4.0.1) temple (>= 0.7.6, < 0.9) tilt (>= 2.0.6, < 2.1) @@ -815,6 +833,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,6 +882,7 @@ 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) @@ -892,7 +914,7 @@ GEM unf_ext (0.0.7.7) unicode-display_width (2.3.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) @@ -933,7 +955,7 @@ GEM 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 +973,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,12 +987,11 @@ 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! - codecov coffee-rails (~> 5.0) colorize commonmarker (~> 0.23.10) @@ -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,8 +1031,9 @@ 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) + matrix (~> 0.4.2) mechanize mimemagic (~> 0.3.10) minitest (= 5.10.3) @@ -1077,8 +1099,10 @@ DEPENDENCIES sidekiq-batch! sidekiq-cron sidekiq-throttled (~> 1.4.0) - simplecov (~> 0.21.2) + simplecov (~> 0.22.0) + simplecov-cobertura (~> 2.1) slim-rails (~> 3.2) + sorted_set (~> 1.0) sprockets-rails state_machines (~> 0.5.0) state_machines-activerecord (~> 0.8) 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 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/decorators/account_decorator.rb b/app/decorators/account_decorator.rb index 8c62216f17..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 - private - 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 7b1fb42e1d..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 - private - def user @user ||= (super || User.new).decorate 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/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/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/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/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/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/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/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/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 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/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..95c762cdfd 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, **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/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/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/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 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 diff --git a/app/services/finance/billing_service.rb b/app/services/finance/billing_service.rb index b623ba3064..0cc1af27c1 100644 --- a/app/services/finance/billing_service.rb +++ b/app/services/finance/billing_service.rb @@ -74,9 +74,8 @@ 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) 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/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/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/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/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/features/support/env_formatter.rb b/features/support/env_formatter.rb index a07419c9e1..8450ef9fd5 100644 --- a/features/support/env_formatter.rb +++ b/features/support/env_formatter.rb @@ -3,12 +3,12 @@ if ENV['CI'] require 'simplecov' require "simplecov_json_formatter" - require 'codecov' + require 'simplecov-cobertura' formatters = [ SimpleCov::Formatter::SimpleFormatter, SimpleCov::Formatter::JSONFormatter, SimpleCov::Formatter::HTMLFormatter, - Codecov::SimpleCov::Formatter + SimpleCov::Formatter::CoberturaFormatter ] SimpleCov.start do formatter SimpleCov::Formatter::MultiFormatter.new(formatters) diff --git a/fedora-manual-setup.md b/fedora-manual-setup.md index 529ad7d758..2b341b071f 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.1.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/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/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/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/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 diff --git a/lib/tasks/coverage.rake b/lib/tasks/coverage.rake index ef38368e89..bce637d9a8 100644 --- a/lib/tasks/coverage.rake +++ b/lib/tasks/coverage.rake @@ -1,4 +1,6 @@ +# frozen_string_literal: true + task :coverage do require 'simplecov' - SimpleCov::ResultMerger.merged_result.format! + SimpleCov::ResultMerger.merged_result&.format! end 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/openshift/system/Dockerfile b/openshift/system/Dockerfile index bae5674e33..459a69f37b 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 \ + && dnf install -y --setopt=skip_missing_names_on_install=False,tsflags=nodocs --enablerepo=crb 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 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 --enablerepo=crb shared-mime-info postgresql rubygem-irb rubygem-rdoc ruby libpq mysql mysql-libs gd git liberation-sans-fonts file libxml2 libxslt \ && 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 +COPY --from=builder /usr/libexec/podman/catatonit /usr/libexec/podman/catatonit RUN echo /usr/local/lib64 > /etc/ld.so.conf.d/jemalloc.conf \ && ldconfig && ldconfig -p | grep jemalloc @@ -93,7 +91,7 @@ RUN rm -rf vendor/oracle/ test/ spec/ features/ lib/proxy \ USER 1001 EXPOSE 3000 9306 -ENTRYPOINT ["/usr/libexec/catatonit/catatonit", "--", "/opt/system/entrypoint.sh"] +ENTRYPOINT ["/usr/libexec/podman/catatonit", "--", "/opt/system/entrypoint.sh"] CMD ["unicorn", "-c", "config/unicorn.rb", "-E", "${RAILS_ENV}", "config.ru"] @@ -109,7 +107,7 @@ 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 \ +RUN dnf install --enablerepo=crb -y mysql-server mysql-test \ && setcap -r /usr/libexec/mysqld \ && setpriv --reuid 27 --regid 27 --clear-groups mysqld --initialize-insecure \ && (mysqld_safe &) \ diff --git a/osx-manual-setup.md b/osx-manual-setup.md index 8ecc4cba9e..3594685e90 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.1.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", 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/spec/rails_helper.rb b/spec/rails_helper.rb index b9a9d369ec..c68f61740b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -39,12 +39,12 @@ if ENV['CI'] require 'simplecov' require "simplecov_json_formatter" - require 'codecov' + require 'simplecov-cobertura' formatters = [ SimpleCov::Formatter::SimpleFormatter, SimpleCov::Formatter::JSONFormatter, SimpleCov::Formatter::HTMLFormatter, - Codecov::SimpleCov::Formatter + SimpleCov::Formatter::CoberturaFormatter ] SimpleCov.start do formatter SimpleCov::Formatter::MultiFormatter.new(formatters) 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/minitest_helper.rb b/test/minitest_helper.rb index 7f2a123a58..a9818a0bda 100644 --- a/test/minitest_helper.rb +++ b/test/minitest_helper.rb @@ -8,12 +8,12 @@ if ENV['CI'] require 'simplecov' require "simplecov_json_formatter" - require 'codecov' + require 'simplecov-cobertura' formatters = [ SimpleCov::Formatter::SimpleFormatter, SimpleCov::Formatter::JSONFormatter, SimpleCov::Formatter::HTMLFormatter, - Codecov::SimpleCov::Formatter + SimpleCov::Formatter::CoberturaFormatter ] SimpleCov.start do formatter SimpleCov::Formatter::MultiFormatter.new(formatters) diff --git a/test/test_helper.rb b/test/test_helper.rb index 805d1ba0ef..61a9b156fa 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,12 +7,12 @@ if ENV['CI'] require 'simplecov' require "simplecov_json_formatter" - require 'codecov' + require 'simplecov-cobertura' formatters = [ SimpleCov::Formatter::SimpleFormatter, SimpleCov::Formatter::JSONFormatter, SimpleCov::Formatter::HTMLFormatter, - Codecov::SimpleCov::Formatter + SimpleCov::Formatter::CoberturaFormatter ] SimpleCov.start do formatter SimpleCov::Formatter::MultiFormatter.new(formatters) 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 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/liquid/drops/authentication_strategy_test.rb b/test/unit/liquid/drops/authentication_strategy_test.rb index eced0255a4..c21cb2beff 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, domain: 'company-domain.com') + 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%2Fcompany-domain.com%2Fsession%2Fcreate", @drop.login_url end - end 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/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' 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}" diff --git a/test/workers/delete_plain_object_worker_test.rb b/test/workers/delete_plain_object_worker_test.rb index 7f291f7ac2..625bfea6ef 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') if Rails.gem_version < "7.1" service = FactoryBot.create(:simple_service) # There is a restriction on deleting service, at least one should remain FactoryBot.create(:simple_service, account: service.account) 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)