diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-07-19 16:01:52 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-07-19 16:08:09 +0100 |
commit | 8dc2821130092d16ee96d703165bd3c505aa867f (patch) | |
tree | 753851503e28373607e48c7bc7304ee362308a82 | |
parent | a555312994060ba682634de58acf934005dfde84 (diff) |
Treat Other more like a normal category.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 12 | ||||
-rw-r--r-- | t/app/controller/dashboard.t | 4 |
2 files changed, 7 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 9933c4409..670ca3d50 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -620,7 +620,7 @@ sub setup_categories_and_councils : Private { $area_ids_to_list{ $first_council->{id} } = 1; my @local_categories; if ($first_council->{id} == COUNCIL_ID_BARNET) { - @local_categories = sort(keys %{ Utils::barnet_categories() }); # removed 'Other' option + @local_categories = sort keys %{ Utils::barnet_categories() } } else { @local_categories = sort keys %{ Utils::london_categories() } } @@ -640,8 +640,6 @@ sub setup_categories_and_councils : Private { $area_ids_to_list{ $contact->area_id } = 1; - next if $contact->category eq _('Other'); - unless ( $seen{$contact->category} ) { push @category_options, $contact->category; @@ -652,9 +650,9 @@ sub setup_categories_and_councils : Private { } if (@category_options) { - @category_options = ( _('-- Pick a category --'), @category_options ); - push @category_options, _('Other') - unless $first_council->{id} == COUNCIL_ID_BROMLEY; + # If there's an Other category present, put it at the bottom + @category_options = ( _('-- Pick a category --'), grep { $_ ne _('Other') } @category_options ); + push @category_options, _('Other') if $seen{_('Other')}; $category_label = _('Category'); } } @@ -816,7 +814,7 @@ sub process_report : Private { } elsif ( $first_council->{id} == COUNCIL_ID_BARNET ) { - unless ( exists Utils::barnet_categories()->{ $report->category } or $report->category eq 'Other') { + unless ( exists Utils::barnet_categories()->{ $report->category } ) { $c->stash->{field_errors}->{category} = _('Please choose a category'); } $report->council( $first_council->{id} ); diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index c3b6c014a..47d10ff5c 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -49,7 +49,7 @@ FixMyStreet::App->model('DB::Contact')->search( { area_id => $test_council } ) delete_problems(); -my @cats = qw( Grafitti Litter Potholes ); +my @cats = qw( Grafitti Litter Potholes Other ); for my $contact ( @cats ) { FixMyStreet::App->model('DB::Contact')->create( { @@ -90,7 +90,7 @@ my $categories = scraper { }, }; -my $expected_cats = [ 'All', '-- Pick a category --', @cats, 'Other' ]; +my $expected_cats = [ 'All', '-- Pick a category --', @cats ]; my $res = $categories->scrape( $mech->content ); is_deeply( $res->{cats}, $expected_cats, 'correct list of categories' ); |