Skip to content

Commit

Permalink
Add WP7 as mobile device
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jan 4, 2011
1 parent db31c41 commit f62dd1b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/user_agent/browsers/all.rb
Expand Up @@ -53,6 +53,8 @@ def mobile?
true
elsif detect_product('Mobile')
true
elsif application.comment.detect { |k, v| k =~ /^IEMobile/ }
true
else
false
end
Expand Down
6 changes: 3 additions & 3 deletions lib/user_agent/browsers/internet_explorer.rb
Expand Up @@ -23,14 +23,14 @@ def compatibility
def compatible?
compatibility == "compatible"
end

# Before version 4.0, Chrome Frame declared itself (unversioned) in a comment;
# as of 4.0 it declares itself as a separate product with a version.

def chromeframe
application.comment.include?("chromeframe") || detect_product("chromeframe")
end

def platform
"Windows"
end
Expand Down
20 changes: 20 additions & 0 deletions spec/browsers/internet_explorer_user_agent_spec.rb
Expand Up @@ -32,6 +32,8 @@
it "should return 'Windows Vista' as its os" do
@useragent.os.should == "Windows Vista"
end

it { @useragent.should_not be_mobile }
end

describe "UserAgent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'" do
Expand Down Expand Up @@ -114,6 +116,24 @@
end
end

describe "UserAgent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; SAMSUNG; SGH-i917)'" do
before do
@useragent = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; SAMSUNG; SGH-i917)")
end

it_should_behave_like "Internet Explorer browser"

it "should return '7.0' as its version" do
@useragent.version.should == "7.0"
end

it "should return 'Windows Phone OS 7.0' as its os" do
@useragent.os.should == "Windows Phone OS 7.0"
end

it { @useragent.should be_mobile }
end

describe "Non-Chrome Frame browsers" do
before do
@useragent = UserAgent.parse("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)")
Expand Down

0 comments on commit f62dd1b

Please sign in to comment.