DEV: Remove unreachable IP address validation message (#24131)

The message: :signup_not_allowed option to the IP address validator does nothing, because the AllowedIpAddressValidator chooses one of either:

- ip_address.blocked or
- ip_address.max_new_accounts_per_registration_ip

internally. This means that the translation for this was also never used.

This PR removes the ineffectual option and the unused translation. It also moves the translated error messages for blocked and max_new_accounts_per_registration_ip into the correct location so we can pass a symbol to ActiveModel::Errors#add.

There is no actual change in behaviour.
This commit is contained in:
Ted Johansson
2023-10-27 15:22:38 +08:00
committed by GitHub
parent 9acdafe87c
commit f9f9cf0bf4
45 changed files with 93 additions and 166 deletions

View File

@ -11,7 +11,9 @@ RSpec.describe AllowedIpAddressValidator do
ScreenedIpAddress.stubs(:should_block?).returns(true)
validate
expect(record.errors[:ip_address]).to be_present
expect(record.errors[:ip_address][0]).to eq(I18n.t("user.ip_address.blocked"))
expect(record.errors[:ip_address][0]).to eq(
I18n.t("activerecord.errors.models.user.attributes.ip_address.blocked"),
)
end
end
@ -21,7 +23,9 @@ RSpec.describe AllowedIpAddressValidator do
validate
expect(record.errors[:ip_address]).to be_present
expect(record.errors[:ip_address][0]).to eq(
I18n.t("user.ip_address.max_new_accounts_per_registration_ip"),
I18n.t(
"activerecord.errors.models.user.attributes.ip_address.max_new_accounts_per_registration_ip",
),
)
end
end