Skip to content
Browse files

categorize some older phones as :mobile

  • Loading branch information...
1 parent 9f32353 commit 3bed238eb489bc73d33c633b2f99fd0757ff9992 @jistr committed Apr 25, 2012
Showing with 22 additions and 1 deletion.
  1. +2 −1 lib/mobvious/strategies/mobileesp.rb
  2. +20 −0 spec/mobvious/strategies/mobileesp_spec.rb
View
3 lib/mobvious/strategies/mobileesp.rb
@@ -8,13 +8,14 @@ class MobileESP
# Detection procedure that classifies mobile phones as `:mobile` and anything
# else as `:desktop`.
DEVICE_TYPES_MOBILE_DESKTOP = lambda {|mobileesp|
- return :mobile if mobileesp.is_tier_generic_mobile || mobileesp.is_tier_iphone
+ return :mobile if mobileesp.is_tier_generic_mobile || mobileesp.is_tier_iphone || mobileesp.is_tier_rich_css
return :desktop
}
# Detection procedure that classifies mobile phones as `:mobile`, tablets as
# `:tablet` and anything else as `:desktop`.
DEVICE_TYPES_MOBILE_TABLET_DESKTOP = lambda {|mobileesp|
+ return :mobile if mobileesp.is_tier_generic_mobile || mobileesp.is_tier_iphone || mobileesp.is_tier_rich_css
return :mobile if mobileesp.is_tier_generic_mobile || mobileesp.is_tier_iphone
return :tablet if mobileesp.is_tier_tablet
return :desktop
View
20 spec/mobvious/strategies/mobileesp_spec.rb
@@ -21,6 +21,16 @@ class MobileESPSpec < MiniTest::Spec
@strategy.get_device_type(@request).must_equal :mobile
end
+ it "categorizes iPod as :mobile" do
+ @request.stubs(:user_agent).returns("Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3")
+ @strategy.get_device_type(@request).must_equal :mobile
+ end
+
+ it "categorizes old BlackBerry as :mobile" do
+ @request.stubs(:user_agent).returns("BlackBerry9530/4.7.0.148 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/105")
+ @strategy.get_device_type(@request).must_equal :mobile
+ end
+
it "categorizes Android tablet as :desktop" do
@request.stubs(:user_agent).returns("Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13")
@strategy.get_device_type(@request).must_equal :desktop
@@ -42,6 +52,16 @@ class MobileESPSpec < MiniTest::Spec
@strategy.get_device_type(@request).must_equal :mobile
end
+ it "categorizes iPod as :mobile" do
+ @request.stubs(:user_agent).returns("Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3")
+ @strategy.get_device_type(@request).must_equal :mobile
+ end
+
+ it "categorizes old BlackBerry as :mobile" do
+ @request.stubs(:user_agent).returns("BlackBerry9530/4.7.0.148 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/105")
+ @strategy.get_device_type(@request).must_equal :mobile
+ end
+
it "categorizes Android tablet as :tablet" do
@request.stubs(:user_agent).returns("Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13")
@strategy.get_device_type(@request).must_equal :tablet

0 comments on commit 3bed238

Please sign in to comment.
Something went wrong with that request. Please try again.