-
-
Notifications
You must be signed in to change notification settings - Fork 910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add interpolation value on messages #1322
base: master
Are you sure you want to change the base?
Add interpolation value on messages #1322
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good try, but I am not sure that this is testing everything that needs to be tested. This scenario for the test you updated seems to be that the model has a custom validation that happens to mimic what validates_inclusion_of
. I don't think it's necessary to reproduce that in fixing #1233; I think you can assume the model has validates_inclusion_of
somewhere in it.
A better place to test this bugfix would probably be in both of the shared contexts that are being utilized in this file ("it supports in_array" and "it supports in_range"), since someone will encounter this bug when using:
validates_inclusion_of :rating, in: [1, 3, 5], message: 'the value: %{value} is not 1, 3, or 5'
just as much as:
validates_inclusion_of :rating, in: 1..5, message: 'the value: %{value} is not between 1 and 5'
Secondly, we will probably want to make sure that there is a test (or multiple tests) that make use of with_message
, with_low_message
and with_high_message
, and not just with_low_message
and with_high_message
.
I realize there are a LOT of tests for validate_inclusion_of
, so feel free to ask more questions if you are confused.
Hi @JuarezLustosa, hope you are ok. Do you still intend to work on this PR? I was thinking about adding more tests to this PR. Thank you for your contribution. |
Hey @vsppedro. All good, hope the same. Go ahead, You can it. Thank you 😃 |
message.gsub(/%{value}/, value.to_s) | ||
end | ||
|
||
def menssage_constructor(string, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo message_constructor
This pr fix interpolation and case value are added to the message, like this.
with_message('the value: %{value} is not inside the acceptable list')
Fix this or #1233