log.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. require 'rails_helper'
  2. RSpec.describe Cti::Log do
  3. subject { create(:cti_log, **factory_attributes) }
  4. let(:factory_attributes) { {} }
  5. context 'with complete, E164 international numbers' do
  6. let(:factory_attributes) { { from: '4930609854180', to: '4930609811111' } }
  7. describe '#from_pretty' do
  8. it 'gives the number in prettified format' do
  9. expect(subject.from_pretty).to eq('+49 30 609854180')
  10. end
  11. end
  12. describe '#to_pretty' do
  13. it 'gives the number in prettified format' do
  14. expect(subject.to_pretty).to eq('+49 30 609811111')
  15. end
  16. end
  17. end
  18. context 'with private network numbers' do
  19. let(:factory_attributes) { { from: '007', to: '008' } }
  20. describe '#from_pretty' do
  21. it 'gives the number unaltered' do
  22. expect(subject.from_pretty).to eq('007')
  23. end
  24. end
  25. describe '#to_pretty' do
  26. it 'gives the number unaltered' do
  27. expect(subject.to_pretty).to eq('008')
  28. end
  29. end
  30. end
  31. describe '#to_json' do
  32. let(:virtual_attributes) { %w[from_pretty to_pretty] }
  33. it 'includes virtual attributes' do
  34. expect(subject.as_json).to include(*virtual_attributes)
  35. end
  36. end
  37. end