Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 0b21287

Browse files
committed
Have PhoneNumberProcessor deal with phone numbers missing + signs
1 parent fd63042 commit 0b21287

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/phone_number_processor.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def initialize
1919
end
2020

2121
def language_for(phone_number)
22-
lookup_hash[phone_number]
22+
if phone_number.include?('+') == false
23+
phone_number_with_plus = '+' + phone_number
24+
lookup_hash[phone_number_with_plus]
25+
else
26+
lookup_hash[phone_number]
27+
end
2328
end
2429
end

spec/lib/phone_number_processor_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
end
1919
end
2020

21+
context "given a phone number missing a + sign" do
22+
let(:twilio_phone_number) { '14151112222' }
23+
24+
it 'returns the correct language' do
25+
result = @pnp.language_for(twilio_phone_number)
26+
expect(result).to eq(:spanish)
27+
end
28+
end
29+
2130
context "given a phone number with no language in its friendly name" do
2231
let(:twilio_phone_number) { '+15103334444' }
2332

0 commit comments

Comments
 (0)