Updated to rails 6. Passing tests

This commit is contained in:
rebuilt 2021-10-14 19:22:26 +02:00
parent 3430069801
commit 770ebc580e
20 changed files with 33 additions and 34 deletions

View file

@ -15,13 +15,13 @@ class AttemptsController < ApplicationController
)
unless (['start', 'resume', 'restart', 'yes', 'go'].index(twilio_params[:Body].downcase).nil?)
recipient.update_attributes(opted_out: false)
recipient.update(opted_out: false)
render plain: 'Thank you, you will now begin receiving messages again.'
return
end
unless (['stop', 'cancel', 'quit', 'no'].index(twilio_params[:Body].downcase).nil?)
recipient.update_attributes(opted_out: true)
recipient.update(opted_out: true)
render plain: 'Thank you, you have been opted out of these messages and will no longer receive them.'
return
end

View file

@ -35,7 +35,7 @@ class RecipientListsController < ApplicationController
# PUT schools/1/recipient_lists/1
def update
if @recipient_list.update_attributes(recipient_list_params)
if @recipient_list.update(recipient_list_params)
redirect_to([@recipient_list.school, @recipient_list], notice: 'Recipient list was successfully updated.')
else
render action: 'edit'

View file

@ -31,7 +31,7 @@ class SchedulesController < ApplicationController
# PUT schools/1/schedules/1
def update
if @schedule.update_attributes(schedule_params)
if @schedule.update(schedule_params)
redirect_to([@schedule.school, @schedule], notice: 'Schedule was successfully updated.')
else
render action: 'edit'

View file

@ -46,8 +46,8 @@ class Attempt < ApplicationRecord
).sid
end
update_attributes(sent_at: Time.new, twilio_sid: sids.join(','))
recipient.update_attributes(phone: client.messages.get(sids.last).to)
update(sent_at: Time.new, twilio_sid: sids.join(','))
recipient.update(phone: client.messages.get(sids.last).to)
end
def response
@ -56,7 +56,7 @@ class Attempt < ApplicationRecord
end
def save_response(answer_index: nil, twilio_details: nil, responded_at: Time.new)
update_attributes(
update(
answer_index: answer_index,
twilio_details: twilio_details,
responded_at: responded_at

View file

@ -23,7 +23,7 @@ class Recipient < ApplicationRecord
# recipient = school.recipients.where(phone: recipient_hash["phone"])
#
# if recipient.count == 1
# recipient.first.update_attributes(recipient_hash)
# recipient.first.update(recipient_hash)
# else
# school.recipients.create!(recipient_hash)
# end
@ -31,7 +31,7 @@ class Recipient < ApplicationRecord
end
def update_counts
update_attributes(
update(
attempts_count: attempts.count,
responses_count: attempts.with_answer.count
)
@ -43,7 +43,7 @@ class Recipient < ApplicationRecord
school.recipient_lists.each do |recipient_list|
next if recipient_list.recipient_id_array.index(id).nil?
updated_ids = recipient_list.recipient_id_array - [id]
recipient_list.update_attributes(recipient_id_array: updated_ids)
recipient_list.update(recipient_id_array: updated_ids)
end
end

View file

@ -82,7 +82,7 @@ class RecipientSchedule < ApplicationRecord
end
end
update_attributes(
update(
upcoming_question_ids: upcoming.empty? ? nil : upcoming.join(','),
attempted_question_ids: attempted.empty? ? nil : attempted.join(','),
queued_question_ids: queued.empty? ? nil : queued.join(','),
@ -127,7 +127,7 @@ class RecipientSchedule < ApplicationRecord
end
end
update_attributes(
update(
upcoming_question_ids: upcoming.empty? ? nil : upcoming.join(','),
attempted_question_ids: attempted.empty? ? nil : attempted.join(','),
queued_question_ids: queued.empty? ? nil : queued.join(','),

View file

@ -91,7 +91,7 @@ class SchoolCategory < ApplicationRecord
# This doesn't seem to be taking into account valid_child_count or Boston's "Community and Wellbeing" category which should be suppressed if the "Health" category is the only child category visible.
return if ENV['BULK_PROCESS']
update_attributes(chained_aggregated_responses)
update(chained_aggregated_responses)
return if response_count == 0 && zscore.nil?
if category.parent_category.present?
parent_school_category = SchoolCategory.for(school, category.parent_category).in(year).first