mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
texting change
This commit is contained in:
parent
986ef0086b
commit
ed4883c9fb
3 changed files with 16 additions and 14 deletions
|
|
@ -22,11 +22,13 @@ class Attempt < ApplicationRecord
|
|||
scope :last_sent, -> { order(sent_at: :desc) }
|
||||
|
||||
def messages
|
||||
child_specific = student.present? ? "\n(for #{student.name})" : ''
|
||||
child_specific = student.present? ? " (for #{student.name})" : ''
|
||||
|
||||
cancel_text = "\nSkip question: skip\nStop all questions: stop"
|
||||
|
||||
[
|
||||
#question.text,
|
||||
"#{question.text}#{child_specific}\n\r#{question.option1}: Reply 1\n#{question.option2}: 2\n#{question.option3}: 3\n#{question.option4}: 4\n#{question.option5}: 5\nSkip question: skip\nStop all questions: stop"
|
||||
"#{question.text}#{child_specific}",
|
||||
"#{question.option1}: Reply 1\n#{question.option2}: 2\n#{question.option3}: 3\n#{question.option4}: 4\n#{question.option5}: 5"
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ describe "survey:attempt_questions" do
|
|||
end
|
||||
|
||||
it 'should not send anything to anyone else' do
|
||||
expect(FakeSMS.messages.length).to eq(@existing_message_count + 1)
|
||||
expect(FakeSMS.messages.length).to eq(@existing_message_count + 2)
|
||||
expect(recipients[0].attempts.count).to eq(1)
|
||||
expect(recipients[1].attempts.count).to eq(2)
|
||||
end
|
||||
|
|
@ -214,7 +214,7 @@ describe "survey:attempt_questions" do
|
|||
end
|
||||
|
||||
it 'should create one attempt per recipient regardless of students' do
|
||||
expect(FakeSMS.messages.length).to eq(3)
|
||||
expect(FakeSMS.messages.length).to eq(6)
|
||||
recipients.each do |recipient|
|
||||
expect(recipient.attempts.count).to eq(1)
|
||||
end
|
||||
|
|
@ -257,7 +257,7 @@ describe "survey:attempt_questions" do
|
|||
end
|
||||
|
||||
it 'should mention the students name in the text' do
|
||||
expect(FakeSMS.messages[1].body).to match(/\(for Student0\)/)
|
||||
expect(FakeSMS.messages[2].body).to match(/\(for Student0\)/)
|
||||
end
|
||||
|
||||
it 'should not mention the students name in the text if the recipient has no student specified' do
|
||||
|
|
@ -267,9 +267,9 @@ describe "survey:attempt_questions" do
|
|||
it 'resends the question about the same student if not responded to' do
|
||||
message_count = FakeSMS.messages.length
|
||||
expect{students_recipient_schedule.attempt_question}.to change{students_recipient.attempts.count}.by(0)
|
||||
expect(FakeSMS.messages.length).to eq(message_count + 1)
|
||||
expect(FakeSMS.messages.last.body).to match(/\(for Student0\)/)
|
||||
expect(FakeSMS.messages.last.body).to match(questions.first.text)
|
||||
expect(FakeSMS.messages.length).to eq(message_count + 2)
|
||||
expect(FakeSMS.messages[message_count].body).to match(questions.first.text)
|
||||
expect(FakeSMS.messages[message_count].body).to match(/\(for Student0\)/)
|
||||
end
|
||||
|
||||
it 'doesnt store any queued_question_ids when no students are present' do
|
||||
|
|
@ -317,7 +317,7 @@ describe "survey:attempt_questions" do
|
|||
end
|
||||
|
||||
it 'should create one attempt per recipient regardless of students' do
|
||||
expect(FakeSMS.messages.length).to eq(3)
|
||||
expect(FakeSMS.messages.length).to eq(6)
|
||||
recipients.each do |recipient|
|
||||
expect(recipient.attempts.count).to eq(1)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -92,13 +92,13 @@ RSpec.describe Attempt, type: :model do
|
|||
end
|
||||
|
||||
it 'should contact the Twilio API' do
|
||||
expect(FakeSMS.messages.length).to eq(1)
|
||||
expect(FakeSMS.messages.length).to eq(2)
|
||||
|
||||
# expect(FakeSMS.messages.first.to).to eq('111111111')
|
||||
# expect(FakeSMS.messages.first.body).to eq("Question 0:1")
|
||||
expect(FakeSMS.messages.first.to).to eq('111111111')
|
||||
expect(FakeSMS.messages.first.body).to eq("Question 0:1")
|
||||
|
||||
expect(FakeSMS.messages.last.to).to eq('111111111')
|
||||
expect(FakeSMS.messages.last.body).to eq("Question 0:1\n\rOption 0:1 A: Reply 1\nOption 0:1 B: 2\nOption 0:1 C: 3\nOption 0:1 D: 4\nOption 0:1 E: 5\nSkip question: skip\nStop all questions: stop")
|
||||
expect(FakeSMS.messages.last.body).to eq("Option 0:1 A: Reply 1\nOption 0:1 B: 2\nOption 0:1 C: 3\nOption 0:1 D: 4\nOption 0:1 E: 5")
|
||||
end
|
||||
|
||||
it 'should update sent_at' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue