From 47c24fe8d70e75ed830731c46de31343ff0e41ca Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Sun, 19 Jan 2025 16:00:11 +0200 Subject: [PATCH 1/2] upgrade rails 7.0 -> 7.1 --- Gemfile | 7 +- Gemfile.lock | 242 ++++++----- app/assets/javascripts/active_admin.js | 5 + app/models/report/realtime/bad_routing.rb | 6 +- .../report/realtime/not_authenticated.rb | 12 +- .../realtime/origination_performance.rb | 6 +- .../realtime/termination_distribution.rb | 6 +- config/application.rb | 21 +- config/environments/development.rb | 18 +- config/environments/production.rb | 105 ++--- config/environments/test.rb | 22 +- .../initializers/content_security_policy.rb | 45 +- .../initializers/filter_parameter_logging.rb | 8 +- config/initializers/inflections.rb | 8 +- config/initializers/permissions_policy.rb | 20 +- config/initializers/print_timezone.rb | 8 +- config/puma.rb | 6 +- config/puma_conteinerized.rb | 4 +- config/puma_production.rb | 4 +- db/cdr_structure.sql | 151 ++++--- db/structure.sql | 396 +++++++++--------- lib/yeti_scheduler.rb | 8 +- .../rest/admin/api/transactions_spec.rb | 2 +- .../factories/report/realtime/bad_routings.rb | 4 +- .../report/realtime/not_authenticateds.rb | 4 +- .../routing/dialpeers/index_dialpeer_spec.rb | 2 +- spec/jobs/jobs/sync_database_tables_spec.rb | 22 +- .../partition_remove_hook_processor_spec.rb | 12 +- .../yeti_cron_job_processor_spec.rb | 12 +- spec/lib/yeti_scheduler_spec.rb | 24 +- .../report/realtime/bad_routing_spec.rb | 4 +- .../report/realtime/not_authenticated_spec.rb | 4 +- spec/spec_helper.rb | 3 +- spec/support/helpers/chosen.rb | 9 +- 34 files changed, 646 insertions(+), 564 deletions(-) diff --git a/Gemfile b/Gemfile index 396b80548..df6623bbf 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ gem 'pg' gem 'pg_advisory_lock', git: 'https://github.com/didww/pg_advisory_lock.git' gem 'pg_sql_caller', git: 'https://github.com/didww/pg_sql_caller.git' gem 'rack', ' ~> 2.2.6' -gem 'rails', '~> 7.0' +gem 'rails', '~> 7.1.0' gem 'responders' # Authentication @@ -18,7 +18,8 @@ gem 'activeldap' gem 'd3-rails', '3.5.2' gem 'devise', '>= 4.6.0' gem 'devise_ldap_authenticatable', github: 'cschiewek/devise_ldap_authenticatable', branch: 'default' -gem 'net-ldap', '~> 0.16.0' +gem 'net-ldap', '~> 0.19.0' +gem 'ostruct', '~> 0.6.1' # need for net-ldap # Seamless JWT authentication for Rails API gem 'jwt' @@ -77,6 +78,7 @@ gem 'delayed_job_active_record' gem 'odf-report', github: 'yeti-switch/odf-report', branch: 'master-2018' gem 'puma', '~> 6.1' gem 'puma_worker_killer' +gem 'syslog', '~> 0.2.0' # need for syslog-logger gem 'syslog-logger' gem 'zip-zip' @@ -91,6 +93,7 @@ gem 'rufus-scheduler', require: false # Easiest way to add multi-environment yaml settings to Rails, Sinatra, Pandrino and other Ruby projects. # https://github.com/rubyconfig/config gem 'config', require: false +gem 'dry-validation', '~> 1.0', require: false group :development do gem 'annotate' diff --git a/Gemfile.lock b/Gemfile.lock index a7a8d583b..78fa259a5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,51 +96,55 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.7) - actionpack (= 7.0.8.7) - activesupport (= 7.0.8.7) + actioncable (7.1.5.1) + actionpack (= 7.1.5.1) + activesupport (= 7.1.5.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.7) - actionpack (= 7.0.8.7) - activejob (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + zeitwerk (~> 2.6) + actionmailbox (7.1.5.1) + actionpack (= 7.1.5.1) + activejob (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.7) - actionpack (= 7.0.8.7) - actionview (= 7.0.8.7) - activejob (= 7.0.8.7) - activesupport (= 7.0.8.7) + actionmailer (7.1.5.1) + actionpack (= 7.1.5.1) + actionview (= 7.1.5.1) + activejob (= 7.1.5.1) + activesupport (= 7.1.5.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8.7) - actionview (= 7.0.8.7) - activesupport (= 7.0.8.7) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.5.1) + actionview (= 7.1.5.1) + activesupport (= 7.1.5.1) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.7) - actionpack (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.5.1) + actionpack (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.7) - activesupport (= 7.0.8.7) + actionview (7.1.5.1) + activesupport (= 7.1.5.1) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) active_admin_datetimepicker (1.1.0) activeadmin (>= 2.14.0, < 4.0) active_admin_import (5.0.0) @@ -165,8 +169,8 @@ GEM kaminari (>= 1.2.1) railties (>= 6.1) ransack (>= 4.0) - activejob (7.0.8.7) - activesupport (= 7.0.8.7) + activejob (7.1.5.1) + activesupport (= 7.1.5.1) globalid (>= 0.3.6) activeldap (5.1.1) activemodel (> 4.0.0) @@ -174,40 +178,51 @@ GEM gettext gettext_i18n_rails locale - activemodel (7.0.8.7) - activesupport (= 7.0.8.7) + activemodel (7.1.5.1) + activesupport (= 7.1.5.1) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (7.0.8.7) - activemodel (= 7.0.8.7) - activesupport (= 7.0.8.7) - activerecord-import (1.4.1) + activerecord (7.1.5.1) + activemodel (= 7.1.5.1) + activesupport (= 7.1.5.1) + timeout (>= 0.4.0) + activerecord-import (2.0.0) activerecord (>= 4.2) - activestorage (7.0.8.7) - actionpack (= 7.0.8.7) - activejob (= 7.0.8.7) - activerecord (= 7.0.8.7) - activesupport (= 7.0.8.7) + activestorage (7.1.5.1) + actionpack (= 7.1.5.1) + activejob (= 7.1.5.1) + activerecord (= 7.1.5.1) + activesupport (= 7.1.5.1) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8.7) + activesupport (7.1.5.1) + base64 + benchmark (>= 0.3) + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) + mutex_m + securerandom (>= 0.3) tzinfo (~> 2.0) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) annotate (3.2.0) activerecord (>= 3.2, < 8.0) rake (>= 10.4, < 14.0) - arbre (1.5.0) - activesupport (>= 3.0.0, < 7.1) - ruby2_keywords (>= 0.0.2, < 1.0) + arbre (1.7.0) + activesupport (>= 3.0.0) + ruby2_keywords (>= 0.0.2) ast (2.4.2) awesome_print (1.8.0) + base64 (0.2.0) bcrypt (3.1.13) + benchmark (0.4.0) + bigdecimal (3.1.9) bootsnap (1.9.1) msgpack (~> 1.0) brakeman (6.1.2) @@ -250,9 +265,10 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.3.4) - config (3.1.0) + config (5.5.2) deep_merge (~> 1.2, >= 1.2.1) - dry-validation (~> 1.0, >= 1.0.0) + ostruct + connection_pool (2.5.0) crack (0.4.5) rexml crass (1.0.6) @@ -292,6 +308,7 @@ GEM activesupport (>= 5.0) request_store (>= 1.0) ruby2_keywords + drb (2.2.1) dry-configurable (1.0.1) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) @@ -374,11 +391,15 @@ GEM multi_xml (>= 0.5.2) i18n (1.14.6) concurrent-ruby (~> 1.0) - inherited_resources (1.13.1) - actionpack (>= 5.2, < 7.1) - has_scope (~> 0.6) - railties (>= 5.2, < 7.1) - responders (>= 2, < 4) + inherited_resources (1.14.0) + actionpack (>= 6.0) + has_scope (>= 0.6) + railties (>= 6.0) + responders (>= 2) + io-console (0.8.0) + irb (1.14.3) + rdoc (>= 4.0.0) + reline (>= 0.4.2) jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -411,6 +432,7 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) locale (2.1.2) + logger (1.6.5) loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -421,7 +443,6 @@ GEM net-smtp marcel (1.0.2) matrix (0.4.2) - method_source (1.0.0) mini_mime (1.1.2) mini_portile2 (2.8.8) mini_racer (0.6.3) @@ -430,10 +451,11 @@ GEM msgpack (1.7.2) multi_xml (0.6.0) mustache (1.1.1) + mutex_m (0.3.0) net-imap (0.3.6) date net-protocol - net-ldap (0.16.3) + net-ldap (0.19.0) net-pop (0.1.2) net-protocol net-protocol (0.2.1) @@ -641,8 +663,9 @@ GEM opentelemetry-semantic_conventions (1.10.0) opentelemetry-api (~> 1.0) orm_adapter (0.5.0) - paper_trail (14.0.0) - activerecord (>= 6.0) + ostruct (0.6.1) + paper_trail (16.0.0) + activerecord (>= 6.1) request_store (~> 1.4) parallel (1.12.1) parallel_tests (2.29.0) @@ -653,6 +676,9 @@ GEM pg (1.4.6) pgq_prometheus (0.2.3) prometheus_exporter + psych (5.2.3) + date + stringio public_suffix (4.0.6) puma (6.5.0) nio4r (~> 2.0) @@ -664,22 +690,27 @@ GEM raabro (1.4.0) racc (1.8.1) rack (2.2.8.1) + rack-session (1.0.2) + rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8.7) - actioncable (= 7.0.8.7) - actionmailbox (= 7.0.8.7) - actionmailer (= 7.0.8.7) - actionpack (= 7.0.8.7) - actiontext (= 7.0.8.7) - actionview (= 7.0.8.7) - activejob (= 7.0.8.7) - activemodel (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + rackup (1.0.1) + rack (< 3) + webrick + rails (7.1.5.1) + actioncable (= 7.1.5.1) + actionmailbox (= 7.1.5.1) + actionmailer (= 7.1.5.1) + actionpack (= 7.1.5.1) + actiontext (= 7.1.5.1) + actionview (= 7.1.5.1) + activejob (= 7.1.5.1) + activemodel (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) bundler (>= 1.15.0) - railties (= 7.0.8.7) + railties (= 7.1.5.1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -687,13 +718,14 @@ GEM rails-html-sanitizer (1.6.1) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (7.0.8.7) - actionpack (= 7.0.8.7) - activesupport (= 7.0.8.7) - method_source + railties (7.1.5.1) + actionpack (= 7.1.5.1) + activesupport (= 7.1.5.1) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.0.6) ransack (4.1.1) @@ -704,34 +736,38 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) rchardet (1.8.0) + rdoc (6.11.0) + psych (>= 4.0.0) regexp_parser (2.9.2) + reline (0.6.0) + io-console (~> 0.5) request_store (1.4.1) rack (>= 1.4) responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) rexml (3.3.9) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-rails (5.0.1) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.10.2) + rspec-support (~> 3.13.0) + rspec-rails (7.1.0) + actionpack (>= 7.0) + activesupport (>= 7.0) + railties (>= 7.0) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.2) rubocop (1.68.0) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -769,6 +805,7 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) + securerandom (0.4.1) selenium-webdriver (3.141.0) childprocess (~> 0.5) rubyzip (~> 1.2, >= 1.2.2) @@ -802,6 +839,8 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + stringio (3.1.2) + syslog (0.2.0) syslog-logger (1.6.8) text (1.3.1) thin (1.8.2) @@ -880,6 +919,7 @@ DEPENDENCIES devise (>= 4.6.0) devise_ldap_authenticatable! draper + dry-validation (~> 1.0) excelinator! factory_bot_rails ferrum @@ -895,7 +935,7 @@ DEPENDENCIES matrix (~> 0.4.2) mini_racer net-imap (~> 0.3.4) - net-ldap (~> 0.16.0) + net-ldap (~> 0.19.0) net-pop (~> 0.1.2) net-smtp (~> 0.3.3) novus-nvd3-rails! @@ -903,6 +943,7 @@ DEPENDENCIES opentelemetry-exporter-otlp opentelemetry-instrumentation-all opentelemetry-sdk + ostruct (~> 0.6.1) paper_trail parallel parallel_tests @@ -915,7 +956,7 @@ DEPENDENCIES puma_worker_killer pundit rack (~> 2.2.6) - rails (~> 7.0) + rails (~> 7.1.0) rails-html-sanitizer (>= 1.6.1) ransack responders @@ -936,6 +977,7 @@ DEPENDENCIES simplecov (~> 0.21.2) simplecov-cobertura (~> 2.1) sprockets + syslog (~> 0.2.0) syslog-logger thin uglifier (>= 1.3) diff --git a/app/assets/javascripts/active_admin.js b/app/assets/javascripts/active_admin.js index aa0974a5b..177e99054 100644 --- a/app/assets/javascripts/active_admin.js +++ b/app/assets/javascripts/active_admin.js @@ -120,4 +120,9 @@ $(document).ready(function () { show_time: true }); + $('form.filter_form div.select_and_search > select').chosen({ + disable_search: true, + allow_single_deselect: false + }) + }); diff --git a/app/models/report/realtime/bad_routing.rb b/app/models/report/realtime/bad_routing.rb index 55f3920c1..35f855fef 100644 --- a/app/models/report/realtime/bad_routing.rb +++ b/app/models/report/realtime/bad_routing.rb @@ -4,7 +4,7 @@ # # Table name: cdr.cdr # -# id :bigint(8) not null +# id :bigint(8) not null, primary key # audio_recorded :boolean # auth_orig_ip :inet # auth_orig_port :integer(4) @@ -96,7 +96,7 @@ # success :boolean # time_connect :timestamptz # time_end :timestamptz -# time_start :timestamptz not null +# time_start :timestamptz not null, primary key # to_domain :string # uuid :uuid # vendor_duration :integer(4) @@ -160,6 +160,8 @@ # class Report::Realtime::BadRouting < Report::Realtime::Base + self.primary_key = :id + scope :detailed_scope, lambda { select(" row_number() over (partition by customer_id, customer_auth_id, rateplan_id, routing_plan_id, internal_disconnect_code, internal_disconnect_reason) AS id, diff --git a/app/models/report/realtime/not_authenticated.rb b/app/models/report/realtime/not_authenticated.rb index 60ac7f9f0..625bd7b7a 100644 --- a/app/models/report/realtime/not_authenticated.rb +++ b/app/models/report/realtime/not_authenticated.rb @@ -4,7 +4,7 @@ # # Table name: cdr.cdr # -# id :bigint(8) not null +# id :bigint(8) not null, primary key # audio_recorded :boolean # auth_orig_ip :inet # auth_orig_port :integer(4) @@ -96,7 +96,7 @@ # success :boolean # time_connect :timestamptz # time_end :timestamptz -# time_start :timestamptz not null +# time_start :timestamptz not null, primary key # to_domain :string # uuid :uuid # vendor_duration :integer(4) @@ -160,6 +160,8 @@ # class Report::Realtime::NotAuthenticated < Report::Realtime::Base + self.primary_key = :id + scope :detailed_scope, lambda { select(" row_number() over (partition by auth_orig_ip, auth_orig_port, internal_disconnect_code, internal_disconnect_reason) AS id, @@ -179,7 +181,11 @@ class Report::Realtime::NotAuthenticated < Report::Realtime::Base } scope :time_interval_eq, lambda { |value| - where('time_start >=(now()-\'? seconds\'::interval) and time_start < (now()-\'? seconds\'::interval)', 2 * value.to_i, value.to_i) + where( + "time_start >=(now()-(?||'seconds')::interval) and time_start < (now()-(?||'seconds')::interval)", + (2 * value.to_i).to_s, + value.to_i.to_s + ) } private diff --git a/app/models/report/realtime/origination_performance.rb b/app/models/report/realtime/origination_performance.rb index 2b3d6a596..896656063 100644 --- a/app/models/report/realtime/origination_performance.rb +++ b/app/models/report/realtime/origination_performance.rb @@ -4,7 +4,7 @@ # # Table name: cdr.cdr # -# id :bigint(8) not null +# id :bigint(8) not null, primary key # audio_recorded :boolean # auth_orig_ip :inet # auth_orig_port :integer(4) @@ -96,7 +96,7 @@ # success :boolean # time_connect :timestamptz # time_end :timestamptz -# time_start :timestamptz not null +# time_start :timestamptz not null, primary key # to_domain :string # uuid :uuid # vendor_duration :integer(4) @@ -160,6 +160,8 @@ # class Report::Realtime::OriginationPerformance < Report::Realtime::Base + self.primary_key = :id + attr_accessor :l scope :detailed_scope, lambda { |length| diff --git a/app/models/report/realtime/termination_distribution.rb b/app/models/report/realtime/termination_distribution.rb index 4174d5859..e8a857f34 100644 --- a/app/models/report/realtime/termination_distribution.rb +++ b/app/models/report/realtime/termination_distribution.rb @@ -4,7 +4,7 @@ # # Table name: cdr.cdr # -# id :bigint(8) not null +# id :bigint(8) not null, primary key # audio_recorded :boolean # auth_orig_ip :inet # auth_orig_port :integer(4) @@ -96,7 +96,7 @@ # success :boolean # time_connect :timestamptz # time_end :timestamptz -# time_start :timestamptz not null +# time_start :timestamptz not null, primary key # to_domain :string # uuid :uuid # vendor_duration :integer(4) @@ -160,6 +160,8 @@ # class Report::Realtime::TerminationDistribution < Report::Realtime::Base + self.primary_key = :id + scope :detailed_scope, lambda { # We need 'vendor_id AS id' here because ActiveAdmin fails to render table # for records without id when it's model class has id in schema. diff --git a/config/application.rb b/config/application.rb index cf53d7fcf..abbd9ce6a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -14,7 +14,7 @@ # require 'action_text/engine' require 'action_view/railtie' # require 'action_cable/engine' -require 'sprockets/railtie' +# require 'rails/test_unit/railtie' # custom require_relative '../lib/capture_error' @@ -26,7 +26,7 @@ module Yeti class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 7.1 # changing defaults Rails.application.config.action_view.default_enforce_utf8 = true @@ -92,5 +92,22 @@ class Application < Rails::Application g.test_framework :rspec g.integration_tool :rspec end + + # reimplementing minimal Rails.application.secrets, that was removed in Rails 7.2 + # https://github.com/rails/rails/pull/47801 + secrets_yml_path = Rails.root.join('config/secrets.yml') + secrets_cfg = if secrets_yml_path.exist? + config_for(secrets_yml_path) + else + secret_key_base = ENV['SECRET_KEY_BASE'] + secret_key_base ||= SecureRandom.hex(64) if Rails.env.local? + { secret_key_base: } + end + config.secrets = ActiveSupport::OrderedOptions.new + config.secrets.merge!(secrets_cfg) + delegate :secrets, to: :config # define Rails.application.secrets + config.secret_key_base = config.secrets.secret_key_base + raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String`" if config.secret_key_base.blank? + raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment" if config.secret_key_base.blank? end end diff --git a/config/environments/development.rb b/config/environments/development.rb index d35311b9e..594b6165d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -8,7 +8,7 @@ # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. - config.cache_classes = false + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -55,6 +55,9 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. @@ -69,14 +72,8 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - # Use an evented file watcher to asynchronously detect changes in source code, - # routes, locales, etc. This feature depends on the listen gem. - if ENV['NO_FILE_WATCHER'].blank? - # We need possibility to remove file_watcher because - # ActiveSupport::EventedFileUpdateChecker causes crash on delayed job process. - # @see https://github.com/collectiveidea/delayed_job/issues/1099 - config.file_watcher = ActiveSupport::EventedFileUpdateChecker - end + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true if ENV['RAILS_LOG_TO_STDOUT'].present? STDOUT.sync = true @@ -84,7 +81,4 @@ logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end - - # Uncomment if you wish to allow Action Cable access from any origin. - # config.action_cable.disable_request_forgery_protection = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index dfb1efe25..181f832c9 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -6,7 +6,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -15,54 +15,62 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass - # Compress JavaScript using a preprocessor. - # We do this only when we are precompiling assets, because Uglifier requires ExecJS runtimes. - # ExecJS runtimes creates MiniRacer contexts, which raise error on forking. - # Puma and Delayed Job use forking. - # see https://github.com/rubyjs/mini_racer/issues/152 - if ENV['RAILS_COMPILE_ASSETS'].present? - config.assets.js_compressor = Uglifier.new(harmony: true) - end - - # Do not fallback to assets pipeline if a precompiled asset is missed. + # Do not fall back to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = 'http://assets.example.com' + # config.asset_host = "http://assets.example.com" # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache + # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Include generic and useful information about system operation, but avoid logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). - config.log_level = :info + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + if ENV['RAILS_LOG_TO_STDOUT'].present? + STDOUT.sync = true + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + else + config.logger = ActiveSupport::TaggedLogging.new(Logger::Syslog.new('yeti-web', Syslog::LOG_LOCAL7)) + end # Prepend all log lines with the following tags. config.log_tags = [:request_id] + # "info" includes generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info') + # Use a different cache store in production. # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque + # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "yeti_production" config.action_mailer.perform_caching = false @@ -75,56 +83,19 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify - # Don't log any deprecations. config.active_support.report_deprecations = false - # Log disallowed deprecations. - config.active_support.disallowed_deprecation = :log - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - - # Use a different logger for distributed setups. - if ENV['RAILS_LOG_TO_STDOUT'].present? - STDOUT.sync = true - logger = ActiveSupport::Logger.new(STDOUT) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - else - # require 'syslog/logger' - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') - config.logger = ActiveSupport::TaggedLogging.new(Logger::Syslog.new('yeti-web', Syslog::LOG_LOCAL7)) - end - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false config.use_schema_cache_dump = true - # Inserts middleware to perform automatic connection switching. - # The `database_selector` hash is used to pass options to the DatabaseSelector - # middleware. The `delay` is used to determine how long to wait after a write - # to send a subsequent read to the primary. - # - # The `database_resolver` class is used by the middleware to determine which - # database is appropriate to use based on the time delay. - # - # The `database_resolver_context` class is used by the middleware to set - # timestamps for the last write to the primary. The resolver uses the context - # class timestamps to determine how long to wait before reading from the - # replica. - # - # By default Rails will store a last write timestamp in the session. The - # DatabaseSelector middleware is designed as such you can define your own - # strategy for connection switching and pass that into the middleware through - # these configuration options. - # config.active_record.database_selector = { delay: 2.seconds } - # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver - # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/config/environments/test.rb b/config/environments/test.rb index 92ee45ea7..c966e2cc3 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,11 +10,13 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = true + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. config.eager_load = ENV['CI'].present? # Configure public file server for tests with Cache-Control for performance. @@ -24,14 +26,16 @@ } # Show full error reports and disable caching. - config.consider_all_requests_local = true + config.consider_all_requests_local = true config.action_controller.perform_caching = false config.cache_store = :null_store - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + # Render exception templates for rescuable exceptions and raise for other exceptions. + # config.action_dispatch.show_exceptions = :rescuable + config.action_dispatch.show_exceptions = :none # Disable request forgery protection in test environment. + # config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = true config.action_mailer.perform_caching = false @@ -42,6 +46,7 @@ config.action_mailer.delivery_method = :test # Print deprecation notices to the stderr. + # config.active_support.deprecation = :stderr config.active_support.deprecation = :raise # Raise exceptions for disallowed deprecations. @@ -56,6 +61,9 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true + # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 87fd451f0..35ab3fd6a 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -2,29 +2,26 @@ # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header -# Rails.application.config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https - -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src style-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true # end - -# If you are using UJS then enable automatic nonce generation -# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } - -# Set the nonce only to specific directives -# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) - -# Report CSP violations to a specified URI -# For further information see the following documentation: -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only -# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 7a4f47b4c..c416e6a62 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -2,5 +2,9 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. +Rails.application.config.filter_parameters += %i[ + passw secret token _key crypt salt certificate otp ssn +] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index dc8474221..9e049dcc9 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -6,13 +6,13 @@ # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' +# inflect.acronym "RESTful" # end diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 50bcf4ead..b635b527e 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_policy.rb @@ -1,12 +1,14 @@ # frozen_string_literal: true +# Be sure to restart your server when you modify this file. + # Define an application-wide HTTP permissions policy. For further -# information see https://developers.google.com/web/updates/2018/06/feature-policy -# -# Rails.application.config.permissions_policy do |f| -# f.camera :none -# f.gyroscope :none -# f.microphone :none -# f.usb :none -# f.fullscreen :self -# f.payment :self, "https://secure.example.com" +# information see: https://developers.google.com/web/updates/2018/06/feature-policy + +# Rails.application.config.permissions_policy do |policy| +# policy.camera :none +# policy.gyroscope :none +# policy.microphone :none +# policy.usb :none +# policy.fullscreen :self +# policy.payment :self, "https://secure.example.com" # end diff --git a/config/initializers/print_timezone.rb b/config/initializers/print_timezone.rb index 0a9865fa2..f84c6915e 100644 --- a/config/initializers/print_timezone.rb +++ b/config/initializers/print_timezone.rb @@ -5,10 +5,10 @@ warn "Yeti DB timezone #{::SqlCaller::Yeti.current_timezone}" warn "CDR DB timezone #{::SqlCaller::Cdr.current_timezone}" warn "ActiveRecord timezone #{Rails.application.config.active_record.default_timezone}" - ApplicationRecord.clear_active_connections! - ApplicationRecord.flush_idle_connections! - Cdr::Base.clear_active_connections! - Cdr::Base.flush_idle_connections! + ApplicationRecord.connection_handler.clear_active_connections!(:all) + ApplicationRecord.connection_handler.flush_idle_connections!(:all) + Cdr::Base.connection_handler.clear_active_connections!(:all) + Cdr::Base.connection_handler.flush_idle_connections!(:all) rescue StandardError => e warn "suppressed error during timezone print <#{e.class}>: #{e.message}" end diff --git a/config/puma.rb b/config/puma.rb index 6b5838ae7..c01d1d08f 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -19,11 +19,13 @@ preload_app! +silence_single_worker_warning + before_fork do # Proper way to clear db connections. # Like AR initializer does in active_record/railtie.rb:265 - ActiveRecord::Base.clear_active_connections! - ActiveRecord::Base.flush_idle_connections! + ActiveRecord::Base.connection_handler.clear_active_connections!(:all) + ActiveRecord::Base.connection_handler.flush_idle_connections!(:all) require 'puma_worker_killer' diff --git a/config/puma_conteinerized.rb b/config/puma_conteinerized.rb index a368b885e..f334f4935 100644 --- a/config/puma_conteinerized.rb +++ b/config/puma_conteinerized.rb @@ -28,8 +28,8 @@ before_fork do # Proper way to clear db connections. # Like AR initializer does in active_record/railtie.rb:265 - ActiveRecord::Base.clear_active_connections! - ActiveRecord::Base.flush_idle_connections! + ActiveRecord::Base.connection_handler.clear_active_connections!(:all) + ActiveRecord::Base.connection_handler.flush_idle_connections!(:all) require 'puma_worker_killer' diff --git a/config/puma_production.rb b/config/puma_production.rb index 8a1044c19..cf861eba2 100644 --- a/config/puma_production.rb +++ b/config/puma_production.rb @@ -24,8 +24,8 @@ before_fork do # Proper way to clear db connections. # Like AR initializer does in active_record/railtie.rb:265 - ActiveRecord::Base.clear_active_connections! - ActiveRecord::Base.flush_idle_connections! + ActiveRecord::Base.connection_handler.clear_active_connections!(:all) + ActiveRecord::Base.connection_handler.flush_idle_connections!(:all) require 'puma_worker_killer' diff --git a/db/cdr_structure.sql b/db/cdr_structure.sql index 5f84e0ee2..06459966c 100644 --- a/db/cdr_structure.sql +++ b/db/cdr_structure.sql @@ -4701,81 +4701,80 @@ ALTER TABLE ONLY sys.config SET search_path TO cdr, reports, billing, public; INSERT INTO "public"."schema_migrations" (version) VALUES -('20170907204350'), -('20170911172650'), -('20171104162958'), -('20180228200703'), -('20180307142909'), -('20180312211714'), -('20180312215122'), -('20180328123622'), -('20180328170352'), -('20180425200716'), -('20180427194936'), -('20180607135226'), -('20180611140540'), -('20180619091111'), -('20180621130107'), -('20180911180345'), -('20181105175206'), -('20190604064015'), -('20190629185813'), -('20190707214813'), -('20200105230734'), -('20200106104136'), -('20200120195529'), -('20200120200605'), -('20200220113109'), -('20200221080918'), -('20200514153523'), -('20200527173737'), -('20200803201602'), -('20201128134302'), -('20210116150950'), -('20210212102105'), -('20210218095038'), -('20210223125543'), -('20210307170219'), -('20210614110059'), -('20211005183259'), -('20220221142459'), -('20220317170217'), -('20220317180321'), -('20220317180333'), -('20220426100841'), -('20220503094804'), -('20220509203319'), -('20220625185940'), -('20220709123408'), -('20220803115423'), -('20221105191015'), -('20230321124900'), -('20230518150839'), -('20230524185032'), -('20230602123903'), -('20230708183812'), -('20230828175949'), -('20230913210707'), -('20230916152534'), -('20230929081324'), -('20231007121159'), -('20231007123320'), -('20231027110359'), -('20231101165858'), -('20231106100135'), -('20231106125344'), -('20231212213111'), -('20231231115209'), -('20240122201619'), -('20240405165010'), -('20240411092931'), -('20240609092136'), -('20240617084103'), -('20241006113650'), -('20241006123022'), -('20241216143200'), -('20241217212213'), +('20241219145036'), ('20241219142219'), -('20241219145036'); - +('20241217212213'), +('20241216143200'), +('20241006123022'), +('20241006113650'), +('20240617084103'), +('20240609092136'), +('20240411092931'), +('20240405165010'), +('20240122201619'), +('20231231115209'), +('20231212213111'), +('20231106125344'), +('20231106100135'), +('20231101165858'), +('20231027110359'), +('20231007123320'), +('20231007121159'), +('20230929081324'), +('20230916152534'), +('20230913210707'), +('20230828175949'), +('20230708183812'), +('20230602123903'), +('20230524185032'), +('20230518150839'), +('20230321124900'), +('20221105191015'), +('20220803115423'), +('20220709123408'), +('20220625185940'), +('20220509203319'), +('20220503094804'), +('20220426100841'), +('20220317180333'), +('20220317180321'), +('20220317170217'), +('20220221142459'), +('20211005183259'), +('20210614110059'), +('20210307170219'), +('20210223125543'), +('20210218095038'), +('20210212102105'), +('20210116150950'), +('20201128134302'), +('20200803201602'), +('20200527173737'), +('20200514153523'), +('20200221080918'), +('20200220113109'), +('20200120200605'), +('20200120195529'), +('20200106104136'), +('20200105230734'), +('20190707214813'), +('20190629185813'), +('20190604064015'), +('20181105175206'), +('20180911180345'), +('20180621130107'), +('20180619091111'), +('20180611140540'), +('20180607135226'), +('20180427194936'), +('20180425200716'), +('20180328170352'), +('20180328123622'), +('20180312215122'), +('20180312211714'), +('20180307142909'), +('20180228200703'), +('20171104162958'), +('20170911172650'), +('20170907204350'); diff --git a/db/structure.sql b/db/structure.sql index 8bca708e5..f0a9916db 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -49990,205 +49990,205 @@ ALTER TABLE ONLY sys.sensors -- PostgreSQL database dump complete -- -SET search_path TO gui, public, switch, billing, class4, runtime_stats, sys, logs, data_import; +SET search_path TO gui, public, switch, billing, class4, runtime_stats, sys, logs, data_import +; INSERT INTO "public"."schema_migrations" (version) VALUES -('20170822151410'), -('20170822151442'), -('20170825100629'), -('20170907201109'), -('20170907203538'), -('20170907203628'), -('20170907203638'), -('20170919200403'), -('20171020164700'), -('20171031211812'), -('20171102183313'), -('20171209201956'), -('20171226210121'), -('20171231175152'), -('20180101202120'), -('20180119133842'), -('20180209140554'), -('20180212105355'), -('20180215094913'), -('20180305132729'), -('20180312205051'), -('20180313135314'), -('20180316061214'), -('20180318143341'), -('20180320120746'), -('20180403104223'), -('20180404135210'), -('20180405132225'), -('20180416121932'), -('20180418101559'), -('20180425203717'), -('20180426090808'), -('20180427194327'), -('20180512225402'), -('20180516095652'), -('20180620093010'), -('20180805100536'), -('20181011105642'), -('20181018164004'), -('20181114213545'), -('20181202175700'), -('20181203204823'), -('20190308190806'), -('20190318173242'), -('20190324161035'), -('20190326070548'), -('20190327134613'), -('20190428191918'), -('20190622131912'), -('20190629193852'), -('20190706114700'), -('20190707141219'), -('20190904174903'), -('20190919080917'), -('20191016183312'), -('20191018180427'), -('20200105131431'), -('20200202154005'), -('20200412135211'), -('20200425110642'), -('20200504210442'), -('20200630132440'), -('20200803202810'), -('20201015195346'), -('20201015202253'), -('20201023122436'), -('20201103092516'), -('20201111201356'), -('20201226161344'), -('20210116152459'), -('20210218092245'), -('20210223142035'), -('20210313203526'), -('20210328145540'), -('20210415123322'), -('20210605094810'), -('20210606143950'), -('20210630120418'), -('20210825190138'), -('20210909143022'), -('20210919130327'), -('20211002164333'), -('20211004152514'), -('20211005184247'), -('20211130113417'), -('20211130142405'), -('20211217132047'), -('20220222110900'), -('20220429111721'), -('20220501181051'), -('20220513084847'), -('20220620135342'), -('20220707145142'), -('20220717150840'), -('20220718195457'), -('20220805080124'), -('20220810115417'), -('20220816081007'), -('20220829195515'), -('20220923131906'), -('20220926083051'), -('20221004060840'), -('20221004062536'), -('20221008113325'), -('20221015081756'), -('20221015082627'), -('20221016081523'), -('20221016100614'), -('20221025105955'), -('20221025175803'), -('20221105134455'), -('20221105203239'), -('20221115180256'), -('20221126105630'), -('20221216095859'), -('20221222184742'), -('20221226124025'), -('20221226205639'), -('20221231184545'), -('20230208213717'), -('20230213210713'), -('20230217170438'), -('20230221112029'), -('20230224000357'), -('20230227110659'), -('20230310102534'), -('20230318105458'), -('20230330131911'), -('20230407140050'), -('20230412134246'), -('20230420082151'), -('20230420144539'), -('20230425141522'), -('20230514130310'), -('20230516110137'), -('20230518130328'), -('20230524191752'), -('20230602113601'), -('20230608134717'), -('20230702152539'), -('20230706164807'), -('20230706202154'), -('20230708194737'), -('20230717103315'), -('20230808192245'), -('20230909093914'), -('20230928100513'), -('20230928134637'), -('20230929114329'), -('20231005114627'), -('20231007204855'), -('20231106095901'), -('20231106100113'), -('20231107100745'), -('20231206200530'), -('20231227093950'), -('20231231115912'), -('20240109201636'), -('20240203212630'), -('20240205213733'), -('20240205213734'), -('20240206210456'), -('20240304194752'), -('20240305181141'), -('20240306173019'), -('20240309103228'), -('20240310195115'), -('20240401193125'), -('20240408143817'), -('20240410084634'), -('20240422204044'), -('20240425124935'), -('20240611191911'), -('20240615214442'), -('20240622173924'), -('20240702142447'), -('20240704100545'), -('20240721201110'), -('20240725132743'), -('20240725135654'), -('20240805121644'), -('20240806205100'), -('20240822145410'), -('20240824084143'), -('20241012124910'), -('20241015092015'), -('20241016075439'), -('20241017124729'), -('20241107212537'), -('20241213172819'), -('20241213175248'), -('20241215155451'), -('20241216165130'), -('20241218154326'), -('20241231160003'), +('20250115133012'), ('20250104221004'), -('20250115133012'); - +('20241231160003'), +('20241218154326'), +('20241216165130'), +('20241215155451'), +('20241213175248'), +('20241213172819'), +('20241107212537'), +('20241017124729'), +('20241016075439'), +('20241015092015'), +('20241012124910'), +('20240824084143'), +('20240822145410'), +('20240806205100'), +('20240805121644'), +('20240725135654'), +('20240725132743'), +('20240721201110'), +('20240704100545'), +('20240702142447'), +('20240622173924'), +('20240615214442'), +('20240611191911'), +('20240425124935'), +('20240422204044'), +('20240410084634'), +('20240408143817'), +('20240401193125'), +('20240310195115'), +('20240309103228'), +('20240306173019'), +('20240305181141'), +('20240304194752'), +('20240206210456'), +('20240205213734'), +('20240205213733'), +('20240203212630'), +('20240109201636'), +('20231231115912'), +('20231227093950'), +('20231206200530'), +('20231107100745'), +('20231106100113'), +('20231106095901'), +('20231007204855'), +('20231005114627'), +('20230929114329'), +('20230928134637'), +('20230928100513'), +('20230909093914'), +('20230808192245'), +('20230717103315'), +('20230708194737'), +('20230706202154'), +('20230706164807'), +('20230702152539'), +('20230608134717'), +('20230602113601'), +('20230524191752'), +('20230518130328'), +('20230516110137'), +('20230514130310'), +('20230425141522'), +('20230420144539'), +('20230420082151'), +('20230412134246'), +('20230407140050'), +('20230330131911'), +('20230318105458'), +('20230310102534'), +('20230227110659'), +('20230224000357'), +('20230221112029'), +('20230217170438'), +('20230213210713'), +('20230208213717'), +('20221231184545'), +('20221226205639'), +('20221226124025'), +('20221222184742'), +('20221216095859'), +('20221126105630'), +('20221115180256'), +('20221105203239'), +('20221105134455'), +('20221025175803'), +('20221025105955'), +('20221016100614'), +('20221016081523'), +('20221015082627'), +('20221015081756'), +('20221008113325'), +('20221004062536'), +('20221004060840'), +('20220926083051'), +('20220923131906'), +('20220829195515'), +('20220816081007'), +('20220810115417'), +('20220805080124'), +('20220718195457'), +('20220717150840'), +('20220707145142'), +('20220620135342'), +('20220513084847'), +('20220501181051'), +('20220429111721'), +('20220222110900'), +('20211217132047'), +('20211130142405'), +('20211130113417'), +('20211005184247'), +('20211004152514'), +('20211002164333'), +('20210919130327'), +('20210909143022'), +('20210825190138'), +('20210630120418'), +('20210606143950'), +('20210605094810'), +('20210415123322'), +('20210328145540'), +('20210313203526'), +('20210223142035'), +('20210218092245'), +('20210116152459'), +('20201226161344'), +('20201111201356'), +('20201103092516'), +('20201023122436'), +('20201015202253'), +('20201015195346'), +('20200803202810'), +('20200630132440'), +('20200504210442'), +('20200425110642'), +('20200412135211'), +('20200202154005'), +('20200105131431'), +('20191018180427'), +('20191016183312'), +('20190919080917'), +('20190904174903'), +('20190707141219'), +('20190706114700'), +('20190629193852'), +('20190622131912'), +('20190428191918'), +('20190327134613'), +('20190326070548'), +('20190324161035'), +('20190318173242'), +('20190308190806'), +('20181203204823'), +('20181202175700'), +('20181114213545'), +('20181018164004'), +('20181011105642'), +('20180805100536'), +('20180620093010'), +('20180516095652'), +('20180512225402'), +('20180427194327'), +('20180426090808'), +('20180425203717'), +('20180418101559'), +('20180416121932'), +('20180405132225'), +('20180404135210'), +('20180403104223'), +('20180320120746'), +('20180318143341'), +('20180316061214'), +('20180313135314'), +('20180312205051'), +('20180305132729'), +('20180215094913'), +('20180212105355'), +('20180209140554'), +('20180119133842'), +('20180101202120'), +('20171231175152'), +('20171226210121'), +('20171209201956'), +('20171102183313'), +('20171031211812'), +('20171020164700'), +('20170919200403'), +('20170907203638'), +('20170907203628'), +('20170907203538'), +('20170907201109'), +('20170825100629'), +('20170822151442'), +('20170822151410'); diff --git a/lib/yeti_scheduler.rb b/lib/yeti_scheduler.rb index f01384fb1..c576d4e1f 100644 --- a/lib/yeti_scheduler.rb +++ b/lib/yeti_scheduler.rb @@ -77,10 +77,10 @@ def format_error(exception) # close database connections if they were open. # main thread does not use database. # each time thread should acquire and release database connection. - ApplicationRecord.clear_active_connections! - ApplicationRecord.flush_idle_connections! - Cdr::Base.clear_active_connections! - Cdr::Base.flush_idle_connections! + ApplicationRecord.connection_handler.clear_active_connections!(:all) + ApplicationRecord.connection_handler.flush_idle_connections!(:all) + Cdr::Base.connection_handler.clear_active_connections!(:all) + Cdr::Base.connection_handler.flush_idle_connections!(:all) if PrometheusConfig.enabled? YetiInfoProcessor.start(labels: { app_type: 'scheduler' }) diff --git a/spec/acceptance/rest/admin/api/transactions_spec.rb b/spec/acceptance/rest/admin/api/transactions_spec.rb index 77d7d8914..5358c9fd8 100644 --- a/spec/acceptance/rest/admin/api/transactions_spec.rb +++ b/spec/acceptance/rest/admin/api/transactions_spec.rb @@ -26,7 +26,7 @@ end get '/api/rest/admin/transactions/:id' do - let(:id) { create(:billing_transaction, account: account).uuid } + let(:id) { create(:billing_transaction, account: account).id } example_request 'get specific entry' do expect(status).to eq(200) diff --git a/spec/factories/report/realtime/bad_routings.rb b/spec/factories/report/realtime/bad_routings.rb index 58e119e66..85e785168 100644 --- a/spec/factories/report/realtime/bad_routings.rb +++ b/spec/factories/report/realtime/bad_routings.rb @@ -4,7 +4,7 @@ # # Table name: cdr.cdr # -# id :bigint(8) not null +# id :bigint(8) not null, primary key # audio_recorded :boolean # auth_orig_ip :inet # auth_orig_port :integer(4) @@ -96,7 +96,7 @@ # success :boolean # time_connect :timestamptz # time_end :timestamptz -# time_start :timestamptz not null +# time_start :timestamptz not null, primary key # to_domain :string # uuid :uuid # vendor_duration :integer(4) diff --git a/spec/factories/report/realtime/not_authenticateds.rb b/spec/factories/report/realtime/not_authenticateds.rb index b88a3e86d..1d1e4b241 100644 --- a/spec/factories/report/realtime/not_authenticateds.rb +++ b/spec/factories/report/realtime/not_authenticateds.rb @@ -4,7 +4,7 @@ # # Table name: cdr.cdr # -# id :bigint(8) not null +# id :bigint(8) not null, primary key # audio_recorded :boolean # auth_orig_ip :inet # auth_orig_port :integer(4) @@ -96,7 +96,7 @@ # success :boolean # time_connect :timestamptz # time_end :timestamptz -# time_start :timestamptz not null +# time_start :timestamptz not null, primary key # to_domain :string # uuid :uuid # vendor_duration :integer(4) diff --git a/spec/features/routing/dialpeers/index_dialpeer_spec.rb b/spec/features/routing/dialpeers/index_dialpeer_spec.rb index 650cda723..bbca2fac1 100644 --- a/spec/features/routing/dialpeers/index_dialpeer_spec.rb +++ b/spec/features/routing/dialpeers/index_dialpeer_spec.rb @@ -25,7 +25,7 @@ context 'with filter by ID in string' do let(:fill_filters!) do within_filters do - page.find('#q_id_input > select > option', text: 'In string').select_option + fill_in_chosen('#q_id_input > select', with: 'In string', no_search: true, selector: true) fill_in 'Id', with: dialpeers.map(&:id).join(',') click_button 'Filter' end diff --git a/spec/jobs/jobs/sync_database_tables_spec.rb b/spec/jobs/jobs/sync_database_tables_spec.rb index 728c27007..b955fe88d 100644 --- a/spec/jobs/jobs/sync_database_tables_spec.rb +++ b/spec/jobs/jobs/sync_database_tables_spec.rb @@ -21,13 +21,21 @@ shared_examples 'sync database' do it 'should sync tables between databases' do - expect { subject }.to change { Cdr::Country.count }.from(0).to(record_count) - .and( - change { Cdr::Network.count }.from(0).to(record_count) - .and( - change { Cdr::NetworkPrefix.count }.from(0).to(record_count) - ) - ) + expect { subject }.to change { + [ + Cdr::Country.count, + Cdr::Network.count, + Cdr::NetworkPrefix.count + ] + }.from( + [0, 0, 0] + ).to( + [ + record_count, + record_count, + record_count + ] + ) end end diff --git a/spec/lib/prometheus/partition_remove_hook_processor_spec.rb b/spec/lib/prometheus/partition_remove_hook_processor_spec.rb index 27e745738..87210b886 100644 --- a/spec/lib/prometheus/partition_remove_hook_processor_spec.rb +++ b/spec/lib/prometheus/partition_remove_hook_processor_spec.rb @@ -14,7 +14,9 @@ subject { PartitionRemoveHookProcessor.collect_executions_metric } it 'responds with correct metrics' do - expect(prometheus_client).to receive(:send_json).with(type: 'yeti_partition_removing_hook', executions: 1, metric_labels: {}).once + expect(prometheus_client).to receive(:send_json).with( + { type: 'yeti_partition_removing_hook', executions: 1, metric_labels: {} } + ).once subject end end @@ -23,7 +25,9 @@ subject { PartitionRemoveHookProcessor.collect_errors_metric } it 'responds with correct metrics' do - expect(prometheus_client).to receive(:send_json).with(type: 'yeti_partition_removing_hook', errors: 1, metric_labels: {}).once + expect(prometheus_client).to receive(:send_json).with( + { type: 'yeti_partition_removing_hook', errors: 1, metric_labels: {} } + ).once subject end end @@ -32,7 +36,9 @@ subject { PartitionRemoveHookProcessor.collect_duration_metric(13) } it 'responds with correct metrics' do - expect(prometheus_client).to receive(:send_json).with(type: 'yeti_partition_removing_hook', duration: 13, metric_labels: {}).once + expect(prometheus_client).to receive(:send_json).with( + { type: 'yeti_partition_removing_hook', duration: 13, metric_labels: {} } + ).once subject end end diff --git a/spec/lib/prometheus/yeti_cron_job_processor_spec.rb b/spec/lib/prometheus/yeti_cron_job_processor_spec.rb index e171d37ef..605f74729 100644 --- a/spec/lib/prometheus/yeti_cron_job_processor_spec.rb +++ b/spec/lib/prometheus/yeti_cron_job_processor_spec.rb @@ -16,11 +16,13 @@ shared_examples :sends_correct_metric do it 'sends metric to prometheus' do expect(prometheus_client).to receive(:send_json).with( - type: 'yeti_cron_job', - metric_labels: { pid: Process.pid }, - name: data[:name], - success: data[:success], - duration: data[:duration] + { + type: 'yeti_cron_job', + metric_labels: { pid: Process.pid }, + name: data[:name], + success: data[:success], + duration: data[:duration] + } ).once subject end diff --git a/spec/lib/yeti_scheduler_spec.rb b/spec/lib/yeti_scheduler_spec.rb index 1e8484620..0b9c633d8 100644 --- a/spec/lib/yeti_scheduler_spec.rb +++ b/spec/lib/yeti_scheduler_spec.rb @@ -54,10 +54,10 @@ let(:rufus_stub) { instance_double(Rufus::Scheduler) } before do - expect(ApplicationRecord).to receive(:clear_active_connections!).once - expect(ApplicationRecord).to receive(:flush_idle_connections!).once - expect(Cdr::Base).to receive(:clear_active_connections!).once - expect(Cdr::Base).to receive(:flush_idle_connections!).once + expect(ApplicationRecord.connection_handler).to receive(:clear_active_connections!).with(:all).once + expect(ApplicationRecord.connection_handler).to receive(:flush_idle_connections!).with(:all).once + expect(Cdr::Base.connection_handler).to receive(:clear_active_connections!).with(:all).once + expect(Cdr::Base.connection_handler).to receive(:flush_idle_connections!).with(:all).once expect(Rufus::Scheduler).to receive(:new).and_return(rufus_stub) described_class._cron_handlers.each do |handler_class| @@ -193,9 +193,11 @@ def call(options) expect(Cdr::Base.connection_pool).to receive(:release_connection).once.ordered expect(job_info_stub).to receive(:update!).with( - last_run_at: be_within(1).of(Time.zone.now), - last_duration: be > 0, - last_exception: nil + { + last_run_at: be_within(1).of(Time.zone.now), + last_duration: be > 0, + last_exception: nil + } ).once end @@ -234,9 +236,11 @@ def call(options) expect(Cdr::Base.connection_pool).to receive(:release_connection).once.ordered expect(job_info_stub).to receive(:update!).with( - last_run_at: be_within(1).of(Time.zone.now), - last_duration: be > 0, - last_exception: be_present + { + last_run_at: be_within(1).of(Time.zone.now), + last_duration: be > 0, + last_exception: be_present + } ).once end diff --git a/spec/models/report/realtime/bad_routing_spec.rb b/spec/models/report/realtime/bad_routing_spec.rb index 66cca9dd0..68fd0260d 100644 --- a/spec/models/report/realtime/bad_routing_spec.rb +++ b/spec/models/report/realtime/bad_routing_spec.rb @@ -4,7 +4,7 @@ # # Table name: cdr.cdr # -# id :bigint(8) not null +# id :bigint(8) not null, primary key # audio_recorded :boolean # auth_orig_ip :inet # auth_orig_port :integer(4) @@ -96,7 +96,7 @@ # success :boolean # time_connect :timestamptz # time_end :timestamptz -# time_start :timestamptz not null +# time_start :timestamptz not null, primary key # to_domain :string # uuid :uuid # vendor_duration :integer(4) diff --git a/spec/models/report/realtime/not_authenticated_spec.rb b/spec/models/report/realtime/not_authenticated_spec.rb index 509cab981..a5a80b540 100644 --- a/spec/models/report/realtime/not_authenticated_spec.rb +++ b/spec/models/report/realtime/not_authenticated_spec.rb @@ -4,7 +4,7 @@ # # Table name: cdr.cdr # -# id :bigint(8) not null +# id :bigint(8) not null, primary key # audio_recorded :boolean # auth_orig_ip :inet # auth_orig_port :integer(4) @@ -96,7 +96,7 @@ # success :boolean # time_connect :timestamptz # time_end :timestamptz -# time_start :timestamptz not null +# time_start :timestamptz not null, primary key # to_domain :string # uuid :uuid # vendor_duration :integer(4) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2e84dc238..138e540a3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -35,13 +35,14 @@ RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = Rails.root.join 'spec/fixtures' + config.fixture_paths = [Rails.root.join('spec/fixtures')] # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. config.use_transactional_fixtures = true config.disable_monkey_patching! + config.raise_errors_for_deprecations! if Bullet.enable? # bullet bug https://github.com/flyerhzm/bullet/issues/586 diff --git a/spec/support/helpers/chosen.rb b/spec/support/helpers/chosen.rb index 8b916a6e5..742e29385 100644 --- a/spec/support/helpers/chosen.rb +++ b/spec/support/helpers/chosen.rb @@ -12,8 +12,13 @@ def fill_in_chosen(label, options = {}) value = options.delete(:with) find_field_opts = { visible: false, disabled: disabled } find_field_opts[:match] = :prefer_exact if exact_label - select_node = find_field(label, **find_field_opts) - chosen_selector = "select##{select_node[:id]} + .chosen-container" + selector = if options.fetch(:selector, false) + label + else + select_node = find_field(label, **find_field_opts) + "select##{select_node[:id]}" + end + chosen_selector = "#{selector} + .chosen-container" if no_search chosen_pick(chosen_selector, text: value, exact: exact) else From 3a20fce25fc0a8b84c053984087d4311005f2d8a Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Sun, 19 Jan 2025 22:03:30 +0200 Subject: [PATCH 2/2] upgrade rails 7.1 -> 7.2 --- Gemfile | 4 +- Gemfile.lock | 146 +++++++++--------- .../concerns/routing_tag_ids_scopeable.rb | 6 +- app/models/report/realtime/bad_routing.rb | 6 +- .../report/realtime/not_authenticated.rb | 6 +- .../realtime/origination_performance.rb | 6 +- app/models/stats/termination_quality_stat.rb | 15 +- config/application.rb | 6 +- config/environments/development.rb | 14 +- config/environments/production.rb | 5 + config/environments/test.rb | 15 +- dev/db_test_prepare.sh | 9 ++ dev/migrate_test_db.sh | 11 ++ public/404.html | 69 +++++++-- public/406-unsupported-browser.html | 66 ++++++++ public/422.html | 69 +++++++-- public/500.html | 67 ++++++-- public/robots.txt | 6 +- spec/delayed_job_spec.rb | 20 ++- .../destinations/copy_destination_spec.rb | 2 +- .../index_background_task_spec.rb | 11 +- .../system/background_tasks/show_spec.rb | 2 +- spec/models/cdr_export_spec.rb | 6 +- spec/support/capybara.rb | 2 + spec/support/helpers/custom_rspec_helper.rb | 15 +- 25 files changed, 418 insertions(+), 166 deletions(-) create mode 100755 dev/db_test_prepare.sh create mode 100755 dev/migrate_test_db.sh create mode 100644 public/406-unsupported-browser.html diff --git a/Gemfile b/Gemfile index df6623bbf..3a186e27f 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ gem 'pg' gem 'pg_advisory_lock', git: 'https://github.com/didww/pg_advisory_lock.git' gem 'pg_sql_caller', git: 'https://github.com/didww/pg_sql_caller.git' gem 'rack', ' ~> 2.2.6' -gem 'rails', '~> 7.1.0' +gem 'rails', '~> 7.2.0' gem 'responders' # Authentication @@ -52,7 +52,7 @@ gem 'jsonapi-resources', '~> 0.9.12' # Ext gem 'validates_timeliness', '~> 7.0.0.beta1' -# Object oriented authorization for Rails applications +# Object-oriented authorization for Rails applications gem 'pundit' gem 'paper_trail' diff --git a/Gemfile.lock b/Gemfile.lock index 78fa259a5..d8ce6da8c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,51 +96,46 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.1.5.1) - actionpack (= 7.1.5.1) - activesupport (= 7.1.5.1) + actioncable (7.2.2.1) + actionpack (= 7.2.2.1) + activesupport (= 7.2.2.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.5.1) - actionpack (= 7.1.5.1) - activejob (= 7.1.5.1) - activerecord (= 7.1.5.1) - activestorage (= 7.1.5.1) - activesupport (= 7.1.5.1) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.5.1) - actionpack (= 7.1.5.1) - actionview (= 7.1.5.1) - activejob (= 7.1.5.1) - activesupport (= 7.1.5.1) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (7.2.2.1) + actionpack (= 7.2.2.1) + activejob (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) + mail (>= 2.8.0) + actionmailer (7.2.2.1) + actionpack (= 7.2.2.1) + actionview (= 7.2.2.1) + activejob (= 7.2.2.1) + activesupport (= 7.2.2.1) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.5.1) - actionview (= 7.1.5.1) - activesupport (= 7.1.5.1) + actionpack (7.2.2.1) + actionview (= 7.2.2.1) + activesupport (= 7.2.2.1) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.5.1) - actionpack (= 7.1.5.1) - activerecord (= 7.1.5.1) - activestorage (= 7.1.5.1) - activesupport (= 7.1.5.1) + useragent (~> 0.16) + actiontext (7.2.2.1) + actionpack (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.5.1) - activesupport (= 7.1.5.1) + actionview (7.2.2.1) + activesupport (= 7.2.2.1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) @@ -156,8 +151,8 @@ GEM active_admin_sidebar (1.1.0) activeadmin active_admin_theme (1.1.2) - active_record_extended (3.2.1) - activerecord (>= 5.2, < 7.2.0) + active_record_extended (3.3.0) + activerecord (>= 5.2, < 8.0.0) pg (< 3.0) activeadmin (3.2.2) arbre (~> 1.2, >= 1.2.1) @@ -169,8 +164,8 @@ GEM kaminari (>= 1.2.1) railties (>= 6.1) ransack (>= 4.0) - activejob (7.1.5.1) - activesupport (= 7.1.5.1) + activejob (7.2.2.1) + activesupport (= 7.2.2.1) globalid (>= 0.3.6) activeldap (5.1.1) activemodel (> 4.0.0) @@ -178,37 +173,36 @@ GEM gettext gettext_i18n_rails locale - activemodel (7.1.5.1) - activesupport (= 7.1.5.1) + activemodel (7.2.2.1) + activesupport (= 7.2.2.1) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (7.1.5.1) - activemodel (= 7.1.5.1) - activesupport (= 7.1.5.1) + activerecord (7.2.2.1) + activemodel (= 7.2.2.1) + activesupport (= 7.2.2.1) timeout (>= 0.4.0) activerecord-import (2.0.0) activerecord (>= 4.2) - activestorage (7.1.5.1) - actionpack (= 7.1.5.1) - activejob (= 7.1.5.1) - activerecord (= 7.1.5.1) - activesupport (= 7.1.5.1) + activestorage (7.2.2.1) + actionpack (= 7.2.2.1) + activejob (= 7.2.2.1) + activerecord (= 7.2.2.1) + activesupport (= 7.2.2.1) marcel (~> 1.0) - activesupport (7.1.5.1) + activesupport (7.2.2.1) base64 benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) logger (>= 1.4.2) minitest (>= 5.1) - mutex_m securerandom (>= 0.3) - tzinfo (~> 2.0) + tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) annotate (3.2.0) @@ -288,10 +282,10 @@ GEM activerecord (>= 3.2) date (3.3.3) deep_merge (1.2.1) - delayed_job (4.1.11) - activesupport (>= 3.0, < 8.0) - delayed_job_active_record (4.1.7) - activerecord (>= 3.0, < 8.0) + delayed_job (4.1.13) + activesupport (>= 3.0, < 9.0) + delayed_job_active_record (4.1.11) + activerecord (>= 3.0, < 9.0) delayed_job (>= 3.0, < 5) devise (4.9.4) bcrypt (~> 3.0) @@ -451,7 +445,6 @@ GEM msgpack (1.7.2) multi_xml (0.6.0) mustache (1.1.1) - mutex_m (0.3.0) net-imap (0.3.6) date net-protocol @@ -697,20 +690,20 @@ GEM rackup (1.0.1) rack (< 3) webrick - rails (7.1.5.1) - actioncable (= 7.1.5.1) - actionmailbox (= 7.1.5.1) - actionmailer (= 7.1.5.1) - actionpack (= 7.1.5.1) - actiontext (= 7.1.5.1) - actionview (= 7.1.5.1) - activejob (= 7.1.5.1) - activemodel (= 7.1.5.1) - activerecord (= 7.1.5.1) - activestorage (= 7.1.5.1) - activesupport (= 7.1.5.1) + rails (7.2.2.1) + actioncable (= 7.2.2.1) + actionmailbox (= 7.2.2.1) + actionmailer (= 7.2.2.1) + actionpack (= 7.2.2.1) + actiontext (= 7.2.2.1) + actionview (= 7.2.2.1) + activejob (= 7.2.2.1) + activemodel (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) bundler (>= 1.15.0) - railties (= 7.1.5.1) + railties (= 7.2.2.1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -718,17 +711,17 @@ GEM rails-html-sanitizer (1.6.1) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (7.1.5.1) - actionpack (= 7.1.5.1) - activesupport (= 7.1.5.1) - irb + railties (7.2.2.1) + actionpack (= 7.2.2.1) + activesupport (= 7.2.2.1) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.0.6) - ransack (4.1.1) + ransack (4.2.1) activerecord (>= 6.1.5) activesupport (>= 6.1.5) i18n @@ -858,6 +851,7 @@ GEM unicode (0.4.4.5) unicode-display_width (2.4.2) uniform_notifier (1.16.0) + useragent (0.16.11) validates_timeliness (7.0.0.beta2) activemodel (>= 7.0.0, < 8) timeliness (>= 0.3.10, < 1) @@ -956,7 +950,7 @@ DEPENDENCIES puma_worker_killer pundit rack (~> 2.2.6) - rails (~> 7.1.0) + rails (~> 7.2.0) rails-html-sanitizer (>= 1.6.1) ransack responders @@ -988,4 +982,4 @@ DEPENDENCIES zip-zip BUNDLED WITH - 2.6.2 + 2.6.3 diff --git a/app/models/concerns/routing_tag_ids_scopeable.rb b/app/models/concerns/routing_tag_ids_scopeable.rb index 521128b49..f1ff6a82e 100644 --- a/app/models/concerns/routing_tag_ids_scopeable.rb +++ b/app/models/concerns/routing_tag_ids_scopeable.rb @@ -6,14 +6,14 @@ module RoutingTagIdsScopeable included do scope :routing_tag_ids_covers, lambda { |*routing_tag_ids| type = ActiveModel::Type::Integer.new(limit: 2) - routing_tag_ids = routing_tag_ids.map do |id| + serialized_tag_ids = routing_tag_ids.map do |id| type.serialize(id) rescue ActiveModel::RangeError nil end - return none if routing_tag_ids.any?(&:nil?) + return none if serialized_tag_ids.any?(&:nil?) - where('yeti_ext.tag_compare(routing_tag_ids, ARRAY[?], routing_tag_mode_id)>0', routing_tag_ids) + where('yeti_ext.tag_compare(routing_tag_ids, ARRAY[?]::smallint[], routing_tag_mode_id)>0', serialized_tag_ids) } scope :tagged, lambda { |value| diff --git a/app/models/report/realtime/bad_routing.rb b/app/models/report/realtime/bad_routing.rb index 35f855fef..fafcfc648 100644 --- a/app/models/report/realtime/bad_routing.rb +++ b/app/models/report/realtime/bad_routing.rb @@ -190,7 +190,11 @@ class Report::Realtime::BadRouting < Report::Realtime::Base } scope :time_interval_eq, lambda { |value| - where('time_start >=(now()-\'? seconds\'::interval) and time_start < (now()-\'? seconds\'::interval)', 2 * value.to_i, value.to_i) + where( + "time_start >= (now()-(?::varchar||' seconds')::interval) AND time_start < (now()-(?::varchar||' seconds')::interval)", + 2 * value.to_i, + value.to_i + ) } private diff --git a/app/models/report/realtime/not_authenticated.rb b/app/models/report/realtime/not_authenticated.rb index 625bd7b7a..8ab67eeb0 100644 --- a/app/models/report/realtime/not_authenticated.rb +++ b/app/models/report/realtime/not_authenticated.rb @@ -182,9 +182,9 @@ class Report::Realtime::NotAuthenticated < Report::Realtime::Base scope :time_interval_eq, lambda { |value| where( - "time_start >=(now()-(?||'seconds')::interval) and time_start < (now()-(?||'seconds')::interval)", - (2 * value.to_i).to_s, - value.to_i.to_s + "time_start >=(now()-(?::varchar||' seconds')::interval) and time_start < (now()-(?||'seconds')::interval)", + 2 * value.to_i, + value.to_i ) } diff --git a/app/models/report/realtime/origination_performance.rb b/app/models/report/realtime/origination_performance.rb index 896656063..17442a847 100644 --- a/app/models/report/realtime/origination_performance.rb +++ b/app/models/report/realtime/origination_performance.rb @@ -185,7 +185,11 @@ class Report::Realtime::OriginationPerformance < Report::Realtime::Base } scope :time_interval_eq, lambda { |value| - where('time_start >=(now()-\'? seconds\'::interval) and time_start < (now()-\'? seconds\'::interval)', 2 * value.to_i, value.to_i) + where( + "time_start >= (now()-(?::varchar||' seconds')::interval) AND time_start < (now()-(?::varchar||' seconds')::interval)", + 2 * value.to_i, + value.to_i + ) } private diff --git a/app/models/stats/termination_quality_stat.rb b/app/models/stats/termination_quality_stat.rb index c77300976..a1c736341 100644 --- a/app/models/stats/termination_quality_stat.rb +++ b/app/models/stats/termination_quality_stat.rb @@ -37,7 +37,8 @@ def self.total min(pdd) as min_pdd, #{GuiConfig.termination_stats_window}::integer as w ").where( - "time_start>= now()-'? hours'::interval", GuiConfig.termination_stats_window + "time_start>= now()-(?::varchar||' hours')::interval", + GuiConfig.termination_stats_window ).reorder('').take end @@ -51,7 +52,8 @@ def self.dp_measurement max(pdd) as max_pdd, min(pdd) as min_pdd, dialpeer_id").where( - "time_start>= now()-'? hours'::interval and dialpeer_id is not null", GuiConfig.termination_stats_window + "time_start>= now()-(?::varchar||' hours')::interval and dialpeer_id is not null", + GuiConfig.termination_stats_window ).group('dialpeer_id').having( 'count(id)>=? AND sum(duration)>=?', min_calls_count, min_calls_duration ).reorder('') @@ -67,7 +69,8 @@ def self.gw_measurement max(pdd) as max_pdd, min(pdd) as min_pdd, gateway_id").where( - "time_start>= now()-'? hours'::interval and gateway_id is not null", GuiConfig.termination_stats_window + "time_start>= now()-(?::varchar||' hours')::interval and gateway_id is not null", + GuiConfig.termination_stats_window ).group('gateway_id').having( 'count(id)>=? AND sum(duration)>=?', min_calls_count, min_calls_duration ).reorder('') @@ -83,7 +86,8 @@ def self.dst_measurement max(pdd) as max_pdd, min(pdd) as min_pdd, destination_id").where( - "time_start>= now()-'? hours'::interval and destination_id is not null", GuiConfig.termination_stats_window + "time_start>= now()-(?::varchar||' hours')::interval and destination_id is not null", + GuiConfig.termination_stats_window ).group('destination_id').having( 'count(id)>=? AND sum(duration)>=?', min_calls_count, min_calls_duration ).reorder('') @@ -91,7 +95,8 @@ def self.dst_measurement def self.pdd_distribution select('pdd::integer, count(id)').where( - "time_start>= now()-'? hours'::interval", GuiConfig.termination_stats_window + "time_start>= now()-(?::varchar||' hours')::interval", + GuiConfig.termination_stats_window ).where(success: true).group('pdd::integer').order('pdd::integer ASC') end diff --git a/config/application.rb b/config/application.rb index abbd9ce6a..e7b67186b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -26,10 +26,10 @@ module Yeti class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.1 + config.load_defaults 7.2 # changing defaults - Rails.application.config.action_view.default_enforce_utf8 = true + config.action_view.default_enforce_utf8 = true # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers @@ -86,11 +86,13 @@ class Application < Rails::Application } config.active_job.queue_adapter = :delayed_job + config.active_job.enqueue_after_transaction_commit = :never # Use RSpec for testing config.generators do |g| g.test_framework :rspec g.integration_tool :rspec + g.system_tests nil end # reimplementing minimal Rails.application.secrets, that was removed in Rails 7.2 diff --git a/config/environments/development.rb b/config/environments/development.rb index 594b6165d..7868c04d1 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -16,7 +16,7 @@ # Show full error reports. config.consider_all_requests_local = true - # Enable server timing + # Enable server timing. config.server_timing = true # Enable/disable caching. By default caching is disabled. @@ -26,9 +26,7 @@ config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store - config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{2.days.to_i}" - } + config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -38,8 +36,12 @@ # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -70,9 +72,9 @@ # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true + config.action_view.annotate_rendered_view_with_filenames = true - # Raise error when a before_action's only/except options reference missing actions + # Raise error when a before_action's only/except options reference missing actions. config.action_controller.raise_on_missing_callback_actions = true if ENV['RAILS_LOG_TO_STDOUT'].present? diff --git a/config/environments/production.rb b/config/environments/production.rb index 181f832c9..2c9c32fdf 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -73,6 +73,8 @@ # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "yeti_production" + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. @@ -91,6 +93,9 @@ config.use_schema_cache_dump = true + # Only use :id for inspections in production. + config.active_record.attributes_for_inspect = [:id] + # Enable DNS rebinding protection and other `Host` header attacks. # config.hosts = [ # "example.com", # Allow requests from example.com diff --git a/config/environments/test.rb b/config/environments/test.rb index c966e2cc3..d14faf7dd 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -20,10 +20,7 @@ config.eager_load = ENV['CI'].present? # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.enabled = true - config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{1.hour.to_i}" - } + config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -38,6 +35,8 @@ # config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = true + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. @@ -45,6 +44,10 @@ # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Unlike controllers, the mailer instance doesn't have any context about the + # incoming request so you'll need to provide the :host parameter yourself. + config.action_mailer.default_url_options = { host: 'www.example.com' } + # Print deprecation notices to the stderr. # config.active_support.deprecation = :stderr config.active_support.deprecation = :raise @@ -61,12 +64,14 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - # Raise error when a before_action's only/except options reference missing actions + # Raise error when a before_action's only/except options reference missing actions. config.action_controller.raise_on_missing_callback_actions = true # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + config.active_job.queue_adapter = :test + config.after_initialize do Bullet.enable = true # Detect unnecessary COUNT queries which could be avoided diff --git a/dev/db_test_prepare.sh b/dev/db_test_prepare.sh new file mode 100755 index 000000000..acc59657b --- /dev/null +++ b/dev/db_test_prepare.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "prepare test databases..." + +RAILS_ENV=test bundle exec rake db:drop \ + db:create \ + db:schema:load \ + db:seed \ + custom_seeds[network_prefixes] diff --git a/dev/migrate_test_db.sh b/dev/migrate_test_db.sh new file mode 100755 index 000000000..87b367cad --- /dev/null +++ b/dev/migrate_test_db.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +echo "prepare and migrate test database..." + +RAILS_ENV=test bundle exec rake db:drop \ + db:create \ + db:schema:load \ + db:migrate \ + db:seed && \ +RAILS_ENV=test bundle exec rake custom_seeds[network_prefixes] && \ +RAILS_ENV=test bundle exec rake annotate_models diff --git a/public/404.html b/public/404.html index 9a48320a5..2be3af26f 100644 --- a/public/404.html +++ b/public/404.html @@ -2,25 +2,66 @@ The page you were looking for doesn't exist (404) - - +
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html new file mode 100644 index 000000000..7cf1e168e --- /dev/null +++ b/public/406-unsupported-browser.html @@ -0,0 +1,66 @@ + + + + Your browser is not supported (406) + + + + + + +
+
+

