http://mojolicious.org/perldoc/Test/Mojo#get_ok
> Perform a GET request and check for transport errors,
> takes the same arguments as "get" in Mojo::UserAgent, except for the callback.

So, this should work

->get_ok( "https://somecourse.test/instructor/filesetdue"; => { Referer
=> "/instructor/filecenter" } )

On 7 January 2018 at 09:38,  <[email protected]> wrote:
> Hello all,
>
> I'm using Test::Mojo to test a course website.
> Suppose I'm on the page https://somecourse.test/instructor/filecenter, which
> displays files and includes buttons to set due for a file (linked to
> /instructor/filesetdue)
> InstructorFilesetdue.pm looks like this:
>
> get '/instructor/filesetdue' => sub {
>
>   my $c = shift;
>
>   ...   # change the due
>
>   $c->redirect_to($c->req->headers->referrer);   # this should redirect me
> back to the /instructor/filecenter
>
> };
>
> So in real operation, after I click the button and change the due, I should
> come back to /instructor/filecenter.
> But for the test object $t, when I write:
>     $t->get_ok("https://somecourse.test/instructor/filecenter";)
>        ->get_ok("https://somecourse.test/instructor/filesetdue";)
>        ->content_like(qr/file center, not filesetdue or login/)
> I can change the due but $t ends up at the login page of my course website
> (As I found out, when executing $c->redirect_to($c->req->headers->referrer),
> $c->req->headers->referrer is actually uninitialized, so redirect_to() will
> direct me to "/", which then prompts to /login page).
>
> My question is, how can I tell the test object it comes from
> /instructor/filecenter and that should be the referrer?
>
> Thanks!
>
> Ni
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.



-- 
//wbr, Dmitry L.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to