From ed7a3b8a3d48d59d2aed04d84e60cd9a27e77292 Mon Sep 17 00:00:00 2001 From: Nelson Jovel Date: Fri, 4 Mar 2022 15:29:54 +0100 Subject: [PATCH] Autoformat code with rubocop --- app/controllers/categories_controller.rb | 2 +- app/controllers/home_controller.rb | 2 +- app/controllers/overview_controller.rb | 4 ++-- app/helpers/gauge_helper.rb | 10 ++++---- app/helpers/header_helper.rb | 2 +- app/models/academic_year.rb | 1 - app/models/category.rb | 2 +- app/models/legacy/attempt.rb | 6 ++--- app/models/legacy/question.rb | 2 +- app/models/legacy/question_list.rb | 2 +- app/models/legacy/recipient.rb | 2 +- app/models/legacy/recipient_list.rb | 2 +- app/models/legacy/recipient_schedule.rb | 16 ++++++------- app/models/legacy/school_question.rb | 2 +- app/presenters/admin_data_presenter.rb | 2 +- app/presenters/category_presenter.rb | 6 ++--- app/presenters/gauge_presenter.rb | 4 +--- app/presenters/student_survey_presenter.rb | 2 +- app/presenters/subcategory_presenter.rb | 1 + app/presenters/teacher_survey_presenter.rb | 2 +- app/services/survey_responses_data_loader.rb | 14 +++++------ config/environments/development.rb | 2 +- config/initializers/assets.rb | 2 +- lib/tasks/data.rake | 24 +++++++++---------- .../legacy/attempts_controller_spec.rb | 16 ++++++------- .../legacy/recipient_lists_controller_spec.rb | 2 +- .../legacy/recipients_controller_spec.rb | 2 +- .../legacy/schedules_controller_spec.rb | 2 +- .../legacy/schools_controller_spec.rb | 6 ++--- spec/lib/tasks/survey_rake_spec.rb | 4 ++-- spec/models/legacy/attempt_spec.rb | 12 +++++----- spec/models/legacy/recipient_list_spec.rb | 2 +- spec/models/legacy/recipient_schedule_spec.rb | 6 ++--- spec/models/legacy/recipient_spec.rb | 2 +- spec/models/legacy/schedule_spec.rb | 6 ++--- spec/presenters/category_presenter_spec.rb | 14 +++++------ spec/presenters/gauge_presenter_spec.rb | 2 +- .../subcategory_card_presenter_spec.rb | 2 +- spec/presenters/subcategory_presenter_spec.rb | 4 ++-- spec/spec_helper.rb | 20 ++++++++-------- spec/system/authentication_spec.rb | 2 +- spec/system/sqm_application_spec.rb | 6 ++--- .../recipient_lists/show.html.erb_spec.rb | 2 +- 43 files changed, 112 insertions(+), 114 deletions(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 0f47bbfb..8ba4ebd3 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -1,6 +1,6 @@ class CategoriesController < SqmApplicationController 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])) end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 7460eb4d..744ec810 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -3,6 +3,6 @@ class HomeController < ApplicationController @districts = District.all.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 diff --git a/app/controllers/overview_controller.rb b/app/controllers/overview_controller.rb index c70a5d3a..5e7ed6e7 100644 --- a/app/controllers/overview_controller.rb +++ b/app/controllers/overview_controller.rb @@ -1,7 +1,7 @@ class OverviewController < SqmApplicationController def index @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 private @@ -9,6 +9,6 @@ class OverviewController < SqmApplicationController def presenter_for_measure(measure) score = measure.score(school: @school, academic_year: @academic_year) - VarianceChartRowPresenter.new(measure: measure, score: score) + VarianceChartRowPresenter.new(measure:, score:) end end diff --git a/app/helpers/gauge_helper.rb b/app/helpers/gauge_helper.rb index bfd03b7e..0244d95d 100644 --- a/app/helpers/gauge_helper.rb +++ b/app/helpers/gauge_helper.rb @@ -39,7 +39,7 @@ module GaugeHelper end def arc_end_point_for(radius:, percentage:) - angle = angle_for(percentage: percentage) + angle = angle_for(percentage:) x = arc_center.x + radius * Math.cos(angle) y = arc_center.y + radius * Math.sin(angle) @@ -47,8 +47,8 @@ module GaugeHelper end def arc_end_line_destination(radius:, percentage:) - x = arc_center.x + radius * Math.cos(angle_for(percentage: percentage)) - y = arc_center.y + radius * Math.sin(angle_for(percentage: percentage)) + x = arc_center.x + radius * Math.cos(angle_for(percentage:)) + y = arc_center.y + radius * Math.sin(angle_for(percentage:)) Point.new(x, y) end @@ -62,8 +62,8 @@ module GaugeHelper def draw_arc(radius:, percentage:, clockwise:) sweep_flag = clockwise ? 1 : 0 - "A #{arc_radius(radius)} 0 0 #{sweep_flag} #{coordinates_for(arc_end_point_for(radius: radius, - percentage: percentage))}" + "A #{arc_radius(radius)} 0 0 #{sweep_flag} #{coordinates_for(arc_end_point_for(radius:, + percentage:))}" end def draw_line_to(point:) diff --git a/app/helpers/header_helper.rb b/app/helpers/header_helper.rb index 391c4b67..e29fe908 100644 --- a/app/helpers/header_helper.rb +++ b/app/helpers/header_helper.rb @@ -26,7 +26,7 @@ module HeaderHelper end def link_weight(path:) - active?(path: path) ? 'weight-700' : 'weight-400' + active?(path:) ? 'weight-700' : 'weight-400' end private diff --git a/app/models/academic_year.rb b/app/models/academic_year.rb index 08ddd2da..1f0224ae 100644 --- a/app/models/academic_year.rb +++ b/app/models/academic_year.rb @@ -14,5 +14,4 @@ class AcademicYear < ActiveRecord::Base years = range.split('-') "#{years.first} – 20#{years.second}" end - end diff --git a/app/models/category.rb b/app/models/category.rb index 48b7ef53..3b3d34b6 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -2,7 +2,7 @@ class Category < ActiveRecord::Base include FriendlyId friendly_id :name, use: [:slugged] - scope :sorted, -> { order(:sort_index)} + scope :sorted, -> { order(:sort_index) } has_many :subcategories has_many :measures, through: :subcategories diff --git a/app/models/legacy/attempt.rb b/app/models/legacy/attempt.rb index 5371fb0a..6e9c3681 100644 --- a/app/models/legacy/attempt.rb +++ b/app/models/legacy/attempt.rb @@ -58,9 +58,9 @@ module Legacy def save_response(answer_index: nil, twilio_details: nil, responded_at: Time.new) update( - answer_index: answer_index, - twilio_details: twilio_details, - responded_at: responded_at + answer_index:, + twilio_details:, + responded_at: ) recipient_schedule.update(next_attempt_at: Time.new) if recipient_schedule.queued_question_ids.present? diff --git a/app/models/legacy/question.rb b/app/models/legacy/question.rb index 7916d0ad..a1a39ca7 100644 --- a/app/models/legacy/question.rb +++ b/app/models/legacy/question.rb @@ -22,7 +22,7 @@ module Legacy validates :option4, 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) } enum target_group: %i[unknown for_students for_teachers for_parents] diff --git a/app/models/legacy/question_list.rb b/app/models/legacy/question_list.rb index 6a2582ec..771b6720 100644 --- a/app/models/legacy/question_list.rb +++ b/app/models/legacy/question_list.rb @@ -9,7 +9,7 @@ module Legacy after_initialize :set_question_id_array def questions - question_id_array.collect { |id| Question.where(id: id).first }.compact + question_id_array.collect { |id| Question.where(id:).first }.compact end private diff --git a/app/models/legacy/recipient.rb b/app/models/legacy/recipient.rb index 0ad1854e..09144f4e 100644 --- a/app/models/legacy/recipient.rb +++ b/app/models/legacy/recipient.rb @@ -12,7 +12,7 @@ module Legacy 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) } before_destroy :sync_lists diff --git a/app/models/legacy/recipient_list.rb b/app/models/legacy/recipient_list.rb index fca266c7..8b1048d2 100644 --- a/app/models/legacy/recipient_list.rb +++ b/app/models/legacy/recipient_list.rb @@ -14,7 +14,7 @@ module Legacy after_save :sync_recipient_schedules def recipients - recipient_id_array.collect { |id| school.recipients.where(id: id).first } + recipient_id_array.collect { |id| school.recipients.where(id:).first } end private diff --git a/app/models/legacy/recipient_schedule.rb b/app/models/legacy/recipient_schedule.rb index df823d4b..32d8e030 100644 --- a/app/models/legacy/recipient_schedule.rb +++ b/app/models/legacy/recipient_schedule.rb @@ -51,7 +51,7 @@ module Legacy return if recipient.opted_out? 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 = [] recipient_attempts = attempts.for_recipient(recipient).for_question(question) @@ -60,9 +60,9 @@ module Legacy end attempt = recipient.attempts.create( - schedule: schedule, + schedule:, recipient_schedule: self, - question: question, + question:, student: missing_students.first ) @@ -101,12 +101,12 @@ module Legacy return if question.nil? && 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( - schedule: schedule, + schedule:, recipient_schedule: self, - question: question + question: ) end @@ -159,9 +159,9 @@ module Legacy end schedule.recipient_schedules.create( - recipient_id: recipient_id, + recipient_id:, upcoming_question_ids: question_ids.join(','), - next_attempt_at: next_attempt_at + next_attempt_at: ) end end diff --git a/app/models/legacy/school_question.rb b/app/models/legacy/school_question.rb index cecd18bd..bed96ea6 100644 --- a/app/models/legacy/school_question.rb +++ b/app/models/legacy/school_question.rb @@ -9,7 +9,7 @@ module Legacy validates_associated :school_category 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 attempt_data = Attempt diff --git a/app/presenters/admin_data_presenter.rb b/app/presenters/admin_data_presenter.rb index add6dacf..9434ab96 100644 --- a/app/presenters/admin_data_presenter.rb +++ b/app/presenters/admin_data_presenter.rb @@ -1,6 +1,6 @@ class AdminDataPresenter < DataItemPresenter 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 end diff --git a/app/presenters/category_presenter.rb b/app/presenters/category_presenter.rb index db6190aa..a9daee48 100644 --- a/app/presenters/category_presenter.rb +++ b/app/presenters/category_presenter.rb @@ -58,9 +58,9 @@ class CategoryPresenter def subcategories(academic_year:, school:) @category.subcategories.includes([:measures]).sort_by(&:subcategory_id).map do |subcategory| SubcategoryPresenter.new( - subcategory: subcategory, - academic_year: academic_year, - school: school + subcategory:, + academic_year:, + school: ) end end diff --git a/app/presenters/gauge_presenter.rb b/app/presenters/gauge_presenter.rb index e0bda7bc..5e81e683 100644 --- a/app/presenters/gauge_presenter.rb +++ b/app/presenters/gauge_presenter.rb @@ -31,9 +31,7 @@ class GaugePresenter end end - def score - @score - end + attr_reader :score private diff --git a/app/presenters/student_survey_presenter.rb b/app/presenters/student_survey_presenter.rb index 66426467..fc00806f 100644 --- a/app/presenters/student_survey_presenter.rb +++ b/app/presenters/student_survey_presenter.rb @@ -1,6 +1,6 @@ class StudentSurveyPresenter < DataItemPresenter 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 end diff --git a/app/presenters/subcategory_presenter.rb b/app/presenters/subcategory_presenter.rb index c978c38d..40e9631f 100644 --- a/app/presenters/subcategory_presenter.rb +++ b/app/presenters/subcategory_presenter.rb @@ -37,6 +37,7 @@ class SubcategoryPresenter def teacher_response_rate 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}%" end diff --git a/app/presenters/teacher_survey_presenter.rb b/app/presenters/teacher_survey_presenter.rb index 73bb49bf..ef46afaa 100644 --- a/app/presenters/teacher_survey_presenter.rb +++ b/app/presenters/teacher_survey_presenter.rb @@ -1,6 +1,6 @@ class TeacherSurveyPresenter < DataItemPresenter 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 end diff --git a/app/services/survey_responses_data_loader.rb b/app/services/survey_responses_data_loader.rb index d913303c..9eadd8f0 100644 --- a/app/services/survey_responses_data_loader.rb +++ b/app/services/survey_responses_data_loader.rb @@ -11,7 +11,7 @@ class SurveyResponsesDataLoader survey_items = SurveyItem.where(survey_item_id: survey_item_ids) 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 end @@ -36,18 +36,18 @@ class SurveyResponsesDataLoader return if school.nil? 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] next if likert_score.nil? next unless likert_score.valid_likert_score? SurveyItemResponse.new( - response_id: response_id, - academic_year: academic_year, - school: school, - survey_item: survey_item, - likert_score: likert_score + response_id:, + academic_year:, + school:, + survey_item:, + likert_score: ) end.compact end diff --git a/config/environments/development.rb b/config/environments/development.rb index dff2e70f..596af92c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -4,7 +4,7 @@ Rails.application.configure do Bullet.alert = false Bullet.bullet_logger = true Bullet.console = true - # Bullet.growl = true + # Bullet.growl = true Bullet.rails_logger = true Bullet.add_footer = true end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 3458d355..8300667d 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -9,4 +9,4 @@ Rails.application.config.assets.version = '1.0' # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # 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] diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 5570772c..634ff9a8 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -39,7 +39,7 @@ namespace :data do task load_survey_responses: :environment do Dir.glob(Rails.root.join('data', 'survey_responses', '*.csv')).each do |filepath| puts "=====================> Loading data from csv at path: #{filepath}" - SurveyResponsesDataLoader.load_data filepath: filepath + SurveyResponsesDataLoader.load_data filepath: end puts "=====================> Completed loading #{SurveyItemResponse.count} survey responses" end @@ -192,13 +192,13 @@ namespace :data do category = nil question['category'].split('-').each do |external_id| 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? puts 'NOTHING' puts external_id puts categories.inspect - category = categories.create(name: question['Category Name'], external_id: external_id) + category = categories.create(name: question['Category Name'], external_id:) end question_text = question['text'].gsub(/[[:space:]]/, ' ').strip if question_text.index('.* teacher').nil? @@ -245,7 +245,7 @@ namespace :data do question['Category19'].split('-').each do |external_id_raw| external_id = external_id_raw.gsub(/[[:space:]]/, ' ').strip 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? puts 'NOTHING' @@ -253,7 +253,7 @@ namespace :data do puts categories.map { |c| "#{c.name} - |#{c.external_id}| == |#{external_id}|: - #{external_id == c.external_id}" }.join(' ---- ') - category = categories.create(name: question['Category Name'], external_id: external_id) + category = categories.create(name: question['Category Name'], external_id:) end question_text = question['Question Text'].gsub(/[[:space:]]/, ' ').strip if question_text.index('.* teacher').nil? @@ -402,7 +402,7 @@ namespace :data do missing_questions[key] = true next elsif question.unknown? - question.update_attributes(target_group: target_group) + question.update_attributes(target_group:) end if value.to_i.blank? @@ -435,7 +435,7 @@ namespace :data do Date.today end 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 puts "DATAERROR: INDEX: #{index} Attempt failed for #{recipient.inspect} -> QUESTION: #{question.inspect}, ANSWER_INDEX: #{answer_index}, RESPONDED_AT: #{responded_at}, ERROR: #{e}" next @@ -481,7 +481,7 @@ namespace :data do errors << row next elsif (benchmark = row['Benchmark']).present? - nonlikert_category.update(benchmark: benchmark) + nonlikert_category.update(benchmark:) end district = District.where(name: row['District'], state_id: 1).first @@ -614,9 +614,9 @@ namespace :data do available_responders = school.available_responders_for(question) school_question = school_category.school_questions.new( - school: school, - question: question, - school_category: school_category, + school:, + question:, + school_category:, year: school_category.year, attempt_count: available_responders, response_count: attempt_data.response_count, @@ -638,7 +638,7 @@ namespace :data do School.all.each do |school| Category.all.each do |category| 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 end end diff --git a/spec/controllers/legacy/attempts_controller_spec.rb b/spec/controllers/legacy/attempts_controller_spec.rb index fa6597f8..6c81e913 100644 --- a/spec/controllers/legacy/attempts_controller_spec.rb +++ b/spec/controllers/legacy/attempts_controller_spec.rb @@ -16,38 +16,38 @@ module Legacy end 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 let(:school) { Legacy::School.create!(name: 'School') } 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 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 let!(:first_attempt) do Attempt.create( - schedule: schedule, + schedule:, recipient: recipients.first, - recipient_schedule: recipient_schedule, + recipient_schedule:, question: questions.first, sent_at: Time.new ) end let!(:attempt) do Attempt.create( - schedule: schedule, + schedule:, recipient: recipients.first, - recipient_schedule: recipient_schedule, + recipient_schedule:, question: questions.first, sent_at: Time.new ) end let!(:attempt2) do Attempt.create( - schedule: schedule, + schedule:, recipient: recipients.last, recipient_schedule: recipient_schedule2, question: questions.first, diff --git a/spec/controllers/legacy/recipient_lists_controller_spec.rb b/spec/controllers/legacy/recipient_lists_controller_spec.rb index f6161704..feb201ab 100644 --- a/spec/controllers/legacy/recipient_lists_controller_spec.rb +++ b/spec/controllers/legacy/recipient_lists_controller_spec.rb @@ -45,7 +45,7 @@ module Legacy let(:valid_session) { {} } before :each do - user.user_schools.create(school: school) + user.user_schools.create(school:) sign_in user end diff --git a/spec/controllers/legacy/recipients_controller_spec.rb b/spec/controllers/legacy/recipients_controller_spec.rb index eeee8762..5127676b 100644 --- a/spec/controllers/legacy/recipients_controller_spec.rb +++ b/spec/controllers/legacy/recipients_controller_spec.rb @@ -42,7 +42,7 @@ module Legacy let(:valid_session) { {} } before :each do - user.user_schools.create(school: school) + user.user_schools.create(school:) sign_in user end diff --git a/spec/controllers/legacy/schedules_controller_spec.rb b/spec/controllers/legacy/schedules_controller_spec.rb index deba8ff1..46a74d26 100644 --- a/spec/controllers/legacy/schedules_controller_spec.rb +++ b/spec/controllers/legacy/schedules_controller_spec.rb @@ -57,7 +57,7 @@ module Legacy let(:valid_session) { {} } before :each do - user.user_schools.create(school: school) + user.user_schools.create(school:) sign_in user end diff --git a/spec/controllers/legacy/schools_controller_spec.rb b/spec/controllers/legacy/schools_controller_spec.rb index c078ac29..de0f21b8 100644 --- a/spec/controllers/legacy/schools_controller_spec.rb +++ b/spec/controllers/legacy/schools_controller_spec.rb @@ -21,15 +21,15 @@ require 'rails_helper' module Legacy RSpec.describe SchoolsController, type: :controller do 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_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 # School. As you add validations to School, be sure to # adjust the attributes here as well. let(:valid_attributes) do - { name: 'School', district: district } + { name: 'School', district: } end let(:invalid_attributes) do diff --git a/spec/lib/tasks/survey_rake_spec.rb b/spec/lib/tasks/survey_rake_spec.rb index d2fd67b5..7ec9249c 100644 --- a/spec/lib/tasks/survey_rake_spec.rb +++ b/spec/lib/tasks/survey_rake_spec.rb @@ -17,7 +17,7 @@ module Legacy let(:ready_recipient_schedule) { double('ready recipient schedule', attempt_question: nil) } 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 date = ActiveSupport::TimeZone['UTC'].parse(now.strftime('%Y-%m-%dT20:00:00%z')) @@ -64,7 +64,7 @@ module Legacy Schedule.create!( name: 'Parent Schedule', recipient_list_id: recipient_list.id, - question_list: question_list, + question_list:, frequency_hours: 24 * 7, start_date: Time.new, end_date: 1.year.from_now, diff --git a/spec/models/legacy/attempt_spec.rb b/spec/models/legacy/attempt_spec.rb index 49b6daab..9c9da2b9 100644 --- a/spec/models/legacy/attempt_spec.rb +++ b/spec/models/legacy/attempt_spec.rb @@ -16,13 +16,13 @@ module Legacy end 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 let(:recipient_schedule) do RecipientSchedule.create!( - recipient: recipient, - schedule: schedule, + recipient:, + schedule:, upcoming_question_ids: "#{question.id},3", attempted_question_ids: '2', last_attempt_at: 2.weeks.ago, @@ -32,9 +32,9 @@ module Legacy let!(:attempt) do recipient.attempts.create( - schedule: schedule, - recipient_schedule: recipient_schedule, - question: question + schedule:, + recipient_schedule:, + question: ) end diff --git a/spec/models/legacy/recipient_list_spec.rb b/spec/models/legacy/recipient_list_spec.rb index 1ef6e47c..7cdd7c71 100644 --- a/spec/models/legacy/recipient_list_spec.rb +++ b/spec/models/legacy/recipient_list_spec.rb @@ -31,7 +31,7 @@ module Legacy Schedule.create!( name: 'Parent Schedule', recipient_list_id: recipient_list.id, - question_list: question_list, + question_list:, random: false, frequency_hours: 24 * 7 ) diff --git a/spec/models/legacy/recipient_schedule_spec.rb b/spec/models/legacy/recipient_schedule_spec.rb index d2f7b2b7..d50a70d6 100644 --- a/spec/models/legacy/recipient_schedule_spec.rb +++ b/spec/models/legacy/recipient_schedule_spec.rb @@ -19,7 +19,7 @@ module Legacy Schedule.create!( name: 'Parent Schedule', recipient_list_id: recipient_list.id, - question_list: question_list, + question_list:, random: false, frequency_hours: 24 ) @@ -28,8 +28,8 @@ module Legacy let!(:not_ready_recipient_schedule) do RecipientSchedule.create!( - recipient: recipient, - schedule: schedule, + recipient:, + schedule:, upcoming_question_ids: '1,3', attempted_question_ids: '2', last_attempt_at: Date.today + (60 * 60 * schedule.frequency_hours), diff --git a/spec/models/legacy/recipient_spec.rb b/spec/models/legacy/recipient_spec.rb index 0b94eeec..2e6e843e 100644 --- a/spec/models/legacy/recipient_spec.rb +++ b/spec/models/legacy/recipient_spec.rb @@ -33,7 +33,7 @@ module Legacy Schedule.create!( name: 'Parent Schedule', recipient_list_id: recipient_list.id, - question_list: question_list, + question_list:, random: false, frequency_hours: 24 * 7 ) diff --git a/spec/models/legacy/schedule_spec.rb b/spec/models/legacy/schedule_spec.rb index dca34c87..b3e8e4cc 100644 --- a/spec/models/legacy/schedule_spec.rb +++ b/spec/models/legacy/schedule_spec.rb @@ -21,9 +21,9 @@ module Legacy let(:default_schedule_params) do { - school: school, - recipient_list: recipient_list, - question_list: question_list, + school:, + recipient_list:, + question_list:, name: 'Parents Schedule', description: 'Schedule for parent questions', start_date: 1.month.ago, diff --git a/spec/presenters/category_presenter_spec.rb b/spec/presenters/category_presenter_spec.rb index c8536b5b..6b7ffcc2 100644 --- a/spec/presenters/category_presenter_spec.rb +++ b/spec/presenters/category_presenter_spec.rb @@ -6,33 +6,33 @@ describe CategoryPresenter do subcategory2 = Subcategory.create(name: 'Another subcategory', subcategory_id: '2') 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') - return CategoryPresenter.new(category: category) + description: 'A description for some Category', short_description: 'A short description for some Category', category_id: '1') + return CategoryPresenter.new(category:) end let(:teachers_and_leadership_presenter) do category = create(:category, name: 'Teachers & Leadership') - return CategoryPresenter.new(category: category) + return CategoryPresenter.new(category:) end let(:school_culture_presenter) do category = create(:category, name: 'School Culture') - return CategoryPresenter.new(category: category) + return CategoryPresenter.new(category:) end let(:resources_presenter) do category = create(:category, name: 'Resources') - return CategoryPresenter.new(category: category) + return CategoryPresenter.new(category:) end let(:academic_learning_presenter) do category = create(:category, name: 'Academic Learning') - return CategoryPresenter.new(category: category) + return CategoryPresenter.new(category:) end let(:community_and_wellbeing_presenter) do category = create(:category, name: 'Community & Wellbeing') - return CategoryPresenter.new(category: category) + return CategoryPresenter.new(category:) end after :each do diff --git a/spec/presenters/gauge_presenter_spec.rb b/spec/presenters/gauge_presenter_spec.rb index 504ccfe1..7cf0e09e 100644 --- a/spec/presenters/gauge_presenter_spec.rb +++ b/spec/presenters/gauge_presenter_spec.rb @@ -11,7 +11,7 @@ describe GaugePresenter do end 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 expect(gauge_presenter.key_benchmark_percentage).to eq 0.625 diff --git a/spec/presenters/subcategory_card_presenter_spec.rb b/spec/presenters/subcategory_card_presenter_spec.rb index cdd5471c..93bd1df6 100644 --- a/spec/presenters/subcategory_card_presenter_spec.rb +++ b/spec/presenters/subcategory_card_presenter_spec.rb @@ -10,7 +10,7 @@ describe SubcategoryCardPresenter do ) 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 let(:score) { 1 } diff --git a/spec/presenters/subcategory_presenter_spec.rb b/spec/presenters/subcategory_presenter_spec.rb index 79878c19..d3ccecf2 100644 --- a/spec/presenters/subcategory_presenter_spec.rb +++ b/spec/presenters/subcategory_presenter_spec.rb @@ -68,11 +68,11 @@ describe SubcategoryPresenter do end 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 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 it 'returns the admin collection rate' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6ad07a30..d251ac84 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,14 @@ require 'simplecov' SimpleCov.start do - add_filter "/app/models/legacy" - add_filter "/app/views/legacy" - add_filter "/app/controllers/legacy" - add_filter "/spec/models/legacy" - add_filter "/spec/views/legacy" - add_filter "/spec/controllers/legacy" - add_filter "/app/helpers/schedules_helper.rb" - add_filter "/lib/tasks/survey.rake" - add_filter "/spec/lib/tasks/survey_rake_spec.rb" + add_filter '/app/models/legacy' + add_filter '/app/views/legacy' + add_filter '/app/controllers/legacy' + add_filter '/spec/models/legacy' + add_filter '/spec/views/legacy' + add_filter '/spec/controllers/legacy' + add_filter '/app/helpers/schedules_helper.rb' + add_filter '/lib/tasks/survey.rake' + add_filter '/spec/lib/tasks/survey_rake_spec.rb' end require 'capybara/rspec' @@ -184,7 +184,7 @@ def create_questions(count, category = nil) option3: "Option #{i}:#{count} C", option4: "Option #{i}:#{count} D", option5: "Option #{i}:#{count} E", - category: category + category: ) end questions diff --git a/spec/system/authentication_spec.rb b/spec/system/authentication_spec.rb index b9f43f73..4d6304a6 100644 --- a/spec/system/authentication_spec.rb +++ b/spec/system/authentication_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' describe 'authentication' do let(:district) { create(:district) } - let(:school) { create(:school, district: district) } + let(:school) { create(:school, district:) } let(:academic_year) { create(:academic_year) } context 'when using the wrong credentials' do diff --git a/spec/system/sqm_application_spec.rb b/spec/system/sqm_application_spec.rb index 8b0ec019..c66ad259 100644 --- a/spec/system/sqm_application_spec.rb +++ b/spec/system/sqm_application_spec.rb @@ -2,11 +2,11 @@ require 'rails_helper' describe 'SQM Application' do let(:district) { create(:district) } - let(:school) { create(:school, district: district) } + let(:school) { create(:school, district:) } let(:academic_year) { create(:academic_year) } let(:category) { create(:category) } let(:measure) { create(:measure) } - let(:scale) {create(:scale, measure:)} + let(:scale) { create(:scale, measure:) } before :each do driven_by :rack_test @@ -30,7 +30,7 @@ describe 'SQM Application' do before :each do teacher_survey_item = create(:teacher_survey_item, scale:) 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 it 'does not show a modal on any page' do diff --git a/spec/views/legacy/recipient_lists/show.html.erb_spec.rb b/spec/views/legacy/recipient_lists/show.html.erb_spec.rb index a9f01d42..f889459f 100644 --- a/spec/views/legacy/recipient_lists/show.html.erb_spec.rb +++ b/spec/views/legacy/recipient_lists/show.html.erb_spec.rb @@ -6,7 +6,7 @@ module Legacy @school = assign(:school, School.create!(name: 'School')) recipients = ['Jared Cosulich', 'Lauren Cosulich'].collect do |name| - @school.recipients.create!(name: name) + @school.recipients.create!(name:) end @recipient_list = assign(:recipient_list, RecipientList.create!(