mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-17 18:18:07 +00:00
Collections: Add missing validations for boolean columns (#37005)
This commit is contained in:
@@ -27,6 +27,9 @@ class Collection < ApplicationRecord
|
|||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :description, 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 :uri, presence: true, if: :remote?
|
||||||
validates :original_number_of_items,
|
validates :original_number_of_items,
|
||||||
presence: true,
|
presence: true,
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ RSpec.describe Collection do
|
|||||||
|
|
||||||
it { is_expected.to validate_presence_of(:description) }
|
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
|
context 'when collection is remote' do
|
||||||
subject { Fabricate.build :collection, local: false }
|
subject { Fabricate.build :collection, local: false }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user