fix: Check medium to decide 24 hour window (#1245)
This commit is contained in:
parent
8b953917e1
commit
646746aa10
2 changed files with 27 additions and 2 deletions
|
@ -31,10 +31,10 @@ class Channel::TwilioSms < ApplicationRecord
|
||||||
has_one :inbox, as: :channel, dependent: :destroy
|
has_one :inbox, as: :channel, dependent: :destroy
|
||||||
|
|
||||||
def name
|
def name
|
||||||
medium == :sms ? 'Twilio SMS' : 'Whatsapp'
|
medium == 'sms' ? 'Twilio SMS' : 'Whatsapp'
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_24_hour_messaging_window?
|
def has_24_hour_messaging_window?
|
||||||
true
|
medium == 'whatsapp'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
25
spec/models/channel/twilio_sms_spec.rb
Normal file
25
spec/models/channel/twilio_sms_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Channel::TwilioSms do
|
||||||
|
context 'with medium whatsapp' do
|
||||||
|
let!(:whatsapp_channel) { create(:channel_twilio_sms, medium: :whatsapp) }
|
||||||
|
|
||||||
|
it 'returns true' do
|
||||||
|
expect(whatsapp_channel.has_24_hour_messaging_window?).to eq true
|
||||||
|
expect(whatsapp_channel.name).to eq 'Whatsapp'
|
||||||
|
expect(whatsapp_channel.medium).to eq 'whatsapp'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with medium sms' do
|
||||||
|
let!(:sms_channel) { create(:channel_twilio_sms, medium: :sms) }
|
||||||
|
|
||||||
|
it 'returns false' do
|
||||||
|
expect(sms_channel.has_24_hour_messaging_window?).to eq false
|
||||||
|
expect(sms_channel.name).to eq 'Twilio SMS'
|
||||||
|
expect(sms_channel.medium).to eq 'sms'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue