I want to test a page with a form that, when submitted, is redirected to the resulting page for the submitted element.
My Mojolicious controller contains:
sub submit_new { my $self = shift; my $new = $self->db->resultset('Item')->new( { title => $self->param('title'), description => $self->param('description'), } ); $new->insert;
The script test for this controller contains:
use Test::More; use Test::Mojo; my $t = Test::Mojo->new('MyApp'); my $tx = $t->ua->build_form_tx('/items/new/submit' => $data); $tx->req->method('POST'); $t->tx( $t->ua->start($tx) ) ->status_is(302);
My problem is that it stops with status 302 . How do I go to redirects to check the resulting page?
source share