shoulda-matchers: using `validate_inclusion_of` to assert that a boolean column allows boolean values
MR: Remove validate_inclusion_of for boolean columns (!140312 - merged)
Description
Running the ee/spec/models/remote_development/remote_development_agent_config_spec.rb
outputs the following warning in the stdout
************************************************************************
Warning from shoulda-matchers:
You are using `validate_inclusion_of` to assert that a boolean column
allows boolean values and disallows non-boolean ones. Be aware that it
is not possible to fully test this, as boolean columns will
automatically convert non-boolean values to boolean ones. Hence, you
should consider removing this test.
************************************************************************
The official documentation states
We discourage using
validate_inclusion_of
with boolean columns. In fact, there is never a case where a boolean column will be anything but true, false, or nil, as ActiveRecord will type-cast an incoming value to one of these three values. That means there isn't any way we can refute this logic in a test. Hence, this will produce a warning:it do should validate_inclusion_of(:imported). in_array([true, false]) end
Thus, we should remove this validation from our specs to avoid this warning.
Acceptance Criteria
-
No warnings from shoulda-matchers about using validate_inclusion_of
with boolean columns while running remote development specs
Edited by Chad Woolley