Skip to content

Commit 6437c03

Browse files
Mohamed AliMohamed Ali
authored andcommitted
Update tests and database index for district_nces_id to fix RuboCop and API response expectations.
1 parent 570564b commit 6437c03

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

app/models/school.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class School < ApplicationRecord
1717
validates :municipality, presence: true
1818
validates :country_code, presence: true, inclusion: { in: ISO3166::Country.codes }
1919
validates :reference, uniqueness: { case_sensitive: false, allow_nil: true }, presence: false
20-
validates :district_nces_id, uniqueness: { allow_nil: true }, presence: false
20+
validates :district_nces_id, uniqueness: { allow_nil: true }, presence: false
2121
validates :creator_id, presence: true, uniqueness: true
2222
validates :creator_agree_authority, presence: true, acceptance: true
2323
validates :creator_agree_terms_and_conditions, presence: true, acceptance: true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class MakeDistrictNcesIdUnique < ActiveRecord::Migration[7.2]
2+
def change
3+
remove_index :schools, :district_nces_id
4+
add_index :schools, :district_nces_id, unique: true
5+
end
6+
end

db/schema.rb

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/features/my_school/showing_my_school_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
end
1818

1919
it "includes the school details and user's roles in the JSON" do
20-
school_json = school.to_json(only: %i[id name website reference address_line_1 address_line_2 municipality administrative_area postal_code country_code code verified_at created_at updated_at])
20+
school_json = school.to_json(only: %i[
21+
id name website reference address_line_1 address_line_2 municipality administrative_area postal_code country_code code verified_at created_at updated_at district_name district_nces_id
22+
])
2123
expected_data = JSON.parse(school_json, symbolize_names: true).merge(roles: ['owner'], import_in_progress: school.import_in_progress?)
2224

2325
get('/api/school', headers:)

0 commit comments

Comments
 (0)