From 0725afe1a957f0a80e79e6efa48252ebd744c1a2 Mon Sep 17 00:00:00 2001 From: David Roetzel Date: Tue, 25 Nov 2025 15:46:50 +0100 Subject: [PATCH] Collections: Add missing validations for boolean columns (#37005) --- app/models/collection.rb | 3 +++ spec/models/collection_spec.rb | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/app/models/collection.rb b/app/models/collection.rb index 320933ea606..41f9ed0f02a 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -27,6 +27,9 @@ class Collection < ApplicationRecord validates :name, presence: true validates :description, presence: true + validates :local, inclusion: [true, false] + validates :sensitive, inclusion: [true, false] + validates :discoverable, inclusion: [true, false] validates :uri, presence: true, if: :remote? validates :original_number_of_items, presence: true, diff --git a/spec/models/collection_spec.rb b/spec/models/collection_spec.rb index c6a500210f6..6c160ecb70a 100644 --- a/spec/models/collection_spec.rb +++ b/spec/models/collection_spec.rb @@ -10,6 +10,12 @@ RSpec.describe Collection do it { is_expected.to validate_presence_of(:description) } + it { is_expected.to_not allow_value(nil).for(:local) } + + it { is_expected.to_not allow_value(nil).for(:sensitive) } + + it { is_expected.to_not allow_value(nil).for(:discoverable) } + context 'when collection is remote' do subject { Fabricate.build :collection, local: false }