tweaking texting format

pull/1/head
Jared Cosulich 9 years ago
parent f2141fb6dc
commit aa06f301df

@ -23,16 +23,14 @@ class Attempt < ApplicationRecord
def messages def messages
if student.present? if student.present?
intro = "#{student.name}'s school, " intro = "From #{student.name}'s school:"
else else
intro = "Your child's school, " intro = "From your child's school:"
end end
intro += "#{recipient.school.name}, would love your opinion on this question:"
[ [
#question.text, #question.text,
"#{intro}\n\r#{question.text}\n\r#{question.option1}: Reply 1\n\r#{question.option2}: Reply 2\n\r#{question.option3}: Reply 3\n\r#{question.option4}: Reply 4\n\r#{question.option5}: Reply 5\n\rReply 'skip' to skip this question.\n\rReply 'stop' to stop these messages." "#{intro}\n\r#{question.text}\n\rReply with:\n\r1: #{question.option1}\n\r2: #{question.option2}\n\r3: #{question.option3}\n\r4: #{question.option4}\n\r5: #{question.option5}\n\r'skip' skips question, 'stop' stops all questions"
] ]
end end

@ -257,18 +257,18 @@ describe "survey:attempt_questions" do
end end
it 'should mention the students name in the text' do it 'should mention the students name in the text' do
expect(FakeSMS.messages[1].body).to match(/Student0's school, School, would love your opinion on this question/) expect(FakeSMS.messages[1].body).to match(/From Student0's school:/)
end end
it 'should not mention the students name in the text if the recipient has no student specified' do it 'should not mention the students name in the text if the recipient has no student specified' do
expect(FakeSMS.messages[0].body).to match(/Your child's school, School, would love your opinion on this question/) expect(FakeSMS.messages[0].body).to match(/From your child's school:/)
end end
it 'resends the question about the same student if not responded to' do it 'resends the question about the same student if not responded to' do
message_count = FakeSMS.messages.length message_count = FakeSMS.messages.length
expect{students_recipient_schedule.attempt_question}.to change{students_recipient.attempts.count}.by(0) 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.length).to eq(message_count + 1)
expect(FakeSMS.messages.last.body).to match(/Student0's school, School/) expect(FakeSMS.messages.last.body).to match(/From Student0's school:/)
expect(FakeSMS.messages.last.body).to match(questions.first.text) expect(FakeSMS.messages.last.body).to match(questions.first.text)
end end
@ -290,7 +290,7 @@ describe "survey:attempt_questions" do
it 'should not mention the students name in the text' do it 'should not mention the students name in the text' do
FakeSMS.messages.each do |message| FakeSMS.messages.each do |message|
expect(message.body).to match(/Your child's school, School, would love your opinion on this question/) expect(message.body).to match(/From your child's school:/)
end end
end end

@ -98,7 +98,7 @@ RSpec.describe Attempt, type: :model do
# expect(FakeSMS.messages.first.body).to eq("Question 0:1") # expect(FakeSMS.messages.first.body).to eq("Question 0:1")
expect(FakeSMS.messages.last.to).to eq('111111111') expect(FakeSMS.messages.last.to).to eq('111111111')
expect(FakeSMS.messages.last.body).to eq("Your child's school, School, would love your opinion on this question:\n\rQuestion 0:1\n\rOption 0:1 A: Reply 1\n\rOption 0:1 B: Reply 2\n\rOption 0:1 C: Reply 3\n\rOption 0:1 D: Reply 4\n\rOption 0:1 E: Reply 5\n\rReply 'skip' to skip this question.\n\rReply 'stop' to stop these messages.") expect(FakeSMS.messages.last.body).to eq("From your child's school:\n\rQuestion 0:1\n\rReply with:\n\r1: Option 0:1 A\n\r2: Option 0:1 B\n\r3: Option 0:1 C\n\r4: Option 0:1 D\n\r5: Option 0:1 E\n\r'skip' skips question, 'stop' stops all questions")
end end
it 'should update sent_at' do it 'should update sent_at' do

Loading…
Cancel
Save