[Catalyst] Setting flash for tests

David Schmidt davewood at gmx.at
Sat Feb 18 09:12:55 GMT 2012


Do you know about CatalystX::SimpleLogin it does exactly what you
described and probably is thoroughly tested.

as far as the testing is concerned i'd simply test the entire
procedure as it would take place in a real workflow.

1) GET /site_that_needs_login
2) check result is a redirect to loginform
3) POST /login with credentials
4) check result is redirect to /site_that_needs_login

You can also use
http://search.cpan.org/~mstrout/Catalyst-Runtime-5.90010/lib/Catalyst/Test.pm#%28$res,_$c%29_=_ctx_request%28_..._%29;
in order to access the context object and check $c->flash->{next}

On 17 February 2012 16:23, Robert Rothenberg <robrwo at gmail.com> wrote:
> The Login controller, on a successful login, will redirect to the location
> in $c->{flash}->{next}, if it is set. (Basically, if the user visits a page
> that requires a login, he is redirected to the login page, and then is
> redirected back to the original page.)
>
> As far as I can tell, it works alright.
>
> I am unsure how to test this using Catalyst::Test, though.
>
> How can I set the "next" variable so as to test redirection?
>
> Thanks,
> Rob
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



More information about the Catalyst mailing list