Skip to content

Commit bbb4d69

Browse files
Change district_nces_id to be optional, update test (#650)
## Status - [Closes](RaspberryPiFoundation/digital-editor-issues#1088) ## What's changed? - Change the `district_nces_id` field to be optional
1 parent 5abaffc commit bbb4d69

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

app/models/school.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class School < ApplicationRecord
2323
validates :district_nces_id,
2424
uniqueness: { conditions: -> { where(rejected_at: nil) }, case_sensitive: false, allow_blank: true, message: I18n.t('validations.school.district_nces_id_exists') },
2525
format: { with: /\A\d{7}\z/, allow_nil: true, message: I18n.t('validations.school.district_nces_id') },
26-
presence: true,
2726
if: :united_states?
2827
validates :district_name, presence: true, if: :united_states?
2928
validates :school_roll_number,

spec/models/school_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,9 @@
214214
expect(school).to be_valid
215215
end
216216

217-
it 'requires district_nces_id for US schools' do
217+
it 'does not require district_nces_id for US schools' do
218218
us_school.district_nces_id = nil
219-
expect(us_school).not_to be_valid
220-
expect(us_school.errors[:district_nces_id]).to include("can't be blank")
219+
expect(us_school).to be_valid
221220
end
222221

223222
it 'requires district_name for US schools' do

0 commit comments

Comments
 (0)