diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/contact.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 7 | ||||
-rw-r--r-- | t/app/controller/report_new_open311.t | 41 |
3 files changed, 29 insertions, 21 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index cb299d161..2cbdbc0da 100644 --- a/t/app/controller/contact.t +++ b/t/app/controller/contact.t @@ -305,7 +305,7 @@ for my $test ( my $email = $mech->get_email; - is $email->header('Subject'), 'FMS message: ' . $test->{fields}->{subject}, 'subject'; + is $email->header('Subject'), 'FixMyStreet message: ' . $test->{fields}->{subject}, 'subject'; is $email->header('From'), "\"$test->{fields}->{name}\" <$test->{fields}->{em}>", 'from'; my $body = $mech->get_text_body_from_email($email); like $body, qr/$test->{fields}->{message}/, 'body'; diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 048f2644e..94c7b1231 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -1669,10 +1669,9 @@ subtest "unresponsive body handling works" => sub { # Test body-level send method my $old_send = $contact1->body->send_method; $contact1->body->update( { send_method => 'Refused' } ); - $mech->get_ok('/report/new/ajax?latitude=55.952055&longitude=-3.189579'); # Edinburgh my $body_id = $contact1->body->id; - ok $mech->content_like( qr{Edinburgh.*accept reports.*/unresponsive\?body=$body_id} ); my $extra_details = $mech->get_ok_json('/report/new/ajax?latitude=55.952055&longitude=-3.189579'); + like $extra_details->{top_message}, qr{Edinburgh.*accept reports.*/unresponsive\?body=$body_id}; is $extra_details->{unresponsive}, $body_id, "unresponsive json set"; $extra_details = $mech->get_ok_json('/report/new/category_extras?category=Street%20lighting&latitude=55.952055&longitude=-3.189579'); is $extra_details->{unresponsive}, $body_id, "unresponsive json set"; @@ -1749,8 +1748,8 @@ subtest "unresponsive body handling works" => sub { # And test per-category refusing my $old_email = $contact3->email; $contact3->update( { email => 'REFUSED' } ); - $mech->get_ok('/report/new/category_extras?category=Trees&latitude=51.896268&longitude=-2.093063'); - ok $mech->content_like( qr/Cheltenham.*Trees.*unresponsive.*category=Trees/ ); + $extra_details = $mech->get_ok_json('/report/new/ajax?latitude=51.896268&longitude=-2.093063'); + like $extra_details->{by_category}{$contact3->category}{category_extra}, qr/Cheltenham.*Trees.*unresponsive.*category=Trees/s; $extra_details = $mech->get_ok_json('/report/new/category_extras?category=Trees&latitude=51.896268&longitude=-2.093063'); is $extra_details->{unresponsive}, $contact3->body->id, "unresponsive json set"; diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index 17b489447..7d4f5429f 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -249,13 +249,18 @@ subtest "Category extras omits description label when all fields are hidden" => ALLOWED_COBRANDS => [ { fixmystreet => '.' } ], MAPIT_URL => 'http://mapit.uk/', }, sub { - my $json = $mech->get_ok_json('/report/new/category_extras?category=Pothole&latitude=55.952055&longitude=-3.189579'); - my $category_extra = $json->{category_extra}; - contains_string($category_extra, "usrn"); - contains_string($category_extra, "central_asset_id"); - lacks_string($category_extra, "USRN", "Lacks 'USRN' label"); - lacks_string($category_extra, "Asset ID", "Lacks 'Asset ID' label"); - lacks_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Lacks description text"); + for ( + { url => '/report/new/ajax?' }, + { url => '/report/new/category_extras?category=Pothole' }, + ) { + my $json = $mech->get_ok_json($_->{url} . '&latitude=55.952055&longitude=-3.189579'); + my $category_extra = $json->{by_category} ? $json->{by_category}{Pothole}{category_extra} : $json->{category_extra}; + contains_string($category_extra, "usrn"); + contains_string($category_extra, "central_asset_id"); + lacks_string($category_extra, "USRN", "Lacks 'USRN' label"); + lacks_string($category_extra, "Asset ID", "Lacks 'Asset ID' label"); + lacks_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Lacks description text"); + } }; }; @@ -266,15 +271,19 @@ subtest "Category extras includes description label for user" => sub { }, sub { $contact4->push_extra_fields({ description => 'Size?', code => 'size', required => 'true', automated => '', variable => 'true', order => '3' }); $contact4->update; - - my $json = $mech->get_ok_json('/report/new/category_extras?category=Pothole&latitude=55.952055&longitude=-3.189579'); - my $category_extra = $json->{category_extra}; - contains_string($category_extra, "usrn"); - contains_string($category_extra, "central_asset_id"); - lacks_string($category_extra, "USRN", "Lacks 'USRN' label"); - lacks_string($category_extra, "Asset ID", "Lacks 'Asset ID' label"); - contains_string($category_extra, "Size?"); - contains_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Contains description text"); + for ( + { url => '/report/new/ajax?' }, + { url => '/report/new/category_extras?category=Pothole' }, + ) { + my $json = $mech->get_ok_json($_->{url} . '&latitude=55.952055&longitude=-3.189579'); + my $category_extra = $json->{by_category} ? $json->{by_category}{Pothole}{category_extra} : $json->{category_extra}; + contains_string($category_extra, "usrn"); + contains_string($category_extra, "central_asset_id"); + lacks_string($category_extra, "USRN", "Lacks 'USRN' label"); + lacks_string($category_extra, "Asset ID", "Lacks 'Asset ID' label"); + contains_string($category_extra, "Size?"); + contains_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Contains description text"); + } }; }; |