diff options
author | Struan Donald <struan@exo.org.uk> | 2020-09-18 16:54:56 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2020-09-25 09:41:37 +0100 |
commit | 6aece0d14bf772aff62152e2572326be964bf161 (patch) | |
tree | 066625ae34deb7fa8d9766b14e11a40e2df593f4 /t/app/controller | |
parent | 9152db674f3367e81eac8194c2b25aea91e4db61 (diff) |
fix using multiple disable messages on category questions
Provide a stopper per disable message, rather than per question.
Previously there was one stopper per dropdown so only the last message
encountered was used.
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/report_new_open311.t | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index 08435fb2b..7cd6dca09 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -394,6 +394,14 @@ subtest "Category extras includes form disabling string" => sub { $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->push_extra_fields({ datatype_description => 'Please ring different numbers', description => 'What sort of dangerous?', code => 'danger_type', + variable => 'true', order => '0', values => [ + { name => 'slightly', key => 'slightly', disable => 1, disable_message => 'Ring the slightly number' }, + { name => 'very', key => 'very', disable => 1, disable_message => 'Ring the very number' }, + { name => 'extremely', key => 'extremely', disable => 1, disable_message => 'Ring the very number' }, + { name => 'No', key => 'no' } + ] + }); $contact4->update; for ( { url => '/report/new/ajax?' }, @@ -401,6 +409,7 @@ subtest "Category extras includes form disabling string" => sub { ) { 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}; + $output->{questions} = [ sort { $a->{message} cmp $b->{message} } @{ $output->{questions} } ]; is_deeply $output, { all => 'Please ring us!', questions => [ @@ -409,6 +418,16 @@ subtest "Category extras includes form disabling string" => sub { code => 'dangerous', answers => [ 'yes' ], }, + { + message => 'Ring the slightly number', + code => 'danger_type', + answers => [ 'slightly' ], + }, + { + message => 'Ring the very number', + code => 'danger_type', + answers => [ 'very', 'extremely' ], + }, ], }; } |