From 973bd38f66a65e971eddd0656811eee2f16652a2 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 13 Nov 2012 02:32:00 +0100 Subject: [PATCH] Use Rack::Request#user_agent --- lib/travis/web/app/mobile_redirect.rb | 2 +- spec/mobile_redirect_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/travis/web/app/mobile_redirect.rb b/lib/travis/web/app/mobile_redirect.rb index 5593b9e5..f2ecaaf7 100644 --- a/lib/travis/web/app/mobile_redirect.rb +++ b/lib/travis/web/app/mobile_redirect.rb @@ -2,7 +2,7 @@ class Travis::Web::App::MobileRedirect < Struct.new(:app) def call(env) request = Rack::Request.new env - if request.params['mobile'] || env['HTTP_AGENT'] =~ /Mobile|webOS/ + if request.params['mobile'] || request.user_agent.to_s =~ /Mobile|webOS/ location = 'https://secure.travis-ci.org' + request.fullpath [301, { 'Content-Type' => 'text/plain', 'Location' => location }, []] else diff --git a/spec/mobile_redirect_spec.rb b/spec/mobile_redirect_spec.rb index 03871d53..490cfae4 100644 --- a/spec/mobile_redirect_spec.rb +++ b/spec/mobile_redirect_spec.rb @@ -6,7 +6,7 @@ describe Travis::Web::App::MobileRedirect do let(:agent) { 'blah blah Mobile blablah' } it 'redirects to secure.travis-ci.org' do - get('/foo/bar?baz', {}, 'HTTP_AGENT' => agent).should be_redirect + get('/foo/bar?baz', {}, 'HTTP_USER_AGENT' => agent).should be_redirect last_response.headers['Location'].should == 'https://secure.travis-ci.org/foo/bar?baz' end end