tweaking texting content

pull/1/head
Jared Cosulich 9 years ago
parent 6b52b22fb6
commit 986ef0086b

@ -22,15 +22,11 @@ class Attempt < ApplicationRecord
scope :last_sent, -> { order(sent_at: :desc) }
def messages
if student.present?
intro = "From #{student.name}'s school:"
else
intro = "From your child's school:"
end
child_specific = student.present? ? "\n(for #{student.name})" : ''
[
#question.text,
"#{intro}\n\r#{question.text}\n\r#{question.option1}: reply 1\n\r#{question.option2}: 2\n\r#{question.option3}: 3\n\r#{question.option4}: 4\n\r#{question.option5}: 5\n\rskip question: skip\n\rstop all questions: stop"
"#{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"
]
end

@ -257,18 +257,18 @@ describe "survey:attempt_questions" do
end
it 'should mention the students name in the text' do
expect(FakeSMS.messages[1].body).to match(/From Student0's school:/)
expect(FakeSMS.messages[1].body).to match(/\(for Student0\)/)
end
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(/From your child's school:/)
expect(FakeSMS.messages[0].body).to_not match(/\(for .*\)/)
end
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(/From Student0's school:/)
expect(FakeSMS.messages.last.body).to match(/\(for Student0\)/)
expect(FakeSMS.messages.last.body).to match(questions.first.text)
end
@ -290,7 +290,7 @@ describe "survey:attempt_questions" do
it 'should not mention the students name in the text' do
FakeSMS.messages.each do |message|
expect(message.body).to match(/From your child's school:/)
expect(message.body).to_not match(/\(for .*\)/)
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.last.to).to eq('111111111')
expect(FakeSMS.messages.last.body).to eq("From your child's school:\n\rQuestion 0:1\n\rOption 0:1 A: reply 1\n\rOption 0:1 B: 2\n\rOption 0:1 C: 3\n\rOption 0:1 D: 4\n\rOption 0:1 E: 5\n\rskip question: skip\n\rstop all questions: stop")
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")
end
it 'should update sent_at' do

Loading…
Cancel
Save