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'