diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-06-10 14:56:00 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-06-10 14:56:00 +0100 |
commit | 391ca1c469d93bb2c4798cc15e56fc495b5e80dd (patch) | |
tree | 6bc90fae589de824095e668fbf510ef259935729 /t/app/controller/index.t | |
parent | 7c96f8ec61d6eddc211f3f0e71cdb276c6a5f773 (diff) | |
parent | 860383f0de3287b0666d64a3ffff3db3a0f087ae (diff) |
Merge branch 'migrate_to_catalyst' into reportemptyhomes
Diffstat (limited to 't/app/controller/index.t')
-rw-r--r-- | t/app/controller/index.t | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/t/app/controller/index.t b/t/app/controller/index.t new file mode 100644 index 000000000..cebeaf676 --- /dev/null +++ b/t/app/controller/index.t @@ -0,0 +1,58 @@ +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('/'); + is $mech->uri->path, '/', "still on '/'"; + + # submit form + $mech->submit_form_ok( { with_fields => { pc => 'SW1A 1AA', } } ); + + # check that we are at /around + is $mech->uri->path, '/around', "Got to /around"; + is_deeply { $mech->uri->query_form }, { pc => 'SW1A 1AA' }, + "query passed along"; +}; + +subtest "does pc, (x,y), (e,n) or (lat,lon) go to /around" => sub { + + foreach my $test ( # + { + in => { pc => 'SW1A 1AA' }, + out => { pc => 'SW1A 1AA' }, + }, + { + in => { lat => 51.50100, lon => -0.14158 }, + out => { lat => 51.50100, lon => -0.14158 }, + }, + { + in => { x => 3281, y => 1113, }, + out => { lat => 51.4998246332569, lon => -0.140137309739907 }, + }, + { + in => { e => 1234, n => 4567 }, + out => { lat => 49.808509, lon => -7.544784 }, + }, + ) + { + + my $uri = URI->new('http://localhost/'); + $uri->query_form( $test->{in} ); + + # get the uri and check for 302 + $mech->get_ok($uri); + + # check that we are at /around + is $mech->uri->path, '/around', "Got to /around"; + is_deeply { $mech->uri->query_form }, $test->{out}, "query correct"; + } +}; + +done_testing(); |