mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-09 15:38:21 -07:00
chore: fix failing legacy tests
This commit is contained in:
parent
79bc91d39f
commit
054e5603b7
5 changed files with 24 additions and 30 deletions
|
|
@ -1,14 +1,14 @@
|
|||
module Legacy
|
||||
class Category < ApplicationRecord
|
||||
has_many :questions
|
||||
belongs_to :parent_category, class_name: 'Legacy::Category', foreign_key: :parent_category_id
|
||||
has_many :child_categories, 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 :school_categories
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
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
|
||||
friendly_id :name, use: [:slugged]
|
||||
|
|
@ -21,7 +21,7 @@ module Legacy
|
|||
end
|
||||
|
||||
def root_identifier
|
||||
path.first.name.downcase.gsub(/\s/, '-')
|
||||
path.first.name.downcase.gsub(/\s/, "-")
|
||||
end
|
||||
|
||||
def root_index
|
||||
|
|
@ -46,7 +46,7 @@ module Legacy
|
|||
def custom_zones
|
||||
return [] if zones.nil?
|
||||
|
||||
zones.split(',').map(&:to_f)
|
||||
zones.split(",").map(&:to_f)
|
||||
end
|
||||
|
||||
def zone_widths
|
||||
|
|
@ -83,11 +83,11 @@ module Legacy
|
|||
end
|
||||
end
|
||||
|
||||
if valid_child_categories > 0
|
||||
average_zones = total_zones.map { |zone| zone / valid_child_categories }
|
||||
puts "TOTAL: #{name} | #{total_zones} | #{valid_child_categories} | #{average_zones} | #{zone_widths}"
|
||||
update(zones: average_zones.join(','))
|
||||
end
|
||||
return unless valid_child_categories > 0
|
||||
|
||||
average_zones = total_zones.map { |zone| zone / valid_child_categories }
|
||||
puts "TOTAL: #{name} | #{total_zones} | #{valid_child_categories} | #{average_zones} | #{zone_widths}"
|
||||
update(zones: average_zones.join(","))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ AggregatedResponses = Struct.new(
|
|||
|
||||
module Legacy
|
||||
class Question < ApplicationRecord
|
||||
belongs_to :category
|
||||
belongs_to :category, optional: true
|
||||
|
||||
has_many :attempts
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ module Legacy
|
|||
enum target_group: %i[unknown for_students for_teachers for_parents]
|
||||
|
||||
def source
|
||||
target_group.gsub('for_', '')
|
||||
target_group.gsub("for_", "")
|
||||
end
|
||||
|
||||
def options
|
||||
|
|
@ -69,7 +69,7 @@ module Legacy
|
|||
end
|
||||
|
||||
def normalized_text
|
||||
text.gsub('[science/math/English/social studies]', '')
|
||||
text.gsub("[science/math/English/social studies]", "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ module Legacy
|
|||
class School < ApplicationRecord
|
||||
has_many :schedules, dependent: :destroy
|
||||
has_many :recipient_lists, dependent: :destroy
|
||||
belongs_to :district
|
||||
belongs_to :district, optional: true
|
||||
has_many :recipients, dependent: :destroy
|
||||
has_many :school_categories, dependent: :destroy
|
||||
has_many :user_schools, dependent: :destroy
|
||||
|
|
|
|||
12
db/schema.rb
12
db/schema.rb
|
|
@ -346,7 +346,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_04_211430) do
|
|||
t.integer "eleven"
|
||||
t.integer "twelve"
|
||||
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
|
||||
|
||||
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 "updated_at", null: false
|
||||
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"
|
||||
end
|
||||
|
||||
|
|
@ -420,7 +420,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_04_211430) do
|
|||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
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"
|
||||
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 ["income_id"], name: "index_survey_item_responses_on_income_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"], 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"], name: "index_survey_item_responses_on_school_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 ["survey_item_id"], name: "index_survey_item_responses_on_survey_item_id"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/recipient_lists/show', type: :view do
|
||||
RSpec.describe "legacy/recipient_lists/show", type: :view 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:)
|
||||
end
|
||||
|
||||
@recipient_list = assign(:recipient_list, RecipientList.create!(
|
||||
name: 'Name',
|
||||
description: 'MyText',
|
||||
name: "Name",
|
||||
description: "MyText",
|
||||
recipient_id_array: recipients.map(&:id),
|
||||
school_id: @school.id
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders attributes in <p>' do
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
expect(rendered).to match(/Name/)
|
||||
expect(rendered).to match(/MyText/)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue