diff --git a/.rubocop.yml b/.rubocop.yml index fa6d9d04f..be9b3320f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -78,7 +78,7 @@ Style/SingleArgumentDig: Enabled: false Layout/LineLength: - Max: 120 + Max: 135 Exclude: - "app/controllers/v0/institutions_controller.rb" - "app/controllers/v1/institutions_controller.rb" diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index ffc8271f2..4124e6193 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -29,7 +29,7 @@ def resolve_version v = params[:version] @version = (v.present? && Version.find_by(uuid: v)) || Version.current_production - raise Common::Exceptions::InvalidFieldValue, "Version #{v} not found" unless @version.try(:number) + raise Common::Exceptions::Internal::InvalidFieldValue, "Version #{v} not found" unless @version.try(:number) end def self_link @@ -42,14 +42,14 @@ def self_link va_exception = case exception when ActionController::ParameterMissing - Common::Exceptions::ParameterMissing.new(exception.param) + Common::Exceptions::Internal::ParameterMissing.new(exception.param) when Common::Exceptions::BaseError exception else - Common::Exceptions::InternalServerError.new(exception) + Common::Exceptions::Internal::InternalServerError.new(exception) end - headers['WWW-Authenticate'] = 'Token realm="Application"' if va_exception.is_a?(Common::Exceptions::Unauthorized) + headers['WWW-Authenticate'] = 'Token realm="Application"' if va_exception.is_a?(Common::Exceptions::Internal::Unauthorized) render json: { errors: va_exception.errors }, status: va_exception.status_code end diff --git a/app/controllers/archives_controller.rb b/app/controllers/archives_controller.rb index b638bf129..ee22b0c9d 100644 --- a/app/controllers/archives_controller.rb +++ b/app/controllers/archives_controller.rb @@ -18,7 +18,7 @@ def export filename: "#{params[:csv_type]}_version_#{params[:number]}.csv" end end - rescue ArgumentError, Common::Exceptions::RecordNotFound, ActionController::UnknownFormat, MissingAttributeError => e + rescue ArgumentError, Common::Exceptions::Internal::RecordNotFound, ActionController::UnknownFormat, MissingAttributeError => e Rails.logger.error e.message redirect_to archives_path, alert: e.message end diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index cf73b50ec..d6b69182a 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -40,7 +40,7 @@ def export_version filename: "institutions_version_#{params[:number]}.csv" end end - rescue ArgumentError, Common::Exceptions::RecordNotFound, ActionController::UnknownFormat => e + rescue ArgumentError, Common::Exceptions::Internal::RecordNotFound, ActionController::UnknownFormat => e log_error(e) end @@ -55,7 +55,7 @@ def export_ungeocodables ), type: 'text/csv', filename: 'ungeocodables.csv' end end - rescue ArgumentError, Common::Exceptions::RecordNotFound, ActionController::UnknownFormat => e + rescue ArgumentError, Common::Exceptions::Internal::RecordNotFound, ActionController::UnknownFormat => e log_error(e) end @@ -67,7 +67,7 @@ def export_unaccrediteds ), type: 'text/csv', filename: 'unaccrediteds.csv' end end - rescue ArgumentError, Common::Exceptions::RecordNotFound, ActionController::UnknownFormat => e + rescue ArgumentError, Common::Exceptions::Internal::RecordNotFound, ActionController::UnknownFormat => e log_error(e) end @@ -78,7 +78,7 @@ def export_partials type: 'text/csv', filename: 'partials.csv' end end - rescue ArgumentError, Common::Exceptions::RecordNotFound, ActionController::UnknownFormat => e + rescue ArgumentError, Common::Exceptions::Internal::RecordNotFound, ActionController::UnknownFormat => e log_error(e) end @@ -89,7 +89,7 @@ def export_orphans type: 'text/csv', filename: 'orphans.csv' end end - rescue ArgumentError, Common::Exceptions::RecordNotFound, ActionController::UnknownFormat => e + rescue ArgumentError, Common::Exceptions::Internal::RecordNotFound, ActionController::UnknownFormat => e log_error(e) end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 2025526c9..90b50303d 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -54,9 +54,9 @@ def requirements def upload_requirements(type) { type: type.name, - requirements: UploadRequirements.requirements_messages(type), + requirements: UploadTypes::UploadRequirements.requirements_messages(type), custom_batch_validator: "#{type.name}Validator::REQUIREMENT_DESCRIPTIONS".safe_constantize, - inclusion: UploadRequirements.validation_messages_inclusion(type) } + inclusion: UploadTypes::UploadRequirements.validation_messages_inclusion(type) } end def alert_messages(loaded_data) diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index c67d550da..b604580ec 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -49,9 +49,9 @@ def show private def csv_requirements - @requirements = [RooHelper.valid_col_seps] + UploadRequirements.requirements_messages(klass) + @requirements = [RooHelper::Shared.valid_col_seps] + UploadTypes::UploadRequirements.requirements_messages(klass) @custom_batch_validator = "#{klass.name}Validator::REQUIREMENT_DESCRIPTIONS".safe_constantize - @inclusion = UploadRequirements.validation_messages_inclusion(klass) + @inclusion = UploadTypes::UploadRequirements.validation_messages_inclusion(klass) end def alert_messages(data) diff --git a/app/controllers/v0/institution_programs_controller.rb b/app/controllers/v0/institution_programs_controller.rb index 2d64c624f..4bcf08913 100644 --- a/app/controllers/v0/institution_programs_controller.rb +++ b/app/controllers/v0/institution_programs_controller.rb @@ -2,7 +2,7 @@ module V0 class InstitutionProgramsController < ApiController - include Facets + include Search::Facets # GET /v0/institution_programs/autocomplete?term=harv def autocomplete diff --git a/app/controllers/v0/institutions_controller.rb b/app/controllers/v0/institutions_controller.rb index 499796b77..b51aa1f55 100644 --- a/app/controllers/v0/institutions_controller.rb +++ b/app/controllers/v0/institutions_controller.rb @@ -2,7 +2,7 @@ module V0 class InstitutionsController < ApiController - include Facets + include Search::Facets # GET /v0/institutions/autocomplete?term=harv def autocomplete @@ -48,7 +48,7 @@ def index def show resource = Institution.approved_institutions(@version).find_by(facility_code: params[:id]) - raise Common::Exceptions::RecordNotFound, params[:id] unless resource + raise Common::Exceptions::Internal::RecordNotFound, params[:id] unless resource @links = { self: self_link } render json: resource, serializer: InstitutionProfileSerializer, diff --git a/app/controllers/v0/yellow_ribbon_programs_controller.rb b/app/controllers/v0/yellow_ribbon_programs_controller.rb index dbd7dc228..b3c4d4876 100644 --- a/app/controllers/v0/yellow_ribbon_programs_controller.rb +++ b/app/controllers/v0/yellow_ribbon_programs_controller.rb @@ -2,7 +2,7 @@ module V0 class YellowRibbonProgramsController < ApiController - include Facets + include Search::Facets # GET /v0/yellow_ribbon_programs # ?page=1 diff --git a/app/controllers/v0/zipcode_rates_controller.rb b/app/controllers/v0/zipcode_rates_controller.rb index 53b3721b4..b0c8c14bf 100644 --- a/app/controllers/v0/zipcode_rates_controller.rb +++ b/app/controllers/v0/zipcode_rates_controller.rb @@ -6,7 +6,7 @@ class ZipcodeRatesController < ApiController def show resource = ZipcodeRate.joins(:version) .where(zip_code: params[:id], version: @version).order(:mha_rate).first - raise Common::Exceptions::RecordNotFound, params[:id] unless resource + raise Common::Exceptions::Internal::RecordNotFound, params[:id] unless resource render json: resource, serializer: ZipcodeRateSerializer end diff --git a/app/controllers/v1/institutions_controller.rb b/app/controllers/v1/institutions_controller.rb index f5b1b73c0..d842e9b41 100644 --- a/app/controllers/v1/institutions_controller.rb +++ b/app/controllers/v1/institutions_controller.rb @@ -2,7 +2,7 @@ module V1 class InstitutionsController < ApiController - include Facets + include Search::Facets # GET /v1/institutions/autocomplete?term=harv def autocomplete @@ -88,7 +88,7 @@ def facility_codes def show resource = Institution.approved_institutions(@version).find_by(facility_code: params[:id]) - raise Common::Exceptions::RecordNotFound, params[:id] unless resource + raise Common::Exceptions::Internal::RecordNotFound, params[:id] unless resource @links = { self: self_link } render json: resource, serializer: InstitutionProfileSerializer, diff --git a/app/controllers/v1/zipcode_rates_controller.rb b/app/controllers/v1/zipcode_rates_controller.rb index d768f9c4a..246251bfc 100644 --- a/app/controllers/v1/zipcode_rates_controller.rb +++ b/app/controllers/v1/zipcode_rates_controller.rb @@ -6,7 +6,7 @@ class ZipcodeRatesController < ApiController def show resource = ZipcodeRate.joins(:version) .where(zip_code: params[:id], version: @version).order(:mha_rate).first - raise Common::Exceptions::RecordNotFound, params[:id] unless resource + raise Common::Exceptions::Internal::RecordNotFound, params[:id] unless resource render json: resource, serializer: ZipcodeRateSerializer end diff --git a/app/models/accreditation_action.rb b/app/models/accreditation_action.rb index 33c839797..ad632cc49 100644 --- a/app/models/accreditation_action.rb +++ b/app/models/accreditation_action.rb @@ -5,17 +5,17 @@ class AccreditationAction < ImportableRecord inverse_of: :accreditation_actions) CSV_CONVERTER_INFO = { - 'dapipid' => { column: :dapip_id, converter: NumberConverter }, - 'agencyid' => { column: :agency_id, converter: NumberConverter }, - 'agencyname' => { column: :agency_name, converter: InstitutionConverter }, - 'programid' => { column: :program_id, converter: NumberConverter }, - 'programname' => { column: :program_name, converter: BaseConverter }, - 'sequentialid' => { column: :sequential_id, converter: NumberConverter }, - 'actiondescription' => { column: :action_description, converter: BaseConverter }, - 'actiondate' => { column: :action_date, converter: AccreditationDateTimeConverter }, - 'justificationdescription' => { column: :justification_description, converter: BaseConverter }, - 'justificationother' => { column: :justification_other, converter: BaseConverter }, - 'enddate' => { column: :end_date, converter: BaseConverter } + 'dapipid' => { column: :dapip_id, converter: Converters::NumberConverter }, + 'agencyid' => { column: :agency_id, converter: Converters::NumberConverter }, + 'agencyname' => { column: :agency_name, converter: Converters::InstitutionConverter }, + 'programid' => { column: :program_id, converter: Converters::NumberConverter }, + 'programname' => { column: :program_name, converter: Converters::BaseConverter }, + 'sequentialid' => { column: :sequential_id, converter: Converters::NumberConverter }, + 'actiondescription' => { column: :action_description, converter: Converters::BaseConverter }, + 'actiondate' => { column: :action_date, converter: Converters::AccreditationDateTimeConverter }, + 'justificationdescription' => { column: :justification_description, converter: Converters::BaseConverter }, + 'justificationother' => { column: :justification_other, converter: Converters::BaseConverter }, + 'enddate' => { column: :end_date, converter: Converters::BaseConverter } }.freeze PROBATIONARY_STATUSES = [ diff --git a/app/models/accreditation_institute_campus.rb b/app/models/accreditation_institute_campus.rb index 818bb8c8d..0b8b03a79 100644 --- a/app/models/accreditation_institute_campus.rb +++ b/app/models/accreditation_institute_campus.rb @@ -11,19 +11,19 @@ class AccreditationInstituteCampus < ImportableRecord dependent: :nullify) CSV_CONVERTER_INFO = { - 'dapipid' => { column: :dapip_id, converter: NumberConverter }, - 'opeid' => { column: :ope, converter: OpeConverter }, - 'locationname' => { column: :location_name, converter: InstitutionConverter }, - 'parentname' => { column: :parent_name, converter: InstitutionConverter }, - 'parentdapipid' => { column: :parent_dapip_id, converter: NumberConverter }, - 'locationtype' => { column: :location_type, converter: BaseConverter }, - 'address' => { column: :address, converter: BaseConverter }, - 'generalphone' => { column: :general_phone, converter: BaseConverter }, - 'adminname' => { column: :admin_name, converter: BaseConverter }, - 'adminphone' => { column: :admin_phone, converter: BaseConverter }, - 'adminemail' => { column: :admin_email, converter: BaseConverter }, - 'fax' => { column: :fax, converter: BaseConverter }, - 'updatedate' => { column: :update_date, converter: DateConverter } + 'dapipid' => { column: :dapip_id, converter: Converters::NumberConverter }, + 'opeid' => { column: :ope, converter: Converters::OpeConverter }, + 'locationname' => { column: :location_name, converter: Converters::InstitutionConverter }, + 'parentname' => { column: :parent_name, converter: Converters::InstitutionConverter }, + 'parentdapipid' => { column: :parent_dapip_id, converter: Converters::NumberConverter }, + 'locationtype' => { column: :location_type, converter: Converters::BaseConverter }, + 'address' => { column: :address, converter: Converters::BaseConverter }, + 'generalphone' => { column: :general_phone, converter: Converters::BaseConverter }, + 'adminname' => { column: :admin_name, converter: Converters::BaseConverter }, + 'adminphone' => { column: :admin_phone, converter: Converters::BaseConverter }, + 'adminemail' => { column: :admin_email, converter: Converters::BaseConverter }, + 'fax' => { column: :fax, converter: Converters::BaseConverter }, + 'updatedate' => { column: :update_date, converter: Converters::DateConverter } }.freeze validates :dapip_id, presence: true @@ -33,6 +33,6 @@ class AccreditationInstituteCampus < ImportableRecord private def set_ope6 - self.ope6 = Ope6Converter.convert(ope) + self.ope6 = Converters::Ope6Converter.convert(ope) end end diff --git a/app/models/accreditation_record.rb b/app/models/accreditation_record.rb index 795f07374..6c983d13f 100644 --- a/app/models/accreditation_record.rb +++ b/app/models/accreditation_record.rb @@ -4,22 +4,23 @@ class AccreditationRecord < ImportableRecord belongs_to(:accreditation_institute_campus, foreign_key: 'dapip_id', primary_key: :dapip_id, inverse_of: :accreditation_records) - belongs_to(:accreditation_type_keyword, inverse_of: :accreditation_records) + # records may not have an accreditation_type_keyword + belongs_to(:accreditation_type_keyword, inverse_of: :accreditation_records, optional: true) CSV_CONVERTER_INFO = { - 'dapipid' => { column: :dapip_id, converter: NumberConverter }, - 'agencyid' => { column: :agency_id, converter: NumberConverter }, - 'agencyname' => { column: :agency_name, converter: InstitutionConverter }, - 'programid' => { column: :program_id, converter: NumberConverter }, - 'programname' => { column: :program_name, converter: BaseConverter }, - 'sequentialid' => { column: :sequential_id, converter: NumberConverter }, - 'initialdateflag' => { column: :initial_date_flag, converter: BaseConverter }, - 'accreditationdate' => { column: :accreditation_date, converter: DateConverter }, - 'accreditationstatus' => { column: :accreditation_status, converter: BaseConverter }, - 'reviewdate' => { column: :review_date, converter: DateConverter }, - 'departmentdescription' => { column: :department_description, converter: BaseConverter }, - 'accreditationenddate' => { column: :accreditation_end_date, converter: DateConverter }, - 'endingactionid' => { column: :ending_action_id, converter: NumberConverter } + 'dapipid' => { column: :dapip_id, converter: Converters::NumberConverter }, + 'agencyid' => { column: :agency_id, converter: Converters::NumberConverter }, + 'agencyname' => { column: :agency_name, converter: Converters::InstitutionConverter }, + 'programid' => { column: :program_id, converter: Converters::NumberConverter }, + 'programname' => { column: :program_name, converter: Converters::BaseConverter }, + 'sequentialid' => { column: :sequential_id, converter: Converters::NumberConverter }, + 'initialdateflag' => { column: :initial_date_flag, converter: Converters::BaseConverter }, + 'accreditationdate' => { column: :accreditation_date, converter: Converters::DateConverter }, + 'accreditationstatus' => { column: :accreditation_status, converter: Converters::BaseConverter }, + 'reviewdate' => { column: :review_date, converter: Converters::DateConverter }, + 'departmentdescription' => { column: :department_description, converter: Converters::BaseConverter }, + 'accreditationenddate' => { column: :accreditation_end_date, converter: Converters::DateConverter }, + 'endingactionid' => { column: :ending_action_id, converter: Converters::NumberConverter } }.freeze validates :dapip_id, presence: true diff --git a/app/models/arf_gi_bill.rb b/app/models/arf_gi_bill.rb index b6380d1ae..12eb5b411 100644 --- a/app/models/arf_gi_bill.rb +++ b/app/models/arf_gi_bill.rb @@ -2,13 +2,13 @@ class ArfGiBill < ImportableRecord CSV_CONVERTER_INFO = { - 'facility_no.' => { column: :facility_code, converter: FacilityCodeConverter }, - 'school_name' => { column: :institution, converter: InstitutionConverter }, - 'station' => { column: :station, converter: BaseConverter }, - 'count_of_adv_pay_students' => { column: :count_of_adv_pay_students, converter: NumberConverter }, - 'count_of_reg_students' => { column: :count_of_reg_students, converter: NumberConverter }, - 'total_count_of_students' => { column: :gibill, converter: NumberConverter }, - 'total_paid' => { column: :station, converter: NumberConverter } + 'facility_no.' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'school_name' => { column: :institution, converter: Converters::InstitutionConverter }, + 'station' => { column: :station, converter: Converters::BaseConverter }, + 'count_of_adv_pay_students' => { column: :count_of_adv_pay_students, converter: Converters::NumberConverter }, + 'count_of_reg_students' => { column: :count_of_reg_students, converter: Converters::NumberConverter }, + 'total_count_of_students' => { column: :gibill, converter: Converters::NumberConverter }, + 'total_paid' => { column: :station, converter: Converters::NumberConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/calculator_constant.rb b/app/models/calculator_constant.rb index 38c797521..333b5cf0d 100644 --- a/app/models/calculator_constant.rb +++ b/app/models/calculator_constant.rb @@ -2,9 +2,9 @@ class CalculatorConstant < ImportableRecord CSV_CONVERTER_INFO = { - 'name' => { column: :name, converter: UpcaseConverter }, - 'value' => { column: :float_value, converter: NumberConverter }, - 'description' => { column: :description, converter: BaseConverter } + 'name' => { column: :name, converter: Converters::UpcaseConverter }, + 'value' => { column: :float_value, converter: Converters::NumberConverter }, + 'description' => { column: :description, converter: Converters::BaseConverter } }.freeze default_scope { order('name') } diff --git a/app/models/census_lat_long.rb b/app/models/census_lat_long.rb index 80c5873d7..208db99cf 100644 --- a/app/models/census_lat_long.rb +++ b/app/models/census_lat_long.rb @@ -2,13 +2,13 @@ class CensusLatLong < ImportableRecord CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: BaseConverter }, - 'input_address' => { column: :input_address, converter: BaseConverter }, - 'tiger_address_range_match_indicator' => { column: :tiger_address_range_match_indicator, converter: BaseConverter }, - 'tiger_match_type' => { column: :tiger_match_type, converter: BaseConverter }, - 'tiger_output_address' => { column: :tiger_output_address, converter: BaseConverter }, - 'interpolated_longitude_latitude' => { column: :interpolated_longitude_latitude, converter: BaseConverter }, - 'tiger_line_id' => { column: :tiger_line_id, converter: BaseConverter }, - 'tiger_line_id_side' => { column: :tiger_line_id_side, converter: BaseConverter } + 'facility_code' => { column: :facility_code, converter: Converters::BaseConverter }, + 'input_address' => { column: :input_address, converter: Converters::BaseConverter }, + 'tiger_address_range_match_indicator' => { column: :tiger_address_range_match_indicator, converter: Converters::BaseConverter }, + 'tiger_match_type' => { column: :tiger_match_type, converter: Converters::BaseConverter }, + 'tiger_output_address' => { column: :tiger_output_address, converter: Converters::BaseConverter }, + 'interpolated_longitude_latitude' => { column: :interpolated_longitude_latitude, converter: Converters::BaseConverter }, + 'tiger_line_id' => { column: :tiger_line_id, converter: Converters::BaseConverter }, + 'tiger_line_id_side' => { column: :tiger_line_id_side, converter: Converters::BaseConverter } }.freeze end diff --git a/app/models/cip_code.rb b/app/models/cip_code.rb index ee160fbb5..ad9b53e10 100644 --- a/app/models/cip_code.rb +++ b/app/models/cip_code.rb @@ -2,13 +2,13 @@ class CipCode < ImportableRecord CSV_CONVERTER_INFO = { - 'cipfamily' => { column: :cip_family, converter: BaseConverter }, - 'cipcode' => { column: :cip_code, converter: BaseConverter }, - 'action' => { column: :action, converter: BaseConverter }, - 'textchange' => { column: :text_change, converter: BooleanConverter }, - 'ciptitle' => { column: :cip_title, converter: BaseConverter }, - 'cipdefinition' => { column: :cip_definition, converter: BaseConverter }, - 'crossreferences' => { column: :cross_references, converter: BaseConverter }, - 'examples' => { column: :examples, converter: BaseConverter } + 'cipfamily' => { column: :cip_family, converter: Converters::BaseConverter }, + 'cipcode' => { column: :cip_code, converter: Converters::BaseConverter }, + 'action' => { column: :action, converter: Converters::BaseConverter }, + 'textchange' => { column: :text_change, converter: Converters::BooleanConverter }, + 'ciptitle' => { column: :cip_title, converter: Converters::BaseConverter }, + 'cipdefinition' => { column: :cip_definition, converter: Converters::BaseConverter }, + 'crossreferences' => { column: :cross_references, converter: Converters::BaseConverter }, + 'examples' => { column: :examples, converter: Converters::BaseConverter } }.freeze end diff --git a/app/models/complaint.rb b/app/models/complaint.rb index 0eff778f1..fdd88d02c 100644 --- a/app/models/complaint.rb +++ b/app/models/complaint.rb @@ -62,20 +62,20 @@ class Complaint < ImportableRecord }.freeze CSV_CONVERTER_INFO = { - 'case_id' => { column: :case_id, converter: BaseConverter }, - 'escalation_level' => { column: :level, converter: BaseConverter }, - 'status' => { column: :status, converter: DowncaseConverter }, - 'case_owner' => { column: :case_owner, converter: BaseConverter }, - 'school_name' => { column: :institution, converter: InstitutionConverter }, - 'opeid' => { column: :ope, converter: OpeConverter }, - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'school_city' => { column: :city, converter: BaseConverter }, - 'school_state' => { column: :state, converter: StateConverter }, - 'date/time_opened' => { column: :submitted, converter: DateTimeConverter }, - 'date_closed' => { column: :closed, converter: DateConverter }, - 'sub_status' => { column: :closed_reason, converter: DowncaseConverter }, - 'issue' => { column: :issues, converter: BaseConverter }, - 'va_education_program' => { column: :education_benefits, converter: BaseConverter } + 'case_id' => { column: :case_id, converter: Converters::BaseConverter }, + 'escalation_level' => { column: :level, converter: Converters::BaseConverter }, + 'status' => { column: :status, converter: Converters::DowncaseConverter }, + 'case_owner' => { column: :case_owner, converter: Converters::BaseConverter }, + 'school_name' => { column: :institution, converter: Converters::InstitutionConverter }, + 'opeid' => { column: :ope, converter: Converters::OpeConverter }, + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'school_city' => { column: :city, converter: Converters::BaseConverter }, + 'school_state' => { column: :state, converter: Converters::StateConverter }, + 'date/time_opened' => { column: :submitted, converter: Converters::DateTimeConverter }, + 'date_closed' => { column: :closed, converter: Converters::DateConverter }, + 'sub_status' => { column: :closed_reason, converter: Converters::DowncaseConverter }, + 'issue' => { column: :issues, converter: Converters::BaseConverter }, + 'va_education_program' => { column: :education_benefits, converter: Converters::BaseConverter } }.freeze validates :facility_code, presence: true @@ -83,7 +83,7 @@ class Complaint < ImportableRecord after_initialize :derive_dependent_columns def derive_dependent_columns - self.ope6 = Ope6Converter.convert(ope) + self.ope6 = Converters::Ope6Converter.convert(ope) set_facility_code_complaint if ok_to_sum? end diff --git a/app/models/converters/accreditation_date_time_converter.rb b/app/models/converters/accreditation_date_time_converter.rb index 0c8fe3c8c..b70f39c92 100644 --- a/app/models/converters/accreditation_date_time_converter.rb +++ b/app/models/converters/accreditation_date_time_converter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AccreditationDateTimeConverter < BaseConverter +class Converters::AccreditationDateTimeConverter < Converters::BaseConverter def self.convert(value) value = super(value) return nil if value.blank? diff --git a/app/models/converters/base_converter.rb b/app/models/converters/base_converter.rb index 6c9e16fc0..6ff14761c 100644 --- a/app/models/converters/base_converter.rb +++ b/app/models/converters/base_converter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class BaseConverter +class Converters::BaseConverter def self.convert(value) return value if value.nil? || !value.is_a?(String) diff --git a/app/models/converters/boolean_converter.rb b/app/models/converters/boolean_converter.rb index 78bfccb7a..26293d75b 100644 --- a/app/models/converters/boolean_converter.rb +++ b/app/models/converters/boolean_converter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class BooleanConverter < BaseConverter +class Converters::BooleanConverter < Converters::BaseConverter def self.convert(value) value = super(value) diff --git a/app/models/converters/cross_converter.rb b/app/models/converters/cross_converter.rb index a0d937113..c6abfe2aa 100644 --- a/app/models/converters/cross_converter.rb +++ b/app/models/converters/cross_converter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CrossConverter < BaseConverter +class Converters::CrossConverter < Converters::BaseConverter def self.convert(value) value = super(value.to_s) value.blank? ? nil : value.upcase diff --git a/app/models/converters/date_converter.rb b/app/models/converters/date_converter.rb index 8bc1dfa5f..b671e2b3f 100644 --- a/app/models/converters/date_converter.rb +++ b/app/models/converters/date_converter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class DateConverter < BaseConverter +class Converters::DateConverter < Converters::BaseConverter def self.convert(value) value = super(value) diff --git a/app/models/converters/date_time_converter.rb b/app/models/converters/date_time_converter.rb index 695077657..2211ed42b 100644 --- a/app/models/converters/date_time_converter.rb +++ b/app/models/converters/date_time_converter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class DateTimeConverter < BaseConverter +class Converters::DateTimeConverter < Converters::BaseConverter def self.convert(value) value = super(value) return nil if value.blank? @@ -10,7 +10,7 @@ def self.convert(value) return value if value.instance_of?(Date) - # Added this here because you can't dynamically decide to use the DateConverter or DateTimeConverter. + # Added this here because you can't dynamically decide to use the Converters::DateConverter or DateTimeConverter. # It is declared as part of the model's upload. There's a situation with the complaint model where the # initial upload type is a date/time but when an export is performed, it gets exported as a date. The upload # of the exxport is a string of the form "yyyy-mm-dd". We have to be able to handle this situation. diff --git a/app/models/converters/display_converter.rb b/app/models/converters/display_converter.rb index e72aba594..da340cd57 100644 --- a/app/models/converters/display_converter.rb +++ b/app/models/converters/display_converter.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Mostly for display only fields not used in comparisons -class DisplayConverter < BaseConverter +class Converters::DisplayConverter < Converters::BaseConverter def self.convert(value) value = super(value.to_s) value.blank? ? nil : value.gsub(/\w+/, &:capitalize) diff --git a/app/models/converters/downcase_converter.rb b/app/models/converters/downcase_converter.rb index a5f029bd8..d066467ea 100644 --- a/app/models/converters/downcase_converter.rb +++ b/app/models/converters/downcase_converter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class DowncaseConverter < BaseConverter +class Converters::DowncaseConverter < Converters::BaseConverter def self.convert(value) value = super(value.to_s) value.blank? ? nil : value.downcase diff --git a/app/models/converters/facility_code_converter.rb b/app/models/converters/facility_code_converter.rb index 61f1a3fc9..ec18a26d6 100644 --- a/app/models/converters/facility_code_converter.rb +++ b/app/models/converters/facility_code_converter.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Right justifies facility_code to 8 characters using zeroes and ensures uppercase. -class FacilityCodeConverter < BaseConverter +class Converters::FacilityCodeConverter < Converters::BaseConverter def self.convert(value) value = super(value.to_s) value = value.gsub('-', '') if value diff --git a/app/models/converters/institution_converter.rb b/app/models/converters/institution_converter.rb index 933f058d7..c97ce1ab8 100644 --- a/app/models/converters/institution_converter.rb +++ b/app/models/converters/institution_converter.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Right stips and upcases institution names. -class InstitutionConverter < BaseConverter +class Converters::InstitutionConverter < Converters::BaseConverter def self.convert(value) value = super(value.to_s) value.blank? ? nil : value.upcase diff --git a/app/models/converters/number_converter.rb b/app/models/converters/number_converter.rb index e018cddfa..47d3c26ce 100644 --- a/app/models/converters/number_converter.rb +++ b/app/models/converters/number_converter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class NumberConverter < BaseConverter +class Converters::NumberConverter < Converters::BaseConverter def self.convert(value) value = super(value.to_s) value.blank? ? nil : value.gsub(/[$,+]/, '') diff --git a/app/models/converters/ope6_converter.rb b/app/models/converters/ope6_converter.rb index 0b6735f28..e87f37513 100644 --- a/app/models/converters/ope6_converter.rb +++ b/app/models/converters/ope6_converter.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # converts an ope to an ope6 -class Ope6Converter < OpeConverter +class Converters::Ope6Converter < Converters::OpeConverter def self.convert(value) value = super(value.to_s) value.blank? ? nil : value[1, 5] diff --git a/app/models/converters/ope_converter.rb b/app/models/converters/ope_converter.rb index 392794a59..f00a98f1a 100644 --- a/app/models/converters/ope_converter.rb +++ b/app/models/converters/ope_converter.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Right justifies ope to 8 characters using 0s. -class OpeConverter < BaseConverter +class Converters::OpeConverter < Converters::BaseConverter def self.convert(value) value = super(value.to_s) value.blank? ? nil : value.rjust(8, '0') diff --git a/app/models/converters/school_rating_converter.rb b/app/models/converters/school_rating_converter.rb index eb92d6f3b..edc8e6eb9 100644 --- a/app/models/converters/school_rating_converter.rb +++ b/app/models/converters/school_rating_converter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class SchoolRatingConverter < BaseConverter +class Converters::SchoolRatingConverter < Converters::BaseConverter def self.convert(value) # allow non-numeric values and let validation handle it return value unless value.is_a? Numeric diff --git a/app/models/converters/state_converter.rb b/app/models/converters/state_converter.rb index 0d0663bc4..0b1dea06f 100644 --- a/app/models/converters/state_converter.rb +++ b/app/models/converters/state_converter.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Checks and converts states and protectorates to standardized abbreviations. -class StateConverter < BaseConverter +class Converters::StateConverter < Converters::BaseConverter STATES = { 'AK' => 'ALASKA', 'AL' => 'ALABAMA', 'AR' => 'ARKANSAS', 'AS' => 'AMERICAN SAMOA', 'AZ' => 'ARIZONA', 'CA' => 'CALIFORNIA', 'CO' => 'COLORADO', 'CT' => 'CONNECTICUT', diff --git a/app/models/converters/upcase_converter.rb b/app/models/converters/upcase_converter.rb index caf2475da..98f9276d3 100644 --- a/app/models/converters/upcase_converter.rb +++ b/app/models/converters/upcase_converter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class UpcaseConverter < BaseConverter +class Converters::UpcaseConverter < Converters::BaseConverter def self.convert(value) value = super(value.to_s) value.blank? ? nil : value.upcase diff --git a/app/models/converters/zip_converter.rb b/app/models/converters/zip_converter.rb index c24f8bc87..10db45f06 100644 --- a/app/models/converters/zip_converter.rb +++ b/app/models/converters/zip_converter.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Right justifies zip to 5 characters using 0s. -class ZipConverter < BaseConverter +class Converters::ZipConverter < Converters::BaseConverter def self.convert(value) value = super(value.to_s) value.blank? ? nil : value.rjust(5, '0') diff --git a/app/models/crosswalk.rb b/app/models/crosswalk.rb index 84c17ee4f..8e5c8b63e 100644 --- a/app/models/crosswalk.rb +++ b/app/models/crosswalk.rb @@ -4,13 +4,13 @@ class Crosswalk < ImportableRecord COLS_USED_IN_INSTITUTION = %i[ope cross ope6].freeze CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'institution_name' => { column: :institution, converter: InstitutionConverter }, - 'city' => { column: :city, converter: BaseConverter }, - 'state' => { column: :state, converter: BaseConverter }, - 'ipeds' => { column: :cross, converter: CrossConverter }, - 'ope' => { column: :ope, converter: OpeConverter }, - 'notes' => { column: :notes, converter: BaseConverter } + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'institution_name' => { column: :institution, converter: Converters::InstitutionConverter }, + 'city' => { column: :city, converter: Converters::BaseConverter }, + 'state' => { column: :state, converter: Converters::BaseConverter }, + 'ipeds' => { column: :cross, converter: Converters::CrossConverter }, + 'ope' => { column: :ope, converter: Converters::OpeConverter }, + 'notes' => { column: :notes, converter: Converters::BaseConverter } }.freeze has_many :crosswalk_issue, dependent: :delete_all @@ -19,6 +19,6 @@ class Crosswalk < ImportableRecord # Instance methods def derive_dependent_columns - self.ope6 = Ope6Converter.convert(ope) + self.ope6 = Converters::Ope6Converter.convert(ope) end end diff --git a/app/models/crosswalk_issue.rb b/app/models/crosswalk_issue.rb index 9da5ebd6b..0036f411e 100644 --- a/app/models/crosswalk_issue.rb +++ b/app/models/crosswalk_issue.rb @@ -1,14 +1,16 @@ # frozen_string_literal: true class CrosswalkIssue < ApplicationRecord - include RooHelper + include RooHelper::Shared PARTIAL_MATCH_TYPE = 'PARTIAL_MATCH_TYPE' IPEDS_ORPHAN_TYPE = 'IPEDS_ORPHAN_TYPE' - belongs_to :crosswalk - belongs_to :ipeds_hd - belongs_to :weam + belongs_to :crosswalk, optional: true + belongs_to :ipeds_hd, optional: true + belongs_to :weam, optional: true + + validate :at_least_one_parent_is_set scope :by_issue_type, ->(n) { where(issue_type: n) } @@ -134,4 +136,10 @@ def weam_crosswalk_match? weam.present? && crosswalk.present? && weam.cross == crosswalk.cross && weam.ope == crosswalk.ope end + + def at_least_one_parent_is_set + return if weam_id.present? || ipeds_hd_id.present? || crosswalk_id.present? + + errors.add :base, :invalid, message: 'At least one weam or iped or crosswalk must be set' + end end diff --git a/app/models/edu_program.rb b/app/models/edu_program.rb index f59f6c108..249c74809 100644 --- a/app/models/edu_program.rb +++ b/app/models/edu_program.rb @@ -2,20 +2,20 @@ class EduProgram < ImportableRecord CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'institution_name' => { column: :institution_name, converter: InstitutionConverter }, - 'school_locale' => { column: :school_locale, converter: BaseConverter }, - 'provider_website' => { column: :provider_website, converter: BaseConverter }, - 'provider_email_address' => { column: :provider_email_address, converter: BaseConverter }, - 'phone_area_code' => { column: :phone_area_code, converter: BaseConverter }, - 'phone_number' => { column: :phone_number, converter: BaseConverter }, - 'student_vet_group' => { column: :student_vet_group, converter: BaseConverter }, - 'student_vet_group_website' => { column: :student_vet_group_website, converter: BaseConverter }, - 'vet_success_name' => { column: :vet_success_name, converter: BaseConverter }, - 'vet_success_email' => { column: :vet_success_email, converter: BaseConverter }, - 'vet_tec_program' => { column: :vet_tec_program, converter: BaseConverter }, - 'tuition_amount' => { column: :tuition_amount, converter: NumberConverter }, - 'program_length' => { column: :length_in_weeks, converter: NumberConverter } + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'institution_name' => { column: :institution_name, converter: Converters::InstitutionConverter }, + 'school_locale' => { column: :school_locale, converter: Converters::BaseConverter }, + 'provider_website' => { column: :provider_website, converter: Converters::BaseConverter }, + 'provider_email_address' => { column: :provider_email_address, converter: Converters::BaseConverter }, + 'phone_area_code' => { column: :phone_area_code, converter: Converters::BaseConverter }, + 'phone_number' => { column: :phone_number, converter: Converters::BaseConverter }, + 'student_vet_group' => { column: :student_vet_group, converter: Converters::BaseConverter }, + 'student_vet_group_website' => { column: :student_vet_group_website, converter: Converters::BaseConverter }, + 'vet_success_name' => { column: :vet_success_name, converter: Converters::BaseConverter }, + 'vet_success_email' => { column: :vet_success_email, converter: Converters::BaseConverter }, + 'vet_tec_program' => { column: :vet_tec_program, converter: Converters::BaseConverter }, + 'tuition_amount' => { column: :tuition_amount, converter: Converters::NumberConverter }, + 'program_length' => { column: :length_in_weeks, converter: Converters::NumberConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/eight_key.rb b/app/models/eight_key.rb index f5e30e0c5..3dd3a1d3b 100644 --- a/app/models/eight_key.rb +++ b/app/models/eight_key.rb @@ -2,12 +2,12 @@ class EightKey < ImportableRecord CSV_CONVERTER_INFO = { - 'institution_of_higher_education' => { column: :institution, converter: InstitutionConverter }, - 'city' => { column: :city, converter: BaseConverter }, - 'state' => { column: :state, converter: BaseConverter }, - 'opeid' => { column: :ope, converter: OpeConverter }, - 'ipeds_id' => { column: :cross, converter: CrossConverter }, - 'notes' => { column: :notes, converter: BaseConverter } + 'institution_of_higher_education' => { column: :institution, converter: Converters::InstitutionConverter }, + 'city' => { column: :city, converter: Converters::BaseConverter }, + 'state' => { column: :state, converter: Converters::BaseConverter }, + 'opeid' => { column: :ope, converter: Converters::OpeConverter }, + 'ipeds_id' => { column: :cross, converter: Converters::CrossConverter }, + 'notes' => { column: :notes, converter: Converters::BaseConverter } }.freeze validate :ope_or_cross @@ -25,6 +25,6 @@ def ope_or_cross end def derive_dependent_columns - self.ope6 = Ope6Converter.convert(ope) + self.ope6 = Converters::Ope6Converter.convert(ope) end end diff --git a/app/models/errors/csv_type_error.rb b/app/models/errors/csv_type_error.rb index 4421a3ef7..59a01614f 100644 --- a/app/models/errors/csv_type_error.rb +++ b/app/models/errors/csv_type_error.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CsvTypeError < StandardError +class Errors::CsvTypeError < StandardError attr_reader :csv_type def initialize(type) diff --git a/app/models/group.rb b/app/models/group.rb index 90445c3e5..38e07fe4e 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class Group < Upload - include RooHelper + include RooHelper::Loader + include RooHelper::Shared attr_accessor :sheet_type_list, :group_config diff --git a/app/models/hcm.rb b/app/models/hcm.rb index 4460aad84..bd28a93dd 100644 --- a/app/models/hcm.rb +++ b/app/models/hcm.rb @@ -2,14 +2,14 @@ class Hcm < ImportableRecord CSV_CONVERTER_INFO = { - 'ope_id' => { column: :ope, converter: OpeConverter }, - 'institution_name' => { column: :institution, converter: InstitutionConverter }, - 'city' => { column: :city, converter: BaseConverter }, - 'state' => { column: :state, converter: BaseConverter }, - 'country' => { column: :country, converter: BaseConverter }, - 'institution_type' => { column: :institution_type, converter: BaseConverter }, - 'stop_pay/monitor_method' => { column: :hcm_type, converter: BaseConverter }, - 'method_reason_desc' => { column: :hcm_reason, converter: BaseConverter } + 'ope_id' => { column: :ope, converter: Converters::OpeConverter }, + 'institution_name' => { column: :institution, converter: Converters::InstitutionConverter }, + 'city' => { column: :city, converter: Converters::BaseConverter }, + 'state' => { column: :state, converter: Converters::BaseConverter }, + 'country' => { column: :country, converter: Converters::BaseConverter }, + 'institution_type' => { column: :institution_type, converter: Converters::BaseConverter }, + 'stop_pay/monitor_method' => { column: :hcm_type, converter: Converters::BaseConverter }, + 'method_reason_desc' => { column: :hcm_reason, converter: Converters::BaseConverter } }.freeze validates :ope, :hcm_type, :hcm_reason, presence: true @@ -17,6 +17,6 @@ class Hcm < ImportableRecord after_initialize :derive_dependent_columns def derive_dependent_columns - self.ope6 = Ope6Converter.convert(ope) + self.ope6 = Converters::Ope6Converter.convert(ope) end end diff --git a/app/models/importable_record.rb b/app/models/importable_record.rb index ba5291e81..0cce9f773 100644 --- a/app/models/importable_record.rb +++ b/app/models/importable_record.rb @@ -3,7 +3,8 @@ require 'roo_helper/shared' class ImportableRecord < ApplicationRecord - include RooHelper + include RooHelper::Loader + include RooHelper::Shared self.abstract_class = true diff --git a/app/models/institution.rb b/app/models/institution.rb index eeb327d61..6d00ffb81 100644 --- a/app/models/institution.rb +++ b/app/models/institution.rb @@ -39,193 +39,193 @@ class Institution < ImportableRecord # Do not change the order of these attributes or add columns. This is used to upload to # another system. CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'institution' => { column: :institution, converter: InstitutionConverter }, - 'city' => { column: :city, converter: UpcaseConverter }, - 'state' => { column: :state, converter: StateConverter }, - 'zip' => { column: :zip, converter: ZipConverter }, - 'country' => { column: :country, converter: UpcaseConverter }, - 'type' => { column: :institution_type_name, converter: UpcaseConverter }, - 'approved' => { column: :approved, converter: BooleanConverter }, - 'correspondence' => { column: :correspondence, converter: BooleanConverter }, - 'flight' => { column: :flight, converter: BooleanConverter }, - 'bah' => { column: :bah, converter: NumberConverter }, - 'cross' => { column: :cross, converter: CrossConverter }, - 'ope' => { column: :ope, converter: OpeConverter }, - 'ope6' => { column: :ope6, converter: Ope6Converter }, - 'school_system_name' => { column: :f1sysnam, converter: BaseConverter }, - 'school_system_code' => { column: :f1syscod, converter: NumberConverter }, - 'alias' => { column: :ialias, converter: BaseConverter }, - 'insturl' => { column: :insturl, converter: BaseConverter }, - 'vet_tuition_policy_url' => { column: :vet_tuition_policy_url, converter: BaseConverter }, - 'pred_degree_awarded' => { column: :pred_degree_awarded, converter: NumberConverter }, - 'locale' => { column: :locale, converter: NumberConverter }, - 'gibill' => { column: :gibill, converter: NumberConverter }, - 'undergrad_enrollment' => { column: :undergrad_enrollment, converter: NumberConverter }, - 'yr' => { column: :yr, converter: BooleanConverter }, - 'student_veteran' => { column: :student_veteran, converter: BooleanConverter }, - 'student_veteran_link' => { column: :student_veteran_link, converter: BaseConverter }, - 'poe' => { column: :poe, converter: BooleanConverter }, - 'eight_keys' => { column: :eight_keys, converter: BooleanConverter }, - 'dodmou' => { column: :dodmou, converter: BooleanConverter }, - 'sec_702' => { column: :sec_702, converter: BooleanConverter }, - 'vetsuccess_name' => { column: :vetsuccess_name, converter: BaseConverter }, - 'vetsuccess_email' => { column: :vetsuccess_email, converter: BaseConverter }, - 'credit_for_mil_training' => { column: :credit_for_mil_training, converter: BooleanConverter }, - 'vet_poc' => { column: :vet_poc, converter: BooleanConverter }, - 'student_vet_grp_ipeds' => { column: :student_vet_grp_ipeds, converter: BooleanConverter }, - 'soc_member' => { column: :soc_member, converter: BooleanConverter }, - 'va_highest_degree_offered' => { column: :va_highest_degree_offered, converter: BaseConverter }, - 'retention_rate_veteran_ba' => { column: :retention_rate_veteran_ba, converter: NumberConverter }, - 'retention_all_students_ba' => { column: :retention_all_students_ba, converter: NumberConverter }, - 'retention_rate_veteran_otb' => { column: :retention_rate_veteran_otb, converter: NumberConverter }, - 'retention_all_students_otb' => { column: :retention_all_students_otb, converter: NumberConverter }, - 'persistance_rate_veteran_ba' => { column: :persistance_rate_veteran_ba, converter: NumberConverter }, - 'persistance_rate_veteran_otb' => { column: :persistance_rate_veteran_otb, converter: NumberConverter }, - 'graduation_rate_veteran' => { column: :graduation_rate_veteran, converter: NumberConverter }, - 'graduation_rate_all_students' => { column: :graduation_rate_all_students, converter: NumberConverter }, - 'transfer_out_rate_veteran' => { column: :transfer_out_rate_veteran, converter: NumberConverter }, - 'transfer_out_rate_all_students' => { column: :transfer_out_rate_all_students, converter: NumberConverter }, - 'salary_all_students' => { column: :salary_all_students, converter: NumberConverter }, - 'repayment_rate_all_students' => { column: :repayment_rate_all_students, converter: NumberConverter }, - 'avg_stu_loan_debt' => { column: :avg_stu_loan_debt, converter: NumberConverter }, - 'calendar' => { column: :calendar, converter: BaseConverter }, - 'tuition_in_state' => { column: :tuition_in_state, converter: NumberConverter }, - 'tuition_out_of_state' => { column: :tuition_out_of_state, converter: NumberConverter }, - 'books' => { column: :books, converter: NumberConverter }, - 'online_all' => { column: :online_all, converter: BooleanConverter }, - 'p911_tuition_fees' => { column: :p911_tuition_fees, converter: NumberConverter }, - 'p911_recipients' => { column: :p911_recipients, converter: NumberConverter }, - 'p911_yellow_ribbon' => { column: :p911_yellow_ribbon, converter: NumberConverter }, - 'p911_yr_recipients' => { column: :p911_yr_recipients, converter: NumberConverter }, - 'accredited' => { column: :accredited, converter: BooleanConverter }, - 'accreditation_type' => { column: :accreditation_type, converter: BaseConverter }, - 'accreditation_status' => { column: :accreditation_status, converter: BaseConverter }, - 'caution_flag' => { column: :caution_flag, converter: BooleanConverter }, - 'caution_flag_reason' => { column: :caution_flag_reason, converter: BaseConverter }, - 'school_closing' => { column: :school_closing, converter: BooleanConverter }, - 'school_closing_on' => { column: :school_closing_on, converter: DateConverter }, - 'school_closing_message' => { column: :school_closing_message, converter: BaseConverter }, - 'closure109' => { column: :closure109, converter: BooleanConverter }, - 'complaints_facility_code' => { column: :complaints_facility_code, converter: NumberConverter }, - 'complaints_financial_by_fac_code' => { column: :complaints_financial_by_fac_code, converter: NumberConverter }, - 'complaints_quality_by_fac_code' => { column: :complaints_quality_by_fac_code, converter: NumberConverter }, - 'complaints_refund_by_fac_code' => { column: :complaints_refund_by_fac_code, converter: NumberConverter }, - 'complaints_marketing_by_fac_code' => { column: :complaints_marketing_by_fac_code, converter: NumberConverter }, + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'institution' => { column: :institution, converter: Converters::InstitutionConverter }, + 'city' => { column: :city, converter: Converters::UpcaseConverter }, + 'state' => { column: :state, converter: Converters::StateConverter }, + 'zip' => { column: :zip, converter: Converters::ZipConverter }, + 'country' => { column: :country, converter: Converters::UpcaseConverter }, + 'type' => { column: :institution_type_name, converter: Converters::UpcaseConverter }, + 'approved' => { column: :approved, converter: Converters::BooleanConverter }, + 'correspondence' => { column: :correspondence, converter: Converters::BooleanConverter }, + 'flight' => { column: :flight, converter: Converters::BooleanConverter }, + 'bah' => { column: :bah, converter: Converters::NumberConverter }, + 'cross' => { column: :cross, converter: Converters::CrossConverter }, + 'ope' => { column: :ope, converter: Converters::OpeConverter }, + 'ope6' => { column: :ope6, converter: Converters::Ope6Converter }, + 'school_system_name' => { column: :f1sysnam, converter: Converters::BaseConverter }, + 'school_system_code' => { column: :f1syscod, converter: Converters::NumberConverter }, + 'alias' => { column: :ialias, converter: Converters::BaseConverter }, + 'insturl' => { column: :insturl, converter: Converters::BaseConverter }, + 'vet_tuition_policy_url' => { column: :vet_tuition_policy_url, converter: Converters::BaseConverter }, + 'pred_degree_awarded' => { column: :pred_degree_awarded, converter: Converters::NumberConverter }, + 'locale' => { column: :locale, converter: Converters::NumberConverter }, + 'gibill' => { column: :gibill, converter: Converters::NumberConverter }, + 'undergrad_enrollment' => { column: :undergrad_enrollment, converter: Converters::NumberConverter }, + 'yr' => { column: :yr, converter: Converters::BooleanConverter }, + 'student_veteran' => { column: :student_veteran, converter: Converters::BooleanConverter }, + 'student_veteran_link' => { column: :student_veteran_link, converter: Converters::BaseConverter }, + 'poe' => { column: :poe, converter: Converters::BooleanConverter }, + 'eight_keys' => { column: :eight_keys, converter: Converters::BooleanConverter }, + 'dodmou' => { column: :dodmou, converter: Converters::BooleanConverter }, + 'sec_702' => { column: :sec_702, converter: Converters::BooleanConverter }, + 'vetsuccess_name' => { column: :vetsuccess_name, converter: Converters::BaseConverter }, + 'vetsuccess_email' => { column: :vetsuccess_email, converter: Converters::BaseConverter }, + 'credit_for_mil_training' => { column: :credit_for_mil_training, converter: Converters::BooleanConverter }, + 'vet_poc' => { column: :vet_poc, converter: Converters::BooleanConverter }, + 'student_vet_grp_ipeds' => { column: :student_vet_grp_ipeds, converter: Converters::BooleanConverter }, + 'soc_member' => { column: :soc_member, converter: Converters::BooleanConverter }, + 'va_highest_degree_offered' => { column: :va_highest_degree_offered, converter: Converters::BaseConverter }, + 'retention_rate_veteran_ba' => { column: :retention_rate_veteran_ba, converter: Converters::NumberConverter }, + 'retention_all_students_ba' => { column: :retention_all_students_ba, converter: Converters::NumberConverter }, + 'retention_rate_veteran_otb' => { column: :retention_rate_veteran_otb, converter: Converters::NumberConverter }, + 'retention_all_students_otb' => { column: :retention_all_students_otb, converter: Converters::NumberConverter }, + 'persistance_rate_veteran_ba' => { column: :persistance_rate_veteran_ba, converter: Converters::NumberConverter }, + 'persistance_rate_veteran_otb' => { column: :persistance_rate_veteran_otb, converter: Converters::NumberConverter }, + 'graduation_rate_veteran' => { column: :graduation_rate_veteran, converter: Converters::NumberConverter }, + 'graduation_rate_all_students' => { column: :graduation_rate_all_students, converter: Converters::NumberConverter }, + 'transfer_out_rate_veteran' => { column: :transfer_out_rate_veteran, converter: Converters::NumberConverter }, + 'transfer_out_rate_all_students' => { column: :transfer_out_rate_all_students, converter: Converters::NumberConverter }, + 'salary_all_students' => { column: :salary_all_students, converter: Converters::NumberConverter }, + 'repayment_rate_all_students' => { column: :repayment_rate_all_students, converter: Converters::NumberConverter }, + 'avg_stu_loan_debt' => { column: :avg_stu_loan_debt, converter: Converters::NumberConverter }, + 'calendar' => { column: :calendar, converter: Converters::BaseConverter }, + 'tuition_in_state' => { column: :tuition_in_state, converter: Converters::NumberConverter }, + 'tuition_out_of_state' => { column: :tuition_out_of_state, converter: Converters::NumberConverter }, + 'books' => { column: :books, converter: Converters::NumberConverter }, + 'online_all' => { column: :online_all, converter: Converters::BooleanConverter }, + 'p911_tuition_fees' => { column: :p911_tuition_fees, converter: Converters::NumberConverter }, + 'p911_recipients' => { column: :p911_recipients, converter: Converters::NumberConverter }, + 'p911_yellow_ribbon' => { column: :p911_yellow_ribbon, converter: Converters::NumberConverter }, + 'p911_yr_recipients' => { column: :p911_yr_recipients, converter: Converters::NumberConverter }, + 'accredited' => { column: :accredited, converter: Converters::BooleanConverter }, + 'accreditation_type' => { column: :accreditation_type, converter: Converters::BaseConverter }, + 'accreditation_status' => { column: :accreditation_status, converter: Converters::BaseConverter }, + 'caution_flag' => { column: :caution_flag, converter: Converters::BooleanConverter }, + 'caution_flag_reason' => { column: :caution_flag_reason, converter: Converters::BaseConverter }, + 'school_closing' => { column: :school_closing, converter: Converters::BooleanConverter }, + 'school_closing_on' => { column: :school_closing_on, converter: Converters::DateConverter }, + 'school_closing_message' => { column: :school_closing_message, converter: Converters::BaseConverter }, + 'closure109' => { column: :closure109, converter: Converters::BooleanConverter }, + 'complaints_facility_code' => { column: :complaints_facility_code, converter: Converters::NumberConverter }, + 'complaints_financial_by_fac_code' => { column: :complaints_financial_by_fac_code, converter: Converters::NumberConverter }, + 'complaints_quality_by_fac_code' => { column: :complaints_quality_by_fac_code, converter: Converters::NumberConverter }, + 'complaints_refund_by_fac_code' => { column: :complaints_refund_by_fac_code, converter: Converters::NumberConverter }, + 'complaints_marketing_by_fac_code' => { column: :complaints_marketing_by_fac_code, converter: Converters::NumberConverter }, 'complaints_accreditation_by_fac_code' => { - column: :complaints_accreditation_by_fac_code, converter: NumberConverter + column: :complaints_accreditation_by_fac_code, converter: Converters::NumberConverter }, 'complaints_degree_requirements_by_fac_code' => { - column: :complaints_degree_requirements_by_fac_code, converter: NumberConverter + column: :complaints_degree_requirements_by_fac_code, converter: Converters::NumberConverter }, 'complaints_student_loans_by_fac_code' => { - column: :complaints_student_loans_by_fac_code, converter: NumberConverter + column: :complaints_student_loans_by_fac_code, converter: Converters::NumberConverter }, - 'complaints_grades_by_fac_code' => { column: :complaints_grades_by_fac_code, converter: NumberConverter }, + 'complaints_grades_by_fac_code' => { column: :complaints_grades_by_fac_code, converter: Converters::NumberConverter }, 'complaints_credit_transfer_by_fac_code' => { - column: :complaints_credit_transfer_by_fac_code, converter: NumberConverter + column: :complaints_credit_transfer_by_fac_code, converter: Converters::NumberConverter }, - 'complaints_job_by_fac_code' => { column: :complaints_job_by_fac_code, converter: NumberConverter }, - 'complaints_transcript_by_fac_code' => { column: :complaints_transcript_by_fac_code, converter: NumberConverter }, - 'complaints_other_by_fac_code' => { column: :complaints_other_by_fac_code, converter: NumberConverter }, - 'complaints_main_campus_roll_up' => { column: :complaints_main_campus_roll_up, converter: NumberConverter }, + 'complaints_job_by_fac_code' => { column: :complaints_job_by_fac_code, converter: Converters::NumberConverter }, + 'complaints_transcript_by_fac_code' => { column: :complaints_transcript_by_fac_code, converter: Converters::NumberConverter }, + 'complaints_other_by_fac_code' => { column: :complaints_other_by_fac_code, converter: Converters::NumberConverter }, + 'complaints_main_campus_roll_up' => { column: :complaints_main_campus_roll_up, converter: Converters::NumberConverter }, 'complaints_financial_by_ope_id_do_not_sum' => { - column: :complaints_financial_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_financial_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_quality_by_ope_id_do_not_sum' => { - column: :complaints_quality_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_quality_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_refund_by_ope_id_do_not_sum' => { - column: :complaints_refund_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_refund_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_marketing_by_ope_id_do_not_sum' => { - column: :complaints_marketing_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_marketing_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_accreditation_by_ope_id_do_not_sum' => { - column: :complaints_accreditation_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_accreditation_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_degree_requirements_by_ope_id_do_not_sum' => { - column: :complaints_degree_requirements_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_degree_requirements_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_student_loans_by_ope_id_do_not_sum' => { - column: :complaints_student_loans_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_student_loans_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_grades_by_ope_id_do_not_sum' => { - column: :complaints_grades_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_grades_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_credit_transfer_by_ope_id_do_not_sum' => { - column: :complaints_credit_transfer_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_credit_transfer_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_jobs_by_ope_id_do_not_sum' => { - column: :complaints_jobs_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_jobs_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_transcript_by_ope_id_do_not_sum' => { - column: :complaints_transcript_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_transcript_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, 'complaints_other_by_ope_id_do_not_sum' => { - column: :complaints_other_by_ope_id_do_not_sum, converter: NumberConverter + column: :complaints_other_by_ope_id_do_not_sum, converter: Converters::NumberConverter }, - 'complies_with_sec_103' => { column: :complies_with_sec_103, converter: BooleanConverter }, - 'solely_requires_coe' => { column: :solely_requires_coe, converter: BooleanConverter }, - 'requires_coe_and_criteria' => { column: :requires_coe_and_criteria, converter: BooleanConverter }, - 'poo_status' => { column: :poo_status, converter: BaseConverter }, - 'latitude' => { column: :latitude, converter: NumberConverter }, - 'longitude' => { column: :longitude, converter: NumberConverter }, - 'employer_provider' => { column: :employer_provider, converter: BooleanConverter }, - 'school_provider' => { column: :school_provider, converter: BooleanConverter }, - 'in_state_tuition_information' => { column: :in_state_tuition_information, converter: BaseConverter }, - 'vrrap_provider' => { column: :vrrap, converter: BooleanConverter }, - 'ownership_name' => { column: :ownership_name, converter: BaseConverter } + 'complies_with_sec_103' => { column: :complies_with_sec_103, converter: Converters::BooleanConverter }, + 'solely_requires_coe' => { column: :solely_requires_coe, converter: Converters::BooleanConverter }, + 'requires_coe_and_criteria' => { column: :requires_coe_and_criteria, converter: Converters::BooleanConverter }, + 'poo_status' => { column: :poo_status, converter: Converters::BaseConverter }, + 'latitude' => { column: :latitude, converter: Converters::NumberConverter }, + 'longitude' => { column: :longitude, converter: Converters::NumberConverter }, + 'employer_provider' => { column: :employer_provider, converter: Converters::BooleanConverter }, + 'school_provider' => { column: :school_provider, converter: Converters::BooleanConverter }, + 'in_state_tuition_information' => { column: :in_state_tuition_information, converter: Converters::BaseConverter }, + 'vrrap_provider' => { column: :vrrap, converter: Converters::BooleanConverter }, + 'ownership_name' => { column: :ownership_name, converter: Converters::BaseConverter } }.freeze # Used for full export of institution rows with all columns. # rubocop:disable Layout/FirstHashElementIndentation CSV_CONVERTER_INFO2 = CSV_CONVERTER_INFO.merge({ - 'version' => { column: :version, converter: NumberConverter }, - 'approval_status' => { column: :approval_status, converter: BaseConverter }, - 'stem_offered' => { column: :stem_offered, converter: BooleanConverter }, - 'priority_enrollment' => { column: :priority_enrollment, converter: BooleanConverter }, - 'online_only' => { column: :online_only, converter: BooleanConverter }, - 'independent_study' => { column: :independent_study, converter: BooleanConverter }, - 'distance_learning' => { column: :distance_learning, converter: BooleanConverter }, - 'address_1' => { column: :address_1, converter: BaseConverter }, - 'address_2' => { column: :address_2, converter: BaseConverter }, - 'address_3' => { column: :address_3, converter: BaseConverter }, - 'physical_address_1' => { column: :physical_address_1, converter: BaseConverter }, - 'physical_address_2' => { column: :physical_address_2, converter: BaseConverter }, - 'physical_address_3' => { column: :physical_address_3, converter: BaseConverter }, - 'physical_city' => { column: :physical_city, converter: BaseConverter }, - 'physical_state' => { column: :physical_state, converter: BaseConverter }, - 'physical_zip' => { column: :physical_zip, converter: BaseConverter }, - 'physical_country' => { column: :physical_country, converter: BaseConverter }, - 'dod_bah' => { column: :dod_bah, converter: NumberConverter }, - 'vet_tec_provider' => { column: :vet_tec_provider, converter: BooleanConverter }, - 'closure109' => { column: :closure109, converter: BooleanConverter }, - 'preferred_provider' => { column: :preferred_provider, converter: BooleanConverter }, - 'stem_indicator' => { column: :stem_indicator, converter: BooleanConverter }, - 'campus_type' => { column: :campus_type, converter: BaseConverter }, - 'parent_facility_code_id' => { column: :parent_facility_code_id, converter: BaseConverter }, - 'version_id' => { column: :version_id, converter: NumberConverter }, - 'hbcu' => { column: :hbcu, converter: NumberConverter }, - 'hcm2' => { column: :hcm2, converter: NumberConverter }, - 'menonly' => { column: :menonly, converter: NumberConverter }, - 'pctfloan' => { column: :pctfloan, converter: NumberConverter }, - 'relaffil' => { column: :relaffil, converter: NumberConverter }, - 'womenonly' => { column: :womenonly, converter: NumberConverter }, - 'institution_search' => { column: :institution_search, converter: BaseConverter }, - 'rating_count' => { column: :rating_count, converter: NumberConverter }, - 'rating_average' => { column: :rating_average, converter: NumberConverter }, - 'section_103_message' => { column: :section_103_message, converter: BaseConverter }, - 'bad_address' => { column: :bad_address, converter: BooleanConverter }, - 'high_school' => { column: :high_school, converter: BooleanConverter }, - 'chief_officer' => { column: :chief_officer, converter: BaseConverter }, - 'hsi' => { column: :hsi, converter: NumberConverter }, - 'nanti' => { column: :nanti, converter: NumberConverter }, - 'annhi' => { column: :annhi, converter: NumberConverter }, - 'aanapii' => { column: :aanapii, converter: NumberConverter }, - 'pbi' => { column: :pbi, converter: NumberConverter }, - 'tribal' => { column: :tribal, converter: NumberConverter }, - 'ungeocodable' => { column: :ungeocodable, converter: BooleanConverter } + 'version' => { column: :version, converter: Converters::NumberConverter }, + 'approval_status' => { column: :approval_status, converter: Converters::BaseConverter }, + 'stem_offered' => { column: :stem_offered, converter: Converters::BooleanConverter }, + 'priority_enrollment' => { column: :priority_enrollment, converter: Converters::BooleanConverter }, + 'online_only' => { column: :online_only, converter: Converters::BooleanConverter }, + 'independent_study' => { column: :independent_study, converter: Converters::BooleanConverter }, + 'distance_learning' => { column: :distance_learning, converter: Converters::BooleanConverter }, + 'address_1' => { column: :address_1, converter: Converters::BaseConverter }, + 'address_2' => { column: :address_2, converter: Converters::BaseConverter }, + 'address_3' => { column: :address_3, converter: Converters::BaseConverter }, + 'physical_address_1' => { column: :physical_address_1, converter: Converters::BaseConverter }, + 'physical_address_2' => { column: :physical_address_2, converter: Converters::BaseConverter }, + 'physical_address_3' => { column: :physical_address_3, converter: Converters::BaseConverter }, + 'physical_city' => { column: :physical_city, converter: Converters::BaseConverter }, + 'physical_state' => { column: :physical_state, converter: Converters::BaseConverter }, + 'physical_zip' => { column: :physical_zip, converter: Converters::BaseConverter }, + 'physical_country' => { column: :physical_country, converter: Converters::BaseConverter }, + 'dod_bah' => { column: :dod_bah, converter: Converters::NumberConverter }, + 'vet_tec_provider' => { column: :vet_tec_provider, converter: Converters::BooleanConverter }, + 'closure109' => { column: :closure109, converter: Converters::BooleanConverter }, + 'preferred_provider' => { column: :preferred_provider, converter: Converters::BooleanConverter }, + 'stem_indicator' => { column: :stem_indicator, converter: Converters::BooleanConverter }, + 'campus_type' => { column: :campus_type, converter: Converters::BaseConverter }, + 'parent_facility_code_id' => { column: :parent_facility_code_id, converter: Converters::BaseConverter }, + 'version_id' => { column: :version_id, converter: Converters::NumberConverter }, + 'hbcu' => { column: :hbcu, converter: Converters::NumberConverter }, + 'hcm2' => { column: :hcm2, converter: Converters::NumberConverter }, + 'menonly' => { column: :menonly, converter: Converters::NumberConverter }, + 'pctfloan' => { column: :pctfloan, converter: Converters::NumberConverter }, + 'relaffil' => { column: :relaffil, converter: Converters::NumberConverter }, + 'womenonly' => { column: :womenonly, converter: Converters::NumberConverter }, + 'institution_search' => { column: :institution_search, converter: Converters::BaseConverter }, + 'rating_count' => { column: :rating_count, converter: Converters::NumberConverter }, + 'rating_average' => { column: :rating_average, converter: Converters::NumberConverter }, + 'section_103_message' => { column: :section_103_message, converter: Converters::BaseConverter }, + 'bad_address' => { column: :bad_address, converter: Converters::BooleanConverter }, + 'high_school' => { column: :high_school, converter: Converters::BooleanConverter }, + 'chief_officer' => { column: :chief_officer, converter: Converters::BaseConverter }, + 'hsi' => { column: :hsi, converter: Converters::NumberConverter }, + 'nanti' => { column: :nanti, converter: Converters::NumberConverter }, + 'annhi' => { column: :annhi, converter: Converters::NumberConverter }, + 'aanapii' => { column: :aanapii, converter: Converters::NumberConverter }, + 'pbi' => { column: :pbi, converter: Converters::NumberConverter }, + 'tribal' => { column: :tribal, converter: Converters::NumberConverter }, + 'ungeocodable' => { column: :ungeocodable, converter: Converters::BooleanConverter } }).freeze # rubocop:enable Layout/FirstHashElementIndentation @@ -768,9 +768,7 @@ def self.set_special_mission_filters(query) latitude = query[:latitude] longitude = query[:longitude] - # rubocop:disable Layout/LineLength distance_column = 'earth_distance(ll_to_earth(:latitude,:longitude), ll_to_earth(latitude, longitude))/:conversion_rate distance' - # rubocop:enable Layout/LineLength clause = ['institutions.*', distance_column] @@ -788,9 +786,7 @@ def self.set_special_mission_filters(query) longitude = query[:longitude] distance = query[:distance] || 50 - # rubocop:disable Layout/LineLength clause = 'earth_distance(ll_to_earth(:latitude,:longitude), ll_to_earth(latitude, longitude))/:conversion_rate <= :distance' - # rubocop:enable Layout/LineLength where(sanitize_sql_for_conditions([clause, { latitude: latitude, diff --git a/app/models/institution_builder.rb b/app/models/institution_builder.rb index efefac67a..0a691c49b 100644 --- a/app/models/institution_builder.rb +++ b/app/models/institution_builder.rb @@ -98,7 +98,6 @@ def self.run(user) # rubocop:enable Rails/SkipsModelValidations end build_messages = run_insertions(version) - version.update(production: true, completed_at: Time.now.utc.to_s(:db)) GibctSiteMapper.new(ping: true) if production? Archiver.archive_previous_versions if Settings.archiver.archive @@ -298,7 +297,7 @@ def self.add_accreditation(version_id) #{where_clause} SQL - CautionFlag.build(version_id, AccreditationCautionFlag, caution_flag_clause) + CautionFlag.build(version_id, CautionFlagTemplates::AccreditationCautionFlag, caution_flag_clause) end def self.add_arf_gi_bill(version_id) @@ -369,7 +368,7 @@ def self.add_mou(version_id) AND institutions.version_id = #{version_id} SQL - CautionFlag.build(version_id, MouCautionFlag, caution_flag_clause) + CautionFlag.build(version_id, CautionFlagTemplates::MouCautionFlag, caution_flag_clause) end # Updates institution table as well as creates caution_flags @@ -420,7 +419,7 @@ def self.add_sec_702(version_id) #{where_conditions} SQL - CautionFlag.build(version_id, Sec702CautionFlag, caution_flag_clause) + CautionFlag.build(version_id, CautionFlagTemplates::Sec702CautionFlag, caution_flag_clause) end # Sets caution flags and caution flag reasons if the corresponding approved school (by IPEDs id) @@ -582,7 +581,7 @@ def self.add_hcm(version_id) AND institutions.version_id = #{version_id} SQL - CautionFlag.build(version_id, HcmCautionFlag, caution_flag_clause) + CautionFlag.build(version_id, CautionFlagTemplates::HcmCautionFlag, caution_flag_clause) end def self.add_complaint(version_id) diff --git a/app/models/institution_owner.rb b/app/models/institution_owner.rb index f631c4e01..546d9dc56 100644 --- a/app/models/institution_owner.rb +++ b/app/models/institution_owner.rb @@ -4,10 +4,10 @@ class InstitutionOwner < ImportableRecord COLS_USED_IN_INSTITUTION = %i[chief_officer ownership_name].freeze CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'institution_name' => { column: :institution_name, converter: InstitutionConverter }, - 'chief_officer' => { column: :chief_officer, converter: BaseConverter }, - 'ownership_name' => { column: :ownership_name, converter: BaseConverter } + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'institution_name' => { column: :institution_name, converter: Converters::InstitutionConverter }, + 'chief_officer' => { column: :chief_officer, converter: Converters::BaseConverter }, + 'ownership_name' => { column: :ownership_name, converter: Converters::BaseConverter } }.freeze validates :facility_code, :institution_name, presence: true diff --git a/app/models/institution_school_rating.rb b/app/models/institution_school_rating.rb index 20adc3e2d..2f60913ba 100644 --- a/app/models/institution_school_rating.rb +++ b/app/models/institution_school_rating.rb @@ -3,34 +3,34 @@ class InstitutionSchoolRating < ImportableRecord # keys need an underscore instead of spaces or hyphens because the converter replaces them with underscores CSV_CONVERTER_INFO = { - 'survey_key' => { column: :survey_key, converter: UpcaseConverter }, - 'age' => { column: :age, converter: NumberConverter }, - 'gender' => { column: :gender, converter: UpcaseConverter }, - 'school' => { column: :school, converter: UpcaseConverter }, - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'degree' => { column: :degree, converter: UpcaseConverter }, - 'graduation_date' => { column: :graduation_date, converter: DateConverter }, - 'benefit_program' => { column: :benefit_program, converter: UpcaseConverter }, - 'enrollment_type' => { column: :enrollment_type, converter: UpcaseConverter }, - 'monthly_payment_benefit' => { column: :monthly_payment_benefit, converter: BooleanConverter }, - 'payee_number' => { column: :payee_number, converter: BaseConverter }, - 'objective_code' => { column: :objective_code, converter: BaseConverter }, - 'feedback_received_(et)' => { column: :response_date, converter: DateTimeConverter }, - 'survey_sent_date_(et)' => { column: :sent_date, converter: DateTimeConverter }, - "instructors'_knowledge_in_the_subject_being_taught" => { column: :q1, converter: NumberConverter }, - "instructors'_ability_to_engage_with_students_around_course_content" => { column: :q2, converter: NumberConverter }, - 'support_of_course_materials_in_meeting_learning_objectives' => { column: :q3, converter: NumberConverter }, - 'contribution_of_school_supplied_technology_and/or_facilities_to_successful_learning_experience' => { column: :q4, converter: NumberConverter }, - 'contribution_of_learning_experience_to_skills_needed_for_career_journey' => { column: :q5, converter: NumberConverter }, - 'did_you_interact_with_the_school_certifying_officials_(school_staff_who_assist_veterans/beneficiaries_with_enrollment,_submit_documentation_to_va,_advise_on_other_va_benefits)?' => { column: :q6, converter: BaseConverter }, - 'supportiveness_of_school_certifying_officials_(school_staff_who_assist_veterans/beneficiaries_with_enrollment,_submit_documentation_to_va,_advise_on_other_va_benefits)' => { column: :q7, converter: NumberConverter }, - 'availability_of_school_certifying_officials_(school_staff_who_assist_veterans/beneficiaries_with_enrollment,_submit_documentation_to_va,_advise_on_other_va_benefits)' => { column: :q8, converter: NumberConverter }, - "school's_timely_completion_of_va_enrollment_documentation" => { column: :q9, converter: NumberConverter }, - 'helpfulness_of_school_provided_information_about_gi_bill,_other_va_benefits' => { column: :q10, converter: NumberConverter }, - "extent_of_school's_support_for_its_veteran_community" => { column: :q11, converter: NumberConverter }, - "extent_of_support_from_others_in_the_school's_veteran_community" => { column: :q12, converter: NumberConverter }, - 'overall_learning_experience' => { column: :q13, converter: NumberConverter }, - 'overall_school_experience' => { column: :q14, converter: NumberConverter } + 'survey_key' => { column: :survey_key, converter: Converters::UpcaseConverter }, + 'age' => { column: :age, converter: Converters::NumberConverter }, + 'gender' => { column: :gender, converter: Converters::UpcaseConverter }, + 'school' => { column: :school, converter: Converters::UpcaseConverter }, + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'degree' => { column: :degree, converter: Converters::UpcaseConverter }, + 'graduation_date' => { column: :graduation_date, converter: Converters::DateConverter }, + 'benefit_program' => { column: :benefit_program, converter: Converters::UpcaseConverter }, + 'enrollment_type' => { column: :enrollment_type, converter: Converters::UpcaseConverter }, + 'monthly_payment_benefit' => { column: :monthly_payment_benefit, converter: Converters::BooleanConverter }, + 'payee_number' => { column: :payee_number, converter: Converters::BaseConverter }, + 'objective_code' => { column: :objective_code, converter: Converters::BaseConverter }, + 'feedback_received_(et)' => { column: :response_date, converter: Converters::DateTimeConverter }, + 'survey_sent_date_(et)' => { column: :sent_date, converter: Converters::DateTimeConverter }, + "instructors'_knowledge_in_the_subject_being_taught" => { column: :q1, converter: Converters::NumberConverter }, + "instructors'_ability_to_engage_with_students_around_course_content" => { column: :q2, converter: Converters::NumberConverter }, + 'support_of_course_materials_in_meeting_learning_objectives' => { column: :q3, converter: Converters::NumberConverter }, + 'contribution_of_school_supplied_technology_and/or_facilities_to_successful_learning_experience' => { column: :q4, converter: Converters::NumberConverter }, + 'contribution_of_learning_experience_to_skills_needed_for_career_journey' => { column: :q5, converter: Converters::NumberConverter }, + 'did_you_interact_with_the_school_certifying_officials_(school_staff_who_assist_veterans/beneficiaries_with_enrollment,_submit_documentation_to_va,_advise_on_other_va_benefits)?' => { column: :q6, converter: Converters::BaseConverter }, + 'supportiveness_of_school_certifying_officials_(school_staff_who_assist_veterans/beneficiaries_with_enrollment,_submit_documentation_to_va,_advise_on_other_va_benefits)' => { column: :q7, converter: Converters::NumberConverter }, + 'availability_of_school_certifying_officials_(school_staff_who_assist_veterans/beneficiaries_with_enrollment,_submit_documentation_to_va,_advise_on_other_va_benefits)' => { column: :q8, converter: Converters::NumberConverter }, + "school's_timely_completion_of_va_enrollment_documentation" => { column: :q9, converter: Converters::NumberConverter }, + 'helpfulness_of_school_provided_information_about_gi_bill,_other_va_benefits' => { column: :q10, converter: Converters::NumberConverter }, + "extent_of_school's_support_for_its_veteran_community" => { column: :q11, converter: Converters::NumberConverter }, + "extent_of_support_from_others_in_the_school's_veteran_community" => { column: :q12, converter: Converters::NumberConverter }, + 'overall_learning_experience' => { column: :q13, converter: Converters::NumberConverter }, + 'overall_school_experience' => { column: :q14, converter: Converters::NumberConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/ipeds_cip_code.rb b/app/models/ipeds_cip_code.rb index ba41274d8..c767d81a9 100644 --- a/app/models/ipeds_cip_code.rb +++ b/app/models/ipeds_cip_code.rb @@ -2,9 +2,9 @@ class IpedsCipCode < ImportableRecord CSV_CONVERTER_INFO = { - 'unitid' => { column: :cross, converter: CrossConverter }, - 'cipcode' => { column: :cipcode, converter: BaseConverter }, - 'ctotalt' => { column: :ctotalt, converter: NumberConverter } + 'unitid' => { column: :cross, converter: Converters::CrossConverter }, + 'cipcode' => { column: :cipcode, converter: Converters::BaseConverter }, + 'ctotalt' => { column: :ctotalt, converter: Converters::NumberConverter } }.freeze validates :cross, presence: true diff --git a/app/models/ipeds_hd.rb b/app/models/ipeds_hd.rb index ed7f48df0..b33368a48 100644 --- a/app/models/ipeds_hd.rb +++ b/app/models/ipeds_hd.rb @@ -4,73 +4,73 @@ class IpedsHd < ImportableRecord COLS_USED_IN_INSTITUTION = %i[vet_tuition_policy_url f1sysnam f1syscod].freeze CSV_CONVERTER_INFO = { - 'unitid' => { column: :cross, converter: CrossConverter }, - 'instnm' => { column: :institution, converter: InstitutionConverter }, - 'addr' => { column: :addr, converter: BaseConverter }, - 'city' => { column: :city, converter: BaseConverter }, - 'stabbr' => { column: :state, converter: BaseConverter }, - 'zip' => { column: :zip, converter: ZipConverter }, - 'fips' => { column: :fips, converter: NumberConverter }, - 'obereg' => { column: :obereg, converter: NumberConverter }, - 'chfnm' => { column: :chfnm, converter: BaseConverter }, - 'chftitle' => { column: :chftitle, converter: BaseConverter }, - 'gentele' => { column: :gentele, converter: BaseConverter }, - 'ein' => { column: :ein, converter: BaseConverter }, - 'opeid' => { column: :ope, converter: OpeConverter }, - 'opeflag' => { column: :opeflag, converter: NumberConverter }, - 'webaddr' => { column: :webaddr, converter: BaseConverter }, - 'adminurl' => { column: :adminurl, converter: BaseConverter }, - 'faidurl' => { column: :faidurl, converter: BaseConverter }, - 'applurl' => { column: :applurl, converter: BaseConverter }, - 'npricurl' => { column: :npricurl, converter: BaseConverter }, - 'veturl' => { column: :vet_tuition_policy_url, converter: BaseConverter }, - 'athurl' => { column: :athurl, converter: BaseConverter }, - 'sector' => { column: :sector, converter: NumberConverter }, - 'iclevel' => { column: :iclevel, converter: NumberConverter }, - 'control' => { column: :control, converter: NumberConverter }, - 'hloffer' => { column: :hloffer, converter: NumberConverter }, - 'ugoffer' => { column: :ugoffer, converter: NumberConverter }, - 'groffer' => { column: :groffer, converter: NumberConverter }, - 'hdegofr1' => { column: :hdegofr1, converter: NumberConverter }, - 'deggrant' => { column: :deggrant, converter: NumberConverter }, - 'hbcu' => { column: :hbcu, converter: NumberConverter }, - 'hospital' => { column: :hospital, converter: NumberConverter }, - 'medical' => { column: :medical, converter: NumberConverter }, - 'tribal' => { column: :tribal, converter: NumberConverter }, - 'locale' => { column: :locale, converter: NumberConverter }, - 'openpubl' => { column: :openpubl, converter: NumberConverter }, - 'act' => { column: :act, converter: BaseConverter }, - 'newid' => { column: :newid, converter: NumberConverter }, - 'deathyr' => { column: :deathyr, converter: NumberConverter }, - 'closedat' => { column: :closedat, converter: BaseConverter }, - 'cyactive' => { column: :cyactive, converter: NumberConverter }, - 'postsec' => { column: :postsec, converter: NumberConverter }, - 'pseflag' => { column: :pseflag, converter: NumberConverter }, - 'pset4flg' => { column: :pset4flg, converter: NumberConverter }, - 'rptmth' => { column: :rptmth, converter: NumberConverter }, - 'ialias' => { column: :ialias, converter: UpcaseConverter }, - 'instcat' => { column: :instcat, converter: NumberConverter }, - 'ccbasic' => { column: :ccbasic, converter: NumberConverter }, - 'ccipug' => { column: :ccipug, converter: NumberConverter }, - 'ccipgrad' => { column: :ccipgrad, converter: NumberConverter }, - 'ccugprof' => { column: :ccugprof, converter: NumberConverter }, - 'ccenrprf' => { column: :ccenrprf, converter: NumberConverter }, - 'ccsizset' => { column: :ccsizset, converter: NumberConverter }, - 'carnegie' => { column: :carnegie, converter: NumberConverter }, - 'landgrnt' => { column: :landgrnt, converter: NumberConverter }, - 'instsize' => { column: :instsize, converter: NumberConverter }, - 'cbsa' => { column: :cbsa, converter: NumberConverter }, - 'cbsatype' => { column: :cbsatype, converter: NumberConverter }, - 'csa' => { column: :csa, converter: NumberConverter }, - 'necta' => { column: :necta, converter: NumberConverter }, - 'f1systyp' => { column: :f1systyp, converter: NumberConverter }, - 'f1sysnam' => { column: :f1sysnam, converter: BaseConverter }, - 'f1syscod' => { column: :f1syscod, converter: NumberConverter }, - 'countycd' => { column: :countycd, converter: NumberConverter }, - 'countynm' => { column: :countynm, converter: BaseConverter }, - 'cngdstcd' => { column: :cngdstcd, converter: NumberConverter }, - 'dfrcgid' => { column: :dfrcgid, converter: NumberConverter }, - 'dfrcuscg' => { column: :dfrcuscg, converter: BaseConverter } + 'unitid' => { column: :cross, converter: Converters::CrossConverter }, + 'instnm' => { column: :institution, converter: Converters::InstitutionConverter }, + 'addr' => { column: :addr, converter: Converters::BaseConverter }, + 'city' => { column: :city, converter: Converters::BaseConverter }, + 'stabbr' => { column: :state, converter: Converters::BaseConverter }, + 'zip' => { column: :zip, converter: Converters::ZipConverter }, + 'fips' => { column: :fips, converter: Converters::NumberConverter }, + 'obereg' => { column: :obereg, converter: Converters::NumberConverter }, + 'chfnm' => { column: :chfnm, converter: Converters::BaseConverter }, + 'chftitle' => { column: :chftitle, converter: Converters::BaseConverter }, + 'gentele' => { column: :gentele, converter: Converters::BaseConverter }, + 'ein' => { column: :ein, converter: Converters::BaseConverter }, + 'opeid' => { column: :ope, converter: Converters::OpeConverter }, + 'opeflag' => { column: :opeflag, converter: Converters::NumberConverter }, + 'webaddr' => { column: :webaddr, converter: Converters::BaseConverter }, + 'adminurl' => { column: :adminurl, converter: Converters::BaseConverter }, + 'faidurl' => { column: :faidurl, converter: Converters::BaseConverter }, + 'applurl' => { column: :applurl, converter: Converters::BaseConverter }, + 'npricurl' => { column: :npricurl, converter: Converters::BaseConverter }, + 'veturl' => { column: :vet_tuition_policy_url, converter: Converters::BaseConverter }, + 'athurl' => { column: :athurl, converter: Converters::BaseConverter }, + 'sector' => { column: :sector, converter: Converters::NumberConverter }, + 'iclevel' => { column: :iclevel, converter: Converters::NumberConverter }, + 'control' => { column: :control, converter: Converters::NumberConverter }, + 'hloffer' => { column: :hloffer, converter: Converters::NumberConverter }, + 'ugoffer' => { column: :ugoffer, converter: Converters::NumberConverter }, + 'groffer' => { column: :groffer, converter: Converters::NumberConverter }, + 'hdegofr1' => { column: :hdegofr1, converter: Converters::NumberConverter }, + 'deggrant' => { column: :deggrant, converter: Converters::NumberConverter }, + 'hbcu' => { column: :hbcu, converter: Converters::NumberConverter }, + 'hospital' => { column: :hospital, converter: Converters::NumberConverter }, + 'medical' => { column: :medical, converter: Converters::NumberConverter }, + 'tribal' => { column: :tribal, converter: Converters::NumberConverter }, + 'locale' => { column: :locale, converter: Converters::NumberConverter }, + 'openpubl' => { column: :openpubl, converter: Converters::NumberConverter }, + 'act' => { column: :act, converter: Converters::BaseConverter }, + 'newid' => { column: :newid, converter: Converters::NumberConverter }, + 'deathyr' => { column: :deathyr, converter: Converters::NumberConverter }, + 'closedat' => { column: :closedat, converter: Converters::BaseConverter }, + 'cyactive' => { column: :cyactive, converter: Converters::NumberConverter }, + 'postsec' => { column: :postsec, converter: Converters::NumberConverter }, + 'pseflag' => { column: :pseflag, converter: Converters::NumberConverter }, + 'pset4flg' => { column: :pset4flg, converter: Converters::NumberConverter }, + 'rptmth' => { column: :rptmth, converter: Converters::NumberConverter }, + 'ialias' => { column: :ialias, converter: Converters::UpcaseConverter }, + 'instcat' => { column: :instcat, converter: Converters::NumberConverter }, + 'ccbasic' => { column: :ccbasic, converter: Converters::NumberConverter }, + 'ccipug' => { column: :ccipug, converter: Converters::NumberConverter }, + 'ccipgrad' => { column: :ccipgrad, converter: Converters::NumberConverter }, + 'ccugprof' => { column: :ccugprof, converter: Converters::NumberConverter }, + 'ccenrprf' => { column: :ccenrprf, converter: Converters::NumberConverter }, + 'ccsizset' => { column: :ccsizset, converter: Converters::NumberConverter }, + 'carnegie' => { column: :carnegie, converter: Converters::NumberConverter }, + 'landgrnt' => { column: :landgrnt, converter: Converters::NumberConverter }, + 'instsize' => { column: :instsize, converter: Converters::NumberConverter }, + 'cbsa' => { column: :cbsa, converter: Converters::NumberConverter }, + 'cbsatype' => { column: :cbsatype, converter: Converters::NumberConverter }, + 'csa' => { column: :csa, converter: Converters::NumberConverter }, + 'necta' => { column: :necta, converter: Converters::NumberConverter }, + 'f1systyp' => { column: :f1systyp, converter: Converters::NumberConverter }, + 'f1sysnam' => { column: :f1sysnam, converter: Converters::BaseConverter }, + 'f1syscod' => { column: :f1syscod, converter: Converters::NumberConverter }, + 'countycd' => { column: :countycd, converter: Converters::NumberConverter }, + 'countynm' => { column: :countynm, converter: Converters::BaseConverter }, + 'cngdstcd' => { column: :cngdstcd, converter: Converters::NumberConverter }, + 'dfrcgid' => { column: :dfrcgid, converter: Converters::NumberConverter }, + 'dfrcuscg' => { column: :dfrcuscg, converter: Converters::BaseConverter } }.freeze has_many :crosswalk_issue, dependent: :delete_all diff --git a/app/models/ipeds_ic.rb b/app/models/ipeds_ic.rb index 59de161c6..0651140a0 100644 --- a/app/models/ipeds_ic.rb +++ b/app/models/ipeds_ic.rb @@ -9,113 +9,113 @@ class IpedsIc < ImportableRecord # Note do not map the "integer" values to "boolean" values otherwise exports will put true/false instead of 1/0, # instead move them to dependent booleans before validation. CSV_CONVERTER_INFO = { - 'unitid' => { column: :cross, converter: CrossConverter }, - 'peo1istr' => { column: :peo1istr, converter: NumberConverter }, - 'peo2istr' => { column: :peo2istr, converter: NumberConverter }, - 'peo3istr' => { column: :peo3istr, converter: NumberConverter }, - 'peo4istr' => { column: :peo4istr, converter: NumberConverter }, - 'peo5istr' => { column: :peo5istr, converter: NumberConverter }, - 'peo6istr' => { column: :peo6istr, converter: NumberConverter }, - 'cntlaffi' => { column: :cntlaffi, converter: NumberConverter }, - 'pubprime' => { column: :pubprime, converter: NumberConverter }, - 'pubsecon' => { column: :pubsecon, converter: NumberConverter }, - 'relaffil' => { column: :relaffil, converter: NumberConverter }, - 'level1' => { column: :level1, converter: NumberConverter }, - 'level2' => { column: :level2, converter: NumberConverter }, - 'level3' => { column: :level3, converter: NumberConverter }, - 'level4' => { column: :level4, converter: NumberConverter }, - 'level5' => { column: :level5, converter: NumberConverter }, - 'level6' => { column: :level6, converter: NumberConverter }, - 'level7' => { column: :level7, converter: NumberConverter }, - 'level8' => { column: :level8, converter: NumberConverter }, - 'level12' => { column: :level12, converter: NumberConverter }, - 'level17' => { column: :level17, converter: NumberConverter }, - 'level18' => { column: :level18, converter: NumberConverter }, - 'level19' => { column: :level19, converter: NumberConverter }, - 'openadmp' => { column: :openadmp, converter: NumberConverter }, - 'credits1' => { column: :credits1, converter: NumberConverter }, - 'credits2' => { column: :credits2, converter: NumberConverter }, - 'credits3' => { column: :credits3, converter: NumberConverter }, - 'credits4' => { column: :credits4, converter: NumberConverter }, - 'slo5' => { column: :slo5, converter: NumberConverter }, - 'slo51' => { column: :slo51, converter: NumberConverter }, - 'slo52' => { column: :slo52, converter: NumberConverter }, - 'slo53' => { column: :slo53, converter: NumberConverter }, - 'slo6' => { column: :slo6, converter: NumberConverter }, - 'slo7' => { column: :slo7, converter: NumberConverter }, - 'slo8' => { column: :slo8, converter: NumberConverter }, - 'slo81' => { column: :slo81, converter: NumberConverter }, - 'slo82' => { column: :slo82, converter: NumberConverter }, - 'slo83' => { column: :slo83, converter: NumberConverter }, - 'slo9' => { column: :slo9, converter: NumberConverter }, - 'yrscoll' => { column: :yrscoll, converter: NumberConverter }, - 'stusrv1' => { column: :stusrv1, converter: NumberConverter }, - 'stusrv2' => { column: :stusrv2, converter: NumberConverter }, - 'stusrv3' => { column: :stusrv3, converter: NumberConverter }, - 'stusrv4' => { column: :stusrv4, converter: NumberConverter }, - 'stusrv8' => { column: :stusrv8, converter: NumberConverter }, - 'stusrv9' => { column: :stusrv9, converter: NumberConverter }, - 'libfac' => { column: :libfac, converter: NumberConverter }, - 'athassoc' => { column: :athassoc, converter: NumberConverter }, - 'assoc1' => { column: :assoc1, converter: NumberConverter }, - 'assoc2' => { column: :assoc2, converter: NumberConverter }, - 'assoc3' => { column: :assoc3, converter: BaseConverter }, - 'assoc4' => { column: :assoc4, converter: NumberConverter }, - 'assoc5' => { column: :assoc5, converter: NumberConverter }, - 'assoc6' => { column: :assoc6, converter: NumberConverter }, - 'sport1' => { column: :sport1, converter: NumberConverter }, - 'confno1' => { column: :confno1, converter: NumberConverter }, - 'sport2' => { column: :sport2, converter: NumberConverter }, - 'confno2' => { column: :confno2, converter: NumberConverter }, - 'sport3' => { column: :sport3, converter: NumberConverter }, - 'confno3' => { column: :confno3, converter: NumberConverter }, - 'sport4' => { column: :sport4, converter: NumberConverter }, - 'confno4' => { column: :confno4, converter: NumberConverter }, - 'calsys' => { column: :calsys, converter: NumberConverter }, - 'xappfeeu' => { column: :xappfeeu, converter: BaseConverter }, - 'applfeeu' => { column: :applfeeu, converter: NumberConverter }, - 'xappfeeg' => { column: :xappfeeg, converter: BaseConverter }, - 'applfeeg' => { column: :applfeeg, converter: NumberConverter }, - 'ft_ug' => { column: :ft_ug, converter: NumberConverter }, - 'ft_ftug' => { column: :ft_ftug, converter: NumberConverter }, - 'ftgdnidp' => { column: :ftgdnidp, converter: NumberConverter }, - 'pt_ug' => { column: :pt_ug, converter: NumberConverter }, - 'pt_ftug' => { column: :pt_ftug, converter: NumberConverter }, - 'ptgdnidp' => { column: :ptgdnidp, converter: NumberConverter }, - 'docpp' => { column: :docpp, converter: NumberConverter }, - 'docppsp' => { column: :docppsp, converter: NumberConverter }, - 'tuitvary' => { column: :tuitvary, converter: NumberConverter }, - 'room' => { column: :room, converter: NumberConverter }, - 'xroomcap' => { column: :xroomcap, converter: BaseConverter }, - 'roomcap' => { column: :roomcap, converter: NumberConverter }, - 'board' => { column: :board, converter: NumberConverter }, - 'xmealswk' => { column: :xmealswk, converter: BaseConverter }, - 'mealswk' => { column: :mealswk, converter: NumberConverter }, - 'xroomamt' => { column: :xroomamt, converter: BaseConverter }, - 'roomamt' => { column: :roomamt, converter: NumberConverter }, - 'xbordamt' => { column: :xbordamt, converter: BaseConverter }, - 'boardamt' => { column: :boardamt, converter: NumberConverter }, - 'xrmbdamt' => { column: :xrmbdamt, converter: BaseConverter }, - 'rmbrdamt' => { column: :rmbrdamt, converter: NumberConverter }, - 'alloncam' => { column: :alloncam, converter: NumberConverter }, - 'tuitpl' => { column: :tuitpl, converter: NumberConverter }, - 'tuitpl1' => { column: :tuitpl1, converter: NumberConverter }, - 'tuitpl2' => { column: :tuitpl2, converter: NumberConverter }, - 'tuitpl3' => { column: :tuitpl3, converter: NumberConverter }, - 'tuitpl4' => { column: :tuitpl4, converter: NumberConverter }, - 'disab' => { column: :disab, converter: NumberConverter }, - 'xdisabpc' => { column: :xdisabpc, converter: BaseConverter }, - 'disabpct' => { column: :disabpct, converter: NumberConverter }, - 'distnced' => { column: :distnced, converter: NumberConverter }, - 'dstnced1' => { column: :dstnced1, converter: NumberConverter }, - 'dstnced2' => { column: :dstnced2, converter: NumberConverter }, - 'dstnced3' => { column: :dstnced3, converter: NumberConverter }, - 'vet1' => { column: :vet1, converter: NumberConverter }, - 'vet2' => { column: :vet2, converter: NumberConverter }, - 'vet3' => { column: :vet3, converter: NumberConverter }, - 'vet4' => { column: :vet4, converter: NumberConverter }, - 'vet5' => { column: :vet5, converter: NumberConverter }, - 'vet9' => { column: :vet9, converter: NumberConverter } + 'unitid' => { column: :cross, converter: Converters::CrossConverter }, + 'peo1istr' => { column: :peo1istr, converter: Converters::NumberConverter }, + 'peo2istr' => { column: :peo2istr, converter: Converters::NumberConverter }, + 'peo3istr' => { column: :peo3istr, converter: Converters::NumberConverter }, + 'peo4istr' => { column: :peo4istr, converter: Converters::NumberConverter }, + 'peo5istr' => { column: :peo5istr, converter: Converters::NumberConverter }, + 'peo6istr' => { column: :peo6istr, converter: Converters::NumberConverter }, + 'cntlaffi' => { column: :cntlaffi, converter: Converters::NumberConverter }, + 'pubprime' => { column: :pubprime, converter: Converters::NumberConverter }, + 'pubsecon' => { column: :pubsecon, converter: Converters::NumberConverter }, + 'relaffil' => { column: :relaffil, converter: Converters::NumberConverter }, + 'level1' => { column: :level1, converter: Converters::NumberConverter }, + 'level2' => { column: :level2, converter: Converters::NumberConverter }, + 'level3' => { column: :level3, converter: Converters::NumberConverter }, + 'level4' => { column: :level4, converter: Converters::NumberConverter }, + 'level5' => { column: :level5, converter: Converters::NumberConverter }, + 'level6' => { column: :level6, converter: Converters::NumberConverter }, + 'level7' => { column: :level7, converter: Converters::NumberConverter }, + 'level8' => { column: :level8, converter: Converters::NumberConverter }, + 'level12' => { column: :level12, converter: Converters::NumberConverter }, + 'level17' => { column: :level17, converter: Converters::NumberConverter }, + 'level18' => { column: :level18, converter: Converters::NumberConverter }, + 'level19' => { column: :level19, converter: Converters::NumberConverter }, + 'openadmp' => { column: :openadmp, converter: Converters::NumberConverter }, + 'credits1' => { column: :credits1, converter: Converters::NumberConverter }, + 'credits2' => { column: :credits2, converter: Converters::NumberConverter }, + 'credits3' => { column: :credits3, converter: Converters::NumberConverter }, + 'credits4' => { column: :credits4, converter: Converters::NumberConverter }, + 'slo5' => { column: :slo5, converter: Converters::NumberConverter }, + 'slo51' => { column: :slo51, converter: Converters::NumberConverter }, + 'slo52' => { column: :slo52, converter: Converters::NumberConverter }, + 'slo53' => { column: :slo53, converter: Converters::NumberConverter }, + 'slo6' => { column: :slo6, converter: Converters::NumberConverter }, + 'slo7' => { column: :slo7, converter: Converters::NumberConverter }, + 'slo8' => { column: :slo8, converter: Converters::NumberConverter }, + 'slo81' => { column: :slo81, converter: Converters::NumberConverter }, + 'slo82' => { column: :slo82, converter: Converters::NumberConverter }, + 'slo83' => { column: :slo83, converter: Converters::NumberConverter }, + 'slo9' => { column: :slo9, converter: Converters::NumberConverter }, + 'yrscoll' => { column: :yrscoll, converter: Converters::NumberConverter }, + 'stusrv1' => { column: :stusrv1, converter: Converters::NumberConverter }, + 'stusrv2' => { column: :stusrv2, converter: Converters::NumberConverter }, + 'stusrv3' => { column: :stusrv3, converter: Converters::NumberConverter }, + 'stusrv4' => { column: :stusrv4, converter: Converters::NumberConverter }, + 'stusrv8' => { column: :stusrv8, converter: Converters::NumberConverter }, + 'stusrv9' => { column: :stusrv9, converter: Converters::NumberConverter }, + 'libfac' => { column: :libfac, converter: Converters::NumberConverter }, + 'athassoc' => { column: :athassoc, converter: Converters::NumberConverter }, + 'assoc1' => { column: :assoc1, converter: Converters::NumberConverter }, + 'assoc2' => { column: :assoc2, converter: Converters::NumberConverter }, + 'assoc3' => { column: :assoc3, converter: Converters::BaseConverter }, + 'assoc4' => { column: :assoc4, converter: Converters::NumberConverter }, + 'assoc5' => { column: :assoc5, converter: Converters::NumberConverter }, + 'assoc6' => { column: :assoc6, converter: Converters::NumberConverter }, + 'sport1' => { column: :sport1, converter: Converters::NumberConverter }, + 'confno1' => { column: :confno1, converter: Converters::NumberConverter }, + 'sport2' => { column: :sport2, converter: Converters::NumberConverter }, + 'confno2' => { column: :confno2, converter: Converters::NumberConverter }, + 'sport3' => { column: :sport3, converter: Converters::NumberConverter }, + 'confno3' => { column: :confno3, converter: Converters::NumberConverter }, + 'sport4' => { column: :sport4, converter: Converters::NumberConverter }, + 'confno4' => { column: :confno4, converter: Converters::NumberConverter }, + 'calsys' => { column: :calsys, converter: Converters::NumberConverter }, + 'xappfeeu' => { column: :xappfeeu, converter: Converters::BaseConverter }, + 'applfeeu' => { column: :applfeeu, converter: Converters::NumberConverter }, + 'xappfeeg' => { column: :xappfeeg, converter: Converters::BaseConverter }, + 'applfeeg' => { column: :applfeeg, converter: Converters::NumberConverter }, + 'ft_ug' => { column: :ft_ug, converter: Converters::NumberConverter }, + 'ft_ftug' => { column: :ft_ftug, converter: Converters::NumberConverter }, + 'ftgdnidp' => { column: :ftgdnidp, converter: Converters::NumberConverter }, + 'pt_ug' => { column: :pt_ug, converter: Converters::NumberConverter }, + 'pt_ftug' => { column: :pt_ftug, converter: Converters::NumberConverter }, + 'ptgdnidp' => { column: :ptgdnidp, converter: Converters::NumberConverter }, + 'docpp' => { column: :docpp, converter: Converters::NumberConverter }, + 'docppsp' => { column: :docppsp, converter: Converters::NumberConverter }, + 'tuitvary' => { column: :tuitvary, converter: Converters::NumberConverter }, + 'room' => { column: :room, converter: Converters::NumberConverter }, + 'xroomcap' => { column: :xroomcap, converter: Converters::BaseConverter }, + 'roomcap' => { column: :roomcap, converter: Converters::NumberConverter }, + 'board' => { column: :board, converter: Converters::NumberConverter }, + 'xmealswk' => { column: :xmealswk, converter: Converters::BaseConverter }, + 'mealswk' => { column: :mealswk, converter: Converters::NumberConverter }, + 'xroomamt' => { column: :xroomamt, converter: Converters::BaseConverter }, + 'roomamt' => { column: :roomamt, converter: Converters::NumberConverter }, + 'xbordamt' => { column: :xbordamt, converter: Converters::BaseConverter }, + 'boardamt' => { column: :boardamt, converter: Converters::NumberConverter }, + 'xrmbdamt' => { column: :xrmbdamt, converter: Converters::BaseConverter }, + 'rmbrdamt' => { column: :rmbrdamt, converter: Converters::NumberConverter }, + 'alloncam' => { column: :alloncam, converter: Converters::NumberConverter }, + 'tuitpl' => { column: :tuitpl, converter: Converters::NumberConverter }, + 'tuitpl1' => { column: :tuitpl1, converter: Converters::NumberConverter }, + 'tuitpl2' => { column: :tuitpl2, converter: Converters::NumberConverter }, + 'tuitpl3' => { column: :tuitpl3, converter: Converters::NumberConverter }, + 'tuitpl4' => { column: :tuitpl4, converter: Converters::NumberConverter }, + 'disab' => { column: :disab, converter: Converters::NumberConverter }, + 'xdisabpc' => { column: :xdisabpc, converter: Converters::BaseConverter }, + 'disabpct' => { column: :disabpct, converter: Converters::NumberConverter }, + 'distnced' => { column: :distnced, converter: Converters::NumberConverter }, + 'dstnced1' => { column: :dstnced1, converter: Converters::NumberConverter }, + 'dstnced2' => { column: :dstnced2, converter: Converters::NumberConverter }, + 'dstnced3' => { column: :dstnced3, converter: Converters::NumberConverter }, + 'vet1' => { column: :vet1, converter: Converters::NumberConverter }, + 'vet2' => { column: :vet2, converter: Converters::NumberConverter }, + 'vet3' => { column: :vet3, converter: Converters::NumberConverter }, + 'vet4' => { column: :vet4, converter: Converters::NumberConverter }, + 'vet5' => { column: :vet5, converter: Converters::NumberConverter }, + 'vet9' => { column: :vet9, converter: Converters::NumberConverter } }.freeze validates :cross, presence: true @@ -148,6 +148,6 @@ def self.to_online_all(value) def self.coded_to_boolean(value) return nil if value.nil? || value.negative? - BooleanConverter.convert(value) + Converters::BooleanConverter.convert(value) end end diff --git a/app/models/ipeds_ic_ay.rb b/app/models/ipeds_ic_ay.rb index 72f667d93..51263fc10 100644 --- a/app/models/ipeds_ic_ay.rb +++ b/app/models/ipeds_ic_ay.rb @@ -4,241 +4,241 @@ class IpedsIcAy < ImportableRecord COLS_USED_IN_INSTITUTION = %i[tuition_in_state tuition_out_of_state books].freeze CSV_CONVERTER_INFO = { - 'unitid' => { column: :cross, converter: CrossConverter }, - 'xtuit1' => { column: :xtuit1, converter: BaseConverter }, - 'tuition1' => { column: :tuition1, converter: NumberConverter }, - 'xfee1' => { column: :xfee1, converter: BaseConverter }, - 'fee1' => { column: :fee1, converter: NumberConverter }, - 'xhrchg1' => { column: :xhrchg1, converter: BaseConverter }, - 'hrchg1' => { column: :hrchg1, converter: NumberConverter }, - 'xtuit2' => { column: :xtuit2, converter: BaseConverter }, - 'tuition2' => { column: :tuition2, converter: NumberConverter }, - 'xfee2' => { column: :xfee2, converter: BaseConverter }, - 'fee2' => { column: :fee2, converter: NumberConverter }, - 'xhrchg2' => { column: :xhrchg2, converter: BaseConverter }, - 'hrchg2' => { column: :hrchg2, converter: NumberConverter }, - 'xtuit3' => { column: :xtuit3, converter: BaseConverter }, - 'tuition3' => { column: :tuition3, converter: NumberConverter }, - 'xfee3' => { column: :xfee3, converter: BaseConverter }, - 'fee3' => { column: :fee3, converter: NumberConverter }, - 'xhrchg3' => { column: :xhrchg3, converter: BaseConverter }, - 'hrchg3' => { column: :hrchg3, converter: NumberConverter }, - 'xtuit5' => { column: :xtuit5, converter: BaseConverter }, - 'tuition5' => { column: :tuition5, converter: NumberConverter }, - 'xfee5' => { column: :xfee5, converter: BaseConverter }, - 'fee5' => { column: :fee5, converter: NumberConverter }, - 'xhrchg5' => { column: :xhrchg5, converter: BaseConverter }, - 'hrchg5' => { column: :hrchg5, converter: NumberConverter }, - 'xtuit6' => { column: :xtuit6, converter: BaseConverter }, - 'tuition6' => { column: :tuition6, converter: NumberConverter }, - 'xfee6' => { column: :xfee6, converter: BaseConverter }, - 'fee6' => { column: :fee6, converter: NumberConverter }, - 'xhrchg6' => { column: :xhrchg6, converter: BaseConverter }, - 'hrchg6' => { column: :hrchg6, converter: NumberConverter }, - 'xtuit7' => { column: :xtuit7, converter: BaseConverter }, - 'tuition7' => { column: :tuition7, converter: NumberConverter }, - 'xfee7' => { column: :xfee7, converter: BaseConverter }, - 'fee7' => { column: :fee7, converter: NumberConverter }, - 'xhrchg7' => { column: :xhrchg7, converter: BaseConverter }, - 'hrchg7' => { column: :hrchg7, converter: NumberConverter }, - 'xispro1' => { column: :xispro1, converter: BaseConverter }, - 'isprof1' => { column: :isprof1, converter: NumberConverter }, - 'xispfe1' => { column: :xispfe1, converter: BaseConverter }, - 'ispfee1' => { column: :ispfee1, converter: NumberConverter }, - 'xospro1' => { column: :xospro1, converter: BaseConverter }, - 'osprof1' => { column: :osprof1, converter: NumberConverter }, - 'xospfe1' => { column: :xospfe1, converter: BaseConverter }, - 'ospfee1' => { column: :ospfee1, converter: NumberConverter }, - 'xispro2' => { column: :xispro2, converter: BaseConverter }, - 'isprof2' => { column: :isprof2, converter: NumberConverter }, - 'xispfe2' => { column: :xispfe2, converter: BaseConverter }, - 'ispfee2' => { column: :ispfee2, converter: NumberConverter }, - 'xospro2' => { column: :xospro2, converter: BaseConverter }, - 'osprof2' => { column: :osprof2, converter: NumberConverter }, - 'xospfe2' => { column: :xospfe2, converter: BaseConverter }, - 'ospfee2' => { column: :ospfee2, converter: NumberConverter }, - 'xispro3' => { column: :xispro3, converter: BaseConverter }, - 'isprof3' => { column: :isprof3, converter: NumberConverter }, - 'xispfe3' => { column: :xispfe3, converter: BaseConverter }, - 'ispfee3' => { column: :ispfee3, converter: NumberConverter }, - 'xospro3' => { column: :xospro3, converter: BaseConverter }, - 'osprof3' => { column: :osprof3, converter: NumberConverter }, - 'xospfe3' => { column: :xospfe3, converter: BaseConverter }, - 'ospfee3' => { column: :ospfee3, converter: NumberConverter }, - 'xispro4' => { column: :xispro4, converter: BaseConverter }, - 'isprof4' => { column: :isprof4, converter: NumberConverter }, - 'xispfe4' => { column: :xispfe4, converter: BaseConverter }, - 'ispfee4' => { column: :ispfee4, converter: NumberConverter }, - 'xospro4' => { column: :xospro4, converter: BaseConverter }, - 'osprof4' => { column: :osprof4, converter: NumberConverter }, - 'xospfe4' => { column: :xospfe4, converter: BaseConverter }, - 'ospfee4' => { column: :ospfee4, converter: NumberConverter }, - 'xispro5' => { column: :xispro5, converter: BaseConverter }, - 'isprof5' => { column: :isprof5, converter: NumberConverter }, - 'xispfe5' => { column: :xispfe5, converter: BaseConverter }, - 'ispfee5' => { column: :ispfee5, converter: NumberConverter }, - 'xospro5' => { column: :xospro5, converter: BaseConverter }, - 'osprof5' => { column: :osprof5, converter: NumberConverter }, - 'xospfe5' => { column: :xospfe5, converter: BaseConverter }, - 'ospfee5' => { column: :ospfee5, converter: NumberConverter }, - 'xispro6' => { column: :xispro6, converter: BaseConverter }, - 'isprof6' => { column: :isprof6, converter: NumberConverter }, - 'xispfe6' => { column: :xispfe6, converter: BaseConverter }, - 'ispfee6' => { column: :ispfee6, converter: NumberConverter }, - 'xospro6' => { column: :xospro6, converter: BaseConverter }, - 'osprof6' => { column: :osprof6, converter: NumberConverter }, - 'xospfe6' => { column: :xospfe6, converter: BaseConverter }, - 'ospfee6' => { column: :ospfee6, converter: NumberConverter }, - 'xispro7' => { column: :xispro7, converter: BaseConverter }, - 'isprof7' => { column: :isprof7, converter: NumberConverter }, - 'xispfe7' => { column: :xispfe7, converter: BaseConverter }, - 'ispfee7' => { column: :ispfee7, converter: NumberConverter }, - 'xospro7' => { column: :xospro7, converter: BaseConverter }, - 'osprof7' => { column: :osprof7, converter: NumberConverter }, - 'xospfe7' => { column: :xospfe7, converter: BaseConverter }, - 'ospfee7' => { column: :ospfee7, converter: NumberConverter }, - 'xispro8' => { column: :xispro8, converter: BaseConverter }, - 'isprof8' => { column: :isprof8, converter: NumberConverter }, - 'xispfe8' => { column: :xispfe8, converter: BaseConverter }, - 'ispfee8' => { column: :ispfee8, converter: NumberConverter }, - 'xospro8' => { column: :xospro8, converter: BaseConverter }, - 'osprof8' => { column: :osprof8, converter: NumberConverter }, - 'xospfe8' => { column: :xospfe8, converter: BaseConverter }, - 'ospfee8' => { column: :ospfee8, converter: NumberConverter }, - 'xispro9' => { column: :xispro9, converter: BaseConverter }, - 'isprof9' => { column: :isprof9, converter: NumberConverter }, - 'xispfe9' => { column: :xispfe9, converter: BaseConverter }, - 'ispfee9' => { column: :ispfee9, converter: NumberConverter }, - 'xospro9' => { column: :xospro9, converter: BaseConverter }, - 'osprof9' => { column: :osprof9, converter: NumberConverter }, - 'xospfe9' => { column: :xospfe9, converter: BaseConverter }, - 'ospfee9' => { column: :ospfee9, converter: NumberConverter }, - 'xchg1at0' => { column: :xchg1at0, converter: BaseConverter }, - 'chg1at0' => { column: :chg1at0, converter: NumberConverter }, - 'xchg1af0' => { column: :xchg1af0, converter: BaseConverter }, - 'chg1af0' => { column: :chg1af0, converter: NumberConverter }, - 'xchg1ay0' => { column: :xchg1ay0, converter: BaseConverter }, - 'chg1ay0' => { column: :chg1ay0, converter: NumberConverter }, - 'xchg1at1' => { column: :xchg1at1, converter: BaseConverter }, - 'chg1at1' => { column: :chg1at1, converter: NumberConverter }, - 'xchg1af1' => { column: :xchg1af1, converter: BaseConverter }, - 'chg1af1' => { column: :chg1af1, converter: NumberConverter }, - 'xchg1ay1' => { column: :xchg1ay1, converter: BaseConverter }, - 'chg1ay1' => { column: :chg1ay1, converter: NumberConverter }, - 'xchg1at2' => { column: :xchg1at2, converter: BaseConverter }, - 'chg1at2' => { column: :chg1at2, converter: NumberConverter }, - 'xchg1af2' => { column: :xchg1af2, converter: BaseConverter }, - 'chg1af2' => { column: :chg1af2, converter: NumberConverter }, - 'xchg1ay2' => { column: :xchg1ay2, converter: BaseConverter }, - 'chg1ay2' => { column: :chg1ay2, converter: NumberConverter }, - 'xchg1at3' => { column: :xchg1at3, converter: BaseConverter }, - 'chg1at3' => { column: :chg1at3, converter: NumberConverter }, - 'xchg1af3' => { column: :xchg1af3, converter: BaseConverter }, - 'chg1af3' => { column: :chg1af3, converter: NumberConverter }, - 'xchg1ay3' => { column: :xchg1ay3, converter: BaseConverter }, - 'chg1ay3' => { column: :chg1ay3, converter: NumberConverter }, - 'chg1tgtd' => { column: :chg1tgtd, converter: NumberConverter }, - 'chg1fgtd' => { column: :chg1fgtd, converter: NumberConverter }, - 'xchg2at0' => { column: :xchg2at0, converter: BaseConverter }, - 'chg2at0' => { column: :chg2at0, converter: NumberConverter }, - 'xchg2af0' => { column: :xchg2af0, converter: BaseConverter }, - 'chg2af0' => { column: :chg2af0, converter: NumberConverter }, - 'xchg2ay0' => { column: :xchg2ay0, converter: BaseConverter }, - 'chg2ay0' => { column: :chg2ay0, converter: NumberConverter }, - 'xchg2at1' => { column: :xchg2at1, converter: BaseConverter }, - 'chg2at1' => { column: :chg2at1, converter: NumberConverter }, - 'xchg2af1' => { column: :xchg2af1, converter: BaseConverter }, - 'chg2af1' => { column: :chg2af1, converter: NumberConverter }, - 'xchg2ay1' => { column: :xchg2ay1, converter: BaseConverter }, - 'chg2ay1' => { column: :chg2ay1, converter: NumberConverter }, - 'xchg2at2' => { column: :xchg2at2, converter: BaseConverter }, - 'chg2at2' => { column: :chg2at2, converter: NumberConverter }, - 'xchg2af2' => { column: :xchg2af2, converter: BaseConverter }, - 'chg2af2' => { column: :chg2af2, converter: NumberConverter }, - 'xchg2ay2' => { column: :xchg2ay2, converter: BaseConverter }, - 'chg2ay2' => { column: :chg2ay2, converter: NumberConverter }, - 'xchg2at3' => { column: :xchg2at3, converter: BaseConverter }, - 'chg2at3' => { column: :chg2at3, converter: NumberConverter }, - 'xchg2af3' => { column: :xchg2af3, converter: BaseConverter }, - 'chg2af3' => { column: :chg2af3, converter: NumberConverter }, - 'xchg2ay3' => { column: :xchg2ay3, converter: BaseConverter }, - 'chg2ay3' => { column: :tuition_in_state, converter: NumberConverter }, - 'chg2tgtd' => { column: :chg2tgtd, converter: NumberConverter }, - 'chg2fgtd' => { column: :chg2fgtd, converter: NumberConverter }, - 'xchg3at0' => { column: :xchg3at0, converter: BaseConverter }, - 'chg3at0' => { column: :chg3at0, converter: NumberConverter }, - 'xchg3af0' => { column: :xchg3af0, converter: BaseConverter }, - 'chg3af0' => { column: :chg3af0, converter: NumberConverter }, - 'xchg3ay0' => { column: :xchg3ay0, converter: BaseConverter }, - 'chg3ay0' => { column: :chg3ay0, converter: NumberConverter }, - 'xchg3at1' => { column: :xchg3at1, converter: BaseConverter }, - 'chg3at1' => { column: :chg3at1, converter: NumberConverter }, - 'xchg3af1' => { column: :xchg3af1, converter: BaseConverter }, - 'chg3af1' => { column: :chg3af1, converter: NumberConverter }, - 'xchg3ay1' => { column: :xchg3ay1, converter: BaseConverter }, - 'chg3ay1' => { column: :chg3ay1, converter: NumberConverter }, - 'xchg3at2' => { column: :xchg3at2, converter: BaseConverter }, - 'chg3at2' => { column: :chg3at2, converter: NumberConverter }, - 'xchg3af2' => { column: :xchg3af2, converter: BaseConverter }, - 'chg3af2' => { column: :chg3af2, converter: NumberConverter }, - 'xchg3ay2' => { column: :xchg3ay2, converter: BaseConverter }, - 'chg3ay2' => { column: :chg3ay2, converter: NumberConverter }, - 'xchg3at3' => { column: :xchg3at3, converter: BaseConverter }, - 'chg3at3' => { column: :chg3at3, converter: NumberConverter }, - 'xchg3af3' => { column: :xchg3af3, converter: BaseConverter }, - 'chg3af3' => { column: :chg3af3, converter: NumberConverter }, - 'xchg3ay3' => { column: :xchg3ay3, converter: BaseConverter }, - 'chg3ay3' => { column: :tuition_out_of_state, converter: NumberConverter }, - 'chg3tgtd' => { column: :chg3tgtd, converter: NumberConverter }, - 'chg3fgtd' => { column: :chg3fgtd, converter: NumberConverter }, - 'xchg4ay0' => { column: :xchg4ay0, converter: BaseConverter }, - 'chg4ay0' => { column: :chg4ay0, converter: NumberConverter }, - 'xchg4ay1' => { column: :xchg4ay1, converter: BaseConverter }, - 'chg4ay1' => { column: :chg4ay1, converter: NumberConverter }, - 'xchg4ay2' => { column: :xchg4ay2, converter: BaseConverter }, - 'chg4ay2' => { column: :chg4ay2, converter: NumberConverter }, - 'xchg4ay3' => { column: :xchg4ay3, converter: BaseConverter }, - 'chg4ay3' => { column: :books, converter: NumberConverter }, - 'xchg5ay0' => { column: :xchg5ay0, converter: BaseConverter }, - 'chg5ay0' => { column: :chg5ay0, converter: NumberConverter }, - 'xchg5ay1' => { column: :xchg5ay1, converter: BaseConverter }, - 'chg5ay1' => { column: :chg5ay1, converter: NumberConverter }, - 'xchg5ay2' => { column: :xchg5ay2, converter: BaseConverter }, - 'chg5ay2' => { column: :chg5ay2, converter: NumberConverter }, - 'xchg5ay3' => { column: :xchg5ay3, converter: BaseConverter }, - 'chg5ay3' => { column: :chg5ay3, converter: NumberConverter }, - 'xchg6ay0' => { column: :xchg6ay0, converter: BaseConverter }, - 'chg6ay0' => { column: :chg6ay0, converter: NumberConverter }, - 'xchg6ay1' => { column: :xchg6ay1, converter: BaseConverter }, - 'chg6ay1' => { column: :chg6ay1, converter: NumberConverter }, - 'xchg6ay2' => { column: :xchg6ay2, converter: BaseConverter }, - 'chg6ay2' => { column: :chg6ay2, converter: NumberConverter }, - 'xchg6ay3' => { column: :xchg6ay3, converter: BaseConverter }, - 'chg6ay3' => { column: :chg6ay3, converter: NumberConverter }, - 'xchg7ay0' => { column: :xchg7ay0, converter: BaseConverter }, - 'chg7ay0' => { column: :chg7ay0, converter: NumberConverter }, - 'xchg7ay1' => { column: :xchg7ay1, converter: BaseConverter }, - 'chg7ay1' => { column: :chg7ay1, converter: NumberConverter }, - 'xchg7ay2' => { column: :xchg7ay2, converter: BaseConverter }, - 'chg7ay2' => { column: :chg7ay2, converter: NumberConverter }, - 'xchg7ay3' => { column: :xchg7ay3, converter: BaseConverter }, - 'chg7ay3' => { column: :chg7ay3, converter: NumberConverter }, - 'xchg8ay0' => { column: :xchg8ay0, converter: BaseConverter }, - 'chg8ay0' => { column: :chg8ay0, converter: NumberConverter }, - 'xchg8ay1' => { column: :xchg8ay1, converter: BaseConverter }, - 'chg8ay1' => { column: :chg8ay1, converter: NumberConverter }, - 'xchg8ay2' => { column: :xchg8ay2, converter: BaseConverter }, - 'chg8ay2' => { column: :chg8ay2, converter: NumberConverter }, - 'xchg8ay3' => { column: :xchg8ay3, converter: BaseConverter }, - 'chg8ay3' => { column: :chg8ay3, converter: NumberConverter }, - 'xchg9ay0' => { column: :xchg9ay0, converter: BaseConverter }, - 'chg9ay0' => { column: :chg9ay0, converter: NumberConverter }, - 'xchg9ay1' => { column: :xchg9ay1, converter: BaseConverter }, - 'chg9ay1' => { column: :chg9ay1, converter: NumberConverter }, - 'xchg9ay2' => { column: :xchg9ay2, converter: BaseConverter }, - 'chg9ay2' => { column: :chg9ay2, converter: NumberConverter }, - 'xchg9ay3' => { column: :xchg9ay3, converter: BaseConverter }, - 'chg9ay3' => { column: :chg9ay3, converter: NumberConverter } + 'unitid' => { column: :cross, converter: Converters::CrossConverter }, + 'xtuit1' => { column: :xtuit1, converter: Converters::BaseConverter }, + 'tuition1' => { column: :tuition1, converter: Converters::NumberConverter }, + 'xfee1' => { column: :xfee1, converter: Converters::BaseConverter }, + 'fee1' => { column: :fee1, converter: Converters::NumberConverter }, + 'xhrchg1' => { column: :xhrchg1, converter: Converters::BaseConverter }, + 'hrchg1' => { column: :hrchg1, converter: Converters::NumberConverter }, + 'xtuit2' => { column: :xtuit2, converter: Converters::BaseConverter }, + 'tuition2' => { column: :tuition2, converter: Converters::NumberConverter }, + 'xfee2' => { column: :xfee2, converter: Converters::BaseConverter }, + 'fee2' => { column: :fee2, converter: Converters::NumberConverter }, + 'xhrchg2' => { column: :xhrchg2, converter: Converters::BaseConverter }, + 'hrchg2' => { column: :hrchg2, converter: Converters::NumberConverter }, + 'xtuit3' => { column: :xtuit3, converter: Converters::BaseConverter }, + 'tuition3' => { column: :tuition3, converter: Converters::NumberConverter }, + 'xfee3' => { column: :xfee3, converter: Converters::BaseConverter }, + 'fee3' => { column: :fee3, converter: Converters::NumberConverter }, + 'xhrchg3' => { column: :xhrchg3, converter: Converters::BaseConverter }, + 'hrchg3' => { column: :hrchg3, converter: Converters::NumberConverter }, + 'xtuit5' => { column: :xtuit5, converter: Converters::BaseConverter }, + 'tuition5' => { column: :tuition5, converter: Converters::NumberConverter }, + 'xfee5' => { column: :xfee5, converter: Converters::BaseConverter }, + 'fee5' => { column: :fee5, converter: Converters::NumberConverter }, + 'xhrchg5' => { column: :xhrchg5, converter: Converters::BaseConverter }, + 'hrchg5' => { column: :hrchg5, converter: Converters::NumberConverter }, + 'xtuit6' => { column: :xtuit6, converter: Converters::BaseConverter }, + 'tuition6' => { column: :tuition6, converter: Converters::NumberConverter }, + 'xfee6' => { column: :xfee6, converter: Converters::BaseConverter }, + 'fee6' => { column: :fee6, converter: Converters::NumberConverter }, + 'xhrchg6' => { column: :xhrchg6, converter: Converters::BaseConverter }, + 'hrchg6' => { column: :hrchg6, converter: Converters::NumberConverter }, + 'xtuit7' => { column: :xtuit7, converter: Converters::BaseConverter }, + 'tuition7' => { column: :tuition7, converter: Converters::NumberConverter }, + 'xfee7' => { column: :xfee7, converter: Converters::BaseConverter }, + 'fee7' => { column: :fee7, converter: Converters::NumberConverter }, + 'xhrchg7' => { column: :xhrchg7, converter: Converters::BaseConverter }, + 'hrchg7' => { column: :hrchg7, converter: Converters::NumberConverter }, + 'xispro1' => { column: :xispro1, converter: Converters::BaseConverter }, + 'isprof1' => { column: :isprof1, converter: Converters::NumberConverter }, + 'xispfe1' => { column: :xispfe1, converter: Converters::BaseConverter }, + 'ispfee1' => { column: :ispfee1, converter: Converters::NumberConverter }, + 'xospro1' => { column: :xospro1, converter: Converters::BaseConverter }, + 'osprof1' => { column: :osprof1, converter: Converters::NumberConverter }, + 'xospfe1' => { column: :xospfe1, converter: Converters::BaseConverter }, + 'ospfee1' => { column: :ospfee1, converter: Converters::NumberConverter }, + 'xispro2' => { column: :xispro2, converter: Converters::BaseConverter }, + 'isprof2' => { column: :isprof2, converter: Converters::NumberConverter }, + 'xispfe2' => { column: :xispfe2, converter: Converters::BaseConverter }, + 'ispfee2' => { column: :ispfee2, converter: Converters::NumberConverter }, + 'xospro2' => { column: :xospro2, converter: Converters::BaseConverter }, + 'osprof2' => { column: :osprof2, converter: Converters::NumberConverter }, + 'xospfe2' => { column: :xospfe2, converter: Converters::BaseConverter }, + 'ospfee2' => { column: :ospfee2, converter: Converters::NumberConverter }, + 'xispro3' => { column: :xispro3, converter: Converters::BaseConverter }, + 'isprof3' => { column: :isprof3, converter: Converters::NumberConverter }, + 'xispfe3' => { column: :xispfe3, converter: Converters::BaseConverter }, + 'ispfee3' => { column: :ispfee3, converter: Converters::NumberConverter }, + 'xospro3' => { column: :xospro3, converter: Converters::BaseConverter }, + 'osprof3' => { column: :osprof3, converter: Converters::NumberConverter }, + 'xospfe3' => { column: :xospfe3, converter: Converters::BaseConverter }, + 'ospfee3' => { column: :ospfee3, converter: Converters::NumberConverter }, + 'xispro4' => { column: :xispro4, converter: Converters::BaseConverter }, + 'isprof4' => { column: :isprof4, converter: Converters::NumberConverter }, + 'xispfe4' => { column: :xispfe4, converter: Converters::BaseConverter }, + 'ispfee4' => { column: :ispfee4, converter: Converters::NumberConverter }, + 'xospro4' => { column: :xospro4, converter: Converters::BaseConverter }, + 'osprof4' => { column: :osprof4, converter: Converters::NumberConverter }, + 'xospfe4' => { column: :xospfe4, converter: Converters::BaseConverter }, + 'ospfee4' => { column: :ospfee4, converter: Converters::NumberConverter }, + 'xispro5' => { column: :xispro5, converter: Converters::BaseConverter }, + 'isprof5' => { column: :isprof5, converter: Converters::NumberConverter }, + 'xispfe5' => { column: :xispfe5, converter: Converters::BaseConverter }, + 'ispfee5' => { column: :ispfee5, converter: Converters::NumberConverter }, + 'xospro5' => { column: :xospro5, converter: Converters::BaseConverter }, + 'osprof5' => { column: :osprof5, converter: Converters::NumberConverter }, + 'xospfe5' => { column: :xospfe5, converter: Converters::BaseConverter }, + 'ospfee5' => { column: :ospfee5, converter: Converters::NumberConverter }, + 'xispro6' => { column: :xispro6, converter: Converters::BaseConverter }, + 'isprof6' => { column: :isprof6, converter: Converters::NumberConverter }, + 'xispfe6' => { column: :xispfe6, converter: Converters::BaseConverter }, + 'ispfee6' => { column: :ispfee6, converter: Converters::NumberConverter }, + 'xospro6' => { column: :xospro6, converter: Converters::BaseConverter }, + 'osprof6' => { column: :osprof6, converter: Converters::NumberConverter }, + 'xospfe6' => { column: :xospfe6, converter: Converters::BaseConverter }, + 'ospfee6' => { column: :ospfee6, converter: Converters::NumberConverter }, + 'xispro7' => { column: :xispro7, converter: Converters::BaseConverter }, + 'isprof7' => { column: :isprof7, converter: Converters::NumberConverter }, + 'xispfe7' => { column: :xispfe7, converter: Converters::BaseConverter }, + 'ispfee7' => { column: :ispfee7, converter: Converters::NumberConverter }, + 'xospro7' => { column: :xospro7, converter: Converters::BaseConverter }, + 'osprof7' => { column: :osprof7, converter: Converters::NumberConverter }, + 'xospfe7' => { column: :xospfe7, converter: Converters::BaseConverter }, + 'ospfee7' => { column: :ospfee7, converter: Converters::NumberConverter }, + 'xispro8' => { column: :xispro8, converter: Converters::BaseConverter }, + 'isprof8' => { column: :isprof8, converter: Converters::NumberConverter }, + 'xispfe8' => { column: :xispfe8, converter: Converters::BaseConverter }, + 'ispfee8' => { column: :ispfee8, converter: Converters::NumberConverter }, + 'xospro8' => { column: :xospro8, converter: Converters::BaseConverter }, + 'osprof8' => { column: :osprof8, converter: Converters::NumberConverter }, + 'xospfe8' => { column: :xospfe8, converter: Converters::BaseConverter }, + 'ospfee8' => { column: :ospfee8, converter: Converters::NumberConverter }, + 'xispro9' => { column: :xispro9, converter: Converters::BaseConverter }, + 'isprof9' => { column: :isprof9, converter: Converters::NumberConverter }, + 'xispfe9' => { column: :xispfe9, converter: Converters::BaseConverter }, + 'ispfee9' => { column: :ispfee9, converter: Converters::NumberConverter }, + 'xospro9' => { column: :xospro9, converter: Converters::BaseConverter }, + 'osprof9' => { column: :osprof9, converter: Converters::NumberConverter }, + 'xospfe9' => { column: :xospfe9, converter: Converters::BaseConverter }, + 'ospfee9' => { column: :ospfee9, converter: Converters::NumberConverter }, + 'xchg1at0' => { column: :xchg1at0, converter: Converters::BaseConverter }, + 'chg1at0' => { column: :chg1at0, converter: Converters::NumberConverter }, + 'xchg1af0' => { column: :xchg1af0, converter: Converters::BaseConverter }, + 'chg1af0' => { column: :chg1af0, converter: Converters::NumberConverter }, + 'xchg1ay0' => { column: :xchg1ay0, converter: Converters::BaseConverter }, + 'chg1ay0' => { column: :chg1ay0, converter: Converters::NumberConverter }, + 'xchg1at1' => { column: :xchg1at1, converter: Converters::BaseConverter }, + 'chg1at1' => { column: :chg1at1, converter: Converters::NumberConverter }, + 'xchg1af1' => { column: :xchg1af1, converter: Converters::BaseConverter }, + 'chg1af1' => { column: :chg1af1, converter: Converters::NumberConverter }, + 'xchg1ay1' => { column: :xchg1ay1, converter: Converters::BaseConverter }, + 'chg1ay1' => { column: :chg1ay1, converter: Converters::NumberConverter }, + 'xchg1at2' => { column: :xchg1at2, converter: Converters::BaseConverter }, + 'chg1at2' => { column: :chg1at2, converter: Converters::NumberConverter }, + 'xchg1af2' => { column: :xchg1af2, converter: Converters::BaseConverter }, + 'chg1af2' => { column: :chg1af2, converter: Converters::NumberConverter }, + 'xchg1ay2' => { column: :xchg1ay2, converter: Converters::BaseConverter }, + 'chg1ay2' => { column: :chg1ay2, converter: Converters::NumberConverter }, + 'xchg1at3' => { column: :xchg1at3, converter: Converters::BaseConverter }, + 'chg1at3' => { column: :chg1at3, converter: Converters::NumberConverter }, + 'xchg1af3' => { column: :xchg1af3, converter: Converters::BaseConverter }, + 'chg1af3' => { column: :chg1af3, converter: Converters::NumberConverter }, + 'xchg1ay3' => { column: :xchg1ay3, converter: Converters::BaseConverter }, + 'chg1ay3' => { column: :chg1ay3, converter: Converters::NumberConverter }, + 'chg1tgtd' => { column: :chg1tgtd, converter: Converters::NumberConverter }, + 'chg1fgtd' => { column: :chg1fgtd, converter: Converters::NumberConverter }, + 'xchg2at0' => { column: :xchg2at0, converter: Converters::BaseConverter }, + 'chg2at0' => { column: :chg2at0, converter: Converters::NumberConverter }, + 'xchg2af0' => { column: :xchg2af0, converter: Converters::BaseConverter }, + 'chg2af0' => { column: :chg2af0, converter: Converters::NumberConverter }, + 'xchg2ay0' => { column: :xchg2ay0, converter: Converters::BaseConverter }, + 'chg2ay0' => { column: :chg2ay0, converter: Converters::NumberConverter }, + 'xchg2at1' => { column: :xchg2at1, converter: Converters::BaseConverter }, + 'chg2at1' => { column: :chg2at1, converter: Converters::NumberConverter }, + 'xchg2af1' => { column: :xchg2af1, converter: Converters::BaseConverter }, + 'chg2af1' => { column: :chg2af1, converter: Converters::NumberConverter }, + 'xchg2ay1' => { column: :xchg2ay1, converter: Converters::BaseConverter }, + 'chg2ay1' => { column: :chg2ay1, converter: Converters::NumberConverter }, + 'xchg2at2' => { column: :xchg2at2, converter: Converters::BaseConverter }, + 'chg2at2' => { column: :chg2at2, converter: Converters::NumberConverter }, + 'xchg2af2' => { column: :xchg2af2, converter: Converters::BaseConverter }, + 'chg2af2' => { column: :chg2af2, converter: Converters::NumberConverter }, + 'xchg2ay2' => { column: :xchg2ay2, converter: Converters::BaseConverter }, + 'chg2ay2' => { column: :chg2ay2, converter: Converters::NumberConverter }, + 'xchg2at3' => { column: :xchg2at3, converter: Converters::BaseConverter }, + 'chg2at3' => { column: :chg2at3, converter: Converters::NumberConverter }, + 'xchg2af3' => { column: :xchg2af3, converter: Converters::BaseConverter }, + 'chg2af3' => { column: :chg2af3, converter: Converters::NumberConverter }, + 'xchg2ay3' => { column: :xchg2ay3, converter: Converters::BaseConverter }, + 'chg2ay3' => { column: :tuition_in_state, converter: Converters::NumberConverter }, + 'chg2tgtd' => { column: :chg2tgtd, converter: Converters::NumberConverter }, + 'chg2fgtd' => { column: :chg2fgtd, converter: Converters::NumberConverter }, + 'xchg3at0' => { column: :xchg3at0, converter: Converters::BaseConverter }, + 'chg3at0' => { column: :chg3at0, converter: Converters::NumberConverter }, + 'xchg3af0' => { column: :xchg3af0, converter: Converters::BaseConverter }, + 'chg3af0' => { column: :chg3af0, converter: Converters::NumberConverter }, + 'xchg3ay0' => { column: :xchg3ay0, converter: Converters::BaseConverter }, + 'chg3ay0' => { column: :chg3ay0, converter: Converters::NumberConverter }, + 'xchg3at1' => { column: :xchg3at1, converter: Converters::BaseConverter }, + 'chg3at1' => { column: :chg3at1, converter: Converters::NumberConverter }, + 'xchg3af1' => { column: :xchg3af1, converter: Converters::BaseConverter }, + 'chg3af1' => { column: :chg3af1, converter: Converters::NumberConverter }, + 'xchg3ay1' => { column: :xchg3ay1, converter: Converters::BaseConverter }, + 'chg3ay1' => { column: :chg3ay1, converter: Converters::NumberConverter }, + 'xchg3at2' => { column: :xchg3at2, converter: Converters::BaseConverter }, + 'chg3at2' => { column: :chg3at2, converter: Converters::NumberConverter }, + 'xchg3af2' => { column: :xchg3af2, converter: Converters::BaseConverter }, + 'chg3af2' => { column: :chg3af2, converter: Converters::NumberConverter }, + 'xchg3ay2' => { column: :xchg3ay2, converter: Converters::BaseConverter }, + 'chg3ay2' => { column: :chg3ay2, converter: Converters::NumberConverter }, + 'xchg3at3' => { column: :xchg3at3, converter: Converters::BaseConverter }, + 'chg3at3' => { column: :chg3at3, converter: Converters::NumberConverter }, + 'xchg3af3' => { column: :xchg3af3, converter: Converters::BaseConverter }, + 'chg3af3' => { column: :chg3af3, converter: Converters::NumberConverter }, + 'xchg3ay3' => { column: :xchg3ay3, converter: Converters::BaseConverter }, + 'chg3ay3' => { column: :tuition_out_of_state, converter: Converters::NumberConverter }, + 'chg3tgtd' => { column: :chg3tgtd, converter: Converters::NumberConverter }, + 'chg3fgtd' => { column: :chg3fgtd, converter: Converters::NumberConverter }, + 'xchg4ay0' => { column: :xchg4ay0, converter: Converters::BaseConverter }, + 'chg4ay0' => { column: :chg4ay0, converter: Converters::NumberConverter }, + 'xchg4ay1' => { column: :xchg4ay1, converter: Converters::BaseConverter }, + 'chg4ay1' => { column: :chg4ay1, converter: Converters::NumberConverter }, + 'xchg4ay2' => { column: :xchg4ay2, converter: Converters::BaseConverter }, + 'chg4ay2' => { column: :chg4ay2, converter: Converters::NumberConverter }, + 'xchg4ay3' => { column: :xchg4ay3, converter: Converters::BaseConverter }, + 'chg4ay3' => { column: :books, converter: Converters::NumberConverter }, + 'xchg5ay0' => { column: :xchg5ay0, converter: Converters::BaseConverter }, + 'chg5ay0' => { column: :chg5ay0, converter: Converters::NumberConverter }, + 'xchg5ay1' => { column: :xchg5ay1, converter: Converters::BaseConverter }, + 'chg5ay1' => { column: :chg5ay1, converter: Converters::NumberConverter }, + 'xchg5ay2' => { column: :xchg5ay2, converter: Converters::BaseConverter }, + 'chg5ay2' => { column: :chg5ay2, converter: Converters::NumberConverter }, + 'xchg5ay3' => { column: :xchg5ay3, converter: Converters::BaseConverter }, + 'chg5ay3' => { column: :chg5ay3, converter: Converters::NumberConverter }, + 'xchg6ay0' => { column: :xchg6ay0, converter: Converters::BaseConverter }, + 'chg6ay0' => { column: :chg6ay0, converter: Converters::NumberConverter }, + 'xchg6ay1' => { column: :xchg6ay1, converter: Converters::BaseConverter }, + 'chg6ay1' => { column: :chg6ay1, converter: Converters::NumberConverter }, + 'xchg6ay2' => { column: :xchg6ay2, converter: Converters::BaseConverter }, + 'chg6ay2' => { column: :chg6ay2, converter: Converters::NumberConverter }, + 'xchg6ay3' => { column: :xchg6ay3, converter: Converters::BaseConverter }, + 'chg6ay3' => { column: :chg6ay3, converter: Converters::NumberConverter }, + 'xchg7ay0' => { column: :xchg7ay0, converter: Converters::BaseConverter }, + 'chg7ay0' => { column: :chg7ay0, converter: Converters::NumberConverter }, + 'xchg7ay1' => { column: :xchg7ay1, converter: Converters::BaseConverter }, + 'chg7ay1' => { column: :chg7ay1, converter: Converters::NumberConverter }, + 'xchg7ay2' => { column: :xchg7ay2, converter: Converters::BaseConverter }, + 'chg7ay2' => { column: :chg7ay2, converter: Converters::NumberConverter }, + 'xchg7ay3' => { column: :xchg7ay3, converter: Converters::BaseConverter }, + 'chg7ay3' => { column: :chg7ay3, converter: Converters::NumberConverter }, + 'xchg8ay0' => { column: :xchg8ay0, converter: Converters::BaseConverter }, + 'chg8ay0' => { column: :chg8ay0, converter: Converters::NumberConverter }, + 'xchg8ay1' => { column: :xchg8ay1, converter: Converters::BaseConverter }, + 'chg8ay1' => { column: :chg8ay1, converter: Converters::NumberConverter }, + 'xchg8ay2' => { column: :xchg8ay2, converter: Converters::BaseConverter }, + 'chg8ay2' => { column: :chg8ay2, converter: Converters::NumberConverter }, + 'xchg8ay3' => { column: :xchg8ay3, converter: Converters::BaseConverter }, + 'chg8ay3' => { column: :chg8ay3, converter: Converters::NumberConverter }, + 'xchg9ay0' => { column: :xchg9ay0, converter: Converters::BaseConverter }, + 'chg9ay0' => { column: :chg9ay0, converter: Converters::NumberConverter }, + 'xchg9ay1' => { column: :xchg9ay1, converter: Converters::BaseConverter }, + 'chg9ay1' => { column: :chg9ay1, converter: Converters::NumberConverter }, + 'xchg9ay2' => { column: :xchg9ay2, converter: Converters::BaseConverter }, + 'chg9ay2' => { column: :chg9ay2, converter: Converters::NumberConverter }, + 'xchg9ay3' => { column: :xchg9ay3, converter: Converters::BaseConverter }, + 'chg9ay3' => { column: :chg9ay3, converter: Converters::NumberConverter } }.freeze validates :cross, presence: true diff --git a/app/models/ipeds_ic_py.rb b/app/models/ipeds_ic_py.rb index 742aec2b7..aa2a27c88 100644 --- a/app/models/ipeds_ic_py.rb +++ b/app/models/ipeds_ic_py.rb @@ -4,130 +4,130 @@ class IpedsIcPy < ImportableRecord COLS_USED_IN_INSTITUTION = %i[tuition_in_state tuition_out_of_state books].freeze CSV_CONVERTER_INFO = { - 'unitid' => { column: :cross, converter: CrossConverter }, - 'prgmofr' => { column: :prgmofr, converter: NumberConverter }, - 'cipcode1' => { column: :cipcode1, converter: NumberConverter }, - 'xciptui1' => { column: :xciptui1, converter: BaseConverter }, - 'ciptuit1' => { column: :ciptuit1, converter: NumberConverter }, - 'xcipsup1' => { column: :xcipsup1, converter: BaseConverter }, - 'cipsupp1' => { column: :cipsupp1, converter: NumberConverter }, - 'xciplgt1' => { column: :xciplgt1, converter: BaseConverter }, - 'ciplgth1' => { column: :ciplgth1, converter: NumberConverter }, - 'prgmsr1' => { column: :prgmsr1, converter: NumberConverter }, - 'xmthcmp1' => { column: :xmthcmp1, converter: BaseConverter }, - 'mthcmp1' => { column: :mthcmp1, converter: NumberConverter }, - 'xwkcmp1' => { column: :xwkcmp1, converter: BaseConverter }, - 'wkcmp1' => { column: :wkcmp1, converter: NumberConverter }, - 'xlnayhr1' => { column: :xlnayhr1, converter: BaseConverter }, - 'lnayhr1' => { column: :lnayhr1, converter: NumberConverter }, - 'xlnaywk1' => { column: :xlnaywk1, converter: BaseConverter }, - 'lnaywk1' => { column: :lnaywk1, converter: NumberConverter }, - 'xchg1py0' => { column: :xchg1py0, converter: BaseConverter }, - 'chg1py0' => { column: :chg1py0, converter: NumberConverter }, - 'xchg1py1' => { column: :xchg1py1, converter: BaseConverter }, - 'chg1py1' => { column: :chg1py1, converter: NumberConverter }, - 'xchg1py2' => { column: :xchg1py2, converter: BaseConverter }, - 'chg1py2' => { column: :chg1py2, converter: NumberConverter }, - 'xchg1py3' => { column: :xchg1py3, converter: BaseConverter }, - 'chg1py3' => { column: :chg1py3, converter: NumberConverter }, - 'xchg4py0' => { column: :xchg4py0, converter: BaseConverter }, - 'chg4py0' => { column: :chg4py0, converter: NumberConverter }, - 'xchg4py1' => { column: :xchg4py1, converter: BaseConverter }, - 'chg4py1' => { column: :chg4py1, converter: NumberConverter }, - 'xchg4py2' => { column: :xchg4py2, converter: BaseConverter }, - 'chg4py2' => { column: :chg4py2, converter: NumberConverter }, - 'xchg4py3' => { column: :xchg4py3, converter: BaseConverter }, - 'chg4py3' => { column: :books, converter: NumberConverter }, - 'xchg5py0' => { column: :xchg5py0, converter: BaseConverter }, - 'chg5py0' => { column: :chg5py0, converter: NumberConverter }, - 'xchg5py1' => { column: :xchg5py1, converter: BaseConverter }, - 'chg5py1' => { column: :chg5py1, converter: NumberConverter }, - 'xchg5py2' => { column: :xchg5py2, converter: BaseConverter }, - 'chg5py2' => { column: :chg5py2, converter: NumberConverter }, - 'xchg5py3' => { column: :xchg5py3, converter: BaseConverter }, - 'chg5py3' => { column: :chg5py3, converter: NumberConverter }, - 'xchg6py0' => { column: :xchg6py0, converter: BaseConverter }, - 'chg6py0' => { column: :chg6py0, converter: NumberConverter }, - 'xchg6py1' => { column: :xchg6py1, converter: BaseConverter }, - 'chg6py1' => { column: :chg6py1, converter: NumberConverter }, - 'xchg6py2' => { column: :xchg6py2, converter: BaseConverter }, - 'chg6py2' => { column: :chg6py2, converter: NumberConverter }, - 'xchg6py3' => { column: :xchg6py3, converter: BaseConverter }, - 'chg6py3' => { column: :chg6py3, converter: NumberConverter }, - 'xchg7py0' => { column: :xchg7py0, converter: BaseConverter }, - 'chg7py0' => { column: :chg7py0, converter: NumberConverter }, - 'xchg7py1' => { column: :xchg7py1, converter: BaseConverter }, - 'chg7py1' => { column: :chg7py1, converter: NumberConverter }, - 'xchg7py2' => { column: :xchg7py2, converter: BaseConverter }, - 'chg7py2' => { column: :chg7py2, converter: NumberConverter }, - 'xchg7py3' => { column: :xchg7py3, converter: BaseConverter }, - 'chg7py3' => { column: :chg7py3, converter: NumberConverter }, - 'xchg8py0' => { column: :xchg8py0, converter: BaseConverter }, - 'chg8py0' => { column: :chg8py0, converter: NumberConverter }, - 'xchg8py1' => { column: :xchg8py1, converter: BaseConverter }, - 'chg8py1' => { column: :chg8py1, converter: NumberConverter }, - 'xchg8py2' => { column: :xchg8py2, converter: BaseConverter }, - 'chg8py2' => { column: :chg8py2, converter: NumberConverter }, - 'xchg8py3' => { column: :xchg8py3, converter: BaseConverter }, - 'chg8py3' => { column: :chg8py3, converter: NumberConverter }, - 'xchg9py0' => { column: :xchg9py0, converter: BaseConverter }, - 'chg9py0' => { column: :chg9py0, converter: NumberConverter }, - 'xchg9py1' => { column: :xchg9py1, converter: BaseConverter }, - 'chg9py1' => { column: :chg9py1, converter: NumberConverter }, - 'xchg9py2' => { column: :xchg9py2, converter: BaseConverter }, - 'chg9py2' => { column: :chg9py2, converter: NumberConverter }, - 'xchg9py3' => { column: :xchg9py3, converter: BaseConverter }, - 'chg9py3' => { column: :chg9py3, converter: NumberConverter }, - 'cipcode2' => { column: :cipcode2, converter: NumberConverter }, - 'xciptui2' => { column: :xciptui2, converter: BaseConverter }, - 'ciptuit2' => { column: :ciptuit2, converter: NumberConverter }, - 'xcipsup2' => { column: :xcipsup2, converter: BaseConverter }, - 'cipsupp2' => { column: :cipsupp2, converter: NumberConverter }, - 'xciplgt2' => { column: :xciplgt2, converter: BaseConverter }, - 'ciplgth2' => { column: :ciplgth2, converter: NumberConverter }, - 'prgmsr2' => { column: :prgmsr2, converter: NumberConverter }, - 'xmthcmp2' => { column: :xmthcmp2, converter: BaseConverter }, - 'mthcmp2' => { column: :mthcmp2, converter: NumberConverter }, - 'cipcode3' => { column: :cipcode3, converter: NumberConverter }, - 'xciptui3' => { column: :xciptui3, converter: BaseConverter }, - 'ciptuit3' => { column: :ciptuit3, converter: NumberConverter }, - 'xcipsup3' => { column: :xcipsup3, converter: BaseConverter }, - 'cipsupp3' => { column: :cipsupp3, converter: NumberConverter }, - 'xciplgt3' => { column: :xciplgt3, converter: BaseConverter }, - 'ciplgth3' => { column: :ciplgth3, converter: NumberConverter }, - 'prgmsr3' => { column: :prgmsr3, converter: NumberConverter }, - 'xmthcmp3' => { column: :xmthcmp3, converter: BaseConverter }, - 'mthcmp3' => { column: :mthcmp3, converter: NumberConverter }, - 'cipcode4' => { column: :cipcode4, converter: NumberConverter }, - 'xciptui4' => { column: :xciptui4, converter: BaseConverter }, - 'ciptuit4' => { column: :ciptuit4, converter: NumberConverter }, - 'xcipsup4' => { column: :xcipsup4, converter: BaseConverter }, - 'cipsupp4' => { column: :cipsupp4, converter: NumberConverter }, - 'xciplgt4' => { column: :xciplgt4, converter: BaseConverter }, - 'ciplgth4' => { column: :ciplgth4, converter: NumberConverter }, - 'prgmsr4' => { column: :prgmsr4, converter: NumberConverter }, - 'xmthcmp4' => { column: :xmthcmp4, converter: BaseConverter }, - 'mthcmp4' => { column: :mthcmp4, converter: NumberConverter }, - 'cipcode5' => { column: :cipcode5, converter: NumberConverter }, - 'xciptui5' => { column: :xciptui5, converter: BaseConverter }, - 'ciptuit5' => { column: :ciptuit5, converter: NumberConverter }, - 'xcipsup5' => { column: :xcipsup5, converter: BaseConverter }, - 'cipsupp5' => { column: :cipsupp5, converter: NumberConverter }, - 'xciplgt5' => { column: :xciplgt5, converter: BaseConverter }, - 'ciplgth5' => { column: :ciplgth5, converter: NumberConverter }, - 'prgmsr5' => { column: :prgmsr5, converter: NumberConverter }, - 'xmthcmp5' => { column: :xmthcmp5, converter: BaseConverter }, - 'mthcmp5' => { column: :mthcmp5, converter: NumberConverter }, - 'cipcode6' => { column: :cipcode6, converter: NumberConverter }, - 'xciptui6' => { column: :xciptui6, converter: BaseConverter }, - 'ciptuit6' => { column: :ciptuit6, converter: NumberConverter }, - 'xcipsup6' => { column: :xcipsup6, converter: BaseConverter }, - 'cipsupp6' => { column: :cipsupp6, converter: NumberConverter }, - 'xciplgt6' => { column: :xciplgt6, converter: BaseConverter }, - 'ciplgth6' => { column: :ciplgth6, converter: NumberConverter }, - 'prgmsr6' => { column: :prgmsr6, converter: NumberConverter }, - 'xmthcmp6' => { column: :xmthcmp6, converter: BaseConverter }, - 'mthcmp6' => { column: :mthcmp6, converter: NumberConverter } + 'unitid' => { column: :cross, converter: Converters::CrossConverter }, + 'prgmofr' => { column: :prgmofr, converter: Converters::NumberConverter }, + 'cipcode1' => { column: :cipcode1, converter: Converters::NumberConverter }, + 'xciptui1' => { column: :xciptui1, converter: Converters::BaseConverter }, + 'ciptuit1' => { column: :ciptuit1, converter: Converters::NumberConverter }, + 'xcipsup1' => { column: :xcipsup1, converter: Converters::BaseConverter }, + 'cipsupp1' => { column: :cipsupp1, converter: Converters::NumberConverter }, + 'xciplgt1' => { column: :xciplgt1, converter: Converters::BaseConverter }, + 'ciplgth1' => { column: :ciplgth1, converter: Converters::NumberConverter }, + 'prgmsr1' => { column: :prgmsr1, converter: Converters::NumberConverter }, + 'xmthcmp1' => { column: :xmthcmp1, converter: Converters::BaseConverter }, + 'mthcmp1' => { column: :mthcmp1, converter: Converters::NumberConverter }, + 'xwkcmp1' => { column: :xwkcmp1, converter: Converters::BaseConverter }, + 'wkcmp1' => { column: :wkcmp1, converter: Converters::NumberConverter }, + 'xlnayhr1' => { column: :xlnayhr1, converter: Converters::BaseConverter }, + 'lnayhr1' => { column: :lnayhr1, converter: Converters::NumberConverter }, + 'xlnaywk1' => { column: :xlnaywk1, converter: Converters::BaseConverter }, + 'lnaywk1' => { column: :lnaywk1, converter: Converters::NumberConverter }, + 'xchg1py0' => { column: :xchg1py0, converter: Converters::BaseConverter }, + 'chg1py0' => { column: :chg1py0, converter: Converters::NumberConverter }, + 'xchg1py1' => { column: :xchg1py1, converter: Converters::BaseConverter }, + 'chg1py1' => { column: :chg1py1, converter: Converters::NumberConverter }, + 'xchg1py2' => { column: :xchg1py2, converter: Converters::BaseConverter }, + 'chg1py2' => { column: :chg1py2, converter: Converters::NumberConverter }, + 'xchg1py3' => { column: :xchg1py3, converter: Converters::BaseConverter }, + 'chg1py3' => { column: :chg1py3, converter: Converters::NumberConverter }, + 'xchg4py0' => { column: :xchg4py0, converter: Converters::BaseConverter }, + 'chg4py0' => { column: :chg4py0, converter: Converters::NumberConverter }, + 'xchg4py1' => { column: :xchg4py1, converter: Converters::BaseConverter }, + 'chg4py1' => { column: :chg4py1, converter: Converters::NumberConverter }, + 'xchg4py2' => { column: :xchg4py2, converter: Converters::BaseConverter }, + 'chg4py2' => { column: :chg4py2, converter: Converters::NumberConverter }, + 'xchg4py3' => { column: :xchg4py3, converter: Converters::BaseConverter }, + 'chg4py3' => { column: :books, converter: Converters::NumberConverter }, + 'xchg5py0' => { column: :xchg5py0, converter: Converters::BaseConverter }, + 'chg5py0' => { column: :chg5py0, converter: Converters::NumberConverter }, + 'xchg5py1' => { column: :xchg5py1, converter: Converters::BaseConverter }, + 'chg5py1' => { column: :chg5py1, converter: Converters::NumberConverter }, + 'xchg5py2' => { column: :xchg5py2, converter: Converters::BaseConverter }, + 'chg5py2' => { column: :chg5py2, converter: Converters::NumberConverter }, + 'xchg5py3' => { column: :xchg5py3, converter: Converters::BaseConverter }, + 'chg5py3' => { column: :chg5py3, converter: Converters::NumberConverter }, + 'xchg6py0' => { column: :xchg6py0, converter: Converters::BaseConverter }, + 'chg6py0' => { column: :chg6py0, converter: Converters::NumberConverter }, + 'xchg6py1' => { column: :xchg6py1, converter: Converters::BaseConverter }, + 'chg6py1' => { column: :chg6py1, converter: Converters::NumberConverter }, + 'xchg6py2' => { column: :xchg6py2, converter: Converters::BaseConverter }, + 'chg6py2' => { column: :chg6py2, converter: Converters::NumberConverter }, + 'xchg6py3' => { column: :xchg6py3, converter: Converters::BaseConverter }, + 'chg6py3' => { column: :chg6py3, converter: Converters::NumberConverter }, + 'xchg7py0' => { column: :xchg7py0, converter: Converters::BaseConverter }, + 'chg7py0' => { column: :chg7py0, converter: Converters::NumberConverter }, + 'xchg7py1' => { column: :xchg7py1, converter: Converters::BaseConverter }, + 'chg7py1' => { column: :chg7py1, converter: Converters::NumberConverter }, + 'xchg7py2' => { column: :xchg7py2, converter: Converters::BaseConverter }, + 'chg7py2' => { column: :chg7py2, converter: Converters::NumberConverter }, + 'xchg7py3' => { column: :xchg7py3, converter: Converters::BaseConverter }, + 'chg7py3' => { column: :chg7py3, converter: Converters::NumberConverter }, + 'xchg8py0' => { column: :xchg8py0, converter: Converters::BaseConverter }, + 'chg8py0' => { column: :chg8py0, converter: Converters::NumberConverter }, + 'xchg8py1' => { column: :xchg8py1, converter: Converters::BaseConverter }, + 'chg8py1' => { column: :chg8py1, converter: Converters::NumberConverter }, + 'xchg8py2' => { column: :xchg8py2, converter: Converters::BaseConverter }, + 'chg8py2' => { column: :chg8py2, converter: Converters::NumberConverter }, + 'xchg8py3' => { column: :xchg8py3, converter: Converters::BaseConverter }, + 'chg8py3' => { column: :chg8py3, converter: Converters::NumberConverter }, + 'xchg9py0' => { column: :xchg9py0, converter: Converters::BaseConverter }, + 'chg9py0' => { column: :chg9py0, converter: Converters::NumberConverter }, + 'xchg9py1' => { column: :xchg9py1, converter: Converters::BaseConverter }, + 'chg9py1' => { column: :chg9py1, converter: Converters::NumberConverter }, + 'xchg9py2' => { column: :xchg9py2, converter: Converters::BaseConverter }, + 'chg9py2' => { column: :chg9py2, converter: Converters::NumberConverter }, + 'xchg9py3' => { column: :xchg9py3, converter: Converters::BaseConverter }, + 'chg9py3' => { column: :chg9py3, converter: Converters::NumberConverter }, + 'cipcode2' => { column: :cipcode2, converter: Converters::NumberConverter }, + 'xciptui2' => { column: :xciptui2, converter: Converters::BaseConverter }, + 'ciptuit2' => { column: :ciptuit2, converter: Converters::NumberConverter }, + 'xcipsup2' => { column: :xcipsup2, converter: Converters::BaseConverter }, + 'cipsupp2' => { column: :cipsupp2, converter: Converters::NumberConverter }, + 'xciplgt2' => { column: :xciplgt2, converter: Converters::BaseConverter }, + 'ciplgth2' => { column: :ciplgth2, converter: Converters::NumberConverter }, + 'prgmsr2' => { column: :prgmsr2, converter: Converters::NumberConverter }, + 'xmthcmp2' => { column: :xmthcmp2, converter: Converters::BaseConverter }, + 'mthcmp2' => { column: :mthcmp2, converter: Converters::NumberConverter }, + 'cipcode3' => { column: :cipcode3, converter: Converters::NumberConverter }, + 'xciptui3' => { column: :xciptui3, converter: Converters::BaseConverter }, + 'ciptuit3' => { column: :ciptuit3, converter: Converters::NumberConverter }, + 'xcipsup3' => { column: :xcipsup3, converter: Converters::BaseConverter }, + 'cipsupp3' => { column: :cipsupp3, converter: Converters::NumberConverter }, + 'xciplgt3' => { column: :xciplgt3, converter: Converters::BaseConverter }, + 'ciplgth3' => { column: :ciplgth3, converter: Converters::NumberConverter }, + 'prgmsr3' => { column: :prgmsr3, converter: Converters::NumberConverter }, + 'xmthcmp3' => { column: :xmthcmp3, converter: Converters::BaseConverter }, + 'mthcmp3' => { column: :mthcmp3, converter: Converters::NumberConverter }, + 'cipcode4' => { column: :cipcode4, converter: Converters::NumberConverter }, + 'xciptui4' => { column: :xciptui4, converter: Converters::BaseConverter }, + 'ciptuit4' => { column: :ciptuit4, converter: Converters::NumberConverter }, + 'xcipsup4' => { column: :xcipsup4, converter: Converters::BaseConverter }, + 'cipsupp4' => { column: :cipsupp4, converter: Converters::NumberConverter }, + 'xciplgt4' => { column: :xciplgt4, converter: Converters::BaseConverter }, + 'ciplgth4' => { column: :ciplgth4, converter: Converters::NumberConverter }, + 'prgmsr4' => { column: :prgmsr4, converter: Converters::NumberConverter }, + 'xmthcmp4' => { column: :xmthcmp4, converter: Converters::BaseConverter }, + 'mthcmp4' => { column: :mthcmp4, converter: Converters::NumberConverter }, + 'cipcode5' => { column: :cipcode5, converter: Converters::NumberConverter }, + 'xciptui5' => { column: :xciptui5, converter: Converters::BaseConverter }, + 'ciptuit5' => { column: :ciptuit5, converter: Converters::NumberConverter }, + 'xcipsup5' => { column: :xcipsup5, converter: Converters::BaseConverter }, + 'cipsupp5' => { column: :cipsupp5, converter: Converters::NumberConverter }, + 'xciplgt5' => { column: :xciplgt5, converter: Converters::BaseConverter }, + 'ciplgth5' => { column: :ciplgth5, converter: Converters::NumberConverter }, + 'prgmsr5' => { column: :prgmsr5, converter: Converters::NumberConverter }, + 'xmthcmp5' => { column: :xmthcmp5, converter: Converters::BaseConverter }, + 'mthcmp5' => { column: :mthcmp5, converter: Converters::NumberConverter }, + 'cipcode6' => { column: :cipcode6, converter: Converters::NumberConverter }, + 'xciptui6' => { column: :xciptui6, converter: Converters::BaseConverter }, + 'ciptuit6' => { column: :ciptuit6, converter: Converters::NumberConverter }, + 'xcipsup6' => { column: :xcipsup6, converter: Converters::BaseConverter }, + 'cipsupp6' => { column: :cipsupp6, converter: Converters::NumberConverter }, + 'xciplgt6' => { column: :xciplgt6, converter: Converters::BaseConverter }, + 'ciplgth6' => { column: :ciplgth6, converter: Converters::NumberConverter }, + 'prgmsr6' => { column: :prgmsr6, converter: Converters::NumberConverter }, + 'xmthcmp6' => { column: :xmthcmp6, converter: Converters::BaseConverter }, + 'mthcmp6' => { column: :mthcmp6, converter: Converters::NumberConverter } }.freeze validates :cross, presence: true diff --git a/app/models/mou.rb b/app/models/mou.rb index 6fb833b1e..839d62e6d 100644 --- a/app/models/mou.rb +++ b/app/models/mou.rb @@ -4,14 +4,14 @@ class Mou < ImportableRecord STATUSES = /\A(probation - dod|title iv non-compliant)\z/i CSV_CONVERTER_INFO = { - 'ope_id' => { column: :ope, converter: OpeConverter }, - 'institution_name' => { column: :institution, converter: InstitutionConverter }, - 'trade_name' => { column: :trade_name, converter: BaseConverter }, - 'city' => { column: :city, converter: BaseConverter }, - 'state' => { column: :state, converter: BaseConverter }, - 'institution_type' => { column: :institution_type, converter: BaseConverter }, - 'status' => { column: :status, converter: BaseConverter }, - 'approval_date' => { column: :approval_date, converter: BaseConverter } + 'ope_id' => { column: :ope, converter: Converters::OpeConverter }, + 'institution_name' => { column: :institution, converter: Converters::InstitutionConverter }, + 'trade_name' => { column: :trade_name, converter: Converters::BaseConverter }, + 'city' => { column: :city, converter: Converters::BaseConverter }, + 'state' => { column: :state, converter: Converters::BaseConverter }, + 'institution_type' => { column: :institution_type, converter: Converters::BaseConverter }, + 'status' => { column: :status, converter: Converters::BaseConverter }, + 'approval_date' => { column: :approval_date, converter: Converters::BaseConverter } }.freeze validates :ope, :ope6, presence: true @@ -21,7 +21,7 @@ class Mou < ImportableRecord def derive_dependent_columns self.dodmou = to_dodmou self.dod_status = to_dod_status - self.ope6 = Ope6Converter.convert(ope) + self.ope6 = Converters::Ope6Converter.convert(ope) end def to_dodmou diff --git a/app/models/outcome.rb b/app/models/outcome.rb index 1d2ebb8c1..19ab8c1a0 100644 --- a/app/models/outcome.rb +++ b/app/models/outcome.rb @@ -8,15 +8,15 @@ class Outcome < ImportableRecord ].freeze CSV_CONVERTER_INFO = { - 'va_facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'va_facility_name' => { column: :institution, converter: InstitutionConverter }, - 'school_level_va' => { column: :school_level_va, converter: BaseConverter }, - 'retention_rate_veteran_ba' => { column: :retention_rate_veteran_ba, converter: NumberConverter }, - 'retention_rate_veteran_otb' => { column: :retention_rate_veteran_otb, converter: NumberConverter }, - 'persistance_rate_veteran_ba' => { column: :persistance_rate_veteran_ba, converter: NumberConverter }, - 'persistance_rate_veteran_otb' => { column: :persistance_rate_veteran_otb, converter: NumberConverter }, - 'graduation_rate_veteran' => { column: :graduation_rate_veteran, converter: NumberConverter }, - 'transfer_out_rate_veteran' => { column: :transfer_out_rate_veteran, converter: NumberConverter } + 'va_facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'va_facility_name' => { column: :institution, converter: Converters::InstitutionConverter }, + 'school_level_va' => { column: :school_level_va, converter: Converters::BaseConverter }, + 'retention_rate_veteran_ba' => { column: :retention_rate_veteran_ba, converter: Converters::NumberConverter }, + 'retention_rate_veteran_otb' => { column: :retention_rate_veteran_otb, converter: Converters::NumberConverter }, + 'persistance_rate_veteran_ba' => { column: :persistance_rate_veteran_ba, converter: Converters::NumberConverter }, + 'persistance_rate_veteran_otb' => { column: :persistance_rate_veteran_otb, converter: Converters::NumberConverter }, + 'graduation_rate_veteran' => { column: :graduation_rate_veteran, converter: Converters::NumberConverter }, + 'transfer_out_rate_veteran' => { column: :transfer_out_rate_veteran, converter: Converters::NumberConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/post911_stat.rb b/app/models/post911_stat.rb index 67c1afde3..6f2b75570 100644 --- a/app/models/post911_stat.rb +++ b/app/models/post911_stat.rb @@ -2,13 +2,13 @@ class Post911Stat < ImportableRecord CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'distinct_count_of_tuition_and_fee' => { column: :tuition_and_fee_count, converter: NumberConverter }, - 'tuition_and_fee_payments' => { column: :tuition_and_fee_payments, converter: NumberConverter }, - 'tuition_and_fee_total_amount' => { column: :tuition_and_fee_total_amount, converter: NumberConverter }, - 'distinct_count_of_yellow_ribbon' => { column: :yellow_ribbon_count, converter: NumberConverter }, - 'yellow_ribbon_payments' => { column: :yellow_ribbon_payments, converter: NumberConverter }, - 'yellow_ribbon_total_amount' => { column: :yellow_ribbon_total_amount, converter: NumberConverter } + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'distinct_count_of_tuition_and_fee' => { column: :tuition_and_fee_count, converter: Converters::NumberConverter }, + 'tuition_and_fee_payments' => { column: :tuition_and_fee_payments, converter: Converters::NumberConverter }, + 'tuition_and_fee_total_amount' => { column: :tuition_and_fee_total_amount, converter: Converters::NumberConverter }, + 'distinct_count_of_yellow_ribbon' => { column: :yellow_ribbon_count, converter: Converters::NumberConverter }, + 'yellow_ribbon_payments' => { column: :yellow_ribbon_payments, converter: Converters::NumberConverter }, + 'yellow_ribbon_total_amount' => { column: :yellow_ribbon_total_amount, converter: Converters::NumberConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/program.rb b/app/models/program.rb index 037f19ede..e60a9b19e 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -2,14 +2,14 @@ class Program < ImportableRecord CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'institution_name' => { column: :institution_name, converter: InstitutionConverter }, - 'program_type' => { column: :program_type, converter: BaseConverter }, - 'description' => { column: :description, converter: BaseConverter }, - 'full_time_undergraduate' => { column: :full_time_undergraduate, converter: BaseConverter }, - 'graduate' => { column: :graduate, converter: BaseConverter }, - 'full_time_modifier' => { column: :full_time_modifier, converter: BaseConverter }, - 'length' => { column: :length, converter: BaseConverter } + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'institution_name' => { column: :institution_name, converter: Converters::InstitutionConverter }, + 'program_type' => { column: :program_type, converter: Converters::BaseConverter }, + 'description' => { column: :description, converter: Converters::BaseConverter }, + 'full_time_undergraduate' => { column: :full_time_undergraduate, converter: Converters::BaseConverter }, + 'graduate' => { column: :graduate, converter: Converters::BaseConverter }, + 'full_time_modifier' => { column: :full_time_modifier, converter: Converters::BaseConverter }, + 'length' => { column: :length, converter: Converters::BaseConverter } }.freeze PROGRAM_TYPES = %w[ diff --git a/app/models/school_certifying_official.rb b/app/models/school_certifying_official.rb index 13f3af833..ba1906072 100644 --- a/app/models/school_certifying_official.rb +++ b/app/models/school_certifying_official.rb @@ -7,16 +7,16 @@ class SchoolCertifyingOfficial < ImportableRecord ].freeze CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'institution_name' => { column: :institution_name, converter: InstitutionConverter }, - 'priority' => { column: :priority, converter: BaseConverter }, - 'first_name' => { column: :first_name, converter: BaseConverter }, - 'last_name' => { column: :last_name, converter: BaseConverter }, - 'title' => { column: :title, converter: BaseConverter }, - 'phone_area_code' => { column: :phone_area_code, converter: BaseConverter }, - 'phone_number' => { column: :phone_number, converter: BaseConverter }, - 'phone_extension' => { column: :phone_extension, converter: BaseConverter }, - 'email' => { column: :email, converter: BaseConverter } + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'institution_name' => { column: :institution_name, converter: Converters::InstitutionConverter }, + 'priority' => { column: :priority, converter: Converters::BaseConverter }, + 'first_name' => { column: :first_name, converter: Converters::BaseConverter }, + 'last_name' => { column: :last_name, converter: Converters::BaseConverter }, + 'title' => { column: :title, converter: Converters::BaseConverter }, + 'phone_area_code' => { column: :phone_area_code, converter: Converters::BaseConverter }, + 'phone_number' => { column: :phone_number, converter: Converters::BaseConverter }, + 'phone_extension' => { column: :phone_extension, converter: Converters::BaseConverter }, + 'email' => { column: :email, converter: Converters::BaseConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/scorecard.rb b/app/models/scorecard.rb index bbf80438a..8b497a305 100644 --- a/app/models/scorecard.rb +++ b/app/models/scorecard.rb @@ -24,129 +24,129 @@ class Scorecard < ImportableRecord ].freeze CSV_CONVERTER_INFO = { - 'unitid' => { column: :cross, converter: CrossConverter }, - 'opeid' => { column: :ope, converter: OpeConverter }, - 'opeid6' => { column: :ope6, converter: Ope6Converter }, - 'instnm' => { column: :institution, converter: InstitutionConverter }, - 'city' => { column: :city, converter: BaseConverter }, - 'stabbr' => { column: :state, converter: StateConverter }, - 'insturl' => { column: :insturl, converter: BaseConverter }, - 'npcurl' => { column: :npcurl, converter: BaseConverter }, - 'hcm2' => { column: :hcm2, converter: NumberConverter }, - 'preddeg' => { column: :pred_degree_awarded, converter: NumberConverter }, - 'control' => { column: :control, converter: NumberConverter }, - 'locale' => { column: :locale, converter: NumberConverter }, - 'hbcu' => { column: :hbcu, converter: NumberConverter }, - 'pbi' => { column: :pbi, converter: NumberConverter }, - 'annhi' => { column: :annhi, converter: NumberConverter }, - 'tribal' => { column: :tribal, converter: NumberConverter }, - 'aanapii' => { column: :aanapii, converter: NumberConverter }, - 'hsi' => { column: :hsi, converter: NumberConverter }, - 'nanti' => { column: :nanti, converter: NumberConverter }, - 'menonly' => { column: :menonly, converter: NumberConverter }, - 'womenonly' => { column: :womenonly, converter: NumberConverter }, - 'relaffil' => { column: :relaffil, converter: NumberConverter }, - 'satvr25' => { column: :satvr25, converter: NumberConverter }, - 'satvr75' => { column: :satvr75, converter: NumberConverter }, - 'satmt25' => { column: :satmt25, converter: NumberConverter }, - 'satmt75' => { column: :satmt75, converter: NumberConverter }, - 'satwr25' => { column: :satwr25, converter: NumberConverter }, - 'satwr75' => { column: :satwr75, converter: NumberConverter }, - 'satvrmid' => { column: :satvrmid, converter: NumberConverter }, - 'satmtmid' => { column: :satmtmid, converter: NumberConverter }, - 'satwrmid' => { column: :satwrmid, converter: NumberConverter }, - 'actcm25' => { column: :actcm25, converter: NumberConverter }, - 'actcm75' => { column: :actcm75, converter: NumberConverter }, - 'acten25' => { column: :acten25, converter: NumberConverter }, - 'acten75' => { column: :acten75, converter: NumberConverter }, - 'actmt25' => { column: :actmt25, converter: NumberConverter }, - 'actmt75' => { column: :actmt75, converter: NumberConverter }, - 'actwr25' => { column: :actwr25, converter: NumberConverter }, - 'actwr75' => { column: :actwr75, converter: NumberConverter }, - 'actcmmid' => { column: :actcmmid, converter: NumberConverter }, - 'actenmid' => { column: :actenmid, converter: NumberConverter }, - 'actmtmid' => { column: :actmtmid, converter: NumberConverter }, - 'actwrmid' => { column: :actwrmid, converter: NumberConverter }, - 'sat_avg' => { column: :sat_avg, converter: NumberConverter }, - 'sat_avg_all' => { column: :sat_avg_all, converter: NumberConverter }, - 'pcip01' => { column: :pcip01, converter: NumberConverter }, - 'pcip03' => { column: :pcip03, converter: NumberConverter }, - 'pcip04' => { column: :pcip04, converter: NumberConverter }, - 'pcip05' => { column: :pcip05, converter: NumberConverter }, - 'pcip09' => { column: :pcip09, converter: NumberConverter }, - 'pcip10' => { column: :pcip10, converter: NumberConverter }, - 'pcip11' => { column: :pcip11, converter: NumberConverter }, - 'pcip12' => { column: :pcip12, converter: NumberConverter }, - 'pcip13' => { column: :pcip13, converter: NumberConverter }, - 'pcip14' => { column: :pcip14, converter: NumberConverter }, - 'pcip15' => { column: :pcip15, converter: NumberConverter }, - 'pcip16' => { column: :pcip16, converter: NumberConverter }, - 'pcip19' => { column: :pcip19, converter: NumberConverter }, - 'pcip22' => { column: :pcip22, converter: NumberConverter }, - 'pcip23' => { column: :pcip23, converter: NumberConverter }, - 'pcip24' => { column: :pcip24, converter: NumberConverter }, - 'pcip25' => { column: :pcip25, converter: NumberConverter }, - 'pcip26' => { column: :pcip26, converter: NumberConverter }, - 'pcip27' => { column: :pcip27, converter: NumberConverter }, - 'pcip29' => { column: :pcip29, converter: NumberConverter }, - 'pcip30' => { column: :pcip30, converter: NumberConverter }, - 'pcip31' => { column: :pcip31, converter: NumberConverter }, - 'pcip38' => { column: :pcip38, converter: NumberConverter }, - 'pcip39' => { column: :pcip39, converter: NumberConverter }, - 'pcip40' => { column: :pcip40, converter: NumberConverter }, - 'pcip41' => { column: :pcip41, converter: NumberConverter }, - 'pcip42' => { column: :pcip42, converter: NumberConverter }, - 'pcip43' => { column: :pcip43, converter: NumberConverter }, - 'pcip44' => { column: :pcip44, converter: NumberConverter }, - 'pcip45' => { column: :pcip45, converter: NumberConverter }, - 'pcip46' => { column: :pcip46, converter: NumberConverter }, - 'pcip47' => { column: :pcip47, converter: NumberConverter }, - 'pcip48' => { column: :pcip48, converter: NumberConverter }, - 'pcip49' => { column: :pcip49, converter: NumberConverter }, - 'pcip50' => { column: :pcip50, converter: NumberConverter }, - 'pcip51' => { column: :pcip51, converter: NumberConverter }, - 'pcip52' => { column: :pcip52, converter: NumberConverter }, - 'pcip54' => { column: :pcip54, converter: NumberConverter }, - 'distanceonly' => { column: :distanceonly, converter: NumberConverter }, - 'ugds' => { column: :undergrad_enrollment, converter: NumberConverter }, - 'ugds_white' => { column: :ugds_white, converter: NumberConverter }, - 'ugds_black' => { column: :ugds_black, converter: NumberConverter }, - 'ugds_hisp' => { column: :ugds_hisp, converter: NumberConverter }, - 'ugds_asian' => { column: :ugds_asian, converter: NumberConverter }, - 'ugds_aian' => { column: :ugds_aian, converter: NumberConverter }, - 'ugds_nhpi' => { column: :ugds_nhpi, converter: NumberConverter }, - 'ugds_2mor' => { column: :ugds_2mor, converter: NumberConverter }, - 'ugds_nra' => { column: :ugds_nra, converter: NumberConverter }, - 'ugds_unkn' => { column: :ugds_unkn, converter: NumberConverter }, - 'pptug_ef' => { column: :pptug_ef, converter: NumberConverter }, - 'curroper' => { column: :curroper, converter: NumberConverter }, - 'npt4_pub' => { column: :npt4_pub, converter: NumberConverter }, - 'npt4_priv' => { column: :npt4_priv, converter: NumberConverter }, - 'npt41_pub' => { column: :npt41_pub, converter: NumberConverter }, - 'npt42_pub' => { column: :npt42_pub, converter: NumberConverter }, - 'npt43_pub' => { column: :npt43_pub, converter: NumberConverter }, - 'npt44_pub' => { column: :npt44_pub, converter: NumberConverter }, - 'npt45_pub' => { column: :npt45_pub, converter: NumberConverter }, - 'npt41_priv' => { column: :npt41_priv, converter: NumberConverter }, - 'npt42_priv' => { column: :npt42_priv, converter: NumberConverter }, - 'npt43_priv' => { column: :npt43_priv, converter: NumberConverter }, - 'npt44_priv' => { column: :npt44_priv, converter: NumberConverter }, - 'npt45_priv' => { column: :npt45_priv, converter: NumberConverter }, - 'pctpell' => { column: :pctpell, converter: NumberConverter }, - 'ret_ft4' => { column: :retention_all_students_ba, converter: NumberConverter }, - 'ret_ftl4' => { column: :retention_all_students_otb, converter: NumberConverter }, - 'ret_pt4' => { column: :ret_pt4, converter: NumberConverter }, - 'ret_ptl4' => { column: :ret_ptl4, converter: NumberConverter }, - 'pctfloan' => { column: :pctfloan, converter: NumberConverter }, - 'ug25abv' => { column: :ug25abv, converter: NumberConverter }, - 'md_earn_wne_p10' => { column: :salary_all_students, converter: NumberConverter }, - 'gt_25k_p6' => { column: :gt_25k_p6, converter: NumberConverter }, - 'grad_debt_mdn_supp' => { column: :avg_stu_loan_debt, converter: NumberConverter }, - 'grad_debt_mdn10yr_supp' => { column: :grad_debt_mdn10yr_supp, converter: NumberConverter }, - 'rpy_3yr_rt_supp' => { column: :repayment_rate_all_students, converter: NumberConverter }, - 'c150_4_pooled_supp' => { column: :c150_4_pooled_supp, converter: NumberConverter }, - 'c150_l4_pooled_supp' => { column: :c150_l4_pooled_supp, converter: NumberConverter }, - 'alias' => { column: :alias, converter: BaseConverter } + 'unitid' => { column: :cross, converter: Converters::CrossConverter }, + 'opeid' => { column: :ope, converter: Converters::OpeConverter }, + 'opeid6' => { column: :ope6, converter: Converters::Ope6Converter }, + 'instnm' => { column: :institution, converter: Converters::InstitutionConverter }, + 'city' => { column: :city, converter: Converters::BaseConverter }, + 'stabbr' => { column: :state, converter: Converters::StateConverter }, + 'insturl' => { column: :insturl, converter: Converters::BaseConverter }, + 'npcurl' => { column: :npcurl, converter: Converters::BaseConverter }, + 'hcm2' => { column: :hcm2, converter: Converters::NumberConverter }, + 'preddeg' => { column: :pred_degree_awarded, converter: Converters::NumberConverter }, + 'control' => { column: :control, converter: Converters::NumberConverter }, + 'locale' => { column: :locale, converter: Converters::NumberConverter }, + 'hbcu' => { column: :hbcu, converter: Converters::NumberConverter }, + 'pbi' => { column: :pbi, converter: Converters::NumberConverter }, + 'annhi' => { column: :annhi, converter: Converters::NumberConverter }, + 'tribal' => { column: :tribal, converter: Converters::NumberConverter }, + 'aanapii' => { column: :aanapii, converter: Converters::NumberConverter }, + 'hsi' => { column: :hsi, converter: Converters::NumberConverter }, + 'nanti' => { column: :nanti, converter: Converters::NumberConverter }, + 'menonly' => { column: :menonly, converter: Converters::NumberConverter }, + 'womenonly' => { column: :womenonly, converter: Converters::NumberConverter }, + 'relaffil' => { column: :relaffil, converter: Converters::NumberConverter }, + 'satvr25' => { column: :satvr25, converter: Converters::NumberConverter }, + 'satvr75' => { column: :satvr75, converter: Converters::NumberConverter }, + 'satmt25' => { column: :satmt25, converter: Converters::NumberConverter }, + 'satmt75' => { column: :satmt75, converter: Converters::NumberConverter }, + 'satwr25' => { column: :satwr25, converter: Converters::NumberConverter }, + 'satwr75' => { column: :satwr75, converter: Converters::NumberConverter }, + 'satvrmid' => { column: :satvrmid, converter: Converters::NumberConverter }, + 'satmtmid' => { column: :satmtmid, converter: Converters::NumberConverter }, + 'satwrmid' => { column: :satwrmid, converter: Converters::NumberConverter }, + 'actcm25' => { column: :actcm25, converter: Converters::NumberConverter }, + 'actcm75' => { column: :actcm75, converter: Converters::NumberConverter }, + 'acten25' => { column: :acten25, converter: Converters::NumberConverter }, + 'acten75' => { column: :acten75, converter: Converters::NumberConverter }, + 'actmt25' => { column: :actmt25, converter: Converters::NumberConverter }, + 'actmt75' => { column: :actmt75, converter: Converters::NumberConverter }, + 'actwr25' => { column: :actwr25, converter: Converters::NumberConverter }, + 'actwr75' => { column: :actwr75, converter: Converters::NumberConverter }, + 'actcmmid' => { column: :actcmmid, converter: Converters::NumberConverter }, + 'actenmid' => { column: :actenmid, converter: Converters::NumberConverter }, + 'actmtmid' => { column: :actmtmid, converter: Converters::NumberConverter }, + 'actwrmid' => { column: :actwrmid, converter: Converters::NumberConverter }, + 'sat_avg' => { column: :sat_avg, converter: Converters::NumberConverter }, + 'sat_avg_all' => { column: :sat_avg_all, converter: Converters::NumberConverter }, + 'pcip01' => { column: :pcip01, converter: Converters::NumberConverter }, + 'pcip03' => { column: :pcip03, converter: Converters::NumberConverter }, + 'pcip04' => { column: :pcip04, converter: Converters::NumberConverter }, + 'pcip05' => { column: :pcip05, converter: Converters::NumberConverter }, + 'pcip09' => { column: :pcip09, converter: Converters::NumberConverter }, + 'pcip10' => { column: :pcip10, converter: Converters::NumberConverter }, + 'pcip11' => { column: :pcip11, converter: Converters::NumberConverter }, + 'pcip12' => { column: :pcip12, converter: Converters::NumberConverter }, + 'pcip13' => { column: :pcip13, converter: Converters::NumberConverter }, + 'pcip14' => { column: :pcip14, converter: Converters::NumberConverter }, + 'pcip15' => { column: :pcip15, converter: Converters::NumberConverter }, + 'pcip16' => { column: :pcip16, converter: Converters::NumberConverter }, + 'pcip19' => { column: :pcip19, converter: Converters::NumberConverter }, + 'pcip22' => { column: :pcip22, converter: Converters::NumberConverter }, + 'pcip23' => { column: :pcip23, converter: Converters::NumberConverter }, + 'pcip24' => { column: :pcip24, converter: Converters::NumberConverter }, + 'pcip25' => { column: :pcip25, converter: Converters::NumberConverter }, + 'pcip26' => { column: :pcip26, converter: Converters::NumberConverter }, + 'pcip27' => { column: :pcip27, converter: Converters::NumberConverter }, + 'pcip29' => { column: :pcip29, converter: Converters::NumberConverter }, + 'pcip30' => { column: :pcip30, converter: Converters::NumberConverter }, + 'pcip31' => { column: :pcip31, converter: Converters::NumberConverter }, + 'pcip38' => { column: :pcip38, converter: Converters::NumberConverter }, + 'pcip39' => { column: :pcip39, converter: Converters::NumberConverter }, + 'pcip40' => { column: :pcip40, converter: Converters::NumberConverter }, + 'pcip41' => { column: :pcip41, converter: Converters::NumberConverter }, + 'pcip42' => { column: :pcip42, converter: Converters::NumberConverter }, + 'pcip43' => { column: :pcip43, converter: Converters::NumberConverter }, + 'pcip44' => { column: :pcip44, converter: Converters::NumberConverter }, + 'pcip45' => { column: :pcip45, converter: Converters::NumberConverter }, + 'pcip46' => { column: :pcip46, converter: Converters::NumberConverter }, + 'pcip47' => { column: :pcip47, converter: Converters::NumberConverter }, + 'pcip48' => { column: :pcip48, converter: Converters::NumberConverter }, + 'pcip49' => { column: :pcip49, converter: Converters::NumberConverter }, + 'pcip50' => { column: :pcip50, converter: Converters::NumberConverter }, + 'pcip51' => { column: :pcip51, converter: Converters::NumberConverter }, + 'pcip52' => { column: :pcip52, converter: Converters::NumberConverter }, + 'pcip54' => { column: :pcip54, converter: Converters::NumberConverter }, + 'distanceonly' => { column: :distanceonly, converter: Converters::NumberConverter }, + 'ugds' => { column: :undergrad_enrollment, converter: Converters::NumberConverter }, + 'ugds_white' => { column: :ugds_white, converter: Converters::NumberConverter }, + 'ugds_black' => { column: :ugds_black, converter: Converters::NumberConverter }, + 'ugds_hisp' => { column: :ugds_hisp, converter: Converters::NumberConverter }, + 'ugds_asian' => { column: :ugds_asian, converter: Converters::NumberConverter }, + 'ugds_aian' => { column: :ugds_aian, converter: Converters::NumberConverter }, + 'ugds_nhpi' => { column: :ugds_nhpi, converter: Converters::NumberConverter }, + 'ugds_2mor' => { column: :ugds_2mor, converter: Converters::NumberConverter }, + 'ugds_nra' => { column: :ugds_nra, converter: Converters::NumberConverter }, + 'ugds_unkn' => { column: :ugds_unkn, converter: Converters::NumberConverter }, + 'pptug_ef' => { column: :pptug_ef, converter: Converters::NumberConverter }, + 'curroper' => { column: :curroper, converter: Converters::NumberConverter }, + 'npt4_pub' => { column: :npt4_pub, converter: Converters::NumberConverter }, + 'npt4_priv' => { column: :npt4_priv, converter: Converters::NumberConverter }, + 'npt41_pub' => { column: :npt41_pub, converter: Converters::NumberConverter }, + 'npt42_pub' => { column: :npt42_pub, converter: Converters::NumberConverter }, + 'npt43_pub' => { column: :npt43_pub, converter: Converters::NumberConverter }, + 'npt44_pub' => { column: :npt44_pub, converter: Converters::NumberConverter }, + 'npt45_pub' => { column: :npt45_pub, converter: Converters::NumberConverter }, + 'npt41_priv' => { column: :npt41_priv, converter: Converters::NumberConverter }, + 'npt42_priv' => { column: :npt42_priv, converter: Converters::NumberConverter }, + 'npt43_priv' => { column: :npt43_priv, converter: Converters::NumberConverter }, + 'npt44_priv' => { column: :npt44_priv, converter: Converters::NumberConverter }, + 'npt45_priv' => { column: :npt45_priv, converter: Converters::NumberConverter }, + 'pctpell' => { column: :pctpell, converter: Converters::NumberConverter }, + 'ret_ft4' => { column: :retention_all_students_ba, converter: Converters::NumberConverter }, + 'ret_ftl4' => { column: :retention_all_students_otb, converter: Converters::NumberConverter }, + 'ret_pt4' => { column: :ret_pt4, converter: Converters::NumberConverter }, + 'ret_ptl4' => { column: :ret_ptl4, converter: Converters::NumberConverter }, + 'pctfloan' => { column: :pctfloan, converter: Converters::NumberConverter }, + 'ug25abv' => { column: :ug25abv, converter: Converters::NumberConverter }, + 'md_earn_wne_p10' => { column: :salary_all_students, converter: Converters::NumberConverter }, + 'gt_25k_p6' => { column: :gt_25k_p6, converter: Converters::NumberConverter }, + 'grad_debt_mdn_supp' => { column: :avg_stu_loan_debt, converter: Converters::NumberConverter }, + 'grad_debt_mdn10yr_supp' => { column: :grad_debt_mdn10yr_supp, converter: Converters::NumberConverter }, + 'rpy_3yr_rt_supp' => { column: :repayment_rate_all_students, converter: Converters::NumberConverter }, + 'c150_4_pooled_supp' => { column: :c150_4_pooled_supp, converter: Converters::NumberConverter }, + 'c150_l4_pooled_supp' => { column: :c150_l4_pooled_supp, converter: Converters::NumberConverter }, + 'alias' => { column: :alias, converter: Converters::BaseConverter } }.freeze after_initialize :derive_dependent_columns @@ -164,7 +164,7 @@ def self.populate def derive_dependent_columns self.graduation_rate_all_students = to_graduation_rate_all_students - self.ope6 = Ope6Converter.convert(ope) + self.ope6 = Converters::Ope6Converter.convert(ope) end def to_graduation_rate_all_students diff --git a/app/models/scorecard_degree_program.rb b/app/models/scorecard_degree_program.rb index e684cf1bb..a645ca2aa 100644 --- a/app/models/scorecard_degree_program.rb +++ b/app/models/scorecard_degree_program.rb @@ -3,14 +3,14 @@ class ScorecardDegreeProgram < ImportableRecord CSV_CONVERTER_INFO = { - 'unitid' => { column: :unitid, converter: NumberConverter }, - 'ope6_id' => { column: :ope6_id, converter: BaseConverter }, - 'control' => { column: :control, converter: NumberConverter }, - 'main' => { column: :main, converter: NumberConverter }, - 'cip_code' => { column: :cip_code, converter: BaseConverter }, - 'cip_desc' => { column: :cip_desc, converter: BaseConverter }, - 'cred_lev' => { column: :cred_lev, converter: NumberConverter }, - 'cred_desc' => { column: :cred_desc, converter: BaseConverter } + 'unitid' => { column: :unitid, converter: Converters::NumberConverter }, + 'ope6_id' => { column: :ope6_id, converter: Converters::BaseConverter }, + 'control' => { column: :control, converter: Converters::NumberConverter }, + 'main' => { column: :main, converter: Converters::NumberConverter }, + 'cip_code' => { column: :cip_code, converter: Converters::BaseConverter }, + 'cip_desc' => { column: :cip_desc, converter: Converters::BaseConverter }, + 'cred_lev' => { column: :cred_lev, converter: Converters::NumberConverter }, + 'cred_desc' => { column: :cred_desc, converter: Converters::BaseConverter } }.freeze API_SOURCE = 'https://collegescorecard.ed.gov/data/' diff --git a/app/models/sec103.rb b/app/models/sec103.rb index e68a973bc..30c117076 100644 --- a/app/models/sec103.rb +++ b/app/models/sec103.rb @@ -4,11 +4,11 @@ class Sec103 < ImportableRecord COLS_USED_IN_INSTITUTION = %i[complies_with_sec_103 solely_requires_coe requires_coe_and_criteria].freeze CSV_CONVERTER_INFO = { - 'facility_name' => { column: :name, converter: BaseConverter }, - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'complies_with_section_103' => { column: :complies_with_sec_103, converter: BooleanConverter }, - 'solely_requires_coe' => { column: :solely_requires_coe, converter: BooleanConverter }, - 'requires_coe_&_additional_criteria' => { column: :requires_coe_and_criteria, converter: BooleanConverter } + 'facility_name' => { column: :name, converter: Converters::BaseConverter }, + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'complies_with_section_103' => { column: :complies_with_sec_103, converter: Converters::BooleanConverter }, + 'solely_requires_coe' => { column: :solely_requires_coe, converter: Converters::BooleanConverter }, + 'requires_coe_&_additional_criteria' => { column: :requires_coe_and_criteria, converter: Converters::BooleanConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/sec109_closed_school.rb b/app/models/sec109_closed_school.rb index cba0521cc..f51ebc623 100644 --- a/app/models/sec109_closed_school.rb +++ b/app/models/sec109_closed_school.rb @@ -4,9 +4,9 @@ class Sec109ClosedSchool < ImportableRecord COLS_USED_IN_INSTITUTION = %i[closure109].freeze CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'school_name' => { column: :school_name, converter: InstitutionConverter }, - 'closure109' => { column: :closure109, converter: BooleanConverter } + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'school_name' => { column: :school_name, converter: Converters::InstitutionConverter }, + 'closure109' => { column: :closure109, converter: Converters::BooleanConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/sec702.rb b/app/models/sec702.rb index 29f8ccb5c..f3c9aa43c 100644 --- a/app/models/sec702.rb +++ b/app/models/sec702.rb @@ -2,10 +2,10 @@ class Sec702 < ImportableRecord CSV_CONVERTER_INFO = { - 'state' => { column: :state, converter: StateConverter }, - 'state_full_name' => { column: :state_full_name, converter: BaseConverter }, - 'sec702' => { column: :sec_702, converter: BooleanConverter } + 'state' => { column: :state, converter: Converters::StateConverter }, + 'state_full_name' => { column: :state_full_name, converter: Converters::BaseConverter }, + 'sec702' => { column: :sec_702, converter: Converters::BooleanConverter } }.freeze - validates :state, inclusion: { in: StateConverter::STATES.keys } + validates :state, inclusion: { in: Converters::StateConverter::STATES.keys } end diff --git a/app/models/section1015.rb b/app/models/section1015.rb index 9ee69f33f..c46ff594b 100644 --- a/app/models/section1015.rb +++ b/app/models/section1015.rb @@ -2,13 +2,13 @@ class Section1015 < ImportableRecord CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'name_of_institution' => { column: :institution, converter: InstitutionConverter }, - 'eff_date_of_withdrawal' => { column: :effective_date, converter: DateConverter }, - '#_of_active_students_from_saa_list' => { column: :active_students, converter: NumberConverter }, - 'last_student_to_graduate' => { column: :last_graduate, converter: DateConverter }, - 'celo_sent_to_gi_bill_comparison_tool' => { column: :celo, converter: BaseConverter }, - 'weams_withdraw_processed' => { column: :weams_withdrawal_processed, converter: BaseConverter } + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'name_of_institution' => { column: :institution, converter: Converters::InstitutionConverter }, + 'eff_date_of_withdrawal' => { column: :effective_date, converter: Converters::DateConverter }, + '#_of_active_students_from_saa_list' => { column: :active_students, converter: Converters::NumberConverter }, + 'last_student_to_graduate' => { column: :last_graduate, converter: Converters::DateConverter }, + 'celo_sent_to_gi_bill_comparison_tool' => { column: :celo, converter: Converters::BaseConverter }, + 'weams_withdraw_processed' => { column: :weams_withdrawal_processed, converter: Converters::BaseConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/stem_cip_code.rb b/app/models/stem_cip_code.rb index 640b27924..ebc399458 100644 --- a/app/models/stem_cip_code.rb +++ b/app/models/stem_cip_code.rb @@ -2,9 +2,9 @@ class StemCipCode < ImportableRecord CSV_CONVERTER_INFO = { - 'two_digit_series' => { column: :two_digit_series, converter: NumberConverter }, - '2010_cip_code' => { column: :twentyten_cip_code, converter: BaseConverter }, - 'cip_code_title' => { column: :cip_code_title, converter: BaseConverter } + 'two_digit_series' => { column: :two_digit_series, converter: Converters::NumberConverter }, + '2010_cip_code' => { column: :twentyten_cip_code, converter: Converters::BaseConverter }, + 'cip_code_title' => { column: :cip_code_title, converter: Converters::BaseConverter } }.freeze validates :two_digit_series, presence: true diff --git a/app/models/sva.rb b/app/models/sva.rb index 5d3a1a958..dc88d446d 100644 --- a/app/models/sva.rb +++ b/app/models/sva.rb @@ -2,14 +2,14 @@ class Sva < ImportableRecord CSV_CONVERTER_INFO = { - 'id' => { column: :csv_id, converter: NumberConverter }, - 'school' => { column: :institution, converter: InstitutionConverter }, - 'city' => { column: :city, converter: BaseConverter }, - 'state' => { column: :state, converter: BaseConverter }, - 'ipeds_code' => { column: :ipeds_code, converter: BaseConverter }, - 'website' => { column: :student_veteran_link, converter: BaseConverter }, - 'ipeds_6' => { column: :cross, converter: CrossConverter }, - 'sva_yes' => { column: :sva_yes, converter: BaseConverter } + 'id' => { column: :csv_id, converter: Converters::NumberConverter }, + 'school' => { column: :institution, converter: Converters::InstitutionConverter }, + 'city' => { column: :city, converter: Converters::BaseConverter }, + 'state' => { column: :state, converter: Converters::BaseConverter }, + 'ipeds_code' => { column: :ipeds_code, converter: Converters::BaseConverter }, + 'website' => { column: :student_veteran_link, converter: Converters::BaseConverter }, + 'ipeds_6' => { column: :cross, converter: Converters::CrossConverter }, + 'sva_yes' => { column: :sva_yes, converter: Converters::BaseConverter } }.freeze validates :cross, presence: true diff --git a/app/models/va_caution_flag.rb b/app/models/va_caution_flag.rb index 79c131566..f159726d2 100644 --- a/app/models/va_caution_flag.rb +++ b/app/models/va_caution_flag.rb @@ -2,15 +2,15 @@ class VaCautionFlag < ImportableRecord CSV_CONVERTER_INFO = { - 'id' => { column: :facility_code, converter: FacilityCodeConverter }, - 'instnm' => { column: :institution_name, converter: InstitutionConverter }, - 'school_system_name' => { column: :school_system_name, converter: BaseConverter }, - 'settlement_title' => { column: :settlement_title, converter: BaseConverter }, - 'settlement_description' => { column: :settlement_description, converter: BaseConverter }, - 'settlement_date' => { column: :settlement_date, converter: BaseConverter }, - 'settlement_link' => { column: :settlement_link, converter: BaseConverter }, - 'school_closing_date' => { column: :school_closing_date, converter: BaseConverter }, - 'sec_702' => { column: :sec_702, converter: BooleanConverter } + 'id' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'instnm' => { column: :institution_name, converter: Converters::InstitutionConverter }, + 'school_system_name' => { column: :school_system_name, converter: Converters::BaseConverter }, + 'settlement_title' => { column: :settlement_title, converter: Converters::BaseConverter }, + 'settlement_description' => { column: :settlement_description, converter: Converters::BaseConverter }, + 'settlement_date' => { column: :settlement_date, converter: Converters::BaseConverter }, + 'settlement_link' => { column: :settlement_link, converter: Converters::BaseConverter }, + 'school_closing_date' => { column: :school_closing_date, converter: Converters::BaseConverter }, + 'sec_702' => { column: :sec_702, converter: Converters::BooleanConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/version.rb b/app/models/version.rb index 9621e0bb5..1cf0113a5 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -88,9 +88,7 @@ def as_json(_options = nil) private def check_version - if number.present? && Version.find_by(number: number).nil? - errors.add(:number, "Version number #{number} doesn't exist") - end + errors.add(:number, "Version number #{number} doesn't exist") if number.present? && Version.find_by(number: number).nil? true end diff --git a/app/models/vrrap_provider.rb b/app/models/vrrap_provider.rb index 4a470eecd..0901d0088 100644 --- a/app/models/vrrap_provider.rb +++ b/app/models/vrrap_provider.rb @@ -2,11 +2,11 @@ class VrrapProvider < ImportableRecord CSV_CONVERTER_INFO = { - 'schoolname' => { column: :school_name, converter: FacilityCodeConverter }, - 'facilitycode' => { column: :facility_code, converter: BaseConverter }, - 'programs' => { column: :programs, converter: BaseConverter }, - 'vaco_approved/disapproved' => { column: :vaco, converter: BooleanConverter }, - 'address' => { column: :address, converter: BaseConverter } + 'schoolname' => { column: :school_name, converter: Converters::FacilityCodeConverter }, + 'facilitycode' => { column: :facility_code, converter: Converters::BaseConverter }, + 'programs' => { column: :programs, converter: Converters::BaseConverter }, + 'vaco_approved/disapproved' => { column: :vaco, converter: Converters::BooleanConverter }, + 'address' => { column: :address, converter: Converters::BaseConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/vsoc.rb b/app/models/vsoc.rb index c9226c6ad..2dc56cd6d 100644 --- a/app/models/vsoc.rb +++ b/app/models/vsoc.rb @@ -4,10 +4,10 @@ class Vsoc < ImportableRecord COLS_USED_IN_INSTITUTION = %i[vetsuccess_name vetsuccess_email].freeze CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'institution' => { column: :institution, converter: InstitutionConverter }, - 'vetsuccess_name' => { column: :vetsuccess_name, converter: BaseConverter }, - 'vetsuccess_email' => { column: :vetsuccess_email, converter: BaseConverter } + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'institution' => { column: :institution, converter: Converters::InstitutionConverter }, + 'vetsuccess_name' => { column: :vetsuccess_name, converter: Converters::BaseConverter }, + 'vetsuccess_email' => { column: :vetsuccess_email, converter: Converters::BaseConverter } }.freeze validates :facility_code, presence: true diff --git a/app/models/weam.rb b/app/models/weam.rb index 52ba3feb5..12a78faaf 100644 --- a/app/models/weam.rb +++ b/app/models/weam.rb @@ -40,48 +40,48 @@ class Weam < ImportableRecord # Used by loadable and (TODO) will be used with added include: true|false when building data.csv CSV_CONVERTER_INFO = { - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'institution_name' => { column: :institution, converter: InstitutionConverter }, - 'address_1' => { column: :address_1, converter: BaseConverter }, - 'address_2' => { column: :address_2, converter: BaseConverter }, - 'address_3' => { column: :address_3, converter: BaseConverter }, - 'institution_city' => { column: :city, converter: UpcaseConverter }, - 'institution_state' => { column: :state, converter: StateConverter }, - 'institution_zip_code' => { column: :zip, converter: ZipConverter }, - 'institution_country' => { column: :country, converter: UpcaseConverter }, - 'accredited' => { column: :accredited, converter: BooleanConverter }, - 'current_academic_year_va_bah_rate' => { column: :bah, converter: NumberConverter }, - 'principles_of_excellence' => { column: :poe, converter: BooleanConverter }, - 'current_academic_year_yellow_ribbon' => { column: :yr, converter: BooleanConverter }, - 'poo_status' => { column: :poo_status, converter: BaseConverter }, - 'applicable_law_code' => { column: :applicable_law_code, converter: BaseConverter }, + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'institution_name' => { column: :institution, converter: Converters::InstitutionConverter }, + 'address_1' => { column: :address_1, converter: Converters::BaseConverter }, + 'address_2' => { column: :address_2, converter: Converters::BaseConverter }, + 'address_3' => { column: :address_3, converter: Converters::BaseConverter }, + 'institution_city' => { column: :city, converter: Converters::UpcaseConverter }, + 'institution_state' => { column: :state, converter: Converters::StateConverter }, + 'institution_zip_code' => { column: :zip, converter: Converters::ZipConverter }, + 'institution_country' => { column: :country, converter: Converters::UpcaseConverter }, + 'accredited' => { column: :accredited, converter: Converters::BooleanConverter }, + 'current_academic_year_va_bah_rate' => { column: :bah, converter: Converters::NumberConverter }, + 'principles_of_excellence' => { column: :poe, converter: Converters::BooleanConverter }, + 'current_academic_year_yellow_ribbon' => { column: :yr, converter: Converters::BooleanConverter }, + 'poo_status' => { column: :poo_status, converter: Converters::BaseConverter }, + 'applicable_law_code' => { column: :applicable_law_code, converter: Converters::BaseConverter }, 'institution_of_higher_learning_indicator' => { - column: :institution_of_higher_learning_indicator, converter: BooleanConverter + column: :institution_of_higher_learning_indicator, converter: Converters::BooleanConverter }, - 'ojt_indicator' => { column: :ojt_indicator, converter: BooleanConverter }, - 'correspondence_indicator' => { column: :correspondence_indicator, converter: BooleanConverter }, - 'flight_indicator' => { column: :flight_indicator, converter: BooleanConverter }, - 'non_college_degree_indicator' => { column: :non_college_degree_indicator, converter: BooleanConverter }, - 'ipeds' => { column: :cross, converter: CrossConverter }, - 'ope' => { column: :ope, converter: OpeConverter }, - 'independent_study' => { column: :independent_study, converter: BooleanConverter }, - 'physical_address_1' => { column: :physical_address_1, converter: BaseConverter }, - 'physical_address_2' => { column: :physical_address_2, converter: BaseConverter }, - 'physical_address_3' => { column: :physical_address_3, converter: BaseConverter }, - 'physical_institution_city' => { column: :physical_city, converter: UpcaseConverter }, - 'physical_institution_state' => { column: :physical_state, converter: StateConverter }, - 'physical_institution_zip_code' => { column: :physical_zip, converter: ZipConverter }, - 'physical_institution_country' => { column: :physical_country, converter: UpcaseConverter }, - 'current_academic_year_dod_bah_rate' => { column: :dod_bah, converter: NumberConverter }, - 'online_only' => { column: :online_only, converter: BooleanConverter }, - 'distance_learning' => { column: :distance_learning, converter: BooleanConverter }, - 'priority_enrollment' => { column: :priority_enrollment, converter: BooleanConverter }, - 'preferred_provider' => { column: :preferred_provider, converter: BooleanConverter }, - 'stem_indicator' => { column: :stem_indicator, converter: BooleanConverter }, - 'campus_indicator' => { column: :campus_type, converter: BaseConverter }, - 'parent_facility_code' => { column: :parent_facility_code_id, converter: BaseConverter }, - 'in_state_tuition_url' => { column: :in_state_tuition_information, converter: BaseConverter }, - 'high_school' => { column: :high_school, converter: BooleanConverter } + 'ojt_indicator' => { column: :ojt_indicator, converter: Converters::BooleanConverter }, + 'correspondence_indicator' => { column: :correspondence_indicator, converter: Converters::BooleanConverter }, + 'flight_indicator' => { column: :flight_indicator, converter: Converters::BooleanConverter }, + 'non_college_degree_indicator' => { column: :non_college_degree_indicator, converter: Converters::BooleanConverter }, + 'ipeds' => { column: :cross, converter: Converters::CrossConverter }, + 'ope' => { column: :ope, converter: Converters::OpeConverter }, + 'independent_study' => { column: :independent_study, converter: Converters::BooleanConverter }, + 'physical_address_1' => { column: :physical_address_1, converter: Converters::BaseConverter }, + 'physical_address_2' => { column: :physical_address_2, converter: Converters::BaseConverter }, + 'physical_address_3' => { column: :physical_address_3, converter: Converters::BaseConverter }, + 'physical_institution_city' => { column: :physical_city, converter: Converters::UpcaseConverter }, + 'physical_institution_state' => { column: :physical_state, converter: Converters::StateConverter }, + 'physical_institution_zip_code' => { column: :physical_zip, converter: Converters::ZipConverter }, + 'physical_institution_country' => { column: :physical_country, converter: Converters::UpcaseConverter }, + 'current_academic_year_dod_bah_rate' => { column: :dod_bah, converter: Converters::NumberConverter }, + 'online_only' => { column: :online_only, converter: Converters::BooleanConverter }, + 'distance_learning' => { column: :distance_learning, converter: Converters::BooleanConverter }, + 'priority_enrollment' => { column: :priority_enrollment, converter: Converters::BooleanConverter }, + 'preferred_provider' => { column: :preferred_provider, converter: Converters::BooleanConverter }, + 'stem_indicator' => { column: :stem_indicator, converter: Converters::BooleanConverter }, + 'campus_indicator' => { column: :campus_type, converter: Converters::BaseConverter }, + 'parent_facility_code' => { column: :parent_facility_code_id, converter: Converters::BaseConverter }, + 'in_state_tuition_url' => { column: :in_state_tuition_information, converter: Converters::BaseConverter }, + 'high_school' => { column: :high_school, converter: Converters::BooleanConverter } }.freeze has_many :crosswalk_issue, dependent: :delete_all @@ -107,7 +107,7 @@ def derive_dependent_columns self.flight = flight? self.correspondence = correspondence? self.approved = approved? - self.ope6 = Ope6Converter.convert(ope) + self.ope6 = Converters::Ope6Converter.convert(ope) self.institution_search = Institution.institution_search_term(institution)[:search_term] end diff --git a/app/models/yellow_ribbon_program_source.rb b/app/models/yellow_ribbon_program_source.rb index ddd36d571..861c20c67 100644 --- a/app/models/yellow_ribbon_program_source.rb +++ b/app/models/yellow_ribbon_program_source.rb @@ -3,31 +3,31 @@ class YellowRibbonProgramSource < ImportableRecord CSV_CONVERTER_INFO = { 'city' => { column: :city }, - 'contribution_amount' => { column: :contribution_amount, converter: NumberConverter }, - 'degree_level' => { column: :degree_level, converter: BaseConverter }, - 'division_professional_school' => { column: :division_professional_school, converter: BaseConverter }, - 'facility_code' => { column: :facility_code, converter: FacilityCodeConverter }, - 'number_of_students' => { column: :number_of_students, converter: NumberConverter }, + 'contribution_amount' => { column: :contribution_amount, converter: Converters::NumberConverter }, + 'degree_level' => { column: :degree_level, converter: Converters::BaseConverter }, + 'division_professional_school' => { column: :division_professional_school, converter: Converters::BaseConverter }, + 'facility_code' => { column: :facility_code, converter: Converters::FacilityCodeConverter }, + 'number_of_students' => { column: :number_of_students, converter: Converters::NumberConverter }, 'school_name_in_yr_database' => { column: :school_name_in_yr_database }, 'state' => { column: :state }, 'street_address' => { column: :street_address }, 'zip' => { column: :zip }, # Unused by GIDS but provided in source file - 'amendment_date' => { column: :amendment_date, converter: DateConverter }, + 'amendment_date' => { column: :amendment_date, converter: Converters::DateConverter }, 'campus' => { column: :campus }, - 'consolidated_agreement' => { column: :consolidated_agreement, converter: BooleanConverter }, - 'dat_yr_signed_by_yr_official' => { column: :date_yr_signed_by_yr_official, converter: DateConverter }, + 'consolidated_agreement' => { column: :consolidated_agreement, converter: Converters::BooleanConverter }, + 'dat_yr_signed_by_yr_official' => { column: :date_yr_signed_by_yr_official, converter: Converters::DateConverter }, 'date_agreement_received' => { column: :date_agreement_received }, - 'date_confirmation_sent' => { column: :date_confirmation_sent, converter: DateConverter }, - 'flight_school' => { column: :flight_school, converter: BooleanConverter }, - 'ineligible' => { column: :ineligible, converter: BooleanConverter }, + 'date_confirmation_sent' => { column: :date_confirmation_sent, converter: Converters::DateConverter }, + 'flight_school' => { column: :flight_school, converter: Converters::BooleanConverter }, + 'ineligible' => { column: :ineligible, converter: Converters::BooleanConverter }, 'initials_yr_processor' => { column: :initials_yr_processor }, - 'missed_deadline' => { column: :missed_deadline, converter: BooleanConverter }, - 'modified' => { column: :modified, converter: BooleanConverter }, - 'new_school' => { column: :new_school, converter: BooleanConverter }, + 'missed_deadline' => { column: :missed_deadline, converter: Converters::BooleanConverter }, + 'modified' => { column: :modified, converter: Converters::BooleanConverter }, + 'new_school' => { column: :new_school, converter: Converters::BooleanConverter }, 'notes' => { column: :notes }, - 'open_ended_agreement' => { column: :open_ended_agreement, converter: BooleanConverter }, + 'open_ended_agreement' => { column: :open_ended_agreement, converter: Converters::BooleanConverter }, 'public_private' => { column: :public_private }, 'school_name_in_weams' => { column: :school_name_in_weams }, 'sco_email_address' => { column: :sco_email_address }, @@ -36,8 +36,8 @@ class YellowRibbonProgramSource < ImportableRecord 'sfr_email_address' => { column: :sfr_email_address }, 'sfr_name' => { column: :sfr_name }, 'sfr_telephone_number' => { column: :sfr_telephone_number }, - 'updated_for_2011_2012' => { column: :updated_for_2011_2012, converter: BooleanConverter }, - 'withdrawn' => { column: :withdrawn, converter: BooleanConverter }, + 'updated_for_2011_2012' => { column: :updated_for_2011_2012, converter: Converters::BooleanConverter }, + 'withdrawn' => { column: :withdrawn, converter: Converters::BooleanConverter }, 'year_of_yr_participation' => { column: :year_of_yr_participation } }.freeze diff --git a/app/serializers/institution_compare_serializer.rb b/app/serializers/institution_compare_serializer.rb index 8d671e38e..483905e75 100644 --- a/app/serializers/institution_compare_serializer.rb +++ b/app/serializers/institution_compare_serializer.rb @@ -93,9 +93,7 @@ class InstitutionCompareSerializer < ActiveModel::Serializer attribute :hcm2 attribute :pctfloan - if ENV['DEPLOYMENT_ENV'].eql?('vagov-dev') || ENV['DEPLOYMENT_ENV'].eql?('vagov-staging') - attribute :institution_rating - end + attribute :institution_rating if ENV['DEPLOYMENT_ENV'].eql?('vagov-dev') || ENV['DEPLOYMENT_ENV'].eql?('vagov-staging') attribute :school_provider attribute :vet_tec_provider diff --git a/app/serializers/institution_profile_serializer.rb b/app/serializers/institution_profile_serializer.rb index 7d9a6c2da..e20a7f0c5 100644 --- a/app/serializers/institution_profile_serializer.rb +++ b/app/serializers/institution_profile_serializer.rb @@ -109,9 +109,7 @@ class InstitutionProfileSerializer < ActiveModel::Serializer attribute :pbi attribute :tribal - if ENV['DEPLOYMENT_ENV'].eql?('vagov-dev') || ENV['DEPLOYMENT_ENV'].eql?('vagov-staging') - attribute :institution_rating - end + attribute :institution_rating if ENV['DEPLOYMENT_ENV'].eql?('vagov-dev') || ENV['DEPLOYMENT_ENV'].eql?('vagov-staging') attribute :rating_average attribute :rating_count diff --git a/app/serializers/institution_search_result_serializer.rb b/app/serializers/institution_search_result_serializer.rb index f122e90f6..0d394c506 100644 --- a/app/serializers/institution_search_result_serializer.rb +++ b/app/serializers/institution_search_result_serializer.rb @@ -11,9 +11,7 @@ class InstitutionSearchResultSerializer < ActiveModel::Serializer attribute :rating_average attribute :rating_count - if ENV['DEPLOYMENT_ENV'].eql?('vagov-dev') || ENV['DEPLOYMENT_ENV'].eql?('vagov-staging') - attribute :institution_rating - end + attribute :institution_rating if ENV['DEPLOYMENT_ENV'].eql?('vagov-dev') || ENV['DEPLOYMENT_ENV'].eql?('vagov-staging') attribute :institution_type_name, key: :type attribute :caution_flags diff --git a/app/serializers/institution_serializer.rb b/app/serializers/institution_serializer.rb index 0643aa3e4..be84eb682 100644 --- a/app/serializers/institution_serializer.rb +++ b/app/serializers/institution_serializer.rb @@ -75,9 +75,7 @@ class InstitutionSerializer < ActiveModel::Serializer attribute :rating_count attribute :rating_average - if ENV['DEPLOYMENT_ENV'].eql?('vagov-dev') || ENV['DEPLOYMENT_ENV'].eql?('vagov-staging') - attribute :institution_rating - end + attribute :institution_rating if ENV['DEPLOYMENT_ENV'].eql?('vagov-dev') || ENV['DEPLOYMENT_ENV'].eql?('vagov-staging') link(:website) { object.website_link } link(:scorecard) { object.scorecard_link } diff --git a/app/utilities/caution_flag_templates/accreditation_caution_flag.rb b/app/utilities/caution_flag_templates/accreditation_caution_flag.rb index 125678bfc..72c8651fe 100644 --- a/app/utilities/caution_flag_templates/accreditation_caution_flag.rb +++ b/app/utilities/caution_flag_templates/accreditation_caution_flag.rb @@ -2,7 +2,7 @@ require_relative 'caution_flag_template' -class AccreditationCautionFlag < CautionFlagTemplate +class CautionFlagTemplates::AccreditationCautionFlag < CautionFlagTemplates::CautionFlagTemplate NAME = AccreditationAction.name TITLE = 'School has an accreditation issue' DESCRIPTION = 'This school\'\'s accreditation has been taken away and is under appeal, '\ diff --git a/app/utilities/caution_flag_templates/caution_flag_template.rb b/app/utilities/caution_flag_templates/caution_flag_template.rb index bc28879e3..6c82caf6b 100644 --- a/app/utilities/caution_flag_templates/caution_flag_template.rb +++ b/app/utilities/caution_flag_templates/caution_flag_template.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -class CautionFlagTemplate +class CautionFlagTemplates::CautionFlagTemplate end diff --git a/app/utilities/caution_flag_templates/hcm_caution_flag.rb b/app/utilities/caution_flag_templates/hcm_caution_flag.rb index 79ef84c18..d1e22f688 100644 --- a/app/utilities/caution_flag_templates/hcm_caution_flag.rb +++ b/app/utilities/caution_flag_templates/hcm_caution_flag.rb @@ -2,7 +2,7 @@ require_relative 'caution_flag_template' -class HcmCautionFlag < CautionFlagTemplate +class CautionFlagTemplates::HcmCautionFlag < CautionFlagTemplates::CautionFlagTemplate NAME = Hcm.name TITLE = 'School placed on Heightened Cash Monitoring' DESCRIPTION = 'The Department of Education has placed this '\ diff --git a/app/utilities/caution_flag_templates/mou_caution_flag.rb b/app/utilities/caution_flag_templates/mou_caution_flag.rb index 0ef6bfc4a..71bbb7407 100644 --- a/app/utilities/caution_flag_templates/mou_caution_flag.rb +++ b/app/utilities/caution_flag_templates/mou_caution_flag.rb @@ -2,7 +2,7 @@ require_relative 'caution_flag_template' -class MouCautionFlag < CautionFlagTemplate +class CautionFlagTemplates::MouCautionFlag < CautionFlagTemplates::CautionFlagTemplate NAME = Mou.name TITLE = 'School is on Military Tuition Assistance probation' DESCRIPTION = 'This school is on Department of Defense (DOD) probation for Military Tuition Assistance (TA).' diff --git a/app/utilities/caution_flag_templates/poo_status_flag.rb b/app/utilities/caution_flag_templates/poo_status_flag.rb index a77cda5eb..0d36dd526 100644 --- a/app/utilities/caution_flag_templates/poo_status_flag.rb +++ b/app/utilities/caution_flag_templates/poo_status_flag.rb @@ -2,7 +2,7 @@ require_relative 'caution_flag_template' -class PooStatusFlag < CautionFlagTemplate +class CautionFlagTemplates::PooStatusFlag < CautionFlagTemplates::CautionFlagTemplate NAME = 'Poo_Status_Susp' TITLE = 'School may not be able to accept new GI Bill students' DESCRIPTION = 'This school currently doesn\'\'t meet the approval criteria for receiving GI Bill funds and has been '\ diff --git a/app/utilities/caution_flag_templates/sec702_caution_flag.rb b/app/utilities/caution_flag_templates/sec702_caution_flag.rb index 228abda7f..bd3b81f0f 100644 --- a/app/utilities/caution_flag_templates/sec702_caution_flag.rb +++ b/app/utilities/caution_flag_templates/sec702_caution_flag.rb @@ -2,7 +2,7 @@ require_relative 'caution_flag_template' -class Sec702CautionFlag < CautionFlagTemplate +class CautionFlagTemplates::Sec702CautionFlag < CautionFlagTemplates::CautionFlagTemplate NAME = 'Sec702' TITLE = 'School isn\'\'t approved for Post-9/11 GI Bill or Montgomery GI Bill-Active Duty benefits' DESCRIPTION = 'This school isn\'\'t approved for Post-9/11 GI Bill or Montgomery GI Bill-Active Duty '\ diff --git a/app/utilities/institution_builder/suspended_caution_flags.rb b/app/utilities/institution_builder/suspended_caution_flags.rb index fb2c4e324..99a807136 100644 --- a/app/utilities/institution_builder/suspended_caution_flags.rb +++ b/app/utilities/institution_builder/suspended_caution_flags.rb @@ -21,7 +21,7 @@ def self.build(version_id) AND institutions.version_id = #{version_id} SQL - CautionFlag.build(version_id, PooStatusFlag, caution_flag_clause) + CautionFlag.build(version_id, CautionFlagTemplates::PooStatusFlag, caution_flag_clause) end end end diff --git a/app/utilities/upload_types/upload_requirements.rb b/app/utilities/upload_types/upload_requirements.rb index 09b22e2a4..05ed30f9a 100644 --- a/app/utilities/upload_types/upload_requirements.rb +++ b/app/utilities/upload_types/upload_requirements.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class UploadRequirements +class UploadTypes::UploadRequirements class << self def requirements_messages(type) [validation_messages_presence(type), diff --git a/config/application.rb b/config/application.rb index 3239e5d06..d04ea5084 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,6 +8,8 @@ module GibctDataService class Application < Rails::Application + config.load_defaults '6.0' # enables zeitwerk mode in CRuby + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. @@ -37,9 +39,8 @@ class Application < Rails::Application # Bootstrap support. config.assets.paths << "#{Rails}/vendor/assets/fonts" - config.autoload_paths += Dir["#{config.root}/app/models/**/"] - config.autoload_paths += Dir["#{config.root}/lib/**/"] - config.autoload_paths += Dir["#{config.root}/app/utilities/**/"] + config.autoload_paths += Dir["#{config.root}/lib"] + config.eager_load_paths += Dir["#{config.root}/lib"] # YAML Defaults for CSV config.csv_defaults = YAML.load_file(Rails.root.join('config', 'csv_file_defaults.yml')) diff --git a/config/initializers/roo_helper.rb b/config/initializers/roo_helper.rb index e7f24d8e0..dba0685e2 100644 --- a/config/initializers/roo_helper.rb +++ b/config/initializers/roo_helper.rb @@ -1 +1 @@ -Dir["#{Rails.application.config.root}/lib/roo_helper/**/*.rb"].each { |f| require(f) } +#Dir["#{Rails.application.config.root}/lib/roo_helper/**/*.rb"].each { |f| require(f) } diff --git a/lib/common/client/base.rb b/lib/common/client/base.rb index d6da8ba41..2902637c7 100644 --- a/lib/common/client/base.rb +++ b/lib/common/client/base.rb @@ -71,14 +71,14 @@ def request(method, path, params = {}, headers = {}, options = {}) # rubocop:dis request.headers.update(headers) options.each { |option, value| request.options.send("#{option}=", value) } end.env - rescue Common::Exceptions::BackendServiceException => e + rescue Common::Exceptions::External::BackendServiceException => e # convert BackendServiceException into a more meaningful exception title for Sentry raise config.service_exception.new( e.key, e.response_values, e.original_status, e.original_body ) rescue Timeout::Error, Faraday::TimeoutError Raven.extra_context(service_name: config.service_name, url: config.base_path) - raise Common::Exceptions::GatewayTimeout + raise Common::Exceptions::External::GatewayTimeout rescue Faraday::ClientError => e error_class = case e when Faraday::ParsingError diff --git a/lib/common/client/configuration/base.rb b/lib/common/client/configuration/base.rb index 31dded1e2..fbe75428c 100644 --- a/lib/common/client/configuration/base.rb +++ b/lib/common/client/configuration/base.rb @@ -62,13 +62,13 @@ def service_name ## # Creates a custom service exception with the same namespace as the implementing class. # - # @return Common::Exceptions::BackendServiceException exception with the class' namespace + # @return Common::Exceptions::External::BackendServiceException exception with the class' namespace # def service_exception if current_module.const_defined?('ServiceException') current_module.const_get('ServiceException') else - current_module.const_set('ServiceException', Class.new(Common::Exceptions::BackendServiceException)) + current_module.const_set('ServiceException', Class.new(Common::Exceptions::External::BackendServiceException)) end end diff --git a/lib/common/client/configuration/rest.rb b/lib/common/client/configuration/rest.rb index 406c66d23..28b68f721 100644 --- a/lib/common/client/configuration/rest.rb +++ b/lib/common/client/configuration/rest.rb @@ -34,7 +34,7 @@ module Configuration # configuration MyConfiguration # end # - class REST < Base + class Rest < Base self.request_types = %i[get put post delete].freeze self.base_request_headers = { 'Accept' => 'application/json', diff --git a/lib/common/client/middleware/response/raise_error.rb b/lib/common/client/middleware/response/raise_error.rb index 8f497be61..f8be10b84 100644 --- a/lib/common/client/middleware/response/raise_error.rb +++ b/lib/common/client/middleware/response/raise_error.rb @@ -27,7 +27,7 @@ def on_complete(env) def raise_error! if status&.between?(400, 599) - raise Common::Exceptions::BackendServiceException.new(service_i18n_key, response_values, status, body) + raise Common::Exceptions::External::BackendServiceException.new(service_i18n_key, response_values, status, body) else raise BackendUnhandledException, "Unhandled Exception - status: #{status}, body: #{body}" end diff --git a/lib/common/exceptions/exception_handler.rb b/lib/common/exceptions/exception_handler.rb index ebea93f79..de7e51c43 100644 --- a/lib/common/exceptions/exception_handler.rb +++ b/lib/common/exceptions/exception_handler.rb @@ -38,7 +38,7 @@ def serialize_error private def validate!(error) - raise Common::Exceptions::ParameterMissing.new('error'), 'error' if error.blank? + raise Common::Exceptions::Internal::ParameterMissing.new('error'), 'error' if error.blank? error end diff --git a/lib/common/exceptions/external/backend_service_exception.rb b/lib/common/exceptions/external/backend_service_exception.rb index e6af273ba..35bcdb04c 100644 --- a/lib/common/exceptions/external/backend_service_exception.rb +++ b/lib/common/exceptions/external/backend_service_exception.rb @@ -2,97 +2,99 @@ module Common module Exceptions - # This will return a generic error, to customize - # you must define the minor code in the locales file and call this class from - # raise_error middleware. - class BackendServiceException < BaseError - attr_reader :response_values, :original_status, :original_body, :key - - def initialize(key = nil, response_values = {}, original_status = nil, original_body = nil) - @response_values = response_values - @key = key || 'VA900' - @original_status = original_status - @original_body = original_body - validate_arguments! - end + module External + # This will return a generic error, to customize + # you must define the minor code in the locales file and call this class from + # raise_error middleware. + class BackendServiceException < BaseError + attr_reader :response_values, :original_status, :original_body, :key + + def initialize(key = nil, response_values = {}, original_status = nil, original_body = nil) + @response_values = response_values + @key = key || 'VA900' + @original_status = original_status + @original_body = original_body + validate_arguments! + end - # The message will be the actual backend service response from middleware, - # not the I18n version. - def message - "BackendServiceException: #{response_values.merge(code: code)}" - end + # The message will be the actual backend service response from middleware, + # not the I18n version. + def message + "BackendServiceException: #{response_values.merge(code: code)}" + end - def errors - Array(SerializableError.new(i18n_data.merge(render_overides))) - end + def errors + Array(SerializableError.new(i18n_data.merge(render_overides))) + end - # VA900 is characterized as a generic type of exception. See exceptions.en.yml for what JSON will render - def va900? - code == 'VA900' - end + # VA900 is characterized as a generic type of exception. See exceptions.en.yml for what JSON will render + def va900? + code == 'VA900' + end - alias generic_error? va900? + alias generic_error? va900? - def va900_warning - "Unmapped VA900 (Backend Response: { status: #{original_status}, message: #{original_body}) }" - end + def va900_warning + "Unmapped VA900 (Backend Response: { status: #{original_status}, message: #{original_body}) }" + end - def va900_hint - <<-MESSAGE.strip_heredoc - Add the following to exceptions.en.yml - #{response_values[:code]}: - code: '#{response_values[:code]}' - detail: '#{response_values[:detail]}' - status: - source: ~ - MESSAGE - end + def va900_hint + <<-MESSAGE.strip_heredoc + Add the following to exceptions.en.yml + #{response_values[:code]}: + code: '#{response_values[:code]}' + detail: '#{response_values[:detail]}' + status: + source: ~ + MESSAGE + end - private + private - def render_overides - { status: status, detail: detail, code: code, source: source } - end + def render_overides + { status: status, detail: detail, code: code, source: source } + end - # REQUIRED - This is the i18n code returned from raise_error middleware. If it exists in - # I18n then it should be like RX139 or EVSS144, otherwise VA900 - def code - if @key.present? && I18n.exists?("common.exceptions.#{@key}") - @key - else - 'VA900' + # REQUIRED - This is the i18n code returned from raise_error middleware. If it exists in + # I18n then it should be like RX139 or EVSS144, otherwise VA900 + def code + if @key.present? && I18n.exists?("common.exceptions.#{@key}") + @key + else + 'VA900' + end end - end - # REQUIRED - This is the http status code. - # unless you've specified that you want the status code to be something other - # then 400 explicitly it will default to 400. IT WILL NOT DEFAULT to whatever - # was provided by the backend service, because the backend service response - # might not always be relevant - def status - i18n_data[:status].presence || 400 - end + # REQUIRED - This is the http status code. + # unless you've specified that you want the status code to be something other + # then 400 explicitly it will default to 400. IT WILL NOT DEFAULT to whatever + # was provided by the backend service, because the backend service response + # might not always be relevant + def status + i18n_data[:status].presence || 400 + end - # OPTIONAL - This is the detail or message that is rendered in JSON response - # Not providing detail will render a detail the same as title, 'Operation failed' - # NOTE: in the future, detail will only work via i18n, not the value from response_values - def detail - i18n_data[:detail].presence || response_values[:detail] - end + # OPTIONAL - This is the detail or message that is rendered in JSON response + # Not providing detail will render a detail the same as title, 'Operation failed' + # NOTE: in the future, detail will only work via i18n, not the value from response_values + def detail + i18n_data[:detail].presence || response_values[:detail] + end - # OPTIONAL - This should usually be a developer message of some sort from the backend service - # if one is not provided by the backend this can be nil and the key will not be rendered - def source - response_values[:source] - end + # OPTIONAL - This should usually be a developer message of some sort from the backend service + # if one is not provided by the backend this can be nil and the key will not be rendered + def source + response_values[:source] + end - def validate_arguments! - raise ArgumentError, "i18n key (#{@key}) is invalid" unless I18n.exists?(i18n_key) - raise ArgumentError, "status (#{status}) is not in range" unless status.between?(400, 599) - end + def validate_arguments! + raise ArgumentError, "i18n key (#{@key}) is invalid" unless I18n.exists?(i18n_key) + raise ArgumentError, "status (#{status}) is not in range" unless status.between?(400, 599) + end - def i18n_key - "common.exceptions.#{code}" + def i18n_key + "common.exceptions.#{code}" + end end end end diff --git a/lib/common/exceptions/external/gateway_timeout.rb b/lib/common/exceptions/external/gateway_timeout.rb index ad7c07ff9..5fe33efd1 100644 --- a/lib/common/exceptions/external/gateway_timeout.rb +++ b/lib/common/exceptions/external/gateway_timeout.rb @@ -2,9 +2,11 @@ module Common module Exceptions - class GatewayTimeout < BaseError - def errors - Array(SerializableError.new(i18n_data)) + module External + class GatewayTimeout < BaseError + def errors + Array(SerializableError.new(i18n_data)) + end end end end diff --git a/lib/common/exceptions/internal/filter_not_allowed.rb b/lib/common/exceptions/internal/filter_not_allowed.rb index 247dc8eba..1cc87d1c4 100644 --- a/lib/common/exceptions/internal/filter_not_allowed.rb +++ b/lib/common/exceptions/internal/filter_not_allowed.rb @@ -2,15 +2,17 @@ module Common module Exceptions - class FilterNotAllowed < BaseError - attr_reader :filter + module Internal + class FilterNotAllowed < BaseError + attr_reader :filter - def initialize(filter) - @filter = filter - end + def initialize(filter) + @filter = filter + end - def errors - Array(SerializableError.new(i18n_interpolated(detail: { filter: @filter }))) + def errors + Array(SerializableError.new(i18n_interpolated(detail: { filter: @filter }))) + end end end end diff --git a/lib/common/exceptions/internal/forbidden.rb b/lib/common/exceptions/internal/forbidden.rb index 953f855fc..a6112bbfc 100644 --- a/lib/common/exceptions/internal/forbidden.rb +++ b/lib/common/exceptions/internal/forbidden.rb @@ -3,13 +3,15 @@ module Common module Exceptions # Forbidden - We may eventually want different variations on this with distinct MinorCodes - class Forbidden < BaseError - def initialize(options = {}) - @detail = options[:detail] - end + module Internal + class Forbidden < BaseError + def initialize(options = {}) + @detail = options[:detail] + end - def errors - Array(SerializableError.new(i18n_data.merge(detail: @detail))) + def errors + Array(SerializableError.new(i18n_data.merge(detail: @detail))) + end end end end diff --git a/lib/common/exceptions/internal/internal_server_error.rb b/lib/common/exceptions/internal/internal_server_error.rb index 024dbaf3b..e60a27c5a 100644 --- a/lib/common/exceptions/internal/internal_server_error.rb +++ b/lib/common/exceptions/internal/internal_server_error.rb @@ -2,19 +2,21 @@ module Common module Exceptions - # Internal Server Error - all exceptions not readily accounted fall into this tier - class InternalServerError < BaseError - attr_reader :exception + module Internal + # Internal Server Error - all exceptions not readily accounted fall into this tier + class InternalServerError < BaseError + attr_reader :exception - def initialize(exception) - raise ArgumentError, 'an exception must be provided' unless exception.is_a?(Exception) + def initialize(exception) + raise ArgumentError, 'an exception must be provided' unless exception.is_a?(Exception) - @exception = exception - end + @exception = exception + end - def errors - meta = { exception: exception.message, backtrace: exception.backtrace } unless ::Rails.env.production? - Array(SerializableError.new(i18n_data.merge(meta: meta))) + def errors + meta = { exception: exception.message, backtrace: exception.backtrace } unless ::Rails.env.production? + Array(SerializableError.new(i18n_data.merge(meta: meta))) + end end end end diff --git a/lib/common/exceptions/internal/invalid_field.rb b/lib/common/exceptions/internal/invalid_field.rb index 64b5716fb..f2fa1dae5 100644 --- a/lib/common/exceptions/internal/invalid_field.rb +++ b/lib/common/exceptions/internal/invalid_field.rb @@ -2,17 +2,19 @@ module Common module Exceptions - # InvalidField - field is invalid - class InvalidField < BaseError - attr_reader :field, :type + module Internal + # InvalidField - field is invalid + class InvalidField < BaseError + attr_reader :field, :type - def initialize(field, type) - @field = field - @type = type - end + def initialize(field, type) + @field = field + @type = type + end - def errors - Array(SerializableError.new(i18n_interpolated(detail: { field: @field, type: @type }))) + def errors + Array(SerializableError.new(i18n_interpolated(detail: { field: @field, type: @type }))) + end end end end diff --git a/lib/common/exceptions/internal/invalid_field_value.rb b/lib/common/exceptions/internal/invalid_field_value.rb index 69955581f..b5eaa4c07 100644 --- a/lib/common/exceptions/internal/invalid_field_value.rb +++ b/lib/common/exceptions/internal/invalid_field_value.rb @@ -2,17 +2,19 @@ module Common module Exceptions - # InvalidFieldValue - field value is invalid - class InvalidFieldValue < BaseError - attr_reader :field, :value + module Internal + # InvalidFieldValue - field value is invalid + class InvalidFieldValue < BaseError + attr_reader :field, :value - def initialize(field, value) - @field = field - @value = value - end + def initialize(field, value) + @field = field + @value = value + end - def errors - Array(SerializableError.new(i18n_interpolated(detail: { field: @field, value: @value }))) + def errors + Array(SerializableError.new(i18n_interpolated(detail: { field: @field, value: @value }))) + end end end end diff --git a/lib/common/exceptions/internal/invalid_filters_syntax.rb b/lib/common/exceptions/internal/invalid_filters_syntax.rb index 5e5f21607..8f9c4d4f6 100644 --- a/lib/common/exceptions/internal/invalid_filters_syntax.rb +++ b/lib/common/exceptions/internal/invalid_filters_syntax.rb @@ -2,17 +2,19 @@ module Common module Exceptions - # InvalidFiltersSyntax - filter keys are invalid - class InvalidFiltersSyntax < BaseError - attr_reader :filters + module Internal + # InvalidFiltersSyntax - filter keys are invalid + class InvalidFiltersSyntax < BaseError + attr_reader :filters - def initialize(filters, options = {}) - @filters = filters - @detail = options[:detail] || i18n_field(:detail, filters: @filters) - end + def initialize(filters, options = {}) + @filters = filters + @detail = options[:detail] || i18n_field(:detail, filters: @filters) + end - def errors - Array(SerializableError.new(i18n_data.merge(detail: @detail))) + def errors + Array(SerializableError.new(i18n_data.merge(detail: @detail))) + end end end end diff --git a/lib/common/exceptions/internal/invalid_pagination_params.rb b/lib/common/exceptions/internal/invalid_pagination_params.rb index 79948da54..76db513ae 100644 --- a/lib/common/exceptions/internal/invalid_pagination_params.rb +++ b/lib/common/exceptions/internal/invalid_pagination_params.rb @@ -2,17 +2,19 @@ module Common module Exceptions - # Invalid Pagination Params - if page or per_page params are invalid - class InvalidPaginationParams < BaseError - attr_reader :pagination_params + module Internal + # Invalid Pagination Params - if page or per_page params are invalid + class InvalidPaginationParams < BaseError + attr_reader :pagination_params - def initialize(pagination_params, options = {}) - @pagination_params = pagination_params - @detail = options[:detail] || i18n_field(:detail, params: @pagination_params) - end + def initialize(pagination_params, options = {}) + @pagination_params = pagination_params + @detail = options[:detail] || i18n_field(:detail, params: @pagination_params) + end - def errors - Array(SerializableError.new(i18n_data.merge(detail: @detail))) + def errors + Array(SerializableError.new(i18n_data.merge(detail: @detail))) + end end end end diff --git a/lib/common/exceptions/internal/invalid_resource.rb b/lib/common/exceptions/internal/invalid_resource.rb index d392ce711..6167168b3 100644 --- a/lib/common/exceptions/internal/invalid_resource.rb +++ b/lib/common/exceptions/internal/invalid_resource.rb @@ -2,17 +2,19 @@ module Common module Exceptions - # Invalid Resource - if a requested route does not exist - class InvalidResource < BaseError - attr_reader :resource + module Internal + # Invalid Resource - if a requested route does not exist + class InvalidResource < BaseError + attr_reader :resource - def initialize(resource, options = {}) - @resource = resource - @detail = options[:detail] || i18n_field(:detail, resource: @resource) - end + def initialize(resource, options = {}) + @resource = resource + @detail = options[:detail] || i18n_field(:detail, resource: @resource) + end - def errors - Array(SerializableError.new(i18n_data.merge(detail: @detail))) + def errors + Array(SerializableError.new(i18n_data.merge(detail: @detail))) + end end end end diff --git a/lib/common/exceptions/internal/invalid_sort_criteria.rb b/lib/common/exceptions/internal/invalid_sort_criteria.rb index e50187eb3..fc00b368b 100644 --- a/lib/common/exceptions/internal/invalid_sort_criteria.rb +++ b/lib/common/exceptions/internal/invalid_sort_criteria.rb @@ -2,17 +2,19 @@ module Common module Exceptions - # InvalidSortCriteria - sort criteria is invalid - class InvalidSortCriteria < BaseError - attr_reader :resource, :sort_criteria + module Internal + # InvalidSortCriteria - sort criteria is invalid + class InvalidSortCriteria < BaseError + attr_reader :resource, :sort_criteria - def initialize(resource, sort_criteria) - @sort_criteria = sort_criteria - @resource = resource - end + def initialize(resource, sort_criteria) + @sort_criteria = sort_criteria + @resource = resource + end - def errors - Array(SerializableError.new(i18n_interpolated(detail: { sort_criteria: @sort_criteria, resource: @resource }))) + def errors + Array(SerializableError.new(i18n_interpolated(detail: { sort_criteria: @sort_criteria, resource: @resource }))) + end end end end diff --git a/lib/common/exceptions/internal/parameter_missing.rb b/lib/common/exceptions/internal/parameter_missing.rb index 2c410235f..f09060dcf 100644 --- a/lib/common/exceptions/internal/parameter_missing.rb +++ b/lib/common/exceptions/internal/parameter_missing.rb @@ -2,17 +2,19 @@ module Common module Exceptions - # Parameter Missing - required parameter was not provided - class ParameterMissing < BaseError - attr_reader :param + module Internal + # Parameter Missing - required parameter was not provided + class ParameterMissing < BaseError + attr_reader :param - def initialize(param, options = {}) - @param = param - @detail = options[:detail] || i18n_field(:detail, param: @param) - end + def initialize(param, options = {}) + @param = param + @detail = options[:detail] || i18n_field(:detail, param: @param) + end - def errors - Array(SerializableError.new(i18n_data.merge(detail: @detail))) + def errors + Array(SerializableError.new(i18n_data.merge(detail: @detail))) + end end end end diff --git a/lib/common/exceptions/internal/record_not_found.rb b/lib/common/exceptions/internal/record_not_found.rb index d2eb7ba4f..765dea38e 100644 --- a/lib/common/exceptions/internal/record_not_found.rb +++ b/lib/common/exceptions/internal/record_not_found.rb @@ -2,16 +2,18 @@ module Common module Exceptions - # Record Not Found - if no record exists having id, or resource having id does not belong to requester - class RecordNotFound < BaseError - attr_reader :id + module Internal + # Record Not Found - if no record exists having id, or resource having id does not belong to requester + class RecordNotFound < BaseError + attr_reader :id - def initialize(id) - @id = id - end + def initialize(id) + @id = id + end - def errors - Array(SerializableError.new(i18n_interpolated(detail: { id: @id }))) + def errors + Array(SerializableError.new(i18n_interpolated(detail: { id: @id }))) + end end end end diff --git a/lib/common/exceptions/internal/routing_error.rb b/lib/common/exceptions/internal/routing_error.rb index b39d5417c..177f5dc79 100644 --- a/lib/common/exceptions/internal/routing_error.rb +++ b/lib/common/exceptions/internal/routing_error.rb @@ -2,16 +2,18 @@ module Common module Exceptions - # Routing Error - if route is invalid - class RoutingError < BaseError - attr_reader :path + module Internal + # Routing Error - if route is invalid + class RoutingError < BaseError + attr_reader :path - def initialize(path = nil) - @path = path - end + def initialize(path = nil) + @path = path + end - def errors - Array(SerializableError.new(i18n_interpolated(detail: { path: @path }))) + def errors + Array(SerializableError.new(i18n_interpolated(detail: { path: @path }))) + end end end end diff --git a/lib/common/exceptions/internal/unauthorized.rb b/lib/common/exceptions/internal/unauthorized.rb index 60c978542..3fe57e341 100644 --- a/lib/common/exceptions/internal/unauthorized.rb +++ b/lib/common/exceptions/internal/unauthorized.rb @@ -2,14 +2,16 @@ module Common module Exceptions - # Unauthorized - We may eventually want different variations on this with distinct MinorCodes - class Unauthorized < BaseError - def initialize(options = {}) - @detail = options[:detail] - end + module Internal + # Unauthorized - We may eventually want different variations on this with distinct MinorCodes + class Unauthorized < BaseError + def initialize(options = {}) + @detail = options[:detail] + end - def errors - Array(SerializableError.new(i18n_data.merge(detail: @detail))) + def errors + Array(SerializableError.new(i18n_data.merge(detail: @detail))) + end end end end diff --git a/lib/common/exceptions/internal/validation_errors.rb b/lib/common/exceptions/internal/validation_errors.rb index 3383808f9..b86fae265 100644 --- a/lib/common/exceptions/internal/validation_errors.rb +++ b/lib/common/exceptions/internal/validation_errors.rb @@ -2,31 +2,33 @@ module Common module Exceptions - # Validation Error - an ActiveModel having validation errors, can be sent to this exception - class ValidationErrors < BaseError - attr_reader :resource + module Internal + # Validation Error - an ActiveModel having validation errors, can be sent to this exception + class ValidationErrors < BaseError + attr_reader :resource - def initialize(resource) - @resource = resource - raise TypeError, 'the resource provided has no errors' if resource.errors.empty? - end + def initialize(resource) + @resource = resource + raise TypeError, 'the resource provided has no errors' if resource.errors.empty? + end - def errors - @resource.errors.map do |k, v| - full_message = resource.errors.full_message(k, v) - attributes = error_attributes(k, v, full_message) - SerializableError.new(attributes) + def errors + @resource.errors.map do |k, v| + full_message = resource.errors.full_message(k, v) + attributes = error_attributes(k, v, full_message) + SerializableError.new(attributes) + end end - end - private + private - def error_attributes(key, message, full_message) - i18n_data.merge( - title: full_message, - detail: "#{key.to_s.underscore.dasherize} - #{message}", - source: { pointer: "data/attributes/#{key.to_s.underscore.dasherize}" } - ) + def error_attributes(key, message, full_message) + i18n_data.merge( + title: full_message, + detail: "#{key.to_s.underscore.dasherize} - #{message}", + source: { pointer: "data/attributes/#{key.to_s.underscore.dasherize}" } + ) + end end end end diff --git a/lib/roo_helper/loader.rb b/lib/roo_helper/loader.rb index 9df0bcbc4..9b04853c5 100644 --- a/lib/roo_helper/loader.rb +++ b/lib/roo_helper/loader.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'common/loader' + module RooHelper module Loader include Common::Loader @@ -155,7 +157,7 @@ def process_sheet(sheet_klass, sheet, sheet_options, file_options) file_header = file_options[:liberal_parsing] ? headers_mapping[key].gsub('"', '').strip : headers_mapping[key] info = converter_info(sheet_klass, file_header) if info.present? - converter = info[:converter] || BaseConverter + converter = info[:converter] || Converters::BaseConverter result[key] = converter.convert(value) end end @@ -262,7 +264,7 @@ def csv_col_sep(file, file_options) first_line = csv.readline col_sep = Settings.csv_upload.column_separators .find { |column_separator| first_line.include?(column_separator) } - valid_col_seps_msg = RooHelper.valid_col_seps[:value].map { |cs| "\"#{cs}\"" }.join(' and ') + valid_col_seps_msg = RooHelper::Shared.valid_col_seps[:value].map { |cs| "\"#{cs}\"" }.join(' and ') error_message = "Unable to determine column separators, valid separators equal #{valid_col_seps_msg}" raise(StandardError, error_message) if col_sep.blank? @@ -294,7 +296,7 @@ def process_as_xml(sheet_klass, sheet, index, sheet_options) headers.each_with_index do |header, h_index| info = converter_info(sheet_klass, header) if info.present? - converter = info[:converter] || BaseConverter + converter = info[:converter] || Converters::BaseConverter result[info[:column]] = converter.convert(values[h_index]) end end diff --git a/lib/roo_helper/shared.rb b/lib/roo_helper/shared.rb index d4a098a61..73dea3f12 100644 --- a/lib/roo_helper/shared.rb +++ b/lib/roo_helper/shared.rb @@ -1,15 +1,17 @@ # frozen_string_literal: true module RooHelper - include Common - def self.included(base) - base.extend Common::Shared - base.extend Loader - base.extend Common::Exporter - end + module Shared + include Common + def self.included(base) + base.extend Common::Shared + base.extend Loader + base.extend Common::Exporter + end - def self.valid_col_seps - valid_col_seps = Settings.csv_upload.column_separators.each(&:to_s) - { value: valid_col_seps, message: 'Valid column separators are:' } + def self.valid_col_seps + valid_col_seps = Settings.csv_upload.column_separators.each(&:to_s) + { value: valid_col_seps, message: 'Valid column separators are:' } + end end end diff --git a/lib/saml/settings.rb b/lib/saml/settings.rb index d14905b34..38eef7bd5 100644 --- a/lib/saml/settings.rb +++ b/lib/saml/settings.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module SAML - class Settings + class Saml::Settings class << self def settings idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new diff --git a/lib/scorecard_api/configuration.rb b/lib/scorecard_api/configuration.rb index 8d1a8d19a..4b4d05168 100644 --- a/lib/scorecard_api/configuration.rb +++ b/lib/scorecard_api/configuration.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module ScorecardApi - class Configuration < Common::Client::Configuration::REST + class Configuration < Common::Client::Configuration::Rest self.read_timeout = Settings.scorecard.read_timeout || read_timeout self.open_timeout = Settings.scorecard.open_timeout || open_timeout diff --git a/lib/search/facets.rb b/lib/search/facets.rb index 661cfd194..e7ad8efe2 100644 --- a/lib/search/facets.rb +++ b/lib/search/facets.rb @@ -1,30 +1,32 @@ # frozen_string_literal: true -module Facets - # rubocop:disable Lint/BooleanSymbol - def boolean_facet - { true: nil, false: nil } - end - # rubocop:enable Lint/BooleanSymbol +module Search + module Facets + # rubocop:disable Lint/BooleanSymbol + def boolean_facet + { true: nil, false: nil } + end + # rubocop:enable Lint/BooleanSymbol - def add_search_facet(raw_facets, field) - return if @query[field].blank? + def add_search_facet(raw_facets, field) + return if @query[field].blank? - key = @query[field].downcase - raw_facets[field][key] = 0 unless raw_facets[field].key? key - end + key = @query[field].downcase + raw_facets[field][key] = 0 unless raw_facets[field].key? key + end - def add_country_search_facet(raw_facets) - return if @query[:country].blank? + def add_country_search_facet(raw_facets) + return if @query[:country].blank? - key = @query[:country].upcase - raw_facets[:country] << { name: key, count: 0 } unless - raw_facets[:country].any? { |c| c[:name] == key } - end + key = @query[:country].upcase + raw_facets[:country] << { name: key, count: 0 } unless + raw_facets[:country].any? { |c| c[:name] == key } + end - def embed(group_counts) - group_counts.each_with_object([]) do |(k, v), array| - array << { name: k, count: v } + def embed(group_counts) + group_counts.each_with_object([]) do |(k, v), array| + array << { name: k, count: v } + end end end end diff --git a/lib/tasks/lint.rake b/lib/tasks/lint.rake index d152bb96a..d38053a49 100644 --- a/lib/tasks/lint.rake +++ b/lib/tasks/lint.rake @@ -6,11 +6,11 @@ require 'rainbow' desc 'shortcut to run all linting tools, at the same time.' task lint: :environment do puts 'running scss-lint...' - scss_result = ShellCommand.run('scss-lint --color') + scss_result = Tasks::Support::ShellCommand.run('scss-lint --color') opts = ENV['CI'] ? '' : '--auto-correct' puts 'running rubocop...' - rubocop_result = ShellCommand.run("rubocop #{opts} --color") + rubocop_result = Tasks::Support::ShellCommand.run("rubocop #{opts} --color") puts "\n" if scss_result && rubocop_result diff --git a/lib/tasks/security.rake b/lib/tasks/security.rake index 9b8eae1f4..423ebb7e4 100644 --- a/lib/tasks/security.rake +++ b/lib/tasks/security.rake @@ -6,13 +6,13 @@ require 'rainbow' desc 'shortcut to run all linting tools, at the same time.' task security: :environment do puts 'running Brakeman security scan...' - brakeman_result = ShellCommand.run( + brakeman_result = Tasks::Support::ShellCommand.run( 'brakeman --no-exit-on-warn --run-all-checks --confidence-level=2' ) puts 'running bundle-audit to check for insecure dependencies...' - exit!(1) unless ShellCommand.run('bundle-audit update') - audit_result = ShellCommand.run('bundle-audit check --ignore CVE-2017-8418 CVE-2024-26143 CVE-2024-27456') + exit!(1) unless Tasks::Support::ShellCommand.run('bundle-audit update') + audit_result = Tasks::Support::ShellCommand.run('bundle-audit check --ignore CVE-2017-8418 CVE-2024-26143 CVE-2024-27456') puts "\n" if brakeman_result && audit_result puts Rainbow('Passed. No obvious security vulnerabilities.').green diff --git a/lib/tasks/support/shell_command.rb b/lib/tasks/support/shell_command.rb index accf2967f..ff324a31a 100644 --- a/lib/tasks/support/shell_command.rb +++ b/lib/tasks/support/shell_command.rb @@ -1,22 +1,26 @@ # frozen_string_literal: true -class ShellCommand - # runs shell command and prints output - # returns boolean depending on the success of the command - def self.run(command) - success = false - old_sync = $stdout.sync - $stdout.sync = true +module Tasks + module Support + class ShellCommand + # runs shell command and prints output + # returns boolean depending on the success of the command + def self.run(command) + success = false + old_sync = $stdout.sync + $stdout.sync = true - Open3.popen2e(command) do |_stdin, stdout_and_stderr, thread| - while (line = stdout_and_stderr.gets) - puts(line) - end + Open3.popen2e(command) do |_stdin, stdout_and_stderr, thread| + while (line = stdout_and_stderr.gets) + puts(line) + end - success = thread.value.success? - end + success = thread.value.success? + end - $stdout.sync = old_sync - success + $stdout.sync = old_sync + success + end + end end end diff --git a/lib/vets_api/client.rb b/lib/vets_api/client.rb index b4e9b43e3..bf0fe39bc 100644 --- a/lib/vets_api/client.rb +++ b/lib/vets_api/client.rb @@ -8,9 +8,7 @@ class Client < Common::Client::Base configuration VetsApi::Configuration def feature_toggles(params) - if params.blank? || params[:features].blank? - raise(ParamsMissingError, 'No feature flags provided for the features param') - end + raise(ParamsMissingError, 'No feature flags provided for the features param') if params.blank? || params[:features].blank? perform(:get, 'feature_toggles', params) end diff --git a/lib/vets_api/configuration.rb b/lib/vets_api/configuration.rb index f08530a86..c4f39eaea 100644 --- a/lib/vets_api/configuration.rb +++ b/lib/vets_api/configuration.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module VetsApi - class Configuration < Common::Client::Configuration::REST + class Configuration < Common::Client::Configuration::Rest self.read_timeout = Settings.vets_api&.read_timeout || read_timeout self.open_timeout = Settings.vets_api&.open_timeout || open_timeout diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb index fc69959ea..877f0f1a4 100644 --- a/spec/controllers/api_controller_spec.rb +++ b/spec/controllers/api_controller_spec.rb @@ -15,7 +15,7 @@ def internal_server_error end def unauthorized - raise Common::Exceptions::Unauthorized + raise Common::Exceptions::Internal::Unauthorized end end diff --git a/spec/controllers/crosswalk_issues_controller_spec.rb b/spec/controllers/crosswalk_issues_controller_spec.rb index 894a1068c..7cc6bec7e 100644 --- a/spec/controllers/crosswalk_issues_controller_spec.rb +++ b/spec/controllers/crosswalk_issues_controller_spec.rb @@ -13,7 +13,7 @@ before do create_list :crosswalk_issue, 3, :partial_match_type, :with_weam_match - create_list :crosswalk_issue, 2, :ipeds_orphan_type + create_list :crosswalk_issue, 2, :ipeds_orphan_type, :with_weam_match get(:partials) end @@ -261,8 +261,8 @@ login_user before do - create_list :crosswalk_issue, 3, :partial_match_type - create_list :crosswalk_issue, 2, :ipeds_orphan_type + create_list :crosswalk_issue, 3, :partial_match_type, :with_weam_match + create_list :crosswalk_issue, 2, :ipeds_orphan_type, :with_weam_match get(:orphans) end diff --git a/spec/controllers/dashboards_controller_spec.rb b/spec/controllers/dashboards_controller_spec.rb index 8d8b2fd77..45abb98c0 100644 --- a/spec/controllers/dashboards_controller_spec.rb +++ b/spec/controllers/dashboards_controller_spec.rb @@ -212,14 +212,7 @@ def load_table(klass) login_user before do - create(:version, :production) - create(:institution, :location, :lat_long) - create(:institution, :foreign_bad_address, :ungeocodable) - - # rubocop:disable Rails/SkipsModelValidations - Institution.update_all version_id: Version.first.id - # rubocop:enable Rails/SkipsModelValidations - + create(:version, :production, :with_ungecodable_foreign_institution, :with_geocoded_institution) get(:geocoding_issues) end @@ -236,16 +229,12 @@ def load_table(klass) login_user before do - create(:version, :production) - create(:institution, :accreditation_issue) - create(:institution, :with_accreditation) + create(:version, :production, :with_institution_accreditation_issue, :with_accredited_institution) + # The institution(s) and accreditation_institute_campus records are + # linked by ope & ope6 in the factories create(:accreditation_institute_campus) create(:accreditation_record) - # rubocop:disable Rails/SkipsModelValidations - Institution.update_all version_id: Version.first.id - # rubocop:enable Rails/SkipsModelValidations - get(:accreditation_issues) end @@ -280,14 +269,7 @@ def load_table(klass) describe 'GET #export_unaccrediteds' do login_user - before do - create(:version, :production) - create(:institution, :accreditation_issue) - - # rubocop:disable Rails/SkipsModelValidations - Institution.update_all version_id: Version.first.id - # rubocop:enable Rails/SkipsModelValidations - end + before { create(:version, :production, :with_institution_accreditation_issue) } it 'causes a CSV to be exported' do allow(Institution).to receive(:export_unaccrediteds) diff --git a/spec/controllers/v0/institution_programs_controller_spec.rb b/spec/controllers/v0/institution_programs_controller_spec.rb index a997b1272..671d4aea8 100644 --- a/spec/controllers/v0/institution_programs_controller_spec.rb +++ b/spec/controllers/v0/institution_programs_controller_spec.rb @@ -5,9 +5,7 @@ RSpec.describe V0::InstitutionProgramsController, type: :controller do context 'when determining version' do it 'uses a production version as a default' do - create(:version, :production) - create(:version, :preview) - create(:institution_program, :contains_harv) + create(:version, :production, :with_institution_that_contains_harv) get(:index) expect(response.media_type).to eq('application/json') expect(response).to match_response_schema('institution_programs') @@ -16,8 +14,7 @@ end it 'accepts invalid version parameter and returns production data' do - create(:version, :production) - create(:institution_program, :contains_harv) + create(:version, :production, :with_institution_that_contains_harv) get(:index, params: { version: 'invalid_data' }) expect(response.media_type).to eq('application/json') expect(response).to match_response_schema('institution_programs') @@ -27,8 +24,7 @@ it 'accepts version number as a version parameter and returns preview data' do create(:version, :production) - v = create(:version, :preview) - create(:institution_program, :contains_harv, version: Version.current_preview.number) + v = create(:version, :preview, :with_institution_that_contains_harv) get(:index, params: { version: v.uuid }) expect(response.media_type).to eq('application/json') expect(response).to match_response_schema('institution_programs') @@ -38,10 +34,7 @@ end context 'when autocomplete' do - before do - create(:version, :production) - create(:institution, version_id: Version.last.id) - end + before { create(:version, :production, :with_institution) } it 'returns collection of matches' do create_list(:institution_program, 2, :start_like_harv, :last_version) diff --git a/spec/controllers/v0/institutions_controller_spec.rb b/spec/controllers/v0/institutions_controller_spec.rb index bb6e7625a..70f03c06d 100644 --- a/spec/controllers/v0/institutions_controller_spec.rb +++ b/spec/controllers/v0/institutions_controller_spec.rb @@ -20,8 +20,7 @@ def create_extension_institutions(trait) context 'with version determination' do it 'uses a production version as a default' do - create(:version, :production) - create(:institution, :contains_harv) + create(:version, :production, :with_institution_that_contains_harv) get(:index) expect_response_match_schema('institutions') end @@ -31,8 +30,7 @@ def preview_body(body) end it 'accepts invalid version parameter and returns production data' do - create(:version, :production) - create(:institution, :contains_harv) + create(:version, :production, :with_institution_that_contains_harv) get(:index, params: { version: 'invalid_data' }) expect(response.media_type).to eq('application/json') expect(response).to match_response_schema('institutions') @@ -41,9 +39,8 @@ def preview_body(body) end it 'accepts version number as a version parameter and returns preview data' do - create(:version, :production) + create(:version, :production, :with_institution_that_contains_harv) v = create(:version, :preview) - create(:institution, :contains_harv, :production_version) get(:index, params: { version: v.uuid }) expect(response.media_type).to eq('application/json') expect(response).to match_response_schema('institutions') @@ -53,9 +50,7 @@ def preview_body(body) end context 'with autocomplete results' do - before do - create(:version, :production) - end + before { create(:version, :production) } it 'returns collection of matches' do create_list(:institution, 2, :start_like_harv, :production_version) @@ -74,7 +69,7 @@ def preview_body(body) end it 'returns empty collection on missing term parameter' do - create(:institution, :start_like_harv) + create(:version, :production, :with_institution_that_starts_like_harv) get(:autocomplete) expect(JSON.parse(response.body)['data'].count).to eq(0) expect(response.media_type).to eq('application/json') @@ -82,7 +77,8 @@ def preview_body(body) end it 'does not return results for non-approved institutions' do - create(:institution, :start_like_harv, approved: false) + v = create(:version, :production) + create(:institution, :start_like_harv, approved: false, version_id: v.id) get(:autocomplete, params: { term: 'harv' }) expect(JSON.parse(response.body)['data'].count).to eq(0) expect(response.media_type).to eq('application/json') @@ -100,7 +96,8 @@ def preview_body(body) end it 'excludes vet_tec_provider institutions' do - create(:institution, :vet_tec_provider, :start_like_harv) + v = create(:version, :production) + create(:institution, :vet_tec_provider, :start_like_harv, version_id: v.id) get(:autocomplete, params: { term: 'harv' }) expect(JSON.parse(response.body)['data'].count).to eq(0) expect(response.media_type).to eq('application/json') diff --git a/spec/controllers/v0/yellow_ribbon_programs_controller_spec.rb b/spec/controllers/v0/yellow_ribbon_programs_controller_spec.rb index 1051bb6b5..fc7369bd6 100644 --- a/spec/controllers/v0/yellow_ribbon_programs_controller_spec.rb +++ b/spec/controllers/v0/yellow_ribbon_programs_controller_spec.rb @@ -3,20 +3,30 @@ require 'rails_helper' RSpec.describe V0::YellowRibbonProgramsController, type: :controller do + def create_prod_version_and_institution + create(:version, :production, :with_institution) + [Version.last, Institution.last] + end + + def create_previw_version_and_institution + create(:version, :preview, :with_institution) + [Version.last, Institution.last] + end + context 'when determining version' do it 'uses a production version as a default' do - production = create(:version, :production) - preview = create(:version, :preview) - create(:yellow_ribbon_program, version: production.number) - create(:yellow_ribbon_program, version: preview.number) + v1, i1 = create_prod_version_and_institution + v2, i2 = create_previw_version_and_institution + create(:yellow_ribbon_program, version: v1.number, institution_id: i1.id) + create(:yellow_ribbon_program, version: v2.number, institution_id: i2.id) get(:index) body = JSON.parse response.body expect(body['data'].count).to eq(1) end it 'accepts invalid version parameter and returns production data' do - create(:version, :production) - create(:yellow_ribbon_program) + v, i = create_prod_version_and_institution + create(:yellow_ribbon_program, version: v.number, institution_id: i.id) get(:index, params: { version: 'invalid_data' }) expect(response.media_type).to eq('application/json') expect(response).to match_response_schema('yellow_ribbon_program') @@ -27,9 +37,9 @@ context 'when searching' do before do - version = create(:version, :production) - create_list(:yellow_ribbon_program, 3, version: version.number) - create(:yellow_ribbon_program, :in_florence, version: version.number) + v, i = create_prod_version_and_institution + create_list(:yellow_ribbon_program, 3, version: v.number, institution_id: i.id) + create(:yellow_ribbon_program, :in_florence, version: v.number, institution_id: i.id) end it 'search returns results' do diff --git a/spec/controllers/v1/institutions_controller_spec.rb b/spec/controllers/v1/institutions_controller_spec.rb index 6ba919b48..1f380907c 100644 --- a/spec/controllers/v1/institutions_controller_spec.rb +++ b/spec/controllers/v1/institutions_controller_spec.rb @@ -20,8 +20,7 @@ def create_extension_institutions(trait) context 'with version determination' do it 'uses a production version as a default' do - create(:version, :production) - create(:institution, :contains_harv) + create(:version, :production, :with_institution_that_contains_harv) get(:index) expect_response_match_schema('institution_search_results') end @@ -31,8 +30,7 @@ def preview_body(body) end it 'accepts invalid version parameter and returns production data' do - create(:version, :production) - create(:institution, :contains_harv) + create(:version, :production, :with_institution_that_contains_harv) get(:index, params: { version: 'invalid_data' }) expect(response.media_type).to eq('application/json') expect(response).to match_response_schema('institution_search_results') @@ -41,9 +39,8 @@ def preview_body(body) end it 'accepts version number as a version parameter and returns preview data' do - create(:version, :production) + create(:version, :production, :with_institution_that_contains_harv) v = create(:version, :preview) - create(:institution, :contains_harv, :production_version) get(:index, params: { version: v.uuid }) expect(response.media_type).to eq('application/json') expect(response).to match_response_schema('institution_search_results') @@ -74,7 +71,7 @@ def preview_body(body) end it 'returns empty collection on missing term parameter' do - create(:institution, :start_like_harv) + create(:version, :production, :with_institution_that_starts_like_harv) get(:autocomplete) expect(JSON.parse(response.body)['data'].count).to eq(0) expect(response.media_type).to eq('application/json') @@ -82,7 +79,7 @@ def preview_body(body) end it 'does not return results for non-approved institutions' do - create(:institution, :start_like_harv, approved: false) + create(:institution, :production_version, :start_like_harv, approved: false) get(:autocomplete, params: { term: 'harv' }) expect(JSON.parse(response.body)['data'].count).to eq(0) expect(response.media_type).to eq('application/json') @@ -222,11 +219,11 @@ def check_boolean_facets(facets) before do create(:version, :production) - create_list(:institution, 2, :in_nyc, version_id: Version.current_production.id) - create(:institution, :in_chicago, online_only: true, version_id: Version.current_production.id) - create(:institution, :in_new_rochelle, distance_learning: true, version_id: Version.current_production.id) + create_list(:institution, 2, :in_nyc, :production_version) + create(:institution, :production_version, :in_chicago, online_only: true) + create(:institution, :production_version, :in_new_rochelle, distance_learning: true) # adding a non approved institutions row - create(:institution, :contains_harv, approved: false, version_id: Version.current_production.id) + create(:institution, :production_version, :contains_harv, approved: false) end it 'search returns results' do @@ -237,7 +234,7 @@ def check_boolean_facets(facets) end it 'search returns results matching name' do - create(:institution, :uchicago, version_id: Version.current_production.id) + create(:institution, :uchicago, :production_version) get(:index, params: { name: 'UNIVERSITY OF CHICAGO - NOT IN CHICAGO' }) expect(JSON.parse(response.body)['data'].count).to eq(1) expect(response.media_type).to eq('application/json') @@ -245,8 +242,8 @@ def check_boolean_facets(facets) end it 'search returns results fuzzy-matching name' do - create(:institution, :independent_study, version_id: Version.current_production.id) - create(:institution, :uchicago, version_id: Version.current_production.id) + create(:institution, :independent_study, :production_version) + create(:institution, :uchicago, :production_version) get(:index, params: { name: 'UNIVERSITY OF NDEPENDENT STUDY' }) expect(JSON.parse(response.body)['data'].count).to eq(1) expect(response.media_type).to eq('application/json') @@ -254,8 +251,8 @@ def check_boolean_facets(facets) end it 'search returns results fuzzy-matching with exact match name' do - first = create(:institution, :independent_study, version_id: Version.current_production.id) - create(:institution, :uchicago, version_id: Version.current_production.id) + first = create(:institution, :independent_study, :production_version) + create(:institution, :uchicago, :production_version) get(:index, params: { name: 'UNIVERSITY OF INDEPENDENT STUDY' }) expect(JSON.parse(response.body)['data'].count).to eq(1) expect(JSON.parse(response.body)['data'][0]['attributes']['name']).to eq(first.institution) @@ -264,10 +261,9 @@ def check_boolean_facets(facets) end it 'search returns results correctly ordered results' do - create(:institution, institution: 'HARVAR', institution_search: 'HARVAR', gibill: 1, - version_id: Version.current_production.id) - first = create(:institution, institution: 'HARVARDY', institution_search: 'HARVARDY', - gibill: 100, version_id: Version.current_production.id) + create(:institution, :production_version, institution: 'HARVAR', institution_search: 'HARVAR', gibill: 1) + first = create(:institution, :production_version, + institution: 'HARVARDY', institution_search: 'HARVARDY', gibill: 100) get(:index, params: { name: 'HARVARD' }) expect(JSON.parse(response.body)['data'][0]['attributes']['name']).to eq(first.institution) expect(response.media_type).to eq('application/json') @@ -275,7 +271,7 @@ def check_boolean_facets(facets) end it 'search returns results alias' do - create(:institution, :independent_study, ialias: 'UIS', version_id: Version.current_production.id) + create(:institution, :production_version, :independent_study, ialias: 'UIS') get(:index, params: { name: 'uis' }) expect(JSON.parse(response.body)['data'].count).to eq(1) expect(response.media_type).to eq('application/json') @@ -290,7 +286,7 @@ def check_boolean_facets(facets) end it 'search with space returns results' do - create(:institution, institution_search: 'with space', version_id: Version.current_production.id) + create(:institution, :production_version, institution_search: 'with space') get(:index, params: { name: 'with space' }) expect(JSON.parse(response.body)['data'].count).to eq(1) expect(response.media_type).to eq('application/json') @@ -298,9 +294,9 @@ def check_boolean_facets(facets) end it 'do not return results for extension institutions' do - create(:institution, :ca_employer, version_id: Version.current_production.id) - create(:institution, :ca_employer, campus_type: 'E', version_id: Version.current_production.id) - create(:institution, :ca_employer, campus_type: 'Y', version_id: Version.current_production.id) + create(:institution, :production_version, :ca_employer) + create(:institution, :production_version, :ca_employer, campus_type: 'E') + create(:institution, :production_version, :ca_employer, campus_type: 'Y') get(:index, params: { name: 'acme' }) expect(JSON.parse(response.body)['data'].count).to eq(2) @@ -330,20 +326,20 @@ def check_boolean_facets(facets) end it 'includes vet_tec_provider institutions' do - vet_tec = create(:institution, :vet_tec_provider, version_id: Version.current_production.id) + vet_tec = create(:institution, :production_version, :vet_tec_provider) get(:index, params: { name: 'vet tec' }) expect(JSON.parse(response.body)['data'][0]['attributes']['facility_code']).to eq(vet_tec.facility_code) end it 'excludes vet_tec_provider institutions' do - create(:institution, :vet_tec_provider, version_id: Version.current_production.id) + create(:institution, :production_version, :vet_tec_provider) get(:index, params: { name: 'vet tec', exclude_vettec: true }) expect(JSON.parse(response.body)['data'].count).to eq(0) end it 'filters by preferred_provider' do - create(:institution, :in_nyc, version_id: Version.current_production.id) - create(:institution, :preferred_provider, version_id: Version.current_production.id) + create(:institution, :production_version, :in_nyc) + create(:institution, :production_version, :preferred_provider) get(:index, params: { exclude_schools: true, exclude_employers: true, preferred_provider: true }) expect(JSON.parse(response.body)['data'].map { |a| a['attributes']['preferred_provider'] }).to all(eq(true)) end @@ -383,7 +379,7 @@ def check_boolean_facets(facets) end it 'search returns location results' do - create(:institution, :location, version_id: Version.current_production.id) + create(:institution, :production_version, :location) get(:location, params: { latitude: '32.7876', longitude: '-79.9403', distance: '50', tab: 'location' }) expect(JSON.parse(response.body)['data'].count).to eq(1) expect(response.media_type).to eq('application/json') @@ -397,9 +393,9 @@ def check_boolean_facets(facets) end it 'search returns compare results' do - i1 = create(:institution, version_id: Version.current_production.id) - i2 = create(:institution, version_id: Version.current_production.id) - i3 = create(:institution, version_id: Version.current_production.id) + i1 = create(:institution, :production_version) + i2 = create(:institution, :production_version) + i3 = create(:institution, :production_version) get(:facility_codes, params: { facility_codes: [i1.facility_code, i2.facility_code, i3.facility_code] }) expect(JSON.parse(response.body)['data'].count).to eq(3) expect(response.media_type).to eq('application/json') @@ -444,9 +440,7 @@ def check_boolean_facets(facets) end context 'with institution profile' do - before do - create(:version, :production) - end + before { create(:version, :production) } it 'returns profile details' do school = create(:institution, :in_chicago, :production_version) @@ -471,9 +465,7 @@ def check_boolean_facets(facets) end context 'with institution children' do - before do - create(:version, :production) - end + before { create(:version, :production) } it 'returns institution children' do school = create(:institution, :in_chicago, :production_version) diff --git a/spec/factories/institutions.rb b/spec/factories/institutions.rb index 057d73a13..f11e5d967 100644 --- a/spec/factories/institutions.rb +++ b/spec/factories/institutions.rb @@ -111,6 +111,10 @@ physical_state { 'MA' } physical_country { 'USA' } ownership_name { 'test' } + + after(:create) do |institution| + create(:institution_program, :start_like_harv, institution_id: institution.id) + end end trait :contains_harv do @@ -121,6 +125,10 @@ physical_state { 'MA' } physical_country { 'USA' } ownership_name { 'test' } + + after(:create) do |institution| + create(:institution_program, :contains_harv, institution_id: institution.id) + end end trait :ca_employer do @@ -292,6 +300,10 @@ version_id { Version.current_production.id } end + trait :preview_version do + version_id { Version.current_preview.id } + end + trait :mit do ialias { 'MIT' } institution { 'MUST INVESTIGATE TARANTULAS' } diff --git a/spec/factories/sec702s.rb b/spec/factories/sec702s.rb index 3d89ab810..75aa4055e 100644 --- a/spec/factories/sec702s.rb +++ b/spec/factories/sec702s.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :sec702 do sequence :state do |n| - StateConverter::STATES.keys[(n - 1) % StateConverter::STATES.length] + Converters::StateConverter::STATES.keys[(n - 1) % Converters::StateConverter::STATES.length] end sec_702 { false } diff --git a/spec/factories/versions.rb b/spec/factories/versions.rb index eb25aefdb..1b5a3b2b3 100644 --- a/spec/factories/versions.rb +++ b/spec/factories/versions.rb @@ -12,5 +12,53 @@ trait :preview do production { false } end + + trait :with_institution do + after(:create) do |version| + create(:institution, version_id: version.id, version: version) + end + end + + trait :with_institution_regular_address do + after(:create) do |version| + create(:institution, :regular_address, version_id: version.id, version: version) + end + end + + trait :with_institution_accreditation_issue do + after(:create) do |version| + create(:institution, :accreditation_issue, version_id: version.id, version: version) + end + end + + trait :with_accredited_institution do + after(:create) do |version| + create(:institution, :with_accreditation, version_id: version.id, version: version) + end + end + + trait :with_ungecodable_foreign_institution do + after(:create) do |version| + create(:institution, :foreign_bad_address, :ungeocodable, version_id: version.id, version: version) + end + end + + trait :with_geocoded_institution do + after(:create) do |version| + create(:institution, :location, :lat_long, version_id: version.id, version: version) + end + end + + trait :with_institution_that_contains_harv do + after(:create) do |version| + create(:institution, :contains_harv, version_id: version.id, version: version) + end + end + + trait :with_institution_that_starts_like_harv do + after(:create) do |version| + create(:institution, :start_like_harv, version_id: version.id, version: version) + end + end end end diff --git a/spec/factories/weams.rb b/spec/factories/weams.rb index 1fea92270..f10753a8b 100644 --- a/spec/factories/weams.rb +++ b/spec/factories/weams.rb @@ -179,9 +179,12 @@ end trait :arf_gi_bill do - arf_gi_bill { create(:arf_gi_bill, facility_code: facility_code) } city { 'Test' } state { 'TN' } + + after(:create) do |weam| + create(:arf_gi_bill, facility_code: weam.facility_code) + end end trait :physical_address do diff --git a/spec/lib/common/client/base_spec.rb b/spec/lib/common/client/base_spec.rb index 02e01262a..450b96fb4 100644 --- a/spec/lib/common/client/base_spec.rb +++ b/spec/lib/common/client/base_spec.rb @@ -74,7 +74,7 @@ .to raise_error(Common::Client::Errors::NotAuthenticated) end - context 'when rescuing Common::Exceptions::BackendServiceException' do + context 'when rescuing Common::Exceptions::External::BackendServiceException' do it 'raises Specs::Common::Client::ServiceException' do service = Specs::Common::Client::BackendServiceExceptionService.new expect { service.send(:request, :get, path) } @@ -83,10 +83,10 @@ end context 'when rescuing Timeout::Error, Faraday::TimeoutError' do - it 'raises Common::Exceptions::GatewayTimeout' do + it 'raises Common::Exceptions::External::GatewayTimeout' do service = Specs::Common::Client::TimeoutExceptionService.new expect { service.send(:request, :get, path) } - .to raise_error(Common::Exceptions::GatewayTimeout) + .to raise_error(Common::Exceptions::External::GatewayTimeout) end end diff --git a/spec/lib/common/client/middleware/response/raise_error_spec.rb b/spec/lib/common/client/middleware/response/raise_error_spec.rb index 08ecc5dec..f2f73eac3 100644 --- a/spec/lib/common/client/middleware/response/raise_error_spec.rb +++ b/spec/lib/common/client/middleware/response/raise_error_spec.rb @@ -32,11 +32,11 @@ end describe '#raise_error!' do - it 'raises Common::Exceptions::BackendServiceException when status is between?(400,599)' do + it 'raises Common::Exceptions::External::BackendServiceException when status is between?(400,599)' do env[:status] = 404 expect { raise_error_instance.on_complete(env) } - .to raise_error(Common::Exceptions::BackendServiceException) + .to raise_error(Common::Exceptions::External::BackendServiceException) end it 'raises BackendUnhandledException when status is not between?(400,599)' do diff --git a/spec/lib/common/exceptions/exception_handler_spec.rb b/spec/lib/common/exceptions/exception_handler_spec.rb index 3dd47e016..1d83b8d71 100644 --- a/spec/lib/common/exceptions/exception_handler_spec.rb +++ b/spec/lib/common/exceptions/exception_handler_spec.rb @@ -12,7 +12,7 @@ describe '.initialize' do context 'when initialized without a nil error' do it 'raises an exception' do - expect { described_class.new(nil, service) }.to raise_error(Common::Exceptions::ParameterMissing) + expect { described_class.new(nil, service) }.to raise_error(Common::Exceptions::Internal::ParameterMissing) end end end @@ -27,8 +27,8 @@ end end - context 'with a Common::Exceptions::GatewayTimeout' do - let(:error) { Common::Exceptions::GatewayTimeout.new } + context 'with a Common::Exceptions::External::GatewayTimeout' do + let(:error) { Common::Exceptions::External::GatewayTimeout.new } let(:results) { described_class.new(error, service).serialize_error } it 'returns a serialized version of the error' do @@ -37,7 +37,7 @@ end def server_error_exception - Common::Exceptions::BackendServiceException.new( + Common::Exceptions::External::BackendServiceException.new( 'SCORECARD_503', { source: 'ScorecardApi::Client' }, 503, @@ -45,7 +45,7 @@ def server_error_exception ) end - context 'with a Common::Exceptions::BackendServiceException' do + context 'with a Common::Exceptions::External::BackendServiceException' do let(:error) { server_error_exception } let(:results) { described_class.new(error, service).serialize_error } diff --git a/spec/models/accreditation_action_spec.rb b/spec/models/accreditation_action_spec.rb index b328bfaa1..7735bb9b8 100644 --- a/spec/models/accreditation_action_spec.rb +++ b/spec/models/accreditation_action_spec.rb @@ -5,6 +5,8 @@ require 'models/shared_examples/shared_examples_for_exportable' RSpec.describe AccreditationAction, type: :model do + before { create(:accreditation_institute_campus) } + it_behaves_like 'a loadable model', skip_lines: 0 it_behaves_like 'an exportable model', skip_lines: 0 diff --git a/spec/models/accreditation_record_spec.rb b/spec/models/accreditation_record_spec.rb index 3a7928548..54a41da65 100644 --- a/spec/models/accreditation_record_spec.rb +++ b/spec/models/accreditation_record_spec.rb @@ -5,6 +5,8 @@ require 'models/shared_examples/shared_examples_for_exportable' RSpec.describe AccreditationRecord, type: :model do + before { create(:accreditation_institute_campus) } # factories linked by ope & ope6 + it_behaves_like 'a loadable model', skip_lines: 0 it_behaves_like 'an exportable model', skip_lines: 0 diff --git a/spec/models/accreditation_type_keyword_spec.rb b/spec/models/accreditation_type_keyword_spec.rb index e222f1733..7ce65a3fd 100644 --- a/spec/models/accreditation_type_keyword_spec.rb +++ b/spec/models/accreditation_type_keyword_spec.rb @@ -66,10 +66,12 @@ describe 'when deleting' do let(:accreditation_type_keyword) { create :accreditation_type_keyword } + let(:accreditation_institute_campus) { create(:accreditation_institute_campus) } let(:accreditation_record) { build :accreditation_record } it 'nils the accreditation_type_keyword_id on accreditation records that reference it' do accreditation_record.accreditation_type_keyword = accreditation_type_keyword + accreditation_record.accreditation_institute_campus = accreditation_institute_campus accreditation_record.save # confirm it took diff --git a/spec/models/arf_gi_bill_spec.rb b/spec/models/arf_gi_bill_spec.rb index a2edf1f38..f2ed71fa6 100644 --- a/spec/models/arf_gi_bill_spec.rb +++ b/spec/models/arf_gi_bill_spec.rb @@ -5,11 +5,13 @@ require 'models/shared_examples/shared_examples_for_exportable' RSpec.describe ArfGiBill, type: :model do + before { create(:weam) } + it_behaves_like 'a loadable model', skip_lines: 0 it_behaves_like 'an exportable model', skip_lines: 0 describe 'when validating' do - subject(:arf_gi_bill) { build :arf_gi_bill } + subject(:arf_gi_bill) { build :arf_gi_bill, facility_code: Weam.last.facility_code } it 'has a valid factory' do expect(arf_gi_bill).to be_valid @@ -20,8 +22,8 @@ end it 'requires numeric gibill or nil' do - expect(build(:arf_gi_bill, gibill: nil)).to be_valid - expect(build(:arf_gi_bill, gibill: 'abc')).not_to be_valid + expect(build(:arf_gi_bill, facility_code: Weam.last.facility_code, gibill: nil)).to be_valid + expect(build(:arf_gi_bill, facility_code: Weam.last.facility_code, gibill: 'abc')).not_to be_valid end end end diff --git a/spec/models/caution_flag_spec.rb b/spec/models/caution_flag_spec.rb index dda5c8a8f..c037ad93a 100644 --- a/spec/models/caution_flag_spec.rb +++ b/spec/models/caution_flag_spec.rb @@ -10,18 +10,21 @@ RSpec.describe CautionFlag, type: :model do describe 'when validating' do - subject(:caution_flag) { build :caution_flag, version_id: version.id } - - let(:version) { build :version, :preview } - it 'has a valid factory' do + create(:version, :preview, :with_institution) + caution_flag = build(:caution_flag, version_id: Version.last.id, institution_id: Institution.last.id) expect(caution_flag).to be_valid end end describe 'when using scope distinct_flags' do it 'has distinct caution flags' do - create_list :caution_flag, 3, :accreditation_issue + create(:version, :preview, :with_institution) + create_list :caution_flag, + 3, + :accreditation_issue, + version_id: Version.last.id, + institution_id: Institution.last.id expect(described_class.distinct_flags.to_a.size).to eq(1) end @@ -33,7 +36,7 @@ # can't check equals on several fields because of quotes being escaped for inserting # into SQL - CautionFlagTemplate.descendants.each do |template| + CautionFlagTemplates::CautionFlagTemplate.descendants.each do |template| context "when creating a flag with #{template.name} values" do before do clause_sql = <<-SQL diff --git a/spec/models/converters/accreditation_date_time_converter_spec.rb b/spec/models/converters/accreditation_date_time_converter_spec.rb index c7aed38a8..3bfe9ab3e 100644 --- a/spec/models/converters/accreditation_date_time_converter_spec.rb +++ b/spec/models/converters/accreditation_date_time_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe AccreditationDateTimeConverter do +RSpec.describe Converters::AccreditationDateTimeConverter do subject { described_class } it 'converts timestamp strings to date' do diff --git a/spec/models/converters/base_converter_spec.rb b/spec/models/converters/base_converter_spec.rb index 59da8ef79..881cc8555 100644 --- a/spec/models/converters/base_converter_spec.rb +++ b/spec/models/converters/base_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe BaseConverter do +RSpec.describe Converters::BaseConverter do subject { described_class } context 'with strings containing a forbidden word or characters' do diff --git a/spec/models/converters/boolean_converter_spec.rb b/spec/models/converters/boolean_converter_spec.rb index 07d58c0ee..08e83ae05 100644 --- a/spec/models/converters/boolean_converter_spec.rb +++ b/spec/models/converters/boolean_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe BooleanConverter do +RSpec.describe Converters::BooleanConverter do subject { described_class } it 'converts strings to booleans' do diff --git a/spec/models/converters/cross_converter_spec.rb b/spec/models/converters/cross_converter_spec.rb index 659c25af3..03d158152 100644 --- a/spec/models/converters/cross_converter_spec.rb +++ b/spec/models/converters/cross_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe CrossConverter do +RSpec.describe Converters::CrossConverter do subject { described_class } it 'returns nil if value is blank' do diff --git a/spec/models/converters/date_converter_spec.rb b/spec/models/converters/date_converter_spec.rb index 78c67b5ca..c6a8a47d6 100644 --- a/spec/models/converters/date_converter_spec.rb +++ b/spec/models/converters/date_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe DateConverter do +RSpec.describe Converters::DateConverter do subject { described_class } it 'converts m/d/yyyy strings to dates' do diff --git a/spec/models/converters/date_time_converter_spec.rb b/spec/models/converters/date_time_converter_spec.rb index b48d02ded..2bb77f9ff 100644 --- a/spec/models/converters/date_time_converter_spec.rb +++ b/spec/models/converters/date_time_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe DateTimeConverter do +RSpec.describe Converters::DateTimeConverter do subject { described_class } it 'converts strings to date' do diff --git a/spec/models/converters/display_converter_spec.rb b/spec/models/converters/display_converter_spec.rb index d45e8fb2f..da654a876 100644 --- a/spec/models/converters/display_converter_spec.rb +++ b/spec/models/converters/display_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe DisplayConverter do +RSpec.describe Converters::DisplayConverter do subject { described_class } it 'capitalizes letters separated by spaces' do diff --git a/spec/models/converters/downcase_converter_spec.rb b/spec/models/converters/downcase_converter_spec.rb index a880f268d..a48e22edc 100644 --- a/spec/models/converters/downcase_converter_spec.rb +++ b/spec/models/converters/downcase_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe DowncaseConverter do +RSpec.describe Converters::DowncaseConverter do subject { described_class } it 'Downcases strings' do diff --git a/spec/models/converters/facility_code_converter_spec.rb b/spec/models/converters/facility_code_converter_spec.rb index 46d521bdd..69b423008 100644 --- a/spec/models/converters/facility_code_converter_spec.rb +++ b/spec/models/converters/facility_code_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe FacilityCodeConverter do +RSpec.describe Converters::FacilityCodeConverter do subject { described_class } it 'converts lower case alphas to upper' do diff --git a/spec/models/converters/institution_converter_spec.rb b/spec/models/converters/institution_converter_spec.rb index 39cefe355..7bce59034 100644 --- a/spec/models/converters/institution_converter_spec.rb +++ b/spec/models/converters/institution_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe InstitutionConverter do +RSpec.describe Converters::InstitutionConverter do subject { described_class } it 'converts lower case alphas to upper' do diff --git a/spec/models/converters/number_converter_spec.rb b/spec/models/converters/number_converter_spec.rb index 1db68fa94..509996409 100644 --- a/spec/models/converters/number_converter_spec.rb +++ b/spec/models/converters/number_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe NumberConverter do +RSpec.describe Converters::NumberConverter do subject { described_class } it 'strips $, +, and commas from number strings' do diff --git a/spec/models/converters/ope6_converter_spec.rb b/spec/models/converters/ope6_converter_spec.rb index a5e2d207c..6b34e148b 100644 --- a/spec/models/converters/ope6_converter_spec.rb +++ b/spec/models/converters/ope6_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Ope6Converter do +RSpec.describe Converters::Ope6Converter do subject { described_class } it 'right justifies with leading 0s to 5 digits in length' do diff --git a/spec/models/converters/ope_converter_spec.rb b/spec/models/converters/ope_converter_spec.rb index 152a970e6..f4917385f 100644 --- a/spec/models/converters/ope_converter_spec.rb +++ b/spec/models/converters/ope_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe OpeConverter do +RSpec.describe Converters::OpeConverter do subject { described_class } it 'right justifies with leading 0s to 8 digits in length' do diff --git a/spec/models/converters/school_rating_converter_spec.rb b/spec/models/converters/school_rating_converter_spec.rb index f5b80716f..af232a0c3 100644 --- a/spec/models/converters/school_rating_converter_spec.rb +++ b/spec/models/converters/school_rating_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe SchoolRatingConverter do +RSpec.describe Converters::SchoolRatingConverter do it 'returns nil if value is nil' do expect(described_class.convert(nil)).to be_nil end diff --git a/spec/models/converters/state_converter_spec.rb b/spec/models/converters/state_converter_spec.rb index 71c5b08f6..8f19dc7b0 100644 --- a/spec/models/converters/state_converter_spec.rb +++ b/spec/models/converters/state_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe StateConverter do +RSpec.describe Converters::StateConverter do subject { described_class } it 'converts long state names to upcased abbreviations' do diff --git a/spec/models/converters/upcase_converter_spec.rb b/spec/models/converters/upcase_converter_spec.rb index 98e4ed10a..f88431040 100644 --- a/spec/models/converters/upcase_converter_spec.rb +++ b/spec/models/converters/upcase_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe UpcaseConverter do +RSpec.describe Converters::UpcaseConverter do subject { described_class } it 'Upcases strings' do diff --git a/spec/models/converters/zip_converter_spec.rb b/spec/models/converters/zip_converter_spec.rb index 708276f66..2bd4f7be0 100644 --- a/spec/models/converters/zip_converter_spec.rb +++ b/spec/models/converters/zip_converter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe ZipConverter do +RSpec.describe Converters::ZipConverter do subject { described_class } it 'right justifies with leading 0s to 5 characters in length' do diff --git a/spec/models/crosswalk_issue_spec.rb b/spec/models/crosswalk_issue_spec.rb index 48238adbf..555449085 100644 --- a/spec/models/crosswalk_issue_spec.rb +++ b/spec/models/crosswalk_issue_spec.rb @@ -11,6 +11,16 @@ def ignore_issue(issue) ) end + it 'has a valid factory' do + crosswalk_issue = build(:crosswalk_issue, :with_weam_match) + expect(crosswalk_issue).to be_valid + end + + it 'errors if no parent is present' do + crosswalk_issue = build(:crosswalk_issue, :partial_match_type) + expect(crosswalk_issue).not_to be_valid + end + def ignore_and_validate_delete_of_only_partial_match_issue issue = described_class.by_issue_type(CrosswalkIssue::PARTIAL_MATCH_TYPE).first ignore_issue(issue) @@ -242,4 +252,18 @@ def ignore_and_validate_delete_of_only_partial_match_issue end end end + + describe '#export_and_pluck_partials' do + it 'responds to #export_and_pluck_partials' do + expect(described_class).to respond_to(:export_and_pluck_partials) + end + + it 'returns an array of partials' do + create(:crosswalk_issue, :with_weam_match, :with_ipeds_hd_match, :partial_match_type) + + # Array of Arrays + expect(described_class.export_and_pluck_partials).to be_an(Array) + expect(described_class.export_and_pluck_partials[0]).to be_an(Array) + end + end end diff --git a/spec/models/db_cleanup_spec.rb b/spec/models/db_cleanup_spec.rb index a58e2013d..79e1cb744 100644 --- a/spec/models/db_cleanup_spec.rb +++ b/spec/models/db_cleanup_spec.rb @@ -3,12 +3,9 @@ require 'rails_helper' RSpec.describe DbCleanup, type: :model do - let(:version) { create(:version, :preview) } - describe '#delete_broken_preview' do it 'removes all dependant version preview data' do - institution = create :institution, :regular_address - institution.update(version: version, version_id: version.id) + version = create(:version, :preview, :with_institution_regular_address) # This seems necessary to overcome RSpec's wrapping things # in transactions and Postgresql does not like wrapping diff --git a/spec/models/institution_builder/institution_builder_1015_spec.rb b/spec/models/institution_builder/institution_builder_1015_spec.rb index 6ec9fecb3..75b7ef95e 100644 --- a/spec/models/institution_builder/institution_builder_1015_spec.rb +++ b/spec/models/institution_builder/institution_builder_1015_spec.rb @@ -8,8 +8,8 @@ describe 'when processing section 1015s' do let(:production_version) { Version.current_production } - let(:institution1) { create(:institution, :section1015a) } - let(:institution2) { create(:institution, :section1015b) } + let(:institution1) { create(:institution, :section1015a, version_id: production_version.id) } + let(:institution2) { create(:institution, :section1015b, version_id: production_version.id) } before do create(:weam, :institution_builder, :approved_institution) diff --git a/spec/models/institution_builder/institution_builder_accreditation_1_spec.rb b/spec/models/institution_builder/institution_builder_accreditation_1_spec.rb index 9434c5028..d8b929aeb 100644 --- a/spec/models/institution_builder/institution_builder_accreditation_1_spec.rb +++ b/spec/models/institution_builder/institution_builder_accreditation_1_spec.rb @@ -62,7 +62,9 @@ end it 'does not add accreditations when there is no dapip_id match' do - create :accreditation_record, dapip_id: -1 + accreditation_record = create :accreditation_record + accreditation_record.dapip_id = -1 + accreditation_record.save(validate: false) described_class.run(user) institution = Institution.first expect(institution.accreditation_type).to be_nil diff --git a/spec/models/institution_builder/institution_builder_accreditation_3_spec.rb b/spec/models/institution_builder/institution_builder_accreditation_3_spec.rb index a4ad735c7..7721450df 100644 --- a/spec/models/institution_builder/institution_builder_accreditation_3_spec.rb +++ b/spec/models/institution_builder/institution_builder_accreditation_3_spec.rb @@ -64,7 +64,7 @@ expect(CautionFlag .where({ institution_id: institution.id, - source: AccreditationCautionFlag::NAME, + source: CautionFlagTemplates::AccreditationCautionFlag::NAME, version_id: Version.current_production.id }) .count).to be > 0 end @@ -75,7 +75,7 @@ expect(CautionFlag .where({ institution_id: institution.id, - source: AccreditationCautionFlag::NAME, + source: CautionFlagTemplates::AccreditationCautionFlag::NAME, version_id: Version.current_production.id }) .count).to eq(0) end @@ -86,7 +86,7 @@ described_class.run(user) caution_flags = CautionFlag.where({ institution_id: institution.id, - source: AccreditationCautionFlag::NAME, + source: CautionFlagTemplates::AccreditationCautionFlag::NAME, version_id: Version.current_production.id }).count expect(caution_flags).to be > 0 expect(institutions.find(institution.id).caution_flag_reason) diff --git a/spec/models/institution_builder/institution_builder_category_spec.rb b/spec/models/institution_builder/institution_builder_category_spec.rb index b80fb0982..43e66e0da 100644 --- a/spec/models/institution_builder/institution_builder_category_spec.rb +++ b/spec/models/institution_builder/institution_builder_category_spec.rb @@ -7,8 +7,7 @@ include_context('with setup') describe 'when calculating category ratings' do - let(:production_version) { Version.current_production } - let(:institution) { create(:institution, :physical_address) } + let(:institution) { create(:institution, :physical_address, :production_version) } before do weam = create(:weam, :physical_address, :approved_institution) @@ -16,7 +15,6 @@ weam.save(validate: false) create :institution_school_rating create :institution_school_rating, :second_rating - institution.version = production_version institution.facility_code = '11913105' institution.save end diff --git a/spec/models/institution_builder/institution_builder_geocoder_spec.rb b/spec/models/institution_builder/institution_builder_geocoder_spec.rb index 68c925bfb..ec835c605 100644 --- a/spec/models/institution_builder/institution_builder_geocoder_spec.rb +++ b/spec/models/institution_builder/institution_builder_geocoder_spec.rb @@ -7,14 +7,12 @@ include_context('with setup') describe '#run - with geocoding and updating geocoding from production' do - let(:production_version) { Version.current_production } - let(:institution) { create(:institution, :physical_address) } + let(:institution) { create(:institution, :physical_address, :production_version) } before do weam = create(:weam, :physical_address, :approved_institution) weam.facility_code = '12345' weam.save(validate: false) - institution.version = production_version institution.facility_code = '12345' end diff --git a/spec/models/institution_builder/institution_builder_run_add_data_1_spec.rb b/spec/models/institution_builder/institution_builder_run_add_data_1_spec.rb index 8b22df398..3e05abea5 100644 --- a/spec/models/institution_builder/institution_builder_run_add_data_1_spec.rb +++ b/spec/models/institution_builder/institution_builder_run_add_data_1_spec.rb @@ -176,7 +176,7 @@ described_class.run(user) expect(CautionFlag .where({ institution_id: institution.id, - source: MouCautionFlag::NAME, + source: CautionFlagTemplates::MouCautionFlag::NAME, version_id: Version.current_production.id }) .count).to be > 0 end @@ -186,7 +186,7 @@ described_class.run(user) expect(CautionFlag .where({ institution_id: institution.id, - source: MouCautionFlag::NAME, + source: CautionFlagTemplates::MouCautionFlag::NAME, version_id: Version.current_production.id }) .count).to eq(0) end @@ -197,7 +197,7 @@ create :mou, :institution_builder, :by_dod described_class.run(user) caution_flags = CautionFlag.where({ institution_id: institution.id, - source: MouCautionFlag::NAME, + source: CautionFlagTemplates::MouCautionFlag::NAME, version_id: Version.current_production.id }).count expect(caution_flags).to be > 0 diff --git a/spec/models/institution_builder/institution_builder_run_add_data_2_spec.rb b/spec/models/institution_builder/institution_builder_run_add_data_2_spec.rb index 1dcab9e03..446477f62 100644 --- a/spec/models/institution_builder/institution_builder_run_add_data_2_spec.rb +++ b/spec/models/institution_builder/institution_builder_run_add_data_2_spec.rb @@ -132,7 +132,7 @@ def check_ipeds_ic_ay institution = institutions.find_by(facility_code: weam_row.facility_code) expect(CautionFlag - .where({ source: Sec702CautionFlag::NAME, + .where({ source: CautionFlagTemplates::Sec702CautionFlag::NAME, institution_id: institution.id, version_id: Version.current_production.id }) .count).to be > 0 @@ -145,7 +145,7 @@ def check_ipeds_ic_ay described_class.run(user) institution = institutions.find_by(facility_code: weam_row.facility_code) - expect(CautionFlag.where({ source: Sec702CautionFlag::NAME, institution_id: institution.id, + expect(CautionFlag.where({ source: CautionFlagTemplates::Sec702CautionFlag::NAME, institution_id: institution.id, version_id: Version.current_production.id }).count).to be > 0 end end @@ -210,7 +210,7 @@ def check_ipeds_ic_ay described_class.run(user) expect(CautionFlag .where({ institution_id: institution.id, - source: HcmCautionFlag::NAME, + source: CautionFlagTemplates::HcmCautionFlag::NAME, version_id: Version.current_production.id }) .count).to be > 0 end @@ -221,7 +221,7 @@ def check_ipeds_ic_ay create :hcm, :institution_builder described_class.run(user) caution_flags = CautionFlag.where({ institution_id: institution.id, - source: HcmCautionFlag::NAME, + source: CautionFlagTemplates::HcmCautionFlag::NAME, version_id: Version.current_production.id }).count expect(caution_flags).to be > 0 @@ -233,7 +233,7 @@ def check_ipeds_ic_ay create :hcm, :institution_builder create :hcm, :institution_builder, hcm_reason: 'another reason' described_class.run(user) - caution_flags = CautionFlag.where({ institution_id: institution.id, source: HcmCautionFlag::NAME, + caution_flags = CautionFlag.where({ institution_id: institution.id, source: CautionFlagTemplates::HcmCautionFlag::NAME, version_id: Version.current_production.id }).count expect(caution_flags).to be > 0 expect(institutions.find(institution.id).caution_flag_reason) diff --git a/spec/models/institution_program_spec.rb b/spec/models/institution_program_spec.rb index d677cf6bc..76760d293 100644 --- a/spec/models/institution_program_spec.rb +++ b/spec/models/institution_program_spec.rb @@ -6,7 +6,8 @@ describe 'when validating' do subject(:institution_program) { create :institution_program, institution: institution } - let(:institution) { create :institution, :physical_address } + let(:version) { create :version, :production } + let(:institution) { create :institution, :physical_address, version_id: version.id } it 'has a valid factory' do expect(institution_program).to be_valid diff --git a/spec/models/institution_spec.rb b/spec/models/institution_spec.rb index e4d1dfd38..88c441a8e 100644 --- a/spec/models/institution_spec.rb +++ b/spec/models/institution_spec.rb @@ -7,9 +7,9 @@ it_behaves_like 'an exportable model by version' describe 'when validating' do - subject(:institution) { create :institution } - it 'has a valid factory' do + version = create(:version, :preview) + institution = build :institution, version: version, version_id: version.id expect(institution).to be_valid end end @@ -130,11 +130,13 @@ end describe 'institution_programs' do - let(:institution) { build :institution } + before { create(:version, :preview) } + + let(:institution) { build :institution, :preview_version } def create_institution(institution, description) InstitutionProgram.create(institution: institution, description: description, - version: institution.version, facility_code: institution.facility_code) + facility_code: institution.facility_code) end it 'returns versioned institution programs' do @@ -170,8 +172,8 @@ def create_institution(institution, description) context 'with filter v1 scope' do it 'filters on state only if only a state is provided in the name' do create(:version, :production) - create(:institution, :in_nyc_state_country, version_id: Version.current_production.id) - create(:institution, :in_nyc_state_only, version_id: Version.current_production.id) + create(:institution, :in_nyc_state_country, :production_version) + create(:institution, :in_nyc_state_only, :production_version) query = { 'name' => 'Hampton', 'state' => 'NY' } expect(described_class.search_v1(query).filter_result_v1(query).count).to eq(2) expect(described_class.search_v1(query).filter_result_v1(query).to_sql).to include('physical_state') @@ -182,8 +184,8 @@ def create_institution(institution, description) context 'with filter v1 scope without country' do it 'filters on state only if only a state is provided in the name' do create(:version, :production) - create(:institution, :in_nyc_state_country, version_id: Version.current_production.id) - create(:institution, :in_nyc_state_only, version_id: Version.current_production.id) + create(:institution, :in_nyc_state_country, :production_version) + create(:institution, :in_nyc_state_only, :production_version) query = { 'name' => 'Hampton', 'state' => 'NY', 'country' => 'USA' } expect(described_class.search_v1(query).filter_result_v1(query).count).to eq(1) expect(described_class.search_v1(query).filter_result_v1(query).to_sql).to include('physical_country') @@ -210,7 +212,8 @@ def create_institution(institution, description) end it 'includes the address fields if include_address is set' do - institution = create(:institution, physical_address_1: 'address_1') + create(:version, :production) + institution = create(:institution, :production_version, physical_address_1: 'address_1') expect(described_class.search({ name: 'address_1', include_address: true }).take).to eq(institution) expect(described_class.search({ name: 'address_1' }).count).to eq(0) end @@ -219,15 +222,15 @@ def create_institution(institution, description) context 'with search order sorts ' do before do create(:version, :production) - create_list(:institution, 2, :in_nyc, version_id: Version.current_production.id) - create(:institution, :in_chicago, online_only: true, version_id: Version.current_production.id) - create(:institution, :in_new_rochelle, distance_learning: true, version_id: Version.current_production.id) + create_list(:institution, 2, :in_nyc, :production_version) + create(:institution, :production_version, :in_chicago, online_only: true) + create(:institution, :production_version, :in_new_rochelle, distance_learning: true) # adding a non approved institutions row - create(:institution, :contains_harv, approved: false, version_id: Version.current_production.id) + create(:institution, :production_version, :contains_harv, approved: false) end it 'ialias exact match' do - institution = create(:institution, :mit) + institution = create(:institution, :production_version, :mit) search_term = institution.ialias query = { name: search_term } results = described_class.search(query).search_order(query) @@ -235,7 +238,7 @@ def create_institution(institution, description) end it 'ialias contains the search term as a word' do - create(:institution, ialias: 'KU | KANSAS UNIVERSITY', institution: 'KANSAS UNIVERSITY NORTH') + create(:institution, :production_version, ialias: 'KU | KANSAS UNIVERSITY', institution: 'KANSAS UNIVERSITY NORTH') search_term = 'KU' query = { name: search_term } results = described_class.search(query).search_order(query) @@ -244,7 +247,13 @@ def create_institution(institution, description) ['!', '$', '(', ')', '*', '+', '.', ':', '<', '=', '>', '?', '[', ']', '^', '{', '|', '}', '-', "'"].each do |postgresql_regex_char| it "institution matches with postgresql regex special character \"#{postgresql_regex_char}\" in search term" do - create(:institution, ialias: 'KU | KANSAS UNIVERSITY', institution: "KANSAS#{postgresql_regex_char} UNIVERSITY NORTH") + create( + :institution, + :production_version, + ialias: 'KU | KANSAS UNIVERSITY', + institution: "KANSAS#{postgresql_regex_char} UNIVERSITY NORTH" + ) + search_term = "KANSAS#{postgresql_regex_char}" query = { name: search_term } results = described_class.search(query).search_order(query) @@ -253,7 +262,7 @@ def create_institution(institution, description) end it 'institution exact match' do - institution = create(:institution, :mit) + institution = create(:institution, :production_version, :mit) search_term = institution.institution query = { name: search_term } results = described_class.search(query).search_order(query) @@ -261,7 +270,7 @@ def create_institution(institution, description) end it 'city exact match' do - institution = create(:institution, :mit) + institution = create(:institution, :production_version, :mit) search_term = institution.physical_city query = { name: search_term } results = described_class.search(query).search_order(query) @@ -269,8 +278,8 @@ def create_institution(institution, description) end it 'gibill value' do - create(:institution, :mit, gibill: 1) - institution = create(:institution, :mit) + create(:institution, :production_version, :mit, gibill: 1) + institution = create(:institution, :production_version, :mit) max_gibill = described_class.maximum(:gibill) query = { name: institution.institution } results = described_class.search(query).search_order(query, max_gibill) @@ -280,17 +289,17 @@ def create_institution(institution, description) it 'approved institutions' do create(:version, :production) - create(:institution, version_id: Version.current_production.id) - create(:institution, approved: false, version_id: Version.current_production.id) + create(:institution, :production_version) + create(:institution, :production_version, approved: false) results = described_class.approved_institutions(Version.current_production) expect(results.count).to eq(1) end it 'non vet tec institutions' do create(:version, :production) - create(:institution, version_id: Version.current_production.id) - create(:institution, approved: false, version_id: Version.current_production.id) - create(:institution, :vet_tec_provider, version_id: Version.current_production.id) + create(:institution, :production_version) + create(:institution, :production_version, approved: false) + create(:institution, :production_version, :vet_tec_provider) results = described_class.non_vet_tec_institutions(Version.current_production) expect(results.count).to eq(1) @@ -298,8 +307,8 @@ def create_institution(institution, description) it 'excludes high schools when filtering them out' do create(:version, :production) - create(:institution, version_id: Version.current_production.id) - create(:institution, :high_school_institution, version_id: Version.current_production.id) + create(:institution, :production_version) + create(:institution, :production_version, :high_school_institution) results = described_class.filter_high_school expect(results.count).to eq(0) end @@ -350,8 +359,8 @@ def create_institution(institution, description) context 'when reporting on ungeocodables' do before do create(:version, :production) - create(:institution, :location, :lat_long) - create(:institution, :foreign_bad_address, :ungeocodable) + create(:institution, :production_version, :location, :lat_long) + create(:institution, :production_version, :foreign_bad_address, :ungeocodable) # rubocop:disable Rails/SkipsModelValidations described_class.update_all version_id: Version.first.id diff --git a/spec/models/search_geocoder_spec.rb b/spec/models/search_geocoder_spec.rb index 3898ab772..176df3486 100644 --- a/spec/models/search_geocoder_spec.rb +++ b/spec/models/search_geocoder_spec.rb @@ -102,9 +102,7 @@ describe '#process_geocoder_address' do it 'does not process without version' do - institution = create :institution, :regular_address - update_institution_name(institution) - update_version_and_id(institution, version) + institution = build_and_create_institution(:regular_address) geo_search_results = described_class.new(nil) geo_search_results.process_geocoder_address expect(geo_search_results.results).to eq([]) @@ -114,9 +112,7 @@ end it 'decrements the results after a successful geocode' do - institution = create :institution, :regular_address - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution(:regular_address) geo_search_results = described_class.new(version) expect(geo_search_results.results.count).to eq(Institution.count) geo_search_results.process_geocoder_address @@ -124,10 +120,8 @@ end it 'updates coordinates using address field' do - institution = create :institution, :regular_address - update_institution_name(institution) + institution = build_and_create_institution(:regular_address) institution.update(address_2: nil, address_3: nil) - update_version_and_id(institution, version) geo_search_results = described_class.new(version) geo_search_results.process_geocoder_address expect(Institution.last.latitude.round(2)).to eq(42.6840271.round(2)) @@ -135,9 +129,7 @@ end it 'updates coordinates using address_1 field' do - institution = create :institution, :regular_address - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution(:regular_address) geo_search_results = described_class.new(version) geo_search_results.process_geocoder_address expect(Institution.last.latitude.round(2)).to eq(42.6840271.round(2)) @@ -145,9 +137,7 @@ end it 'updates coordinates using address_2 field' do - institution = create :institution, :regular_address_2 - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution(:regular_address_2) geo_search_results = described_class.new(version) geo_search_results.process_geocoder_address expect(Institution.last.latitude.round(2)).to eq(42.6840271.round(2)) @@ -155,9 +145,7 @@ end it 'updates coordinates bad address fields' do - institution = create :institution, :bad_address - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution(:bad_address) geo_search_results = described_class.new(version) geo_search_results.process_geocoder_address expect(Institution.last.latitude.round(2)).to eq(42.6840271.round(2)) @@ -165,9 +153,8 @@ end it 'updates coordinates bad address fields, can not find address' do - institution = create :institution, :bad_address - update_institution_name(institution) - institution.update(version: version, version_id: version.id, address_1: 'sunshine highway') + institution = build_and_create_institution(:bad_address) + institution.update(address_1: 'sunshine highway') geo_search_results = described_class.new(version) geo_search_results.process_geocoder_address expect(Institution.last.latitude.round(2)).to eq(42.6511674.round(2)) @@ -176,9 +163,7 @@ end it 'updates coordinates bad address fields by name' do - institution = create :institution, :bad_address_with_name - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution(:bad_address_with_name) geo_search_results = described_class.new(version) geo_search_results.process_geocoder_address expect(Institution.last.latitude.round(2)).to eq(42.6840271.round(2)) @@ -187,9 +172,7 @@ it 'coordinates bad address fields by name with numbering' do # fixed flakey test - institution = create :institution, :bad_address_with_name_numbered - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution(:bad_address_with_name_numbered) geo_search_results = described_class.new(version) geo_search_results.process_geocoder_address expect(Institution.last.latitude.round(1)).to eq(33.7976469.round(1)) @@ -197,9 +180,7 @@ end it 'updates coordinates bad address fields, country' do - institution = create :institution, :regular_address_country - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution(:regular_address_country) geo_search_results = described_class.new(version) geo_search_results.process_geocoder_country expect(Institution.last.latitude.round(2)).to eq(40.6150446.round(2)) @@ -207,9 +188,8 @@ end it 'updates coordinates bad address fields, country with state' do - institution = create :institution, :regular_address_country - update_institution_name(institution) - institution.update(version: version, version_id: version.id, state: 'NY') + institution = build_and_create_institution(:regular_address_country) + institution.update(state: 'NY') geo_search_results = described_class.new(version) geo_search_results.process_geocoder_country expect(Institution.last.latitude.round(2)).to eq(42.6384261.round(2)) @@ -217,9 +197,7 @@ end it 'adds records to the progress table as it runs' do - institution = create :institution, :regular_address - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution :regular_address initial_progress_count = PreviewGenerationStatusInformation.count geo_search_results = described_class.new(version) geo_search_results.process_geocoder_address @@ -229,9 +207,7 @@ it 'sets the ungeocodable flag to true if it could not find the coordinates' do allow(Rails.logger).to receive(:info) - institution = create :institution, :regular_address - update_institution_name(institution) - update_version_and_id(institution, version) + institution = build_and_create_institution(:regular_address) geo_search = described_class.new(version) geo_search.update_mismatch(institution, nil) expect(institution.ungeocodable).to be true @@ -251,7 +227,7 @@ def run_exception_test(geocoding_exception) allow(Rails.logger).to receive(:info) - create_institution + build_and_create_institution(:regular_address) geo_search = described_class.new(version) results = geo_search.send :geocode_addy, 'exception_test', geocoding_exception, 0 expect(results[0]).to be_nil @@ -259,22 +235,13 @@ def run_exception_test(geocoding_exception) expect(Rails.logger).to have_received(:info).with(/Geocode/).at_least(:once) end - - def create_institution - institution = create :institution, :regular_address - update_version_and_id(institution, version) - update_institution_name(institution) - end end end describe '#initialize' do it 'only includes current preview institutions with null long and lat' do - non_geocoded_institution = create :institution, :regular_address - update_institution_name(non_geocoded_institution) - update_version_and_id(non_geocoded_institution, version) - geocoded_institution = create :institution, :location - update_version_and_id(geocoded_institution, version) + non_geocoded_institution = build_and_create_institution :regular_address + geocoded_institution = build_and_create_institution :location geocoder = described_class.new(version) expect(geocoder.results.first.longitude).to be_nil @@ -283,17 +250,10 @@ def create_institution expect(geocoder.results.ids).to include(non_geocoded_institution.id) end - def create_institution(trait, version) - institution = create :institution, trait - update_institution_name(institution) - update_version_and_id(institution, version) - institution - end - it 'by_address collection only includes country USA or nil' do - institution1 = create_institution(:physical_address, version) - institution2 = create_institution(:regular_address_country_nil, version) - institution3 = create_institution(:regular_address_country, version) + institution1 = build_and_create_institution(:physical_address) + institution2 = build_and_create_institution(:regular_address_country_nil) + institution3 = build_and_create_institution(:regular_address_country) geocoder = described_class.new(version) expect(geocoder.by_address.ids).to include(institution1.id) @@ -302,9 +262,7 @@ def create_institution(trait, version) end it 'stops trying to geocode after a successful geocode match' do - institution = create :institution, :mixed_addresses - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution :mixed_addresses geocoder = described_class.new(version) geocoder.process_geocoder_address @@ -314,9 +272,7 @@ def create_institution(trait, version) end it 'geocodes foreign address in bad_address logic if unable to geocode by address lines' do - institution = create :institution, :foreign_bad_address - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution :foreign_bad_address geocoder = described_class.new(version) geocoder.process_geocoder_address expect(Institution.first.longitude).not_to be_nil @@ -324,19 +280,21 @@ def create_institution(trait, version) end it 'does not set bad_address flag for foreign institutions' do - institution = create :institution, :foreign_bad_address - update_institution_name(institution) - update_version_and_id(institution, version) + build_and_create_institution :foreign_bad_address geocoder = described_class.new(version) geocoder.process_geocoder_address expect(Institution.first.bad_address).not_to eq(true) end end - def update_version_and_id(institution, version) + # Rails 7 is enforcing that version must be present when instantiating an institution + def build_and_create_institution(trait) + institution = build :institution, trait institution.version = version institution.version_id = version.id institution.save + update_institution_name(institution) + institution end def update_institution_name(institution) diff --git a/spec/models/shared_examples/shared_examples_for_loadable.rb b/spec/models/shared_examples/shared_examples_for_loadable.rb index f663621cb..47019996c 100644 --- a/spec/models/shared_examples/shared_examples_for_loadable.rb +++ b/spec/models/shared_examples/shared_examples_for_loadable.rb @@ -7,7 +7,14 @@ before do create :user - create_list factory_name, 5 + if factory_name.eql?(:arf_gi_bill) + 5.times do + weam = create :weam + create(:arf_gi_bill, facility_code: weam.facility_code) + end + else + create_list factory_name, 5 + end end describe 'when loading' do diff --git a/spec/models/storage_spec.rb b/spec/models/storage_spec.rb index d422565c6..4e558b03d 100644 --- a/spec/models/storage_spec.rb +++ b/spec/models/storage_spec.rb @@ -67,7 +67,9 @@ def generate_csv_upload(name) it 'requires a user' do params[:user] = nil - expect(described_class.find_and_update(params).errors.full_messages).to eq(["User can't be blank"]) + expect( + described_class.find_and_update(params).errors.full_messages + ).to eq(['User must exist', "User can't be blank"]) end it 'requires an upload_file' do diff --git a/spec/serializers/caution_flag_serializer_spec.rb b/spec/serializers/caution_flag_serializer_spec.rb index 2acaafa55..6084b15a3 100644 --- a/spec/serializers/caution_flag_serializer_spec.rb +++ b/spec/serializers/caution_flag_serializer_spec.rb @@ -5,7 +5,11 @@ RSpec.describe CautionFlagSerializer, type: :serializer do subject { serialize(caution_flag, serializer_class: described_class) } - let(:caution_flag) { create :caution_flag, :accreditation_issue } + let(:preview_version) { create :version, :preview } + let(:institution) { create :institution, version_id: preview_version.id } + + let(:caution_flag) { create :caution_flag, :accreditation_issue, institution_id: institution.id, version_id: preview_version.id } + let(:data) { JSON.parse(subject)['data'] } let(:attributes) { data['attributes'] } diff --git a/spec/serializers/yellow_ribbon_program_serializer_spec.rb b/spec/serializers/yellow_ribbon_program_serializer_spec.rb index 7653418e5..7767213c1 100644 --- a/spec/serializers/yellow_ribbon_program_serializer_spec.rb +++ b/spec/serializers/yellow_ribbon_program_serializer_spec.rb @@ -5,13 +5,11 @@ RSpec.describe YellowRibbonProgramSerializer, type: :serializer do subject { serialize(yellow_ribbon_program, serializer_class: described_class) } - let(:yellow_ribbon_program) { create :yellow_ribbon_program } + let(:yellow_ribbon_program) { create :yellow_ribbon_program, institution_id: Institution.last.id } let(:data) { JSON.parse(subject)['data'] } let(:attributes) { data['attributes'] } - before do - create(:version, :production) - end + before { create(:version, :production, :with_institution) } it 'city' do expect(attributes['city']).to eq(yellow_ribbon_program.city) diff --git a/spec/support/configuration_helper.rb b/spec/support/configuration_helper.rb index 26b517448..5edff2de0 100644 --- a/spec/support/configuration_helper.rb +++ b/spec/support/configuration_helper.rb @@ -16,7 +16,7 @@ def adapter_only class BackendServiceExceptionConfiguration < DefaultConfiguration def connection - raise ::Common::Exceptions::BackendServiceException, 'TEST404' + raise ::Common::Exceptions::External::BackendServiceException, 'TEST404' end end diff --git a/spec/support/default_configuration_helper.rb b/spec/support/default_configuration_helper.rb index 227a6abc7..e17200a8b 100644 --- a/spec/support/default_configuration_helper.rb +++ b/spec/support/default_configuration_helper.rb @@ -5,7 +5,7 @@ module Specs module Common module Client - class DefaultConfiguration < ::Common::Client::Configuration::REST + class DefaultConfiguration < ::Common::Client::Configuration::Rest def connection @connection ||= Faraday.new(base_path) do |faraday| faraday.use Faraday::Response::RaiseError unless adapter_only diff --git a/spec/utilities/caution_flags/caution_flag_template_spec.rb b/spec/utilities/caution_flags/caution_flag_template_spec.rb index 5eb1b9853..eb2dae839 100644 --- a/spec/utilities/caution_flags/caution_flag_template_spec.rb +++ b/spec/utilities/caution_flags/caution_flag_template_spec.rb @@ -8,7 +8,8 @@ require_relative '../../../app/utilities/caution_flag_templates/mou_caution_flag' require_relative '../../../app/utilities/caution_flag_templates/poo_status_flag' -RSpec.describe CautionFlagTemplate do +# rubocop:disable RSpec/FilePath +RSpec.describe CautionFlagTemplates::CautionFlagTemplate do describe 'as a parent class' do described_class.descendants.each do |template| it "requires #{template.name} templates to define required constants" do @@ -19,3 +20,4 @@ end end end +# rubocop:enable RSpec/FilePath diff --git a/spec/utilities/upload_types/upload_requirements_spec.rb b/spec/utilities/upload_types/upload_requirements_spec.rb index 043f5951f..557253787 100644 --- a/spec/utilities/upload_types/upload_requirements_spec.rb +++ b/spec/utilities/upload_types/upload_requirements_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe UploadRequirements do +RSpec.describe UploadTypes::UploadRequirements do def validations(csv_class, requirement_class) csv_class.validators .find { |requirements| requirements.instance_of?(requirement_class) } diff --git a/spec/views/dashboards/accreditation_issues.html.erb_spec.rb b/spec/views/dashboards/accreditation_issues.html.erb_spec.rb index 140e7b422..5b974a3d0 100644 --- a/spec/views/dashboards/accreditation_issues.html.erb_spec.rb +++ b/spec/views/dashboards/accreditation_issues.html.erb_spec.rb @@ -4,9 +4,7 @@ RSpec.describe 'dashboards/accreditation_issues', type: :view do before do # set the instance variables from the controller before the view is rendered or tests fail - create(:version, :production) - create(:institution, :accreditation_issue) - create(:institution, :with_accreditation) + create(:version, :production, :with_accredited_institution, :with_institution_accreditation_issue) create(:accreditation_institute_campus) create(:accreditation_record)