From 986ef0086b4f393e1938a2c863e6940070f2b5ff Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Tue, 2 May 2017 12:55:38 -0400 Subject: [PATCH] tweaking texting content --- app/models/attempt.rb | 8 ++------ spec/lib/tasks/survey_rake_spec.rb | 8 ++++---- spec/models/attempt_spec.rb | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/models/attempt.rb b/app/models/attempt.rb index aabb438f..89eee44a 100644 --- a/app/models/attempt.rb +++ b/app/models/attempt.rb @@ -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 diff --git a/spec/lib/tasks/survey_rake_spec.rb b/spec/lib/tasks/survey_rake_spec.rb index 9ce3b7c7..e323ec79 100644 --- a/spec/lib/tasks/survey_rake_spec.rb +++ b/spec/lib/tasks/survey_rake_spec.rb @@ -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 diff --git a/spec/models/attempt_spec.rb b/spec/models/attempt_spec.rb index 5c67e91b..c687d9af 100644 --- a/spec/models/attempt_spec.rb +++ b/spec/models/attempt_spec.rb @@ -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