aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/index.t
blob: 1d0bff33c41c48055b75c7a554ff4c595efb6b73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use strict;
use warnings;
use Test::More;

use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;

# check that the homepage loads
$mech->get_ok('/');

subtest "check that the form goes to /around" => sub {
    $mech->get_ok('/');

    # submit form
    $mech->submit_form_ok( { with_fields => { pc => 'SW1A 1AA', } } );

    # check that we are at /around
    is $mech->res->uri->path, '/around', "Got to /around";
    is $mech->res->uri->query_form, { pc => 'SW1A 1AA' }, "query passed along";
};

subtest "check that requests with pc, x,y or lat,lon go to /around" => sub {
    foreach my $test (
        { pc  => 'SW1A 1AA', },
        { x   => 3281, y => 1113, },
        { lat => 51.50100, lon => -0.14158, },
      )
    {
        my $uri = URI->new('http://localhost/');
        $uri->query_form($test);
        $mech->get_ok($uri);

        # check that we are at /around
        is $mech->res->uri->path, '/around', "Got to /around";
        is $mech->res->uri->query_form, $test, "query passed along";
    }
};

done_testing();