Hi,
Im trying to test the following method:
def notice
65 userAgent = request.env[''HTTP_USER_AGENT'']
66
67 if userAgent.index(''MSIE 7.0;'') != nil
68 @ie7 = true
69 elsif userAgent.index(''MSIE 6.0;'') != nil
70 @ie6 = true
71 end
72
73 if (@ie6)
74 render :action=> "notice", :layout => false
75 else
76 redirect_to :controller => "home", :action =>
"index"
77 end
78 end
the problem im having is that i cant seem to find a way of setting the
user agent before it goes into the method and checks the type of browser
being used.
im sure this is something trivial involving a mock but its just proving
to be a bit illusive to me :(
Cheers,
Chris
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
If you''re in a functional test and have a TestRequest object named
@request, you could do this:
@request.env["User-Agent"] = "whutever" # I think that
header
name is right...
You can set arbitrary headers like that.
--Jeremy
On Wed, Jun 25, 2008 at 4:31 AM, Chris Gallagher
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> Hi,
>
> Im trying to test the following method:
>
> def notice
> 65 userAgent = request.env[''HTTP_USER_AGENT'']
> 66
> 67 if userAgent.index(''MSIE 7.0;'') != nil
> 68 @ie7 = true
> 69 elsif userAgent.index(''MSIE 6.0;'') != nil
> 70 @ie6 = true
> 71 end
> 72
> 73 if (@ie6)
> 74 render :action=> "notice", :layout => false
> 75 else
> 76 redirect_to :controller => "home", :action =>
"index"
> 77 end
> 78 end
>
>
> the problem im having is that i cant seem to find a way of setting the
> user agent before it goes into the method and checks the type of browser
> being used.
>
> im sure this is something trivial involving a mock but its just proving
> to be a bit illusive to me :(
>
> Cheers,
> Chris
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--
http://jeremymcanally.com/
http://entp.com
Read my books:
Ruby in Practice (http://manning.com/mcanally/)
My free Ruby e-book (http://humblelittlerubybook.com/)
Or, my blogs:
http://mrneighborly.com
http://rubyinpractice.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi Jeremy, thanks for the reply. How exactly do i build a testRequest? ive never come across such a thing? Chris -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You need to read up on Rails'' functional testing. Google has a lot of good resources! :) http://www.google.com/search?client=safari&rls=en-us&q=rails+functional+testing&ie=UTF-8&oe=UTF-8 --Jeremy On Thu, Jun 26, 2008 at 3:20 AM, Chris Gallagher <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi Jeremy, > > thanks for the reply. > > How exactly do i build a testRequest? ive never come across such a > thing? > > Chris > -- > Posted via http://www.ruby-forum.com/. > > > >-- http://jeremymcanally.com/ http://entp.com Read my books: Ruby in Practice (http://manning.com/mcanally/) My free Ruby e-book (http://humblelittlerubybook.com/) Or, my blogs: http://mrneighborly.com http://rubyinpractice.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---