Your browser is not supported.

+

Please upgrade your browser to continue.

+
+
+ + diff --git a/public/422.html b/public/422.html index 83660ab18..c08eac0d1 100644 --- a/public/422.html +++ b/public/422.html @@ -2,25 +2,66 @@ The change you wanted was rejected (422) - - +
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

diff --git a/public/500.html b/public/500.html index f3648a0db..78a030af2 100644 --- a/public/500.html +++ b/public/500.html @@ -2,24 +2,65 @@ We're sorry, but something went wrong (500) - - +
-

We're sorry, but something went wrong.

+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

diff --git a/public/robots.txt b/public/robots.txt index 085187fa5..c19f78ab6 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,5 +1 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file -# -# To ban all spiders from the entire site uncomment the next two lines: -# User-Agent: * -# Disallow: / +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/spec/delayed_job_spec.rb b/spec/delayed_job_spec.rb index 61ef99462..b178fca45 100644 --- a/spec/delayed_job_spec.rb +++ b/spec/delayed_job_spec.rb @@ -16,7 +16,15 @@ end let!(:regular_delayed_jobs) do - active_jobs = with_real_active_job_adapter do + klasses = [ + Worker::CdrExportJob, + Worker::FillInvoiceJob, + Worker::PingCallbackUrlJob, + Worker::RemoveCdrExportFileJob, + Worker::SendEmailLogJob, + Worker::GenerateReportDataJob + ] + active_jobs = with_dj_queue_adapter(*klasses) do [ Worker::CdrExportJob.perform_later(123), Worker::CdrExportJob.perform_later(124), @@ -36,7 +44,7 @@ Delayed::Job.find(*delayed_job_ids) end let!(:custom_cdr_report_job) do - active_job = with_real_active_job_adapter do + active_job = with_dj_queue_adapter(Worker::CustomCdrReportJob) do Worker::CustomCdrReportJob.perform_later(123) end Delayed::Job.find(active_job.provider_job_id) @@ -69,7 +77,7 @@ context 'when 2 Worker::CustomCdrReportJob are enqueued' do let!(:old_custom_cdr_report_job) do - active_job = with_real_active_job_adapter do + active_job = with_dj_queue_adapter(Worker::CustomCdrReportJob) do Worker::CustomCdrReportJob.perform_later(122) end Delayed::Job.find(active_job.provider_job_id) @@ -103,13 +111,13 @@ context 'when 3 Worker::CustomCdrReportJob are enqueued' do let!(:old_custom_cdr_report_job) do - active_job = with_real_active_job_adapter do + active_job = with_dj_queue_adapter(Worker::CustomCdrReportJob) do Worker::CustomCdrReportJob.perform_later(122) end Delayed::Job.find(active_job.provider_job_id) end let!(:very_old_custom_cdr_report_job) do - active_job = with_real_active_job_adapter do + active_job = with_dj_queue_adapter(Worker::CustomCdrReportJob) do Worker::CustomCdrReportJob.perform_later(121) end Delayed::Job.find(active_job.provider_job_id) @@ -148,7 +156,7 @@ describe 'enqueue' do subject do - active_job = with_real_active_job_adapter do + active_job = with_dj_queue_adapter(active_job_class) do active_job_class.perform_later(*active_job_args) end Delayed::Job.find(active_job.provider_job_id) diff --git a/spec/features/routing/destinations/copy_destination_spec.rb b/spec/features/routing/destinations/copy_destination_spec.rb index 308844479..d7c360f26 100644 --- a/spec/features/routing/destinations/copy_destination_spec.rb +++ b/spec/features/routing/destinations/copy_destination_spec.rb @@ -16,7 +16,7 @@ click_link 'Copy' end - it 'check only not standart attribute **batch_prefix**' do + it 'check only not standard attribute **batch_prefix**' do within 'form#new_routing_destination' do expect(page).to have_field('Prefix', with: attrs[:prefix]) end diff --git a/spec/features/system/background_tasks/index_background_task_spec.rb b/spec/features/system/background_tasks/index_background_task_spec.rb index 202021e14..ae3301f3d 100644 --- a/spec/features/system/background_tasks/index_background_task_spec.rb +++ b/spec/features/system/background_tasks/index_background_task_spec.rb @@ -14,7 +14,16 @@ end let!(:background_tasks) do - active_jobs = with_real_active_job_adapter do + klasses = [ + Worker::CdrExportJob, + Worker::FillInvoiceJob, + Worker::PingCallbackUrlJob, + Worker::RemoveCdrExportFileJob, + Worker::SendEmailLogJob, + Worker::CustomCdrReportJob, + Worker::GenerateReportDataJob + ] + active_jobs = with_dj_queue_adapter(*klasses) do [ Worker::CdrExportJob.perform_later(123), Worker::FillInvoiceJob.perform_later(123), diff --git a/spec/features/system/background_tasks/show_spec.rb b/spec/features/system/background_tasks/show_spec.rb index 209bf098f..58a498267 100644 --- a/spec/features/system/background_tasks/show_spec.rb +++ b/spec/features/system/background_tasks/show_spec.rb @@ -8,7 +8,7 @@ include_context :login_as_admin let!(:background_task) do - active_job = with_real_active_job_adapter do + active_job = with_dj_queue_adapter(active_job_class) do active_job_class.perform_later(*active_job_args) end delayed_job_id = active_job.provider_job_id diff --git a/spec/models/cdr_export_spec.rb b/spec/models/cdr_export_spec.rb index e3aa6734c..419befddd 100644 --- a/spec/models/cdr_export_spec.rb +++ b/spec/models/cdr_export_spec.rb @@ -339,7 +339,7 @@ 'AND', '(1 = ANY(routing_tag_ids))', 'AND', - 'NOT (2 = ANY(routing_tag_ids))', + 'NOT ((2 = ANY(routing_tag_ids)))', 'AND', "(\"cdr\".\"cdr\".\"time_start\" >= '2018-01-01 00:00:00'", 'AND', @@ -381,7 +381,7 @@ 'AND', '(1 = ANY(routing_tag_ids))', 'AND', - 'NOT (2 = ANY(routing_tag_ids))', + 'NOT ((2 = ANY(routing_tag_ids)))', 'AND NOT', '(routing_tag_ids IS NULL OR routing_tag_ids = \'{}\')', 'AND', @@ -426,7 +426,7 @@ 'AND', '(1 = ANY(routing_tag_ids))', 'AND', - 'NOT (2 = ANY(routing_tag_ids))', + 'NOT ((2 = ANY(routing_tag_ids)))', 'AND', '(routing_tag_ids IS NULL OR routing_tag_ids = \'{}\')', 'AND', diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 5ce76fe72..3c529af55 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -45,6 +45,8 @@ driver.render(path, full: true) end +Capybara.raise_server_errors = true + # Capybara::Screenshot.screenshot_and_save_page Capybara::Screenshot.prune_strategy = :keep_last_run diff --git a/spec/support/helpers/custom_rspec_helper.rb b/spec/support/helpers/custom_rspec_helper.rb index 366887b41..b759b2eaa 100644 --- a/spec/support/helpers/custom_rspec_helper.rb +++ b/spec/support/helpers/custom_rspec_helper.rb @@ -7,13 +7,20 @@ def safe_subject nil end - # @see ActiveJob::TestHelper - def with_real_active_job_adapter - queue_adapter_changed_jobs.each(&:disable_test_adapter) + def with_dj_queue_adapter(*job_klasses, &) + with_queue_adapter(:delayed_job, *job_klasses, &) + end + + def with_queue_adapter(adapter_name, *job_klasses) + raise ArgumentError if job_klasses.empty? + begin + job_klasses.each { |klass| klass.queue_adapter = adapter_name } yield ensure - queue_adapter_changed_jobs.each { |klass| klass.enable_test_adapter(queue_adapter_for_test) } + # we need to set the exact same adapter for all job classes, because it will affect matchers + test_adapter = ActiveJob::Base.queue_adapter + job_klasses.each { |klass| klass.queue_adapter = test_adapter } end end end