lib/customer_fwd.rb 🔗
@@ -22,7 +22,7 @@ class CustomerFwd
end
def initialize(s)
- @timeout = s.nil? || s.to_i.negative? ? 300 : s.to_i
+ @timeout = s.nil? || s.to_i.negative? || s.to_i > 300 ? 300 : s.to_i
end
def zero?
Stephen Paul Weber created
lib/customer_fwd.rb | 2 +-
test/test_customer_fwd.rb | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
@@ -22,7 +22,7 @@ class CustomerFwd
end
def initialize(s)
- @timeout = s.nil? || s.to_i.negative? ? 300 : s.to_i
+ @timeout = s.nil? || s.to_i.negative? || s.to_i > 300 ? 300 : s.to_i
end
def zero?
@@ -12,6 +12,11 @@ class Rantly
end
class CustomerFwdTest < Minitest::Test
+ def test_too_big_timeout
+ fwd = CustomerFwd.for(uri: "xmpp:test@example.com", timeout: 500)
+ assert_equal 300, fwd.timeout.to_i
+ end
+
property(:for_xmpp) { jid }
def for_xmpp(jid)
sip = "sip:#{ERB::Util.url_encode(jid.to_s)}@sip.cheogram.com"