Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/models/school.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class School < ApplicationRecord
format: { with: /\A\d{5,6}\z/, allow_nil: true, message: I18n.t('validations.school.reference') },
if: :united_kingdom?
validates :district_nces_id,
uniqueness: { conditions: -> { where(rejected_at: nil) }, case_sensitive: false, allow_blank: true, message: I18n.t('validations.school.district_nces_id_exists') },
format: { with: /\A\d{7}\z/, allow_nil: true, message: I18n.t('validations.school.district_nces_id') },
if: :united_states?
validates :district_name, presence: true, if: :united_states?
Expand Down
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ en:
reference: "must be 5-6 digits (e.g., 100000)"
reference_urn_exists: "URN number already exists"
district_nces_id: "must be 7 digits (e.g., 0100000)"
district_nces_id_exists: "NCES ID already exists"
school_roll_number: "must be numbers followed by letters (e.g., 01572D)"
school_roll_number_exists: "School roll number already exists"
invitation:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveUniqueIndexFromSchoolsDistrictNcesId < ActiveRecord::Migration[7.2]
def change
remove_index :schools, name: "index_schools_on_district_nces_id"
end
end
3 changes: 1 addition & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions spec/models/school_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@
expect(duplicate_school).not_to be_valid
end

it 'returns error if district_nces_id is not unique' do
duplicate_school = build(:school, country_code: 'US', district_nces_id: '0100000')
duplicate_school.valid?
expect(duplicate_school.errors.details[:district_nces_id]).to include(hash_including(error: :taken))
end

it 'accepts a valid district_nces_id format (7 digits)' do
us_school.district_nces_id = '0100000'
expect(us_school).to be_valid
Expand Down