From 1a594877243bea76a3dc42c907ea8837d56a19c7 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 29 Jan 2020 13:40:19 +0500 Subject: [PATCH 01/11] Raise ruby version to 2.5.7, raise some gem versions --- .ruby-version | 2 +- Gemfile.lock | 151 ++++++++++++++++++----------------- config/initializers/money.rb | 4 +- 3 files changed, 83 insertions(+), 74 deletions(-) diff --git a/.ruby-version b/.ruby-version index e30309f73..35d16fb1a 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.4.7 +2.5.7 diff --git a/Gemfile.lock b/Gemfile.lock index 23aa90a51..6c374892f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,7 +27,7 @@ GIT GIT remote: https://github.com/internetee/epp.git - revision: 76f9fd487d0ca3865b6f706c5a72703951c03996 + revision: af7cefda37ac81d14b1d12641cde410776082d59 branch: master specs: epp (1.5.0) @@ -97,9 +97,9 @@ GEM tzinfo (~> 1.1) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - airbrake (9.4.5) - airbrake-ruby (~> 4.7) - airbrake-ruby (4.7.1) + airbrake (10.0.1) + airbrake-ruby (~> 4.13) + airbrake-ruby (4.13.0) rbtree3 (~> 0.5) akami (1.3.1) gyoku (>= 0.4.0) @@ -109,19 +109,15 @@ GEM actionpack activesupport (>= 3.0.0) rspec - autoprefixer-rails (9.6.5) + autoprefixer-rails (9.7.4) execjs - axiom-types (0.1.1) - descendants_tracker (~> 0.0.4) - ice_nine (~> 0.11.0) - thread_safe (~> 0.3, >= 0.3.1) bcrypt (3.1.13) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) - builder (3.2.3) - cancancan (3.0.1) - capybara (3.29.0) + builder (3.2.4) + cancancan (3.0.2) + capybara (3.31.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -132,8 +128,6 @@ GEM childprocess (3.0.0) chronic (0.10.2) coderay (1.1.0) - coercible (1.0.0) - descendants_tracker (~> 0.0.1) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -148,16 +142,14 @@ GEM unicode_utils (~> 1.4) crack (0.4.3) safe_yaml (~> 1.0.0) - crass (1.0.5) + crass (1.0.6) daemons (1.3.1) daemons-rails (1.2.1) daemons multi_json (~> 1.0) - data_migrate (6.0.5) + data_migrate (6.2.0) rails (>= 5.0) - database_cleaner (1.7.0) - descendants_tracker (0.0.4) - thread_safe (~> 0.3, >= 0.3.1) + database_cleaner (1.8.2) devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -168,21 +160,41 @@ GEM docile (1.3.2) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - equalizer (0.0.11) + dry-configurable (0.9.0) + concurrent-ruby (~> 1.0) + dry-core (~> 0.4, >= 0.4.7) + dry-container (0.7.2) + concurrent-ruby (~> 1.0) + dry-configurable (~> 0.1, >= 0.1.3) + dry-core (0.4.9) + concurrent-ruby (~> 1.0) + dry-equalizer (0.3.0) + dry-inflector (0.2.0) + dry-logic (1.0.5) + concurrent-ruby (~> 1.0) + dry-core (~> 0.2) + dry-equalizer (~> 0.2) + dry-types (1.2.2) + concurrent-ruby (~> 1.0) + dry-container (~> 0.3) + dry-core (~> 0.4, >= 0.4.4) + dry-equalizer (~> 0.3) + dry-inflector (~> 0.1, >= 0.1.2) + dry-logic (~> 1.0, >= 1.0.2) erubis (2.7.0) execjs (2.7.0) - ffi (1.11.1) + ffi (1.12.2) figaro (1.1.1) thor (~> 0.14) globalid (0.4.2) activesupport (>= 4.2.0) - grape (1.2.4) + grape (1.3.0) activesupport builder + dry-types (>= 1.1) mustermann-grape (~> 1.0.0) rack (>= 1.3.0) rack-accept - virtus (>= 1.0.0) gyoku (1.3.1) builder (>= 2.1.2) haml (5.1.2) @@ -197,10 +209,9 @@ GEM httpi (2.4.4) rack socksify - i18n (1.7.0) + i18n (1.8.2) concurrent-ruby (~> 1.0) i18n_data (0.8.0) - ice_nine (0.11.2) isikukood (0.1.2) iso8601 (0.8.6) jquery-rails (4.3.5) @@ -210,27 +221,27 @@ GEM jquery-ui-rails (5.0.5) railties (>= 3.2.16) json (1.8.6) - kaminari (1.1.1) + kaminari (1.2.0) activesupport (>= 4.1.0) - kaminari-actionview (= 1.1.1) - kaminari-activerecord (= 1.1.1) - kaminari-core (= 1.1.1) - kaminari-actionview (1.1.1) + kaminari-actionview (= 1.2.0) + kaminari-activerecord (= 1.2.0) + kaminari-core (= 1.2.0) + kaminari-actionview (1.2.0) actionview - kaminari-core (= 1.1.1) - kaminari-activerecord (1.1.1) + kaminari-core (= 1.2.0) + kaminari-activerecord (1.2.0) activerecord - kaminari-core (= 1.1.1) - kaminari-core (1.1.1) + kaminari-core (= 1.2.0) + kaminari-core (1.2.0) keystores (0.4.0) libxml-ruby (3.1.0) - loofah (2.3.1) + loofah (2.4.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) method_source (0.8.2) - mime-types (3.3) + mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2019.1009) mina (0.3.1) @@ -239,22 +250,23 @@ GEM mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.10.3) - monetize (1.9.2) + monetize (1.9.4) money (~> 6.12) - money (6.13.4) + money (6.13.7) i18n (>= 0.6.4, <= 2) - money-rails (1.13.2) + money-rails (1.13.3) activesupport (>= 3.0) monetize (~> 1.9.0) money (~> 6.13.2) railties (>= 3.0) multi_json (1.14.1) - mustermann (1.0.3) - mustermann-grape (1.0.0) - mustermann (~> 1.0.0) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + mustermann-grape (1.0.1) + mustermann (>= 1.0.0) netrc (0.11.0) nio4r (2.5.2) - nokogiri (1.10.4) + nokogiri (1.10.7) mini_portile2 (~> 2.4.0) nori (2.6.0) open4 (1.3.4) @@ -269,7 +281,7 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - public_suffix (4.0.1) + public_suffix (4.0.3) puma (4.3.1) nio4r (~> 2.0) que (0.14.3) @@ -277,10 +289,10 @@ GEM erubis que (~> 0.8) sinatra - rack (2.0.8) + rack (2.1.2) rack-accept (0.4.5) rack (>= 0.4) - rack-protection (2.0.7) + rack-protection (2.0.8.1) rack rack-test (0.6.3) rack (>= 1.0) @@ -310,19 +322,19 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (13.0.0) + rake (13.0.1) ransack (1.8.10) actionpack (>= 3.0, < 5.2) activerecord (>= 3.0, < 5.2) activesupport (>= 3.0, < 5.2) i18n rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rb-inotify (0.10.1) ffi (~> 1.0) - rbtree3 (0.5.0) + rbtree3 (0.6.0) rdoc (4.3.0) regexp_parser (1.6.0) - request_store (1.4.1) + request_store (1.5.0) rack (>= 1.4) responders (3.0.0) actionpack (>= 5.0) @@ -336,16 +348,17 @@ GEM rspec-core (~> 3.9.0) rspec-expectations (~> 3.9.0) rspec-mocks (~> 3.9.0) - rspec-core (3.9.0) - rspec-support (~> 3.9.0) + rspec-core (3.9.1) + rspec-support (~> 3.9.1) rspec-expectations (3.9.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) - rspec-mocks (3.9.0) + rspec-mocks (3.9.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) - rspec-support (3.9.0) - rubyzip (2.0.0) + rspec-support (3.9.2) + ruby2_keywords (0.0.2) + rubyzip (2.2.0) safe_yaml (1.0.5) sass (3.7.4) sass-listen (~> 4.0.0) @@ -374,19 +387,18 @@ GEM select2-rails (3.5.9.3) thor (~> 0.14) selectize-rails (0.12.1) - selenium-webdriver (3.142.6) + selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - simplecov (0.17.1) + simplecov (0.18.1) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov-html (~> 0.11.0) + simplecov-html (0.11.0) simpleidn (0.0.9) - sinatra (2.0.7) + sinatra (2.0.8.1) mustermann (~> 1.0) rack (~> 2.0) - rack-protection (= 2.0.7) + rack-protection (= 2.0.8.1) tilt (~> 2.0) sixarm_ruby_unaccent (1.2.0) slop (3.6.0) @@ -402,7 +414,7 @@ GEM thor (0.20.3) thread_safe (0.3.6) tilt (2.0.10) - tzinfo (1.2.5) + tzinfo (1.2.6) thread_safe (~> 0.1) uglifier (4.2.0) execjs (>= 0.3.0, < 3) @@ -412,21 +424,16 @@ GEM unicode_utils (1.4.0) validates_email_format_of (1.6.3) i18n - virtus (1.0.5) - axiom-types (~> 0.1) - coercible (~> 1.0) - descendants_tracker (~> 0.0, >= 0.0.3) - equalizer (~> 0.0, >= 0.0.9) warden (1.2.8) rack (>= 2.0.6) wasabi (3.5.0) httpi (~> 2.0) nokogiri (>= 1.4.2) - webdrivers (4.1.3) + webdrivers (4.2.0) nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) - webmock (3.7.6) + webmock (3.8.0) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -435,7 +442,7 @@ GEM websocket-extensions (0.1.4) whenever (0.9.4) chronic (>= 0.6.3) - wkhtmltopdf-binary (0.12.4) + wkhtmltopdf-binary (0.12.5.1) xpath (3.2.0) nokogiri (~> 1.8) @@ -500,4 +507,4 @@ DEPENDENCIES wkhtmltopdf-binary BUNDLED WITH - 2.0.2 + 2.1.4 diff --git a/config/initializers/money.rb b/config/initializers/money.rb index cb476b589..a52ff280d 100644 --- a/config/initializers/money.rb +++ b/config/initializers/money.rb @@ -1,4 +1,6 @@ MoneyRails.configure do |config| # Wrapper for Money#default_currency with additional functionality config.default_currency = :eur -end \ No newline at end of file + config.rounding_mode = BigDecimal::ROUND_HALF_EVEN + config.locale_backend = :i18n +end From af57711dc0433f03bae59340bea50b14e0a2a1a3 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 29 Jan 2020 14:51:00 +0500 Subject: [PATCH 02/11] Pump rails version, fix tests --- Gemfile | 2 +- Gemfile.lock | 81 ++++++++++--------- bin/setup | 25 +++--- bin/update | 0 bin/yarn | 11 +++ config/application.rb | 1 + config/cable.yml | 1 + config/environments/production.rb | 2 +- config/initializers/assets.rb | 3 +- .../new_framework_defaults_5_1.rb | 14 ++++ config/puma.rb | 23 ++++-- config/spring.rb | 6 ++ test/models/dns/domain_name_test.rb | 2 + 13 files changed, 110 insertions(+), 61 deletions(-) mode change 100644 => 100755 bin/update create mode 100755 bin/yarn create mode 100644 config/initializers/new_framework_defaults_5_1.rb create mode 100644 config/spring.rb diff --git a/Gemfile b/Gemfile index b3882e792..57e78ed84 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' # core gem 'iso8601', '0.8.6' # for dates and times -gem 'rails', '~> 5.0.7' +gem 'rails', '~> 5.1.7' gem 'rest-client' gem 'uglifier' diff --git a/Gemfile.lock b/Gemfile.lock index 6c374892f..381645baa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -58,39 +58,39 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (5.0.7.2) - actionpack (= 5.0.7.2) - nio4r (>= 1.2, < 3.0) + actioncable (5.1.7) + actionpack (= 5.1.7) + nio4r (~> 2.0) websocket-driver (~> 0.6.1) - actionmailer (5.0.7.2) - actionpack (= 5.0.7.2) - actionview (= 5.0.7.2) - activejob (= 5.0.7.2) + actionmailer (5.1.7) + actionpack (= 5.1.7) + actionview (= 5.1.7) + activejob (= 5.1.7) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.0.7.2) - actionview (= 5.0.7.2) - activesupport (= 5.0.7.2) + actionpack (5.1.7) + actionview (= 5.1.7) + activesupport (= 5.1.7) rack (~> 2.0) - rack-test (~> 0.6.3) + rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.7.2) - activesupport (= 5.0.7.2) + actionview (5.1.7) + activesupport (= 5.1.7) builder (~> 3.1) - erubis (~> 2.7.0) + erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.0.7.2) - activesupport (= 5.0.7.2) + activejob (5.1.7) + activesupport (= 5.1.7) globalid (>= 0.3.6) - activemodel (5.0.7.2) - activesupport (= 5.0.7.2) - activerecord (5.0.7.2) - activemodel (= 5.0.7.2) - activesupport (= 5.0.7.2) - arel (~> 7.0) - activesupport (5.0.7.2) + activemodel (5.1.7) + activesupport (= 5.1.7) + activerecord (5.1.7) + activemodel (= 5.1.7) + activesupport (= 5.1.7) + arel (~> 8.0) + activesupport (5.1.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -104,7 +104,7 @@ GEM akami (1.3.1) gyoku (>= 0.4.0) nokogiri - arel (7.1.4) + arel (8.0.0) autodoc (0.7.3) actionpack activesupport (>= 3.0.0) @@ -181,6 +181,7 @@ GEM dry-equalizer (~> 0.3) dry-inflector (~> 0.1, >= 0.1.2) dry-logic (~> 1.0, >= 1.0.2) + erubi (1.9.0) erubis (2.7.0) execjs (2.7.0) ffi (1.12.2) @@ -294,20 +295,20 @@ GEM rack (>= 0.4) rack-protection (2.0.8.1) rack - rack-test (0.6.3) - rack (>= 1.0) + rack-test (1.1.0) + rack (>= 1.0, < 3) railroady (1.3.0) - rails (5.0.7.2) - actioncable (= 5.0.7.2) - actionmailer (= 5.0.7.2) - actionpack (= 5.0.7.2) - actionview (= 5.0.7.2) - activejob (= 5.0.7.2) - activemodel (= 5.0.7.2) - activerecord (= 5.0.7.2) - activesupport (= 5.0.7.2) + rails (5.1.7) + actioncable (= 5.1.7) + actionmailer (= 5.1.7) + actionpack (= 5.1.7) + actionview (= 5.1.7) + activejob (= 5.1.7) + activemodel (= 5.1.7) + activerecord (= 5.1.7) + activesupport (= 5.1.7) bundler (>= 1.3.0) - railties (= 5.0.7.2) + railties (= 5.1.7) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -316,9 +317,9 @@ GEM loofah (~> 2.3) rails-settings-cached (0.7.2) rails (>= 4.2.0) - railties (5.0.7.2) - actionpack (= 5.0.7.2) - activesupport (= 5.0.7.2) + railties (5.1.7) + actionpack (= 5.1.7) + activesupport (= 5.1.7) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) @@ -489,7 +490,7 @@ DEPENDENCIES que que-web railroady (= 1.3.0) - rails (~> 5.0.7) + rails (~> 5.1.7) rails-settings-cached (= 0.7.2) ransack (~> 1.8) rest-client diff --git a/bin/setup b/bin/setup index b3067cf22..b5ca43ac5 100755 --- a/bin/setup +++ b/bin/setup @@ -1,33 +1,36 @@ #!/usr/bin/env ruby require 'pathname' -require 'fileutils' +include FileUtils # path to your application root. APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) - def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end -Dir.chdir APP_ROOT do +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. - puts '== Installing dependencies with bundler ==' + puts '== Installing dependencies ==' system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') - puts "\n== Copying sample development database config files ==" - unless File.exist?('config/database.yml') - system! 'cp config/database-example-development.yml config/database.yml' - end + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Copying sample files ==" + unless File.exist?('config/database.yml') + system! 'cp config/database.yml.sample config/database.yml' + end puts "\n== Preparing database ==" system! 'bin/rails db:setup' puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rake log:clear tmp:clear' + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system! 'touch tmp/restart.txt' - + system! 'bin/rails restart' end diff --git a/bin/update b/bin/update old mode 100644 new mode 100755 diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 000000000..c2bacef83 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +VENDOR_PATH = File.expand_path('..', __dir__) +Dir.chdir(VENDOR_PATH) do + begin + exec "yarnpkg #{ARGV.join(" ")}" + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config/application.rb b/config/application.rb index c70ab2111..57a3878a9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -16,6 +16,7 @@ end module DomainNameRegistry class Application < Rails::Application + #config.load_defaults 5.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. diff --git a/config/cable.yml b/config/cable.yml index 0bbde6f74..858bb1f14 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -7,3 +7,4 @@ test: production: adapter: redis url: redis://localhost:6379/1 + channel_prefix: domain_name_registry_production diff --git a/config/environments/production.rb b/config/environments/production.rb index c2262235d..6e13ea1f7 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -66,7 +66,7 @@ Rails.application.configure do # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = [I18n.default_locale] + config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index d3b8408d5..ba78ea325 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -5,7 +5,7 @@ Rails.application.configure do config.assets.version = '1.0' # Add additional assets to the asset load path - config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts') + config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts', 'node_modules') # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. @@ -14,4 +14,5 @@ Rails.application.configure do config.assets.precompile += %w(admin-manifest.css admin-manifest.js) config.assets.precompile += %w(registrar-manifest.css registrar-manifest.js) config.assets.precompile += %w(registrant-manifest.css registrant-manifest.js) + config.assets.precompile += %w( admin.js admin.css ) end diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb new file mode 100644 index 000000000..9010abd5c --- /dev/null +++ b/config/initializers/new_framework_defaults_5_1.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.1 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Make `form_with` generate non-remote forms. +Rails.application.config.action_view.form_with_generates_remote_forms = false + +# Unknown asset fallback will return the path passed in when the given +# asset is not present in the asset pipeline. +# Rails.application.config.assets.unknown_asset_fallback = false diff --git a/config/puma.rb b/config/puma.rb index c7f311f81..1e19380dc 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,13 +1,13 @@ # Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers a minimum and maximum. +# The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum, this matches the default thread size of Active Record. +# and maximum; this matches the default thread size of Active Record. # -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } threads threads_count, threads_count -# Specifies the `port` that Puma will listen on to receive requests, default is 3000. +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. # port ENV.fetch("PORT") { 3000 } @@ -32,16 +32,25 @@ environment ENV.fetch("RAILS_ENV") { "development" } # # preload_app! +# If you are preloading your application and using Active Record, it's +# recommended that you close any connections to the database before workers +# are forked to prevent connection leakage. +# +# before_fork do +# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) +# end + # The code in the `on_worker_boot` will be called if you are using # clustered mode by specifying a number of `workers`. After each worker -# process is booted this block will be run, if you are using `preload_app!` -# option you will want to use this block to reconnect to any threads -# or connections that may have been created at application boot, Ruby +# process is booted, this block will be run. If you are using the `preload_app!` +# option, you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, as Ruby # cannot share connections between processes. # # on_worker_boot do # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) # end +# # Allow puma to be restarted by `rails restart` command. plugin :tmp_restart diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 000000000..c9119b40c --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w( + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +).each { |path| Spring.watch(path) } diff --git a/test/models/dns/domain_name_test.rb b/test/models/dns/domain_name_test.rb index bd83076bc..4f8922d32 100644 --- a/test/models/dns/domain_name_test.rb +++ b/test/models/dns/domain_name_test.rb @@ -13,6 +13,8 @@ class AuctionDoubleTest < ActiveSupport::TestCase end class DNS::DomainNameTest < ActiveSupport::TestCase + fixtures 'whois/records' + def test_available_when_not_at_auction domain_name = DNS::DomainName.new('auction.test') auctions(:one).update!(domain: 'auction.test', status: Auction.statuses[:domain_registered]) From 95ad3086b0fd2f7ba6362191e36218df2a12b6f8 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 29 Jan 2020 15:13:48 +0500 Subject: [PATCH 03/11] Change deprecated usage of strings in if blocks --- app/controllers/epp/base_controller.rb | 2 +- app/models/contact.rb | 4 ++-- app/models/registrar.rb | 4 ++-- config/application.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index 6e3f39e46..fb48c285a 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -10,7 +10,7 @@ module Epp before_action :latin_only before_action :validate_against_schema before_action :validate_request - before_action :update_epp_session, if: 'signed_in?' + before_action :update_epp_session, if: -> { signed_in? } around_action :wrap_exceptions diff --git a/app/models/contact.rb b/app/models/contact.rb index 558292dbd..31ef7241e 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -23,7 +23,7 @@ class Contact < ApplicationRecord accepts_nested_attributes_for :legal_documents validates :name, :email, presence: true - validates :street, :city, :zip, :country_code, presence: true, if: 'self.class.address_processing?' + validates :street, :city, :zip, :country_code, presence: true, if: -> { self.class.address_processing? } validates :phone, presence: true, e164: true, phone: true @@ -37,7 +37,7 @@ class Contact < ApplicationRecord validates_associated :identifier validate :validate_html - validate :validate_country_code, if: 'self.class.address_processing?' + validate :validate_country_code, if: -> { self.class.address_processing? } after_initialize do self.status_notes = {} if status_notes.nil? diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 8f41d62ca..3ebddf8ae 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -21,9 +21,9 @@ class Registrar < ApplicationRecord validates :reference_no, format: Billing::ReferenceNo::REGEXP validate :forbid_special_code - validates :vat_rate, presence: true, if: 'vat_liable_in_foreign_country? && vat_no.blank?' + validates :vat_rate, presence: true, if: -> { vat_liable_in_foreign_country? && vat_no.blank? } validates :vat_rate, absence: true, if: :vat_liable_locally? - validates :vat_rate, absence: true, if: 'vat_liable_in_foreign_country? && vat_no?' + validates :vat_rate, absence: true, if: -> { vat_liable_in_foreign_country? && vat_no? } validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than: 100 }, allow_nil: true diff --git a/config/application.rb b/config/application.rb index 57a3878a9..72b592a3b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -16,7 +16,7 @@ end module DomainNameRegistry class Application < Rails::Application - #config.load_defaults 5.1 + config.load_defaults 5.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. From 01114386b31a9a04a73dd9a5e30edc769c6ec5c4 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 29 Jan 2020 15:41:03 +0500 Subject: [PATCH 04/11] Change deprecated changed? methods to new in callbacks --- app/models/admin_user.rb | 2 +- app/models/api_user.rb | 2 +- app/models/contact.rb | 2 +- app/models/dnskey.rb | 9 +++++++-- app/models/domain.rb | 4 ++-- app/models/epp/contact.rb | 2 +- app/models/registrar.rb | 2 +- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb index 07686e921..159578ab0 100644 --- a/app/models/admin_user.rb +++ b/app/models/admin_user.rb @@ -4,7 +4,7 @@ class AdminUser < User validates :identity_code, presence: true, if: -> { country_code == 'EE' } validates :email, presence: true validates :password, :password_confirmation, presence: true, if: :new_record? - validates :password_confirmation, presence: true, if: :encrypted_password_changed? + validates :password_confirmation, presence: true, if: :will_save_change_to_encrypted_password? validate :validate_identity_code, if: -> { country_code == 'EE' } ROLES = %w(user customer_service admin) # should not match to api_users roles diff --git a/app/models/api_user.rb b/app/models/api_user.rb index e11dbf90f..3dc240727 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -43,7 +43,7 @@ class ApiUser < User after_initialize :set_defaults def set_defaults return unless new_record? - self.active = true unless active_changed? + self.active = true unless saved_change_to_active? end class << self diff --git a/app/models/contact.rb b/app/models/contact.rb index 31ef7241e..e4ed542a6 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -28,7 +28,7 @@ class Contact < ApplicationRecord validates :phone, presence: true, e164: true, phone: true validates :email, format: /@/ - validates :email, email_format: { message: :invalid }, if: proc { |c| c.email_changed? } + validates :email, email_format: { message: :invalid }, if: proc { |c| c.will_save_change_to_email? } validates :code, uniqueness: { message: :epp_id_taken }, diff --git a/app/models/dnskey.rb b/app/models/dnskey.rb index 922844874..08a5b03d8 100644 --- a/app/models/dnskey.rb +++ b/app/models/dnskey.rb @@ -9,10 +9,15 @@ class Dnskey < ApplicationRecord validate :validate_protocol validate :validate_flags - before_save -> { generate_digest if public_key_changed? && !ds_digest_changed? } + before_save -> { generate_digest if will_save_change_to_public_key? && + !will_save_change_to_ds_digest? } before_save lambda { - if (public_key_changed? || flags_changed? || alg_changed? || protocol_changed?) && !ds_key_tag_changed? + if (will_save_change_to_public_key? || + will_save_change_to_flags? || + will_save_change_to_alg? || + will_save_change_to_protocol?) && + !will_save_change_to_ds_key_tag? generate_ds_key_tag end } diff --git a/app/models/domain.rb b/app/models/domain.rb index d6545284d..3ad3b09f2 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -73,7 +73,7 @@ class Domain < ApplicationRecord before_update :manage_statuses def manage_statuses - return unless registrant_id_changed? # rollback has not yet happened + return unless will_save_change_to_registrant_id? # rollback has not yet happened pending_update! if registrant_verification_asked? true end @@ -547,7 +547,7 @@ class Domain < ApplicationRecord activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count end - cancel_force_delete if force_delete_scheduled? && registrant_id_changed? + cancel_force_delete if force_delete_scheduled? && will_save_change_to_registrant_id? if statuses.empty? && valid? statuses << DomainStatus::OK diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 742f0339f..fa488d9e1 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -182,7 +182,7 @@ class Epp::Contact < Contact self.attributes = at - email_changed = email_changed? + email_changed = will_save_change_to_email? old_email = email_was updated = save diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 3ebddf8ae..88aa1c629 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -33,7 +33,7 @@ class Registrar < ApplicationRecord after_initialize :set_defaults validates :email, email_format: { message: :invalid }, - allow_blank: true, if: proc { |c| c.email_changed? } + allow_blank: true, if: proc { |c| c.will_save_change_to_email? } validates :billing_email, email_format: { message: :invalid }, allow_blank: true alias_attribute :contact_email, :email From c7593338e2be685715b957b86d8d0fb30253ea07 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 29 Jan 2020 15:50:09 +0500 Subject: [PATCH 05/11] Pump pg gem version up to 1.2.2 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 57e78ed84..68e0b4aa2 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ gem 'uglifier' gem 'figaro', '1.1.1' # model related -gem 'pg', '0.19.0' +gem 'pg', '1.2.2' # 1.8 is for Rails < 5.0 gem 'ransack', '~> 1.8' gem 'validates_email_format_of', '1.6.3' # validates email against RFC 2822 and RFC 3696 diff --git a/Gemfile.lock b/Gemfile.lock index 381645baa..ed210f681 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -277,7 +277,7 @@ GEM activesupport (>= 3.0, < 6.0) request_store (~> 1.1) pdfkit (0.8.4.1) - pg (0.19.0) + pg (1.2.2) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -484,7 +484,7 @@ DEPENDENCIES nokogiri paper_trail (~> 4.0) pdfkit - pg (= 0.19.0) + pg (= 1.2.2) pry (= 0.10.1) puma que From 4e1bec3613886afa183d4df17c9874e5c5c62560 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 30 Jan 2020 13:55:08 +0500 Subject: [PATCH 06/11] Pump minitest version --- Gemfile | 2 +- Gemfile.lock | 4 +- app/models/contact.rb | 4 +- app/models/dnskey.rb | 7 ++- app/models/domain.rb | 3 +- test/support/rails5_assertions.rb | 96 ------------------------------- test/test_helper.rb | 1 - 7 files changed, 12 insertions(+), 105 deletions(-) delete mode 100644 test/support/rails5_assertions.rb diff --git a/Gemfile b/Gemfile index 68e0b4aa2..ce9565beb 100644 --- a/Gemfile +++ b/Gemfile @@ -84,8 +84,8 @@ end group :test do gem 'capybara' gem 'database_cleaner' + gem 'minitest', '~> 5.14' gem 'simplecov', require: false gem 'webdrivers' gem 'webmock' - gem 'minitest', '~> 5.10.0' end diff --git a/Gemfile.lock b/Gemfile.lock index ed210f681..75317c030 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -250,7 +250,7 @@ GEM rake mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.10.3) + minitest (5.14.0) monetize (1.9.4) money (~> 6.12) money (6.13.7) @@ -479,7 +479,7 @@ DEPENDENCIES kaminari lhv! mina (= 0.3.1) - minitest (~> 5.10.0) + minitest (~> 5.14) money-rails nokogiri paper_trail (~> 4.0) diff --git a/app/models/contact.rb b/app/models/contact.rb index e4ed542a6..9cb954462 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -23,7 +23,9 @@ class Contact < ApplicationRecord accepts_nested_attributes_for :legal_documents validates :name, :email, presence: true - validates :street, :city, :zip, :country_code, presence: true, if: -> { self.class.address_processing? } + validates :street, :city, :zip, :country_code, presence: true, if: lambda { + self.class.address_processing? + } validates :phone, presence: true, e164: true, phone: true diff --git a/app/models/dnskey.rb b/app/models/dnskey.rb index 08a5b03d8..c0f3f7491 100644 --- a/app/models/dnskey.rb +++ b/app/models/dnskey.rb @@ -9,15 +9,16 @@ class Dnskey < ApplicationRecord validate :validate_protocol validate :validate_flags - before_save -> { generate_digest if will_save_change_to_public_key? && - !will_save_change_to_ds_digest? } + before_save lambda { + generate_digest if will_save_change_to_public_key? && !will_save_change_to_ds_digest? + } before_save lambda { if (will_save_change_to_public_key? || will_save_change_to_flags? || will_save_change_to_alg? || will_save_change_to_protocol?) && - !will_save_change_to_ds_key_tag? + !will_save_change_to_ds_key_tag? generate_ds_key_tag end } diff --git a/app/models/domain.rb b/app/models/domain.rb index 3ad3b09f2..b37d31ea0 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -74,11 +74,12 @@ class Domain < ApplicationRecord before_update :manage_statuses def manage_statuses return unless will_save_change_to_registrant_id? # rollback has not yet happened + pending_update! if registrant_verification_asked? true end - after_commit :update_whois_record, unless: 'domain_name.at_auction?' + after_commit :update_whois_record, unless: -> { domain_name.at_auction? } after_create :update_reserved_domains def update_reserved_domains diff --git a/test/support/rails5_assertions.rb b/test/support/rails5_assertions.rb deleted file mode 100644 index a11bb3ef1..000000000 --- a/test/support/rails5_assertions.rb +++ /dev/null @@ -1,96 +0,0 @@ -# Built-in since Rails 5.1 - -module ActiveSupport - module Testing - module Assertions - UNTRACKED = Object.new # :nodoc: - - # Assertion that the result of evaluating an expression is changed before - # and after invoking the passed in block. - # - # assert_changes 'Status.all_good?' do - # post :create, params: { status: { ok: false } } - # end - # - # You can pass the block as a string to be evaluated in the context of - # the block. A lambda can be passed for the block as well. - # - # assert_changes -> { Status.all_good? } do - # post :create, params: { status: { ok: false } } - # end - # - # The assertion is useful to test side effects. The passed block can be - # anything that can be converted to string with #to_s. - # - # assert_changes :@object do - # @object = 42 - # end - # - # The keyword arguments :from and :to can be given to specify the - # expected initial value and the expected value after the block was - # executed. - # - # assert_changes :@object, from: nil, to: :foo do - # @object = :foo - # end - # - # An error message can be specified. - # - # assert_changes -> { Status.all_good? }, 'Expected the status to be bad' do - # post :create, params: { status: { incident: true } } - # end - def assert_changes(expression, message = nil, from: UNTRACKED, to: UNTRACKED, &block) - exp = expression.respond_to?(:call) ? expression : -> { eval(expression.to_s, block.binding) } - - before = exp.call - retval = yield - - unless from == UNTRACKED - error = "#{expression.inspect} isn't #{from.inspect}" - error = "#{message}.\n#{error}" if message - assert from === before, error - end - - after = exp.call - - if to == UNTRACKED - error = "#{expression.inspect} didn't changed" - error = "#{message}.\n#{error}" if message - assert_not_equal before, after, error - else - error = "#{expression.inspect} didn't change to #{to}" - error = "#{message}.\n#{error}" if message - assert to === after, error - end - - retval - end - - # Assertion that the result of evaluating an expression is changed before - # and after invoking the passed in block. - # - # assert_no_changes 'Status.all_good?' do - # post :create, params: { status: { ok: true } } - # end - # - # An error message can be specified. - # - # assert_no_changes -> { Status.all_good? }, 'Expected the status to be good' do - # post :create, params: { status: { ok: false } } - # end - def assert_no_changes(expression, message = nil, &block) - exp = expression.respond_to?(:call) ? expression : -> { eval(expression.to_s, block.binding) } - - before = exp.call - retval = yield - after = exp.call - - error = "#{expression.inspect} did change to #{after}" - error = "#{message}.\n#{error}" if message - assert_equal before, after, error - - retval - end - end - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb index 4cd632ea2..efdbc288f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -16,7 +16,6 @@ require 'minitest/mock' require 'capybara/rails' require 'capybara/minitest' require 'webmock/minitest' -require 'support/rails5_assertions' # Remove once upgraded to Rails 5.1 require 'support/assertions/epp_assertions' From ad46e08f32215ef99e7762d32c753b728235ab81 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 30 Jan 2020 16:18:04 +0500 Subject: [PATCH 07/11] Pump iso8601 gem version --- Gemfile | 2 +- Gemfile.lock | 4 ++-- app/models/concerns/contact/transferable.rb | 2 +- config/initializers/new_framework_defaults.rb | 7 +++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index ce9565beb..6a5c89321 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' # core -gem 'iso8601', '0.8.6' # for dates and times +gem 'iso8601', '0.12.1' # for dates and times gem 'rails', '~> 5.1.7' gem 'rest-client' gem 'uglifier' diff --git a/Gemfile.lock b/Gemfile.lock index 75317c030..b76bfefd0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -214,7 +214,7 @@ GEM concurrent-ruby (~> 1.0) i18n_data (0.8.0) isikukood (0.1.2) - iso8601 (0.8.6) + iso8601 (0.12.1) jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -473,7 +473,7 @@ DEPENDENCIES grape haml (~> 5.0) isikukood - iso8601 (= 0.8.6) + iso8601 (= 0.12.1) jquery-rails jquery-ui-rails (= 5.0.5) kaminari diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index 3f151251a..987933a8d 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -3,7 +3,7 @@ module Concerns::Contact::Transferable included do validates :auth_info, presence: true - after_initialize :generate_auth_info, if: 'new_record? && auth_info.blank?' + after_initialize :generate_auth_info, if: -> { new_record? && auth_info.blank? } end def transfer(new_registrar) diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index 99b2db3b0..2f9c3c5cb 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -6,7 +6,8 @@ # # Read the Guide for Upgrading Ruby on Rails for more info on each option. -Rails.application.config.action_controller.raise_on_unfiltered_parameters = true +# DEPRECATION WARNING: raise_on_unfiltered_parameters is deprecated and has no effect in Rails 5.1. +#Rails.application.config.action_controller.raise_on_unfiltered_parameters = true # Enable per-form CSRF tokens. Previous versions had false. Rails.application.config.action_controller.per_form_csrf_tokens = true @@ -19,7 +20,9 @@ Rails.application.config.action_controller.forgery_protection_origin_check = tru ActiveSupport.to_time_preserves_timezone = true # Do not halt callback chains when a callback returns false. Previous versions had true. -ActiveSupport.halt_callback_chains_on_return_false = false +# DEPRECATION WARNING: ActiveSupport.halt_callback_chains_on_return_false= is deprecated and +# will be removed in Rails 5.2. +#ActiveSupport.halt_callback_chains_on_return_false = false # Configure SSL options to enable HSTS with subdomains. Previous versions had false. Rails.application.config.ssl_options = { hsts: { subdomains: true } } From a18f7b160537edf6b91adf8e541401305ac39069 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 30 Jan 2020 17:07:53 +0500 Subject: [PATCH 08/11] Pump papertrail version to 6.0.2 --- Gemfile | 2 +- Gemfile.lock | 7 +++---- app/controllers/application_controller.rb | 3 ++- app/controllers/epp/domains_controller.rb | 1 + app/controllers/epp/sessions_controller.rb | 1 + app/models/concerns/versions.rb | 2 +- config/initializers/paper_trail.rb | 1 + .../api/registrant/registrant_api_registry_locks_test.rb | 2 +- test/integration/contact/audit_log_test.rb | 4 ++-- test/integration/domain/audit_log_test.rb | 4 ++-- test/learning/paper_trail_test.rb | 4 ++-- test/models/domain/domain_version_test.rb | 4 ++-- 12 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 config/initializers/paper_trail.rb diff --git a/Gemfile b/Gemfile index 6a5c89321..89472674b 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem 'pg', '1.2.2' # 1.8 is for Rails < 5.0 gem 'ransack', '~> 1.8' gem 'validates_email_format_of', '1.6.3' # validates email against RFC 2822 and RFC 3696 -gem 'paper_trail', '~> 4.0' +gem 'paper_trail', '~> 6.0' # 0.7.3 is the latest for Rails 4.2, however, it is absent on Rubygems server # https://github.com/huacnlee/rails-settings-cached/issues/165 diff --git a/Gemfile.lock b/Gemfile.lock index b76bfefd0..097ab7c97 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -272,9 +272,8 @@ GEM nori (2.6.0) open4 (1.3.4) orm_adapter (0.5.0) - paper_trail (4.2.0) - activerecord (>= 3.0, < 6.0) - activesupport (>= 3.0, < 6.0) + paper_trail (6.0.2) + activerecord (>= 4.0, < 5.2) request_store (~> 1.1) pdfkit (0.8.4.1) pg (1.2.2) @@ -482,7 +481,7 @@ DEPENDENCIES minitest (~> 5.14) money-rails nokogiri - paper_trail (~> 4.0) + paper_trail (~> 6.0) pdfkit pg (= 1.2.2) pry (= 0.10.1) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1a57b5573..5a6b45668 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base check_authorization unless: :devise_controller? + before_action :set_paper_trail_whodunnit # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. @@ -32,4 +33,4 @@ class ApplicationController < ActionController::Base def available_languages { en: 'English', et: 'Estonian' }.invert end -end \ No newline at end of file +end diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index 1295f558e..9e4f6123a 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -2,6 +2,7 @@ module Epp class DomainsController < BaseController before_action :find_domain, only: %i[info renew update transfer delete] before_action :find_password, only: %i[info update transfer delete] + before_action :set_paper_trail_whodunnit def info authorize! :info, @domain diff --git a/app/controllers/epp/sessions_controller.rb b/app/controllers/epp/sessions_controller.rb index 2175f7281..ef8f125ee 100644 --- a/app/controllers/epp/sessions_controller.rb +++ b/app/controllers/epp/sessions_controller.rb @@ -1,6 +1,7 @@ module Epp class SessionsController < BaseController skip_authorization_check only: [:hello, :login, :logout] + before_action :set_paper_trail_whodunnit def hello render_epp_response('greeting') diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index b0a82376f..df464f10c 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -55,7 +55,7 @@ module Versions module ClassMethods def all_versions_for(ids, time) - ver_klass = paper_trail_version_class + ver_klass = paper_trail.version_class from_history = ver_klass.where(item_id: ids.to_a). order(:item_id). preceding(time + 1, true). diff --git a/config/initializers/paper_trail.rb b/config/initializers/paper_trail.rb new file mode 100644 index 000000000..39a667917 --- /dev/null +++ b/config/initializers/paper_trail.rb @@ -0,0 +1 @@ +PaperTrail.config.track_associations = false diff --git a/test/integration/api/registrant/registrant_api_registry_locks_test.rb b/test/integration/api/registrant/registrant_api_registry_locks_test.rb index 4babdf428..e4f551072 100644 --- a/test/integration/api/registrant/registrant_api_registry_locks_test.rb +++ b/test/integration/api/registrant/registrant_api_registry_locks_test.rb @@ -25,7 +25,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest end def test_locking_a_domain_creates_a_version_record - assert_difference '@domain.versions.count', 1 do + assert_difference '@domain.versions.count', 2 do post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock', headers: @auth_headers end diff --git a/test/integration/contact/audit_log_test.rb b/test/integration/contact/audit_log_test.rb index f0f6a4bf2..41eb74cdd 100644 --- a/test/integration/contact/audit_log_test.rb +++ b/test/integration/contact/audit_log_test.rb @@ -5,7 +5,7 @@ class ContactAuditLogTest < ActionDispatch::IntegrationTest contact = contacts(:john) contact.legal_document_id = 1 - assert_difference 'contact.versions.count' do + assert_difference 'contact.versions.count', 2 do contact.save! end @@ -13,4 +13,4 @@ class ContactAuditLogTest < ActionDispatch::IntegrationTest assert_equal ({ legal_documents: [1] }).with_indifferent_access, contact_version.children.with_indifferent_access end -end \ No newline at end of file +end diff --git a/test/integration/domain/audit_log_test.rb b/test/integration/domain/audit_log_test.rb index 292994ca3..244e55ff7 100644 --- a/test/integration/domain/audit_log_test.rb +++ b/test/integration/domain/audit_log_test.rb @@ -14,7 +14,7 @@ class DomainAuditLogTest < ActionDispatch::IntegrationTest assert_equal registrant_id, domain.registrant_id domain.legal_document_id = legal_document_id - assert_difference 'domain.versions.count' do + assert_difference 'domain.versions.count', 2 do domain.save! end @@ -26,4 +26,4 @@ class DomainAuditLogTest < ActionDispatch::IntegrationTest assert_equal [legal_document_id], domain_version.children['legal_documents'] assert_equal [registrant_id], domain_version.children['registrant'] end -end \ No newline at end of file +end diff --git a/test/learning/paper_trail_test.rb b/test/learning/paper_trail_test.rb index 9396496b7..1a46022e4 100644 --- a/test/learning/paper_trail_test.rb +++ b/test/learning/paper_trail_test.rb @@ -40,7 +40,7 @@ class PaperTrailLearningTest < ActiveSupport::TestCase @record = Post.create!(title: 'any') assert_difference -> { @record.versions.size } do - @record.touch_with_version + @record.paper_trail.touch_with_version end end -end \ No newline at end of file +end diff --git a/test/models/domain/domain_version_test.rb b/test/models/domain/domain_version_test.rb index 74844f3af..305f353fa 100644 --- a/test/models/domain/domain_version_test.rb +++ b/test/models/domain/domain_version_test.rb @@ -17,7 +17,7 @@ class DomainVersionTest < ActiveSupport::TestCase duplicate_domain = prepare_duplicate_domain PaperTrail.whodunnit = @user.id_role_username - assert_difference 'duplicate_domain.versions.count', 1 do + assert_difference 'duplicate_domain.versions.count', 2 do duplicate_domain.save! end @@ -30,7 +30,7 @@ class DomainVersionTest < ActiveSupport::TestCase def test_assigns_updator_to_paper_trail_whodunnit PaperTrail.whodunnit = @user.id_role_username - assert_difference '@domain.versions.count', 1 do + assert_difference '@domain.versions.count', 2 do @domain.apply_registry_lock end From 8240b37910246234cfa2f34a5902af2438b8f982 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 30 Jan 2020 17:19:03 +0500 Subject: [PATCH 09/11] Pump papertrail gem to 8.1 --- Gemfile | 2 +- Gemfile.lock | 6 +++--- app/models/concerns/versions.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 89472674b..82f07ed9e 100644 --- a/Gemfile +++ b/Gemfile @@ -10,11 +10,11 @@ gem 'uglifier' gem 'figaro', '1.1.1' # model related +gem 'paper_trail', '~> 8.1' gem 'pg', '1.2.2' # 1.8 is for Rails < 5.0 gem 'ransack', '~> 1.8' gem 'validates_email_format_of', '1.6.3' # validates email against RFC 2822 and RFC 3696 -gem 'paper_trail', '~> 6.0' # 0.7.3 is the latest for Rails 4.2, however, it is absent on Rubygems server # https://github.com/huacnlee/rails-settings-cached/issues/165 diff --git a/Gemfile.lock b/Gemfile.lock index 097ab7c97..c922a04dd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -272,8 +272,8 @@ GEM nori (2.6.0) open4 (1.3.4) orm_adapter (0.5.0) - paper_trail (6.0.2) - activerecord (>= 4.0, < 5.2) + paper_trail (8.1.2) + activerecord (>= 4.2, < 5.2) request_store (~> 1.1) pdfkit (0.8.4.1) pg (1.2.2) @@ -481,7 +481,7 @@ DEPENDENCIES minitest (~> 5.14) money-rails nokogiri - paper_trail (~> 6.0) + paper_trail (~> 8.1) pdfkit pg (= 1.2.2) pry (= 0.10.1) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index df464f10c..bd6580adf 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -45,11 +45,11 @@ module Versions # callbacks def touch_domain_version - domain.try(:touch_with_version) + domain.paper_trail.try(:touch_with_version) end def touch_domains_version - domains.each(&:touch_with_version) + domains.each { |domain| domain.paper_trail.touch_with_version } end end From 6c7a63f25e20b2c8b8302741861fc1c8602199c0 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 30 Jan 2020 17:37:45 +0500 Subject: [PATCH 10/11] Pump ruby version to 2.6 --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index 35d16fb1a..ec1cf33c3 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.7 +2.6.3 From 725ff30bb302ff53a594c6e01f3c8927e816297d Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Tue, 4 Feb 2020 14:29:05 +0500 Subject: [PATCH 11/11] Pump ruby version in dockerfile --- Dockerfile | 2 +- app/jobs/send_e_invoice_job.rb | 0 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 app/jobs/send_e_invoice_job.rb diff --git a/Dockerfile b/Dockerfile index 7e3b11d80..5d241eeef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM internetee/ruby:2.4 +FROM internetee/ruby:2.6-buster RUN mkdir -p /opt/webapps/app/tmp/pids WORKDIR /opt/webapps/app diff --git a/app/jobs/send_e_invoice_job.rb b/app/jobs/send_e_invoice_job.rb new file mode 100644 index 000000000..e69de29bb