diff options
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/admin/reportextrafields.t | 7 | ||||
-rw-r--r-- | t/app/controller/report_new_open311.t | 26 |
2 files changed, 33 insertions, 0 deletions
diff --git a/t/app/controller/admin/reportextrafields.t b/t/app/controller/admin/reportextrafields.t index 6011b13e3..070e3e2fc 100644 --- a/t/app/controller/admin/reportextrafields.t +++ b/t/app/controller/admin/reportextrafields.t @@ -82,6 +82,7 @@ FixMyStreet::override_config { description => "this is a test description", datatype_description => "hint here", datatype => "string", + disable_form => "false", }; $contact->discard_changes; is_deeply $contact->get_extra_fields, $contact_extra_fields, 'new string field was added'; @@ -93,6 +94,7 @@ FixMyStreet::override_config { "metadata[1].code" => "list_test", "metadata[1].required" => undef, "metadata[1].notice" => "", + "metadata[1].disable_form" => "on", "metadata[1].description" => "this field is a list", "metadata[1].datatype_description" => "", "metadata[1].datatype" => "list", @@ -108,6 +110,7 @@ FixMyStreet::override_config { required => "false", variable => "true", protected => "false", + disable_form => "true", description => "this field is a list", datatype_description => "", datatype => "singlevaluelist", @@ -145,6 +148,7 @@ FixMyStreet::override_config { required => 'false', variable => 'true', protected => 'false', + disable_form => 'false', code => 'POT', automated => 'server_set' } ], "automated fields not unset"; @@ -181,6 +185,7 @@ FixMyStreet::override_config { required => "true", variable => "true", protected => "false", + disable_form => "false", description => "this is a test description", datatype_description => "hint here", datatype => "string", @@ -209,6 +214,7 @@ FixMyStreet::override_config { required => "false", variable => "true", protected => "false", + disable_form => "false", description => "this field is a list", datatype_description => "", datatype => "singlevaluelist", @@ -239,6 +245,7 @@ FixMyStreet::override_config { required => "false", variable => "true", protected => "false", + disable_form => "false", description => "", datatype_description => "", datatype => "string", diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index 3b733622b..b52e0af18 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -287,4 +287,30 @@ subtest "Category extras includes description label for user" => sub { }; }; +subtest "Category extras includes form disabling string" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => 'fixmystreet', + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $contact4->push_extra_fields({ description => 'Please ring us!', code => 'ring', variable => 'false', order => '0', disable_form => 'true' }); + $contact4->push_extra_fields({ datatype_description => 'Please please ring', description => 'Is it dangerous?', code => 'dangerous', + variable => 'true', order => '0', values => [ { name => 'Yes', key => 'yes', disable => 1 }, { name => 'No', key => 'no' } ] + }); + $contact4->update; + 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 $output = $json->{by_category} ? $json->{by_category}{Pothole}{disable_form} : $json->{disable_form}; + is_deeply $output, { + all => 'Please ring us!', + message => 'Please please ring', + code => 'dangerous', + answers => [ 'yes' ], + }; + } + }; +}; + done_testing(); |