From 357eca387598eaadd7b3e71a73b1915d2814c8f5 Mon Sep 17 00:00:00 2001 From: Stefanni Brasil Date: Fri, 23 Jan 2026 14:28:48 -0700 Subject: [PATCH] Ensure CustomOrgLink#active tests inclusion in [true, false] When running the tests, the following shoulda-matchers warning message is printed out: ``` 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. ``` `active` needs to be either true or false but not nil. With this explicit test, we ensure the attribute is accurately covered. --- spec/models/custom_org_link_spec.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/models/custom_org_link_spec.rb b/spec/models/custom_org_link_spec.rb index d763bda9c0..4ed5ec5a08 100644 --- a/spec/models/custom_org_link_spec.rb +++ b/spec/models/custom_org_link_spec.rb @@ -5,7 +5,6 @@ it { is_expected.to validate_presence_of :text } it { is_expected.to validate_presence_of :url } it { is_expected.to validate_length_of(:text).is_at_most described_class::TEXT_MAX_LENGTH } - it { is_expected.to validate_inclusion_of(:active).in_array [true, false] } describe "#trim_name" do let(:casa_org) { create(:casa_org) } @@ -27,4 +26,14 @@ it { is_expected.not_to allow_value("example.com").for(:url) } it { is_expected.not_to allow_value("some arbitrary string").for(:url) } end + + describe "#active" do + it "only allows true or false" do + casa_org = build(:casa_org) + + expect(build(:custom_org_link, casa_org: casa_org, active: false)).to be_valid + expect(build(:custom_org_link, casa_org: casa_org, active: true)).to be_valid + expect(build(:custom_org_link, casa_org: casa_org, active: nil)).to be_invalid + end + end end