From 0b9493c7b8f6514c808fe0a4b92d78e1e09e674c Mon Sep 17 00:00:00 2001 From: jazairi <16103405+jazairi@users.noreply.github.com> Date: Wed, 29 Jul 2026 08:55:26 -0700 Subject: [PATCH 1/2] Add missing validations to the Hold model Why these changes are being introduced: Thesis and Hold Source are required fields on the Hold model. This is defined in the db schema, but not at the model layer. Because administrate checks model validations to identify required fields, this means that these fields don't appear as required in the admin forms. Relevant ticket(s): - [ETD-691](https://mitlibraries.atlassian.net/browse/ETD-691) How this addresses that need: This adds validations for Thesis and Hold Source to the Hold model. Side effects of this change: None. --- app/models/hold.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/hold.rb b/app/models/hold.rb index ceece1bb..0cc2211f 100644 --- a/app/models/hold.rb +++ b/app/models/hold.rb @@ -36,7 +36,9 @@ class Hold < ApplicationRecord validates :date_requested, presence: true validates :date_start, presence: true validates :date_end, presence: true + validates :hold_source, presence: true validates :status, presence: true + validates :thesis, presence: true after_save :update_thesis_status From 8bd29605d64b6ea376819c34137e7eb851b3b750 Mon Sep 17 00:00:00 2001 From: jazairi <16103405+jazairi@users.noreply.github.com> Date: Wed, 29 Jul 2026 10:20:45 -0700 Subject: [PATCH 2/2] Add regression coverage for missing validations --- test/models/hold_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/models/hold_test.rb b/test/models/hold_test.rb index 90395222..4d7cde5d 100644 --- a/test/models/hold_test.rb +++ b/test/models/hold_test.rb @@ -43,6 +43,24 @@ class HoldTest < ActiveSupport::TestCase assert(hold.invalid?) end + test 'invalid without thesis' do + hold = holds(:valid) + assert hold.thesis.present? + assert hold.valid? + + hold.thesis = nil + assert_not hold.valid? + end + + test 'invalid without hold source' do + hold = holds(:valid) + assert hold.hold_source.present? + assert hold.valid? + + hold.hold_source = nil + assert_not hold.valid? + end + test 'valid date_start' do hold = holds(:valid) assert(hold.valid?)