Skip to content

Commit

Permalink
treat pound and star as valid digits
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Berdeen committed Feb 13, 2009
1 parent 0001dc5 commit 03a7354
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/adhearsion/voip/asterisk/commands.rb
Expand Up @@ -891,7 +891,7 @@ def from_pbx

def validate_digits(digits)
returning digits.to_s do |digits_as_string|
raise ArgumentError, "Can only be called with valid digits!" unless digits_as_string =~ /^\d+$/
raise ArgumentError, "Can only be called with valid digits!" unless digits_as_string =~ /^[0-9*#]+$/
end
end

Expand Down
6 changes: 6 additions & 0 deletions spec/voip/asterisk/test_commands.rb
Expand Up @@ -1149,6 +1149,12 @@
pbx_was_asked_to_execute "saydigits", digits
end

test 'Digits that include pound and star are considered valid' do
digits = "1#2*3#4*5"
mock_call.should_receive(:execute).once.with("saydigits", digits)
mock_call.say_digits digits
end

test 'Cannot pass non-integers into say_digits. Will raise an ArgumentError' do
the_following_code {
mock_call.say_digits 'abc'
Expand Down

0 comments on commit 03a7354

Please sign in to comment.