Remove message argument from NoteLengthValidator error approach (#37977)

This commit is contained in:
Matt Jankowski
2026-03-05 12:44:52 -05:00
committed by GitHub
parent 3d8d5f6dc7
commit 812c109e87
4 changed files with 4 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
class NoteLengthValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :too_long, message: I18n.t('statuses.over_character_limit', max: options[:maximum]), count: options[:maximum]) if too_long?(value)
record.errors.add(attribute, :too_long, count: options[:maximum]) if too_long?(value)
end
private

View File

@@ -91,7 +91,7 @@ RSpec.describe 'credentials API' do
expect(response.parsed_body)
.to include(
error: /Validation failed/,
details: include(note: contain_exactly(include(error: 'ERR_TOO_LONG', description: /character limit/)))
details: include(note: contain_exactly(include(error: 'ERR_TOO_LONG', description: /too long/)))
)
end
end

View File

@@ -89,7 +89,7 @@ RSpec.describe 'Profile API' do
expect(response.parsed_body)
.to include(
error: /Validation failed/,
details: include(note: contain_exactly(include(error: 'ERR_TOO_LONG', description: /character limit/)))
details: include(note: contain_exactly(include(error: 'ERR_TOO_LONG', description: /too long/)))
)
end
end

View File

@@ -50,7 +50,7 @@ RSpec.describe NoteLengthValidator do
private
def too_long_message
I18n.t('statuses.over_character_limit', max: 100)
I18n.t('errors.messages.too_long', count: 100)
end
def starting_string