Autoformat code with rubocop

pull/1/head
Nelson Jovel 4 years ago
parent 68dde8a6ef
commit ed7a3b8a3d

@ -1,6 +1,6 @@
class CategoriesController < SqmApplicationController class CategoriesController < SqmApplicationController
def show def show
@categories = Category.sorted.map { |category| CategoryPresenter.new(category: category) } @categories = Category.sorted.map { |category| CategoryPresenter.new(category:) }
@category = CategoryPresenter.new(category: Category.find_by_slug(params[:id])) @category = CategoryPresenter.new(category: Category.find_by_slug(params[:id]))
end end

@ -3,6 +3,6 @@ class HomeController < ApplicationController
@districts = District.all.order(:name) @districts = District.all.order(:name)
@schools = School.all.includes([:district]).order(:name) @schools = School.all.includes([:district]).order(:name)
@categories = Category.sorted.map { |category| CategoryPresenter.new(category: category) } @categories = Category.sorted.map { |category| CategoryPresenter.new(category:) }
end end
end end

@ -1,7 +1,7 @@
class OverviewController < SqmApplicationController class OverviewController < SqmApplicationController
def index def index
@variance_chart_row_presenters = Measure.all.map(&method(:presenter_for_measure)) @variance_chart_row_presenters = Measure.all.map(&method(:presenter_for_measure))
@category_presenters = Category.sorted.map { |category| CategoryPresenter.new(category: category) } @category_presenters = Category.sorted.map { |category| CategoryPresenter.new(category:) }
end end
private private
@ -9,6 +9,6 @@ class OverviewController < SqmApplicationController
def presenter_for_measure(measure) def presenter_for_measure(measure)
score = measure.score(school: @school, academic_year: @academic_year) score = measure.score(school: @school, academic_year: @academic_year)
VarianceChartRowPresenter.new(measure: measure, score: score) VarianceChartRowPresenter.new(measure:, score:)
end end
end end

@ -39,7 +39,7 @@ module GaugeHelper
end end
def arc_end_point_for(radius:, percentage:) def arc_end_point_for(radius:, percentage:)
angle = angle_for(percentage: percentage) angle = angle_for(percentage:)
x = arc_center.x + radius * Math.cos(angle) x = arc_center.x + radius * Math.cos(angle)
y = arc_center.y + radius * Math.sin(angle) y = arc_center.y + radius * Math.sin(angle)
@ -47,8 +47,8 @@ module GaugeHelper
end end
def arc_end_line_destination(radius:, percentage:) def arc_end_line_destination(radius:, percentage:)
x = arc_center.x + radius * Math.cos(angle_for(percentage: percentage)) x = arc_center.x + radius * Math.cos(angle_for(percentage:))
y = arc_center.y + radius * Math.sin(angle_for(percentage: percentage)) y = arc_center.y + radius * Math.sin(angle_for(percentage:))
Point.new(x, y) Point.new(x, y)
end end
@ -62,8 +62,8 @@ module GaugeHelper
def draw_arc(radius:, percentage:, clockwise:) def draw_arc(radius:, percentage:, clockwise:)
sweep_flag = clockwise ? 1 : 0 sweep_flag = clockwise ? 1 : 0
"A #{arc_radius(radius)} 0 0 #{sweep_flag} #{coordinates_for(arc_end_point_for(radius: radius, "A #{arc_radius(radius)} 0 0 #{sweep_flag} #{coordinates_for(arc_end_point_for(radius:,
percentage: percentage))}" percentage:))}"
end end
def draw_line_to(point:) def draw_line_to(point:)

@ -26,7 +26,7 @@ module HeaderHelper
end end
def link_weight(path:) def link_weight(path:)
active?(path: path) ? 'weight-700' : 'weight-400' active?(path:) ? 'weight-700' : 'weight-400'
end end
private private

@ -14,5 +14,4 @@ class AcademicYear < ActiveRecord::Base
years = range.split('-') years = range.split('-')
"#{years.first} 20#{years.second}" "#{years.first} 20#{years.second}"
end end
end end

@ -2,7 +2,7 @@ class Category < ActiveRecord::Base
include FriendlyId include FriendlyId
friendly_id :name, use: [:slugged] friendly_id :name, use: [:slugged]
scope :sorted, -> { order(:sort_index)} scope :sorted, -> { order(:sort_index) }
has_many :subcategories has_many :subcategories
has_many :measures, through: :subcategories has_many :measures, through: :subcategories

@ -58,9 +58,9 @@ module Legacy
def save_response(answer_index: nil, twilio_details: nil, responded_at: Time.new) def save_response(answer_index: nil, twilio_details: nil, responded_at: Time.new)
update( update(
answer_index: answer_index, answer_index:,
twilio_details: twilio_details, twilio_details:,
responded_at: responded_at responded_at:
) )
recipient_schedule.update(next_attempt_at: Time.new) if recipient_schedule.queued_question_ids.present? recipient_schedule.update(next_attempt_at: Time.new) if recipient_schedule.queued_question_ids.present?

@ -22,7 +22,7 @@ module Legacy
validates :option4, presence: true validates :option4, presence: true
validates :option5, presence: true validates :option5, presence: true
scope :for_category, ->(category) { where(category: category) } scope :for_category, ->(category) { where(category:) }
scope :created_in, ->(year) { where("extract(year from #{table_name}.created_at) = ?", year) } scope :created_in, ->(year) { where("extract(year from #{table_name}.created_at) = ?", year) }
enum target_group: %i[unknown for_students for_teachers for_parents] enum target_group: %i[unknown for_students for_teachers for_parents]

@ -9,7 +9,7 @@ module Legacy
after_initialize :set_question_id_array after_initialize :set_question_id_array
def questions def questions
question_id_array.collect { |id| Question.where(id: id).first }.compact question_id_array.collect { |id| Question.where(id:).first }.compact
end end
private private

@ -12,7 +12,7 @@ module Legacy
validates :name, presence: true validates :name, presence: true
scope :for_school, ->(school) { where(school: school) } scope :for_school, ->(school) { where(school:) }
scope :created_in, ->(year) { where('extract(year from recipients.created_at) = ?', year) } scope :created_in, ->(year) { where('extract(year from recipients.created_at) = ?', year) }
before_destroy :sync_lists before_destroy :sync_lists

@ -14,7 +14,7 @@ module Legacy
after_save :sync_recipient_schedules after_save :sync_recipient_schedules
def recipients def recipients
recipient_id_array.collect { |id| school.recipients.where(id: id).first } recipient_id_array.collect { |id| school.recipients.where(id:).first }
end end
private private

@ -51,7 +51,7 @@ module Legacy
return if recipient.opted_out? return if recipient.opted_out?
return if question.nil? return if question.nil?
return attempt_question(question: question) unless question.for_recipient_students? return attempt_question(question:) unless question.for_recipient_students?
missing_students = [] missing_students = []
recipient_attempts = attempts.for_recipient(recipient).for_question(question) recipient_attempts = attempts.for_recipient(recipient).for_question(question)
@ -60,9 +60,9 @@ module Legacy
end end
attempt = recipient.attempts.create( attempt = recipient.attempts.create(
schedule: schedule, schedule:,
recipient_schedule: self, recipient_schedule: self,
question: question, question:,
student: missing_students.first student: missing_students.first
) )
@ -101,12 +101,12 @@ module Legacy
return if question.nil? && unanswered_attempt.nil? return if question.nil? && unanswered_attempt.nil?
if unanswered_attempt.nil? if unanswered_attempt.nil?
return attempt_question_for_recipient_students(question: question) if question.for_recipient_students? return attempt_question_for_recipient_students(question:) if question.for_recipient_students?
attempt = recipient.attempts.create( attempt = recipient.attempts.create(
schedule: schedule, schedule:,
recipient_schedule: self, recipient_schedule: self,
question: question question:
) )
end end
@ -159,9 +159,9 @@ module Legacy
end end
schedule.recipient_schedules.create( schedule.recipient_schedules.create(
recipient_id: recipient_id, recipient_id:,
upcoming_question_ids: question_ids.join(','), upcoming_question_ids: question_ids.join(','),
next_attempt_at: next_attempt_at next_attempt_at:
) )
end end
end end

@ -9,7 +9,7 @@ module Legacy
validates_associated :school_category validates_associated :school_category
scope :for, ->(school, question) { where(school_id: school.id, question_id: question.id) } scope :for, ->(school, question) { where(school_id: school.id, question_id: question.id) }
scope :in, ->(year) { where(year: year) } scope :in, ->(year) { where(year:) }
def sync_attempts def sync_attempts
attempt_data = Attempt attempt_data = Attempt

@ -1,6 +1,6 @@
class AdminDataPresenter < DataItemPresenter class AdminDataPresenter < DataItemPresenter
def initialize(measure_id:, admin_data_items:) def initialize(measure_id:, admin_data_items:)
super(measure_id: measure_id, has_sufficient_data: false) super(measure_id:, has_sufficient_data: false)
@admin_data_items = admin_data_items @admin_data_items = admin_data_items
end end

@ -58,9 +58,9 @@ class CategoryPresenter
def subcategories(academic_year:, school:) def subcategories(academic_year:, school:)
@category.subcategories.includes([:measures]).sort_by(&:subcategory_id).map do |subcategory| @category.subcategories.includes([:measures]).sort_by(&:subcategory_id).map do |subcategory|
SubcategoryPresenter.new( SubcategoryPresenter.new(
subcategory: subcategory, subcategory:,
academic_year: academic_year, academic_year:,
school: school school:
) )
end end
end end

@ -31,9 +31,7 @@ class GaugePresenter
end end
end end
def score attr_reader :score
@score
end
private private

@ -1,6 +1,6 @@
class StudentSurveyPresenter < DataItemPresenter class StudentSurveyPresenter < DataItemPresenter
def initialize(measure_id:, survey_items:, has_sufficient_data:) def initialize(measure_id:, survey_items:, has_sufficient_data:)
super(measure_id: measure_id, has_sufficient_data: has_sufficient_data) super(measure_id:, has_sufficient_data:)
@survey_items = survey_items @survey_items = survey_items
end end

@ -37,6 +37,7 @@ class SubcategoryPresenter
def teacher_response_rate def teacher_response_rate
return 'N / A' if Respondent.where(school: @school, academic_year: @academic_year).count.zero? return 'N / A' if Respondent.where(school: @school, academic_year: @academic_year).count.zero?
"#{@subcategory.teacher_response_rate(school: @school, academic_year: @academic_year).rate}%" "#{@subcategory.teacher_response_rate(school: @school, academic_year: @academic_year).rate}%"
end end

@ -1,6 +1,6 @@
class TeacherSurveyPresenter < DataItemPresenter class TeacherSurveyPresenter < DataItemPresenter
def initialize(measure_id:, survey_items:, has_sufficient_data:) def initialize(measure_id:, survey_items:, has_sufficient_data:)
super(measure_id: measure_id, has_sufficient_data: has_sufficient_data) super(measure_id:, has_sufficient_data:)
@survey_items = survey_items @survey_items = survey_items
end end

@ -11,7 +11,7 @@ class SurveyResponsesDataLoader
survey_items = SurveyItem.where(survey_item_id: survey_item_ids) survey_items = SurveyItem.where(survey_item_id: survey_item_ids)
file.lazy.each_slice(1000) do |lines| file.lazy.each_slice(1000) do |lines|
survey_item_responses = CSV.parse(lines.join, headers: headers).map do |row| survey_item_responses = CSV.parse(lines.join, headers:).map do |row|
process_row row: row, survey_items: survey_items process_row row: row, survey_items: survey_items
end end
@ -36,18 +36,18 @@ class SurveyResponsesDataLoader
return if school.nil? return if school.nil?
survey_items.map do |survey_item| survey_items.map do |survey_item|
next if SurveyItemResponse.where(response_id: response_id, survey_item: survey_item).exists? next if SurveyItemResponse.where(response_id:, survey_item:).exists?
likert_score = row[survey_item.survey_item_id] likert_score = row[survey_item.survey_item_id]
next if likert_score.nil? next if likert_score.nil?
next unless likert_score.valid_likert_score? next unless likert_score.valid_likert_score?
SurveyItemResponse.new( SurveyItemResponse.new(
response_id: response_id, response_id:,
academic_year: academic_year, academic_year:,
school: school, school:,
survey_item: survey_item, survey_item:,
likert_score: likert_score likert_score:
) )
end.compact end.compact
end end

@ -4,7 +4,7 @@ Rails.application.configure do
Bullet.alert = false Bullet.alert = false
Bullet.bullet_logger = true Bullet.bullet_logger = true
Bullet.console = true Bullet.console = true
# Bullet.growl = true # Bullet.growl = true
Bullet.rails_logger = true Bullet.rails_logger = true
Bullet.add_footer = true Bullet.add_footer = true
end end

@ -9,4 +9,4 @@ Rails.application.config.assets.version = '1.0'
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets # application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added. # folder are already added.
Rails.application.config.assets.precompile += %w( application.css sqm.css welcome.css) Rails.application.config.assets.precompile += %w[application.css sqm.css welcome.css]

@ -39,7 +39,7 @@ namespace :data do
task load_survey_responses: :environment do task load_survey_responses: :environment do
Dir.glob(Rails.root.join('data', 'survey_responses', '*.csv')).each do |filepath| Dir.glob(Rails.root.join('data', 'survey_responses', '*.csv')).each do |filepath|
puts "=====================> Loading data from csv at path: #{filepath}" puts "=====================> Loading data from csv at path: #{filepath}"
SurveyResponsesDataLoader.load_data filepath: filepath SurveyResponsesDataLoader.load_data filepath:
end end
puts "=====================> Completed loading #{SurveyItemResponse.count} survey responses" puts "=====================> Completed loading #{SurveyItemResponse.count} survey responses"
end end
@ -192,13 +192,13 @@ namespace :data do
category = nil category = nil
question['category'].split('-').each do |external_id| question['category'].split('-').each do |external_id|
categories = category.present? ? category.child_categories : Category categories = category.present? ? category.child_categories : Category
category = categories.where(external_id: external_id).first category = categories.where(external_id:).first
next unless category.nil? next unless category.nil?
puts 'NOTHING' puts 'NOTHING'
puts external_id puts external_id
puts categories.inspect puts categories.inspect
category = categories.create(name: question['Category Name'], external_id: external_id) category = categories.create(name: question['Category Name'], external_id:)
end end
question_text = question['text'].gsub(/[[:space:]]/, ' ').strip question_text = question['text'].gsub(/[[:space:]]/, ' ').strip
if question_text.index('.* teacher').nil? if question_text.index('.* teacher').nil?
@ -245,7 +245,7 @@ namespace :data do
question['Category19'].split('-').each do |external_id_raw| question['Category19'].split('-').each do |external_id_raw|
external_id = external_id_raw.gsub(/[[:space:]]/, ' ').strip external_id = external_id_raw.gsub(/[[:space:]]/, ' ').strip
categories = category.present? ? category.child_categories : Category categories = category.present? ? category.child_categories : Category
category = categories.where(external_id: external_id).first category = categories.where(external_id:).first
next unless category.nil? next unless category.nil?
puts 'NOTHING' puts 'NOTHING'
@ -253,7 +253,7 @@ namespace :data do
puts categories.map { |c| puts categories.map { |c|
"#{c.name} - |#{c.external_id}| == |#{external_id}|: - #{external_id == c.external_id}" "#{c.name} - |#{c.external_id}| == |#{external_id}|: - #{external_id == c.external_id}"
}.join(' ---- ') }.join(' ---- ')
category = categories.create(name: question['Category Name'], external_id: external_id) category = categories.create(name: question['Category Name'], external_id:)
end end
question_text = question['Question Text'].gsub(/[[:space:]]/, ' ').strip question_text = question['Question Text'].gsub(/[[:space:]]/, ' ').strip
if question_text.index('.* teacher').nil? if question_text.index('.* teacher').nil?
@ -402,7 +402,7 @@ namespace :data do
missing_questions[key] = true missing_questions[key] = true
next next
elsif question.unknown? elsif question.unknown?
question.update_attributes(target_group: target_group) question.update_attributes(target_group:)
end end
if value.to_i.blank? if value.to_i.blank?
@ -435,7 +435,7 @@ namespace :data do
Date.today Date.today
end end
begin begin
recipient.attempts.create(question: question, answer_index: answer_index, responded_at: responded_at) recipient.attempts.create(question:, answer_index:, responded_at:)
rescue Exception => e rescue Exception => e
puts "DATAERROR: INDEX: #{index} Attempt failed for #{recipient.inspect} -> QUESTION: #{question.inspect}, ANSWER_INDEX: #{answer_index}, RESPONDED_AT: #{responded_at}, ERROR: #{e}" puts "DATAERROR: INDEX: #{index} Attempt failed for #{recipient.inspect} -> QUESTION: #{question.inspect}, ANSWER_INDEX: #{answer_index}, RESPONDED_AT: #{responded_at}, ERROR: #{e}"
next next
@ -481,7 +481,7 @@ namespace :data do
errors << row errors << row
next next
elsif (benchmark = row['Benchmark']).present? elsif (benchmark = row['Benchmark']).present?
nonlikert_category.update(benchmark: benchmark) nonlikert_category.update(benchmark:)
end end
district = District.where(name: row['District'], state_id: 1).first district = District.where(name: row['District'], state_id: 1).first
@ -614,9 +614,9 @@ namespace :data do
available_responders = school.available_responders_for(question) available_responders = school.available_responders_for(question)
school_question = school_category.school_questions.new( school_question = school_category.school_questions.new(
school: school, school:,
question: question, question:,
school_category: school_category, school_category:,
year: school_category.year, year: school_category.year,
attempt_count: available_responders, attempt_count: available_responders,
response_count: attempt_data.response_count, response_count: attempt_data.response_count,
@ -638,7 +638,7 @@ namespace :data do
School.all.each do |school| School.all.each do |school|
Category.all.each do |category| Category.all.each do |category|
school_category = SchoolCategory.for(school, category).in(@year).first school_category = SchoolCategory.for(school, category).in(@year).first
school_category = school.school_categories.create(category: category, year: @year) if school_category.nil? school_category = school.school_categories.create(category:, year: @year) if school_category.nil?
school_category.sync_aggregated_responses school_category.sync_aggregated_responses
end end
end end

@ -16,38 +16,38 @@ module Legacy
end end
let(:schedule) do let(:schedule) do
Schedule.create(name: 'Test Schedule', question_list: question_list, recipient_list: recipient_list) Schedule.create(name: 'Test Schedule', question_list:, recipient_list:)
end end
let(:school) { Legacy::School.create!(name: 'School') } let(:school) { Legacy::School.create!(name: 'School') }
let(:recipient_schedule) do let(:recipient_schedule) do
RecipientSchedule.create(recipient: recipients.first, schedule: schedule, next_attempt_at: Time.now) RecipientSchedule.create(recipient: recipients.first, schedule:, next_attempt_at: Time.now)
end end
let(:recipient_schedule2) do let(:recipient_schedule2) do
RecipientSchedule.create(recipient: recipients.last, schedule: schedule, next_attempt_at: Time.now) RecipientSchedule.create(recipient: recipients.last, schedule:, next_attempt_at: Time.now)
end end
let!(:first_attempt) do let!(:first_attempt) do
Attempt.create( Attempt.create(
schedule: schedule, schedule:,
recipient: recipients.first, recipient: recipients.first,
recipient_schedule: recipient_schedule, recipient_schedule:,
question: questions.first, question: questions.first,
sent_at: Time.new sent_at: Time.new
) )
end end
let!(:attempt) do let!(:attempt) do
Attempt.create( Attempt.create(
schedule: schedule, schedule:,
recipient: recipients.first, recipient: recipients.first,
recipient_schedule: recipient_schedule, recipient_schedule:,
question: questions.first, question: questions.first,
sent_at: Time.new sent_at: Time.new
) )
end end
let!(:attempt2) do let!(:attempt2) do
Attempt.create( Attempt.create(
schedule: schedule, schedule:,
recipient: recipients.last, recipient: recipients.last,
recipient_schedule: recipient_schedule2, recipient_schedule: recipient_schedule2,
question: questions.first, question: questions.first,

@ -45,7 +45,7 @@ module Legacy
let(:valid_session) { {} } let(:valid_session) { {} }
before :each do before :each do
user.user_schools.create(school: school) user.user_schools.create(school:)
sign_in user sign_in user
end end

@ -42,7 +42,7 @@ module Legacy
let(:valid_session) { {} } let(:valid_session) { {} }
before :each do before :each do
user.user_schools.create(school: school) user.user_schools.create(school:)
sign_in user sign_in user
end end

@ -57,7 +57,7 @@ module Legacy
let(:valid_session) { {} } let(:valid_session) { {} }
before :each do before :each do
user.user_schools.create(school: school) user.user_schools.create(school:)
sign_in user sign_in user
end end

@ -21,15 +21,15 @@ require 'rails_helper'
module Legacy module Legacy
RSpec.describe SchoolsController, type: :controller do RSpec.describe SchoolsController, type: :controller do
let(:district) { District.create! name: 'District' } let(:district) { District.create! name: 'District' }
let!(:school) { School.create! name: 'school', district: district } let!(:school) { School.create! name: 'school', district: }
let!(:user) { User.create(email: 'test@example.com', password: '123456') } let!(:user) { User.create(email: 'test@example.com', password: '123456') }
let!(:user_school) { user.user_schools.create(school: school) } let!(:user_school) { user.user_schools.create(school:) }
# This should return the minimal set of attributes required to create a valid # This should return the minimal set of attributes required to create a valid
# School. As you add validations to School, be sure to # School. As you add validations to School, be sure to
# adjust the attributes here as well. # adjust the attributes here as well.
let(:valid_attributes) do let(:valid_attributes) do
{ name: 'School', district: district } { name: 'School', district: }
end end
let(:invalid_attributes) do let(:invalid_attributes) do

@ -17,7 +17,7 @@ module Legacy
let(:ready_recipient_schedule) { double('ready recipient schedule', attempt_question: nil) } let(:ready_recipient_schedule) { double('ready recipient schedule', attempt_question: nil) }
let(:recipient_schedules) { double('recipient schedules', ready: [ready_recipient_schedule]) } let(:recipient_schedules) { double('recipient schedules', ready: [ready_recipient_schedule]) }
let(:active_schedule) { double('active schedule', recipient_schedules: recipient_schedules) } let(:active_schedule) { double('active schedule', recipient_schedules:) }
it 'finds all active schedules' do it 'finds all active schedules' do
date = ActiveSupport::TimeZone['UTC'].parse(now.strftime('%Y-%m-%dT20:00:00%z')) date = ActiveSupport::TimeZone['UTC'].parse(now.strftime('%Y-%m-%dT20:00:00%z'))
@ -64,7 +64,7 @@ module Legacy
Schedule.create!( Schedule.create!(
name: 'Parent Schedule', name: 'Parent Schedule',
recipient_list_id: recipient_list.id, recipient_list_id: recipient_list.id,
question_list: question_list, question_list:,
frequency_hours: 24 * 7, frequency_hours: 24 * 7,
start_date: Time.new, start_date: Time.new,
end_date: 1.year.from_now, end_date: 1.year.from_now,

@ -16,13 +16,13 @@ module Legacy
end end
let(:schedule) do let(:schedule) do
Schedule.create!(name: 'Parent Schedule', recipient_list_id: recipient_list.id, question_list: question_list) Schedule.create!(name: 'Parent Schedule', recipient_list_id: recipient_list.id, question_list:)
end end
let(:recipient_schedule) do let(:recipient_schedule) do
RecipientSchedule.create!( RecipientSchedule.create!(
recipient: recipient, recipient:,
schedule: schedule, schedule:,
upcoming_question_ids: "#{question.id},3", upcoming_question_ids: "#{question.id},3",
attempted_question_ids: '2', attempted_question_ids: '2',
last_attempt_at: 2.weeks.ago, last_attempt_at: 2.weeks.ago,
@ -32,9 +32,9 @@ module Legacy
let!(:attempt) do let!(:attempt) do
recipient.attempts.create( recipient.attempts.create(
schedule: schedule, schedule:,
recipient_schedule: recipient_schedule, recipient_schedule:,
question: question question:
) )
end end

@ -31,7 +31,7 @@ module Legacy
Schedule.create!( Schedule.create!(
name: 'Parent Schedule', name: 'Parent Schedule',
recipient_list_id: recipient_list.id, recipient_list_id: recipient_list.id,
question_list: question_list, question_list:,
random: false, random: false,
frequency_hours: 24 * 7 frequency_hours: 24 * 7
) )

@ -19,7 +19,7 @@ module Legacy
Schedule.create!( Schedule.create!(
name: 'Parent Schedule', name: 'Parent Schedule',
recipient_list_id: recipient_list.id, recipient_list_id: recipient_list.id,
question_list: question_list, question_list:,
random: false, random: false,
frequency_hours: 24 frequency_hours: 24
) )
@ -28,8 +28,8 @@ module Legacy
let!(:not_ready_recipient_schedule) do let!(:not_ready_recipient_schedule) do
RecipientSchedule.create!( RecipientSchedule.create!(
recipient: recipient, recipient:,
schedule: schedule, schedule:,
upcoming_question_ids: '1,3', upcoming_question_ids: '1,3',
attempted_question_ids: '2', attempted_question_ids: '2',
last_attempt_at: Date.today + (60 * 60 * schedule.frequency_hours), last_attempt_at: Date.today + (60 * 60 * schedule.frequency_hours),

@ -33,7 +33,7 @@ module Legacy
Schedule.create!( Schedule.create!(
name: 'Parent Schedule', name: 'Parent Schedule',
recipient_list_id: recipient_list.id, recipient_list_id: recipient_list.id,
question_list: question_list, question_list:,
random: false, random: false,
frequency_hours: 24 * 7 frequency_hours: 24 * 7
) )

@ -21,9 +21,9 @@ module Legacy
let(:default_schedule_params) do let(:default_schedule_params) do
{ {
school: school, school:,
recipient_list: recipient_list, recipient_list:,
question_list: question_list, question_list:,
name: 'Parents Schedule', name: 'Parents Schedule',
description: 'Schedule for parent questions', description: 'Schedule for parent questions',
start_date: 1.month.ago, start_date: 1.month.ago,

@ -6,33 +6,33 @@ describe CategoryPresenter do
subcategory2 = Subcategory.create(name: 'Another subcategory', subcategory_id: '2') subcategory2 = Subcategory.create(name: 'Another subcategory', subcategory_id: '2')
category = Category.create(name: 'Some Category', subcategories: [subcategory1, subcategory2], category = Category.create(name: 'Some Category', subcategories: [subcategory1, subcategory2],
description: 'A description for some Category', short_description: 'A short description for some Category', category_id: '1') description: 'A description for some Category', short_description: 'A short description for some Category', category_id: '1')
return CategoryPresenter.new(category: category) return CategoryPresenter.new(category:)
end end
let(:teachers_and_leadership_presenter) do let(:teachers_and_leadership_presenter) do
category = create(:category, name: 'Teachers & Leadership') category = create(:category, name: 'Teachers & Leadership')
return CategoryPresenter.new(category: category) return CategoryPresenter.new(category:)
end end
let(:school_culture_presenter) do let(:school_culture_presenter) do
category = create(:category, name: 'School Culture') category = create(:category, name: 'School Culture')
return CategoryPresenter.new(category: category) return CategoryPresenter.new(category:)
end end
let(:resources_presenter) do let(:resources_presenter) do
category = create(:category, name: 'Resources') category = create(:category, name: 'Resources')
return CategoryPresenter.new(category: category) return CategoryPresenter.new(category:)
end end
let(:academic_learning_presenter) do let(:academic_learning_presenter) do
category = create(:category, name: 'Academic Learning') category = create(:category, name: 'Academic Learning')
return CategoryPresenter.new(category: category) return CategoryPresenter.new(category:)
end end
let(:community_and_wellbeing_presenter) do let(:community_and_wellbeing_presenter) do
category = create(:category, name: 'Community & Wellbeing') category = create(:category, name: 'Community & Wellbeing')
return CategoryPresenter.new(category: category) return CategoryPresenter.new(category:)
end end
after :each do after :each do

@ -11,7 +11,7 @@ describe GaugePresenter do
end end
let(:score) { 3 } let(:score) { 3 }
let(:gauge_presenter) { GaugePresenter.new(zones: zones, score: score) } let(:gauge_presenter) { GaugePresenter.new(zones:, score:) }
it 'returns the key benchmark percentage for the gauge' do it 'returns the key benchmark percentage for the gauge' do
expect(gauge_presenter.key_benchmark_percentage).to eq 0.625 expect(gauge_presenter.key_benchmark_percentage).to eq 0.625

@ -10,7 +10,7 @@ describe SubcategoryCardPresenter do
) )
end end
let(:subcategory_card_presenter) { SubcategoryCardPresenter.new(name: 'Card name', zones: zones, score: score) } let(:subcategory_card_presenter) { SubcategoryCardPresenter.new(name: 'Card name', zones:, score:) }
context 'when the given score is in the Warning zone for the given scale' do context 'when the given score is in the Warning zone for the given scale' do
let(:score) { 1 } let(:score) { 1 }

@ -68,11 +68,11 @@ describe SubcategoryPresenter do
end end
it 'returns the student response rate' do it 'returns the student response rate' do
expect(subcategory_presenter.student_response_rate).to eq "25%" expect(subcategory_presenter.student_response_rate).to eq '25%'
end end
it 'returns the teacher response rate' do it 'returns the teacher response rate' do
expect(subcategory_presenter.teacher_response_rate).to eq "50%" expect(subcategory_presenter.teacher_response_rate).to eq '50%'
end end
it 'returns the admin collection rate' do it 'returns the admin collection rate' do

@ -1,14 +1,14 @@
require 'simplecov' require 'simplecov'
SimpleCov.start do SimpleCov.start do
add_filter "/app/models/legacy" add_filter '/app/models/legacy'
add_filter "/app/views/legacy" add_filter '/app/views/legacy'
add_filter "/app/controllers/legacy" add_filter '/app/controllers/legacy'
add_filter "/spec/models/legacy" add_filter '/spec/models/legacy'
add_filter "/spec/views/legacy" add_filter '/spec/views/legacy'
add_filter "/spec/controllers/legacy" add_filter '/spec/controllers/legacy'
add_filter "/app/helpers/schedules_helper.rb" add_filter '/app/helpers/schedules_helper.rb'
add_filter "/lib/tasks/survey.rake" add_filter '/lib/tasks/survey.rake'
add_filter "/spec/lib/tasks/survey_rake_spec.rb" add_filter '/spec/lib/tasks/survey_rake_spec.rb'
end end
require 'capybara/rspec' require 'capybara/rspec'
@ -184,7 +184,7 @@ def create_questions(count, category = nil)
option3: "Option #{i}:#{count} C", option3: "Option #{i}:#{count} C",
option4: "Option #{i}:#{count} D", option4: "Option #{i}:#{count} D",
option5: "Option #{i}:#{count} E", option5: "Option #{i}:#{count} E",
category: category category:
) )
end end
questions questions

@ -2,7 +2,7 @@ require 'rails_helper'
describe 'authentication' do describe 'authentication' do
let(:district) { create(:district) } let(:district) { create(:district) }
let(:school) { create(:school, district: district) } let(:school) { create(:school, district:) }
let(:academic_year) { create(:academic_year) } let(:academic_year) { create(:academic_year) }
context 'when using the wrong credentials' do context 'when using the wrong credentials' do

@ -2,11 +2,11 @@ require 'rails_helper'
describe 'SQM Application' do describe 'SQM Application' do
let(:district) { create(:district) } let(:district) { create(:district) }
let(:school) { create(:school, district: district) } let(:school) { create(:school, district:) }
let(:academic_year) { create(:academic_year) } let(:academic_year) { create(:academic_year) }
let(:category) { create(:category) } let(:category) { create(:category) }
let(:measure) { create(:measure) } let(:measure) { create(:measure) }
let(:scale) {create(:scale, measure:)} let(:scale) { create(:scale, measure:) }
before :each do before :each do
driven_by :rack_test driven_by :rack_test
@ -30,7 +30,7 @@ describe 'SQM Application' do
before :each do before :each do
teacher_survey_item = create(:teacher_survey_item, scale:) teacher_survey_item = create(:teacher_survey_item, scale:)
create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD, create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD,
survey_item: teacher_survey_item, academic_year: academic_year, school: school) survey_item: teacher_survey_item, academic_year:, school:)
end end
it 'does not show a modal on any page' do it 'does not show a modal on any page' do

@ -6,7 +6,7 @@ module Legacy
@school = assign(:school, School.create!(name: 'School')) @school = assign(:school, School.create!(name: 'School'))
recipients = ['Jared Cosulich', 'Lauren Cosulich'].collect do |name| recipients = ['Jared Cosulich', 'Lauren Cosulich'].collect do |name|
@school.recipients.create!(name: name) @school.recipients.create!(name:)
end end
@recipient_list = assign(:recipient_list, RecipientList.create!( @recipient_list = assign(:recipient_list, RecipientList.create!(

Loading…
Cancel
Save