diff --git a/app/models/school.rb b/app/models/school.rb index 4a898be3..570e94fc 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -6,7 +6,7 @@ class School < ApplicationRecord validates :school_name, presence: true - enum school_type: { elementary: 0, middle_school: 1, high_school: 2, charter_school: 3, specialty_school: 4 } + enum school_type: { elementary: 0, middle: 1, high: 2, charter: 3, specialty: 4 } scope :enabled, -> { where(enabled: true) } end diff --git a/spec/controllers/admin/schools_controller_spec.rb b/spec/controllers/admin/schools_controller_spec.rb index 35eb6540..1c8ea5b3 100644 --- a/spec/controllers/admin/schools_controller_spec.rb +++ b/spec/controllers/admin/schools_controller_spec.rb @@ -53,8 +53,8 @@ it 'updates school' do expect do - patch :update, params: { id: school.id, school: { school_type: 'middle_school' }, format: 'js' } - end.to change { school.reload.school_type }.from('elementary').to('middle_school') + patch :update, params: { id: school.id, school: { school_type: 'middle' }, format: 'js' } + end.to change { school.reload.school_type }.from('elementary').to('middle') end it 'does not update school for another subsite' do @@ -62,7 +62,7 @@ sign_in other_subsite_admin expect do - patch :update, params: { id: school.id, school: { school_type: 'middle_school' }, format: 'js' } + patch :update, params: { id: school.id, school: { school_type: 'middle' }, format: 'js' } end.to_not(change { school.reload.school_type }) end end diff --git a/spec/controllers/ajax/schools_controller_spec.rb b/spec/controllers/ajax/schools_controller_spec.rb index c826bc70..adc38010 100644 --- a/spec/controllers/ajax/schools_controller_spec.rb +++ b/spec/controllers/ajax/schools_controller_spec.rb @@ -8,13 +8,17 @@ before do @elementary_school1 = create(:school, school_type: :elementary, organization: organization) @elementary_school2 = create(:school, school_type: :elementary, organization: organization) - @middle_school = create(:school, school_type: :middle_school, organization: organization) - @high_school = create(:school, school_type: :high_school, organization: organization) + @middle_school = create(:school, school_type: :middle, organization: organization) + @high_school = create(:school, school_type: :high, organization: organization) + @charter_school = create(:school, school_type: :charter, organization: organization) + @specialty_school = create(:school, school_type: :specialty, organization: organization) create(:school, school_type: :elementary, organization: organization, enabled: false) create(:school, school_type: :elementary, organization: organization, enabled: false) - create(:school, school_type: :middle_school, organization: organization, enabled: false) - create(:school, school_type: :high_school, organization: organization, enabled: false) + create(:school, school_type: :middle, organization: organization, enabled: false) + create(:school, school_type: :high, organization: organization, enabled: false) + create(:school, school_type: :charter, organization: organization, enabled: false) + create(:school, school_type: :specialty, organization: organization, enabled: false) @request.host = "#{organization.subdomain}.test.host" end @@ -26,13 +30,23 @@ end it 'returns active middle schools' do - get :index, params: { school_type: 'middle_school' }, format: :js + get :index, params: { school_type: 'middle' }, format: :js expect(response.body).to eq([@middle_school].to_json) end it 'returns active high schools' do - get :index, params: { school_type: 'high_school' }, format: :js + get :index, params: { school_type: 'high' }, format: :js expect(response.body).to eq([@high_school].to_json) end + + it 'returns active charter schools' do + get :index, params: { school_type: 'charter' }, format: :js + expect(response.body).to eq([@charter_school].to_json) + end + + it 'returns active specialty schools' do + get :index, params: { school_type: 'specialty' }, format: :js + expect(response.body).to eq([@specialty_school].to_json) + end end end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index bb1f6dd8..cf1bb5cd 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -80,7 +80,7 @@ describe 'school registration' do let(:organization) { create(:organization, accepts_programs: true) } let(:program) { create(:program, parent_type: :students_and_parents, organization: organization) } - let(:school) { create(:school, school_type: :middle_school, organization: organization) } + let(:school) { create(:school, school_type: :middle, organization: organization) } before do @request.host = "#{organization.subdomain}.test.host" diff --git a/spec/factories/schools.rb b/spec/factories/schools.rb index fde20085..5af475a8 100644 --- a/spec/factories/schools.rb +++ b/spec/factories/schools.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :school do school_name { Faker::Hipster.sentence(word_count: 3) } - school_type { :middle_school } + school_type { :middle } organization trait :disabled do diff --git a/spec/features/admin/school_management_spec.rb b/spec/features/admin/school_management_spec.rb index 92ce27d3..d4fb727c 100644 --- a/spec/features/admin/school_management_spec.rb +++ b/spec/features/admin/school_management_spec.rb @@ -15,10 +15,10 @@ scenario 'Admin view a list of schools' do @elementary_school = FactoryBot.create(:school, organization: organization, school_type: 'elementary') - @middle_school = FactoryBot.create(:school, organization: organization, school_type: 'middle_school') - @high_school = FactoryBot.create(:school, organization: organization, school_type: 'high_school') - @charter_school = FactoryBot.create(:school, organization: organization, school_type: 'charter_school') - @specialty_school = FactoryBot.create(:school, organization: organization, school_type: 'specialty_school') + @middle_school = FactoryBot.create(:school, organization: organization, school_type: 'middle') + @high_school = FactoryBot.create(:school, organization: organization, school_type: 'high') + @charter_school = FactoryBot.create(:school, organization: organization, school_type: 'charter') + @specialty_school = FactoryBot.create(:school, organization: organization, school_type: 'specialty') visit admin_dashboard_index_path click_link 'Manage Schools' @@ -30,10 +30,10 @@ expect(page).to have_content(@high_school.school_name) expect(page).to have_select('school_school_type', selected: 'Elementary') - expect(page).to have_select('school_school_type', selected: 'Middle School') - expect(page).to have_select('school_school_type', selected: 'High School') - expect(page).to have_select('school_school_type', selected: 'Charter School') - expect(page).to have_select('school_school_type', selected: 'Specialty School') + expect(page).to have_select('school_school_type', selected: 'Middle') + expect(page).to have_select('school_school_type', selected: 'High') + expect(page).to have_select('school_school_type', selected: 'Charter') + expect(page).to have_select('school_school_type', selected: 'Specialty') end scenario 'Admin changes a school type', js: true do @@ -42,14 +42,14 @@ visit admin_schools_path within('.resource-row') do - select('Middle School', from: 'school_school_type') + select('Middle', from: 'school_school_type') end - expect(page).to have_select('school_school_type', selected: 'Middle School') + expect(page).to have_select('school_school_type', selected: 'Middle') visit admin_schools_path - expect(page).to have_select('school_school_type', selected: 'Middle School') + expect(page).to have_select('school_school_type', selected: 'Middle') end scenario 'Admin creates a new school', js: true do @@ -57,13 +57,13 @@ fill_in 'School Name', with: 'New School' - select('Middle School', from: 'school_school_type') + select('Middle', from: 'school_school_type') click_button 'Add School' expect(page).to have_selector('.resource-row') within('.resource-row') do expect(page).to have_content('New School') - expect(page).to have_select('school_school_type', selected: 'Middle School') + expect(page).to have_select('school_school_type', selected: 'Middle') end end end diff --git a/spec/features/user/school_registration_spec.rb b/spec/features/user/school_registration_spec.rb index 1ca4c550..d9efa226 100644 --- a/spec/features/user/school_registration_spec.rb +++ b/spec/features/user/school_registration_spec.rb @@ -13,10 +13,10 @@ before do create(:program, program_name: 'MNPS', parent_type: :students_and_parents, organization: organization) create(:school, school_type: :elementary, school_name: 'Lincoln Elementary', organization: organization) - create(:school, school_type: :middle_school, school_name: 'Middle School East', organization: organization) - create(:school, school_type: :high_school, school_name: 'GLHS', organization: organization) - create(:school, school_type: :charter_school, school_name: 'Magna Carta Charter School', organization: organization) - create(:school, school_type: :specialty_school, school_name: 'Denver School of Performing Arts', organization: organization) + create(:school, school_type: :middle, school_name: 'Middle School East', organization: organization) + create(:school, school_type: :high, school_name: 'GLHS', organization: organization) + create(:school, school_type: :charter, school_name: 'Magna Carta Charter School', organization: organization) + create(:school, school_type: :specialty, school_name: 'Denver School of Performing Arts', organization: organization) end scenario 'registers as student', js: true do @@ -47,16 +47,16 @@ expect(page).to have_select('School', exact: true) expect(page).to have_select('School', options: ['Select School...', 'Lincoln Elementary']) - select('Middle School', from: 'School Type') + select('Middle', from: 'School Type') expect(page).to have_select('School', options: ['Select School...', 'Middle School East']) - select('Charter School', from: 'School Type') + select('Charter', from: 'School Type') expect(page).to have_select('School', options: ['Select School...', 'Magna Carta Charter School']) - select('Specialty School', from: 'School Type') + select('Specialty', from: 'School Type') expect(page).to have_select('School', options: ['Select School...', 'Denver School of Performing Arts']) - select('High School', from: 'School Type') + select('High', from: 'School Type') expect(page).to have_select('School', options: ['Select School...', 'GLHS']) select('GLHS', from: 'School')