From 5ea72635dd4ae43b81bc0994ff01ecb57858c39e Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Tue, 27 Feb 2018 09:35:45 -0800 Subject: [PATCH] Add a test case for bot detection with nil user agent. --- test/unit/bots_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/unit/bots_test.rb b/test/unit/bots_test.rb index 9f35fd6d..9375d7b4 100644 --- a/test/unit/bots_test.rb +++ b/test/unit/bots_test.rb @@ -27,6 +27,15 @@ class BotsTest < Minitest::Test assert browser.bot? end + test "allows setting nil as user agent for bots" do + browser = Browser.new(nil) + refute browser.bot? + + Browser::Bot.detect_empty_ua! + browser = Browser.new(nil) + assert browser.bot? + end + test "doesn't detect mozilla as a bot when considering empty UA" do Browser::Bot.detect_empty_ua! browser = Browser.new("Mozilla")