mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Updated to rails 6. Passing tests
This commit is contained in:
parent
3430069801
commit
770ebc580e
20 changed files with 33 additions and 34 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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(','),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ RSpec.describe AttemptsController, type: :controller do
|
|||
context "with valid params" do
|
||||
|
||||
let!(:recent_first_attempt) {
|
||||
first_attempt.update_attributes(sent_at: Time.new)
|
||||
first_attempt.update(sent_at: Time.new)
|
||||
return first_attempt
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ describe "survey:attempt_questions" do
|
|||
|
||||
describe 'A Week Later' do
|
||||
before :each do
|
||||
recipients[1].attempts.first.update_attributes(
|
||||
recipients[1].attempts.first.update(
|
||||
answer_index: 4,
|
||||
responded_at: Time.new
|
||||
)
|
||||
|
|
@ -209,7 +209,7 @@ describe "survey:attempt_questions" do
|
|||
let!(:date) { ActiveSupport::TimeZone["UTC"].parse(now.strftime("%Y-%m-%dT20:00:00%z")) }
|
||||
|
||||
before :each do
|
||||
questions.first.update_attributes(for_recipient_students: true)
|
||||
questions.first.update(for_recipient_students: true)
|
||||
Timecop.freeze(date) { subject.invoke }
|
||||
end
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ describe "survey:attempt_questions" do
|
|||
let!(:date) { ActiveSupport::TimeZone["UTC"].parse(now.strftime("%Y-%m-%dT20:00:00%z")) }
|
||||
|
||||
before :each do
|
||||
questions.first.update_attributes(for_recipient_students: true)
|
||||
questions.first.update(for_recipient_students: true)
|
||||
Timecop.freeze(date) { subject.invoke }
|
||||
end
|
||||
|
||||
|
|
@ -332,7 +332,7 @@ describe "survey:attempt_questions" do
|
|||
describe 'Opted Out Recipient' do
|
||||
|
||||
before :each do
|
||||
recipients[1].update_attributes(opted_out: true)
|
||||
recipients[1].update(opted_out: true)
|
||||
|
||||
date = ActiveSupport::TimeZone["UTC"].parse(now.strftime("%Y-%m-%dT20:00:00%z"))
|
||||
Timecop.freeze(date) { subject.invoke }
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ RSpec.describe Attempt, type: :model do
|
|||
|
||||
describe 'after_update' do
|
||||
before :each do
|
||||
attempt.update_attributes(answer_index: 4)
|
||||
attempt.update(answer_index: 4)
|
||||
end
|
||||
|
||||
xit 'updates associated school_categories' do
|
||||
|
|
@ -73,13 +73,13 @@ RSpec.describe Attempt, type: :model do
|
|||
end
|
||||
|
||||
it 'are updated when an attempt is responded to' do
|
||||
attempt.update_attributes(answer_index: 2)
|
||||
attempt.update(answer_index: 2)
|
||||
expect(recipient.attempts_count).to eq(1)
|
||||
expect(recipient.responses_count).to eq(1)
|
||||
end
|
||||
|
||||
it 'are updated when an attempt is responded to with an open-ended response' do
|
||||
attempt.update_attributes(open_response_id: 1)
|
||||
attempt.update(open_response_id: 1)
|
||||
expect(recipient.attempts_count).to eq(1)
|
||||
expect(recipient.responses_count).to eq(1)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ describe RecipientList do
|
|||
it 'should delete recipient_schedules if a recipient is removed' do
|
||||
modified_recipient_ids = recipients.map(&:id)[0,2].join(',')
|
||||
expect do
|
||||
recipient_list.update_attributes(recipient_ids: modified_recipient_ids)
|
||||
recipient_list.update(recipient_ids: modified_recipient_ids)
|
||||
end.to change { schedule.recipient_schedules.count }.from(3).to(2)
|
||||
end
|
||||
|
||||
it 'should create recipient_schedules if a recipient is added' do
|
||||
new_recipients = create_recipients(school, 2)
|
||||
expect do
|
||||
recipient_list.update_attributes(recipient_ids: (recipients + new_recipients).map(&:id).join(','))
|
||||
recipient_list.update(recipient_ids: (recipients + new_recipients).map(&:id).join(','))
|
||||
end.to change { schedule.recipient_schedules.count }.from(3).to(5)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ RSpec.describe RecipientSchedule, type: :model do
|
|||
|
||||
describe 'with an opted out recipient' do
|
||||
before :each do
|
||||
recipient_schedule.recipient.update_attributes(opted_out: true)
|
||||
recipient_schedule.recipient.update(opted_out: true)
|
||||
end
|
||||
|
||||
let!(:attempt) { recipient_schedule.attempt_question }
|
||||
|
|
@ -79,7 +79,7 @@ RSpec.describe RecipientSchedule, type: :model do
|
|||
before :each do
|
||||
friday_time = ActiveSupport::TimeZone["UTC"].parse('2017-04-21T20:00:00')
|
||||
Timecop.freeze()
|
||||
recipient_schedule.update_attributes(next_attempt_at: friday_time)
|
||||
recipient_schedule.update(next_attempt_at: friday_time)
|
||||
end
|
||||
|
||||
let!(:attempt) { recipient_schedule.attempt_question }
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ RSpec.describe "categories/index", type: :view do
|
|||
end
|
||||
|
||||
it "renders a list of categories" do
|
||||
render
|
||||
render(template: "categories/index.html.haml")
|
||||
assert_select "tr>td", :text => "Name".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Blurb".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "MyText".to_s, :count => 2
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ RSpec.describe "districts/show", type: :view do
|
|||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
render(template: "districts/show.html.haml")
|
||||
expect(rendered).to match(/Milford/)
|
||||
expect(rendered).to match(/2/)
|
||||
3.times do |i|
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ RSpec.describe "question_lists/index", type: :view do
|
|||
end
|
||||
|
||||
it "renders a list of question_lists" do
|
||||
render
|
||||
render(template: "question_lists/index.html.haml" )
|
||||
assert_select "tr>td", :text => "Name".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "MyText".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "1,2,3".to_s, :count => 1
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ RSpec.describe "question_lists/show", type: :view do
|
|||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
render(template: "question_lists/show.html.haml")
|
||||
expect(rendered).to match(/Name/)
|
||||
expect(rendered).to match(/MyText/)
|
||||
expect(rendered).to match(/MyText/)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ RSpec.describe "questions/index", type: :view do
|
|||
end
|
||||
|
||||
it "renders a list of questions" do
|
||||
render
|
||||
render(template: "questions/index.html.haml")
|
||||
assert_select "tr>td", :text => "Text".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Option1".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Option2".to_s, :count => 2
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ RSpec.describe "questions/show", type: :view do
|
|||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
render(template: "questions/show.html.haml")
|
||||
expect(rendered).to match(/School/)
|
||||
expect(rendered).to match(/Question Text/)
|
||||
expect(rendered).to match(/Option1/)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ RSpec.describe "recipients/index", type: :view do
|
|||
end
|
||||
|
||||
it "renders a list of recipients" do
|
||||
render
|
||||
render(template: "recipients/index.html.haml")
|
||||
assert_select "tr>td", :text => "Name".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Phone".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Gender".to_s, :count => 2
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ RSpec.describe "schools/show", type: :view do
|
|||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
puts rendered.class
|
||||
render(template: "schools/show.html.haml")
|
||||
expect(rendered).to match(/School/)
|
||||
expect(rendered).to match(/District/)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue