mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Tweak warning to be descriptive, not prescriptive
While we do advise against using the validates_inclusion_of or validates_format_of validations with boolean columns, we won't judge if you would like to do so.
This commit is contained in:
parent
e2b83760ce
commit
c714193528
1 changed files with 4 additions and 6 deletions
|
@ -251,17 +251,15 @@ module Shoulda
|
||||||
ARBITRARY_OUTSIDE_DECIMAL = BigDecimal.new('0.123456789')
|
ARBITRARY_OUTSIDE_DECIMAL = BigDecimal.new('0.123456789')
|
||||||
BOOLEAN_ALLOWS_BOOLEAN_MESSAGE = <<EOT
|
BOOLEAN_ALLOWS_BOOLEAN_MESSAGE = <<EOT
|
||||||
You are using `validate_inclusion_of` to assert that a boolean column allows
|
You are using `validate_inclusion_of` to assert that a boolean column allows
|
||||||
boolean values and disallows non-boolean ones. Assuming you are using
|
boolean values and disallows non-boolean ones. Be aware that it is not possible
|
||||||
`validates_format_of` in your model, be aware that it is not possible to fully
|
to fully test this, as boolean columns will automatically convert non-boolean
|
||||||
test this, and in fact the validation is superfluous, as boolean columns will
|
values to boolean ones. Hence, you should consider removing this test.
|
||||||
automatically convert non-boolean values to boolean ones. Hence, you should
|
|
||||||
consider removing this test and the corresponding validation.
|
|
||||||
EOT
|
EOT
|
||||||
BOOLEAN_ALLOWS_NIL_MESSAGE = <<EOT
|
BOOLEAN_ALLOWS_NIL_MESSAGE = <<EOT
|
||||||
You are using `validate_inclusion_of` to assert that a boolean column allows nil.
|
You are using `validate_inclusion_of` to assert that a boolean column allows nil.
|
||||||
Be aware that it is not possible to fully test this, as anything other than
|
Be aware that it is not possible to fully test this, as anything other than
|
||||||
true, false or nil will be converted to false. Hence, you should consider
|
true, false or nil will be converted to false. Hence, you should consider
|
||||||
removing this test and the corresponding validation.
|
removing this test.
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
def initialize(attribute)
|
def initialize(attribute)
|
||||||
|
|
Loading…
Reference in a new issue