renew deprecated methods (#1444)

* renew deprecated methods

* replace "attribute_names" with the methods that exist in the Rails 5.2 and 6.0 APIs
This commit is contained in:
ryu-sato 2021-06-13 03:41:26 +09:00 committed by GitHub
parent b3c792338a
commit 7663821cff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -8,7 +8,7 @@ module Shoulda
end
def format_validation_errors(errors)
list_items = errors.keys.map do |attribute|
list_items = errors.to_hash.keys.map do |attribute|
messages = errors[attribute]
"* #{attribute}: #{messages}"
end

View File

@ -73,7 +73,7 @@ describe Shoulda::Matchers::ActiveModel::DisallowValueMatcher, type: :model do
def custom_validation # rubocop:disable Lint/NestedMethodDefinition
if self[:attr] != 'good value'
errors[:attr2] << 'some message'
errors.add :attr2, 'some message'
end
end
end.new