mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
working on twilio integration
This commit is contained in:
parent
5429034f8f
commit
44ddd0fba9
3 changed files with 12 additions and 4 deletions
|
|
@ -18,7 +18,7 @@ class Attempt < ApplicationRecord
|
|||
)
|
||||
|
||||
update_attributes(sent_at: Time.new, twilio_sid: message.sid)
|
||||
recipient.update_attributes(phone: client.account.messages.get(message.sid).to)
|
||||
recipient.update_attributes(phone: client.messages.get(message.sid).to)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -43,12 +43,16 @@ RSpec.describe Attempt, type: :model do
|
|||
|
||||
it 'should contact the Twilio API' do
|
||||
expect(FakeSMS.messages.length).to eq(1)
|
||||
# expect(FakeSMS.messages.first.body).to eq('Question 0:1%0a%0aOption 0:1 A: Reply 1\n\r%0a%OaOption 0:1 B: Reply 2%0aOption 0:1 C: Reply 3%0aOption 0:1 D: Reply 4%0aOption 0:1 E: Reply 5')
|
||||
expect(FakeSMS.messages.first.to).to eq(recipient.phone)
|
||||
expect(FakeSMS.messages.first.body).to eq("Question 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")
|
||||
expect(FakeSMS.messages.first.to).to eq('1111111111')
|
||||
end
|
||||
|
||||
it 'should update sent_at' do
|
||||
expect(attempt.sent_at).to eq(Time.new)
|
||||
end
|
||||
|
||||
it 'should update the recipient phone number' do
|
||||
expect(attempt.recipient.reload.phone).to eq('+11111111111')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -119,7 +119,11 @@ class FakeSMS
|
|||
|
||||
def create(from:, to:, body:)
|
||||
self.class.messages << Message.new(from, to, body)
|
||||
return Struct.new(:sid).new('sid')
|
||||
return Struct.new(:sid).new(self.class.messages.length-1)
|
||||
end
|
||||
|
||||
def get(sid)
|
||||
Struct.new(:to).new("+1#{self.class.messages[sid].to}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue