Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Setting flash for tests

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


robrwo at gmail

Feb 17, 2012, 7:23 AM

Post #1 of 2 (153 views)
Permalink
Setting flash for tests

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
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


davewood at gmx

Feb 18, 2012, 1:12 AM

Post #2 of 2 (141 views)
Permalink
Re: Setting flash for tests [In reply to]

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> 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
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.