chore: fix failing legacy tests

mciea-main
Nelson Jovel 2 years ago
parent 79bc91d39f
commit 054e5603b7

@ -1,14 +1,14 @@
module Legacy module Legacy
class Category < ApplicationRecord class Category < ApplicationRecord
has_many :questions has_many :questions
belongs_to :parent_category, class_name: 'Legacy::Category', foreign_key: :parent_category_id belongs_to :parent_category, class_name: "Legacy::Category", foreign_key: :parent_category_id, optional: true
has_many :child_categories, class_name: 'Legacy::Category', foreign_key: :parent_category_id has_many :child_categories, class_name: "Legacy::Category", foreign_key: :parent_category_id
has_many :school_categories has_many :school_categories
validates :name, presence: true validates :name, presence: true
scope :for_parent, ->(category = nil) { where(parent_category_id: category.try(:id)) } scope :for_parent, ->(category = nil) { where(parent_category_id: category.try(:id)) }
scope :likert, -> { where('benchmark is null') } scope :likert, -> { where("benchmark is null") }
include FriendlyId include FriendlyId
friendly_id :name, use: [:slugged] friendly_id :name, use: [:slugged]
@ -21,7 +21,7 @@ module Legacy
end end
def root_identifier def root_identifier
path.first.name.downcase.gsub(/\s/, '-') path.first.name.downcase.gsub(/\s/, "-")
end end
def root_index def root_index
@ -46,7 +46,7 @@ module Legacy
def custom_zones def custom_zones
return [] if zones.nil? return [] if zones.nil?
zones.split(',').map(&:to_f) zones.split(",").map(&:to_f)
end end
def zone_widths def zone_widths
@ -83,11 +83,11 @@ module Legacy
end end
end end
if valid_child_categories > 0 return unless valid_child_categories > 0
average_zones = total_zones.map { |zone| zone / valid_child_categories } average_zones = total_zones.map { |zone| zone / valid_child_categories }
puts "TOTAL: #{name} | #{total_zones} | #{valid_child_categories} | #{average_zones} | #{zone_widths}" puts "TOTAL: #{name} | #{total_zones} | #{valid_child_categories} | #{average_zones} | #{zone_widths}"
update(zones: average_zones.join(',')) update(zones: average_zones.join(","))
end
end end
end end
end end

@ -11,7 +11,7 @@ AggregatedResponses = Struct.new(
module Legacy module Legacy
class Question < ApplicationRecord class Question < ApplicationRecord
belongs_to :category belongs_to :category, optional: true
has_many :attempts has_many :attempts
@ -28,7 +28,7 @@ module Legacy
enum target_group: %i[unknown for_students for_teachers for_parents] enum target_group: %i[unknown for_students for_teachers for_parents]
def source def source
target_group.gsub('for_', '') target_group.gsub("for_", "")
end end
def options def options
@ -69,7 +69,7 @@ module Legacy
end end
def normalized_text def normalized_text
text.gsub('[science/math/English/social studies]', '') text.gsub("[science/math/English/social studies]", "")
end end
end end
end end

@ -2,7 +2,7 @@ module Legacy
class School < ApplicationRecord class School < ApplicationRecord
has_many :schedules, dependent: :destroy has_many :schedules, dependent: :destroy
has_many :recipient_lists, dependent: :destroy has_many :recipient_lists, dependent: :destroy
belongs_to :district belongs_to :district, optional: true
has_many :recipients, dependent: :destroy has_many :recipients, dependent: :destroy
has_many :school_categories, dependent: :destroy has_many :school_categories, dependent: :destroy
has_many :user_schools, dependent: :destroy has_many :user_schools, dependent: :destroy

@ -346,7 +346,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_04_211430) do
t.integer "eleven" t.integer "eleven"
t.integer "twelve" t.integer "twelve"
t.index ["academic_year_id"], name: "index_respondents_on_academic_year_id" t.index ["academic_year_id"], name: "index_respondents_on_academic_year_id"
t.index %w[school_id academic_year_id], name: "index_respondents_on_school_id_and_academic_year_id", unique: true t.index ["school_id", "academic_year_id"], name: "index_respondents_on_school_id_and_academic_year_id", unique: true
end end
create_table "response_rates", force: :cascade do |t| create_table "response_rates", force: :cascade do |t|
@ -360,7 +360,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_04_211430) do
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.index ["academic_year_id"], name: "index_response_rates_on_academic_year_id" t.index ["academic_year_id"], name: "index_response_rates_on_academic_year_id"
t.index %w[school_id subcategory_id], name: "index_response_rates_on_school_id_and_subcategory_id" t.index ["school_id", "subcategory_id"], name: "index_response_rates_on_school_id_and_subcategory_id"
t.index ["subcategory_id"], name: "index_response_rates_on_subcategory_id" t.index ["subcategory_id"], name: "index_response_rates_on_subcategory_id"
end end
@ -420,7 +420,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_04_211430) do
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.index ["race_id"], name: "index_student_races_on_race_id" t.index ["race_id"], name: "index_student_races_on_race_id"
t.index %w[student_id race_id], name: "index_student_races_on_student_id_and_race_id" t.index ["student_id", "race_id"], name: "index_student_races_on_student_id_and_race_id"
t.index ["student_id"], name: "index_student_races_on_student_id" t.index ["student_id"], name: "index_student_races_on_student_id"
end end
@ -462,17 +462,11 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_04_211430) do
t.index ["gender_id"], name: "index_survey_item_responses_on_gender_id" t.index ["gender_id"], name: "index_survey_item_responses_on_gender_id"
t.index ["income_id"], name: "index_survey_item_responses_on_income_id" t.index ["income_id"], name: "index_survey_item_responses_on_income_id"
t.index ["response_id"], name: "index_survey_item_responses_on_response_id" t.index ["response_id"], name: "index_survey_item_responses_on_response_id"
<<<<<<< HEAD
t.index %w[school_id academic_year_id survey_item_id], name: "by_school_year_and_survey_item"
t.index %w[school_id academic_year_id], name: "index_survey_item_responses_on_school_id_and_academic_year_id"
t.index %w[school_id survey_item_id academic_year_id grade], name: "index_survey_responses_on_grade"
=======
t.index ["school_id", "academic_year_id", "survey_item_id"], name: "by_school_year_and_survey_item" t.index ["school_id", "academic_year_id", "survey_item_id"], name: "by_school_year_and_survey_item"
t.index ["school_id", "academic_year_id"], name: "index_survey_item_responses_on_school_id_and_academic_year_id" t.index ["school_id", "academic_year_id"], name: "index_survey_item_responses_on_school_id_and_academic_year_id"
t.index ["school_id", "survey_item_id", "academic_year_id", "grade"], name: "index_survey_responses_on_grade" t.index ["school_id", "survey_item_id", "academic_year_id", "grade"], name: "index_survey_responses_on_grade"
t.index ["school_id"], name: "index_survey_item_responses_on_school_id" t.index ["school_id"], name: "index_survey_item_responses_on_school_id"
t.index ["sped_id"], name: "index_survey_item_responses_on_sped_id" t.index ["sped_id"], name: "index_survey_item_responses_on_sped_id"
>>>>>>> 48e795f (feat: add special education disaggregation)
t.index ["student_id"], name: "index_survey_item_responses_on_student_id" t.index ["student_id"], name: "index_survey_item_responses_on_student_id"
t.index ["survey_item_id"], name: "index_survey_item_responses_on_survey_item_id" t.index ["survey_item_id"], name: "index_survey_item_responses_on_survey_item_id"
end end

@ -1,23 +1,23 @@
require 'rails_helper' require "rails_helper"
module Legacy module Legacy
RSpec.describe 'legacy/recipient_lists/show', type: :view do RSpec.describe "legacy/recipient_lists/show", type: :view do
before(:each) do before(:each) do
@school = assign(:school, School.create!(name: 'School')) @school = assign(:school, Legacy::School.create!(name: "School"))
recipients = ['Jared Cosulich', 'Lauren Cosulich'].collect do |name| recipients = ["Jared Cosulich", "Lauren Cosulich"].collect do |name|
@school.recipients.create!(name:) @school.recipients.create!(name:)
end end
@recipient_list = assign(:recipient_list, RecipientList.create!( @recipient_list = assign(:recipient_list, RecipientList.create!(
name: 'Name', name: "Name",
description: 'MyText', description: "MyText",
recipient_id_array: recipients.map(&:id), recipient_id_array: recipients.map(&:id),
school_id: @school.id school_id: @school.id
)) ))
end end
it 'renders attributes in <p>' do it "renders attributes in <p>" do
render render
expect(rendered).to match(/Name/) expect(rendered).to match(/Name/)
expect(rendered).to match(/MyText/) expect(rendered).to match(/MyText/)

Loading…
Cancel
Save