(premise: I''m sending this through the gmane nntp gateway, I think this should be ok, but if this is considered bad please excuse me, I''ll avoid it next time) I was trying to write some functional tests for a controller which does some basic authentication, and I''m trying to check that it behaves correctly wrt to existing cookies and variables passed from a previous controller via #flash. The problem is that it seem I can''t assign to the cookies hash nor the flash one before I do a request with get/post. Is there some way to do this or am I just approaching the problem from a wrong angle? Thanks in advance
Jeremy Kemper
2005-Nov-07 00:39 UTC
Re: Assigning to cookies and flash in functional tests
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Nov 6, 2005, at 7:59 AM, gabriele renzi wrote:> I was trying to write some functional tests for a controller which > does some basic authentication, and I''m trying to check that it > behaves correctly wrt to existing cookies and variables passed from > a previous controller via #flash. > The problem is that it seem I can''t assign to the cookies hash nor > the flash one before I do a request with get/post. > > Is there some way to do this or am I just approaching the problem > from a wrong angle?@request.cookies = { ''mycookie'' => ''foo'' } get :some_action, { ''queryparam'' => ''bar'' }, { ''sessionvar'' => ''baz'' }, { ''flashvar'' => ''quux'' } get, post, and friends take four arguments: action name, query parameter hash, session variable hash, and flash variable hash. The @request.cookies bit is obtuse; that hash should be added to the process methods as well. jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDbqI+AQHALep9HFYRAlJnAKCW1KCexxZ4D/n2eKSEpBtmlo/XKACg2kmY 9pMWm0bNEwaZ1bL9UaxdMIM=KeKs -----END PGP SIGNATURE-----
gabriele renzi
2005-Nov-07 09:43 UTC
Re: Assigning to cookies and flash in functional tests
Jeremy Kemper ha scritto:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Nov 6, 2005, at 7:59 AM, gabriele renzi wrote: > >> I was trying to write some functional tests for a controller which >> does some basic authentication, and I''m trying to check that it >> behaves correctly wrt to existing cookies and variables passed from a >> previous controller via #flash. >> The problem is that it seem I can''t assign to the cookies hash nor >> the flash one before I do a request with get/post. >> >> Is there some way to do this or am I just approaching the problem >> from a wrong angle? > > > > @request.cookies = { ''mycookie'' => ''foo'' } > > get :some_action, { ''queryparam'' => ''bar'' }, { ''sessionvar'' => ''baz'' > }, { ''flashvar'' => ''quux'' } > > get, post, and friends take four arguments: action name, query > parameter hash, session variable hash, and flash variable hash. > > The @request.cookies bit is obtuse; that hash should be added to the > process methods as well. > > jeremyah, thanks a lot for this