From 5c3ceb3687e80d321ec83456495d83a460386c58 Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Wed, 5 Apr 2017 12:01:12 -0400 Subject: [PATCH] changing from cancel to stop --- app/controllers/attempts_controller.rb | 4 ++-- app/models/attempt.rb | 2 +- spec/controllers/attempts_controller_spec.rb | 6 +++--- spec/models/attempt_spec.rb | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/attempts_controller.rb b/app/controllers/attempts_controller.rb index 8f0ed808..41c0c642 100644 --- a/app/controllers/attempts_controller.rb +++ b/app/controllers/attempts_controller.rb @@ -5,7 +5,7 @@ class AttemptsController < ApplicationController def twilio attempt = Recipient.where(phone: twilio_params['From']).first.attempts.last - if (twilio_params[:Body].downcase == 'cancel') + if (twilio_params[:Body].downcase == 'stop') attempt.recipient.update_attributes(opted_out: true) attempt.update_attributes(twilio_details: twilio_params.to_h.to_yaml) render plain: 'Thank you, you have been opted out of these messages and will no longer receive them.' @@ -17,7 +17,7 @@ class AttemptsController < ApplicationController responded_at: Time.new, twilio_details: twilio_params.to_h.to_yaml ) - render plain: """We've registered your response of #{attempt.response}. + render plain: """We've registered your response of \"#{attempt.response}\". To see how others responded to the same question please visit #{school_category_url(attempt.recipient.school, attempt.question.category)}""" end diff --git a/app/models/attempt.rb b/app/models/attempt.rb index e82eeca6..b072b5cc 100644 --- a/app/models/attempt.rb +++ b/app/models/attempt.rb @@ -17,7 +17,7 @@ class Attempt < ApplicationRecord def messages [ question.text, - "#{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 'cancel' to stop these messages." + "#{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 'stop' to stop these messages." ] end diff --git a/spec/controllers/attempts_controller_spec.rb b/spec/controllers/attempts_controller_spec.rb index 76e91880..f58d1f3c 100644 --- a/spec/controllers/attempts_controller_spec.rb +++ b/spec/controllers/attempts_controller_spec.rb @@ -48,15 +48,15 @@ RSpec.describe AttemptsController, type: :controller do it "sends back a message" do post :twilio, params: twilio_attributes - expect(response.body).to eq """We\'ve registered your response of Option 0:1 C. + expect(response.body).to eq """We\'ve registered your response of \"Option 0:1 C\". To see how others responded to the same question please visit http://test.host/schools/school/categories/category""" end end - context 'with cancel params' do + context 'with stop params' do let(:twilio_attributes) { - {'MessageSid' => 'ewuefhwieuhfweiuhfewiuhf','AccountSid' => 'wefiuwhefuwehfuwefinwefw','MessagingServiceSid' => 'efwneufhwuefhweiufhiuewhf','From' => '+11231231234','To' => '2223334444','Body' => 'cAnCel','NumMedia' => '0'} + {'MessageSid' => 'ewuefhwieuhfweiuhfewiuhf','AccountSid' => 'wefiuwhefuwehfuwefinwefw','MessagingServiceSid' => 'efwneufhwuefhweiufhiuewhf','From' => '+11231231234','To' => '2223334444','Body' => 'sToP','NumMedia' => '0'} } it "updates the last attempt by recipient phone number" do diff --git a/spec/models/attempt_spec.rb b/spec/models/attempt_spec.rb index d76158cb..4036ccbf 100644 --- a/spec/models/attempt_spec.rb +++ b/spec/models/attempt_spec.rb @@ -94,7 +94,7 @@ RSpec.describe Attempt, type: :model do it 'should contact the Twilio API' do expect(FakeSMS.messages.length).to eq(2) expect(FakeSMS.messages.first.body).to eq("Question 0:1") - expect(FakeSMS.messages.last.body).to eq("Option 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 'cancel' to stop these messages.") + expect(FakeSMS.messages.last.body).to eq("Option 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 'stop' to stop these messages.") expect(FakeSMS.messages.first.to).to eq('1111111111') end