Subject: | _cookie and _flash methods create a new request, which isn't necessary |
I don't understand why the _cookie and _flash methods build an entire new app and controller? These result in unnecessary duplicate calls in testing and lead to warnings in earlier versions of Mojolicious. Surely the information is already available in the test object, for example the _cookie method could be replaced with the following:
sub _cookie {
my ( $self,$name ) = @_;
foreach my $cookie ( $self->ua->cookie_jar->all ) {
return $cookie if $cookie->name eq $name;
}
return;
}
Probably something similar for the _flash and _session. Have a look at Test::Mojo::Session, which has similar functionality.
Thanks,
Lee.