mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
changing from cancel to stop
This commit is contained in:
parent
cc82f74525
commit
5c3ceb3687
4 changed files with 7 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue