diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Photo.pm | 2 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Questionnaire.pm | 9 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/Original.pm | 5 | ||||
-rw-r--r-- | t/app/controller/questionnaire.t | 9 | ||||
-rw-r--r-- | t/map/tilma/original.t | 105 |
6 files changed, 123 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index 17862aa0a..b4fa3a457 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -48,7 +48,7 @@ sub index :Path :Args(0) { $c->detach( 'no_photo' ) if $id =~ /\D/; @photo = $c->cobrand->problems->search( { id => $id, - state => [ 'confirmed', 'fixed', 'partial' ], + state => [ FixMyStreet::DB::Result::Problem->visible_states(), 'partial' ], photo => { '!=', undef }, } ); } diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index 19d057958..27c413259 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -48,7 +48,7 @@ sub load_questionnaire : Private { $c->detach; } - unless ( $questionnaire->problem->state eq 'confirmed' || $questionnaire->problem->state eq 'fixed' ) { + unless ( $questionnaire->problem->is_visible ) { $c->detach('missing_problem'); } @@ -129,7 +129,7 @@ sub submit_creator_fixed : Private { { problem_id => $c->stash->{problem}, old_state => 'confirmed', - new_state => 'fixed', + new_state => 'fixed - user', } ); @@ -156,8 +156,9 @@ sub submit_standard : Private { my $problem = $c->stash->{problem}; my $old_state = $problem->state; my $new_state = ''; - $new_state = 'fixed' if $c->stash->{been_fixed} eq 'Yes' && $old_state eq 'confirmed'; - $new_state = 'confirmed' if $c->stash->{been_fixed} eq 'No' && $old_state eq 'fixed'; + $new_state = 'fixed - user' if $c->stash->{been_fixed} eq 'Yes' && $old_state eq 'confirmed'; + $new_state = 'confirmed' if $c->stash->{been_fixed} eq 'No' && + exists FixMyStreet::DB::Result::Problem->fixed_states()->{$old_state}; # Record state change, if there was one if ( $new_state ) { diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 58b689bf9..2f895015b 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -354,7 +354,8 @@ sub add_row { ? 'unknown' : ($problem->{age} > $fourweeks ? 'older' : 'new'); # Fixed problems are either old or new - push @{$fixed->{$council}{$duration_str}}, $problem if $problem->{state} eq 'fixed'; + push @{$fixed->{$council}{$duration_str}}, $problem if + exists FixMyStreet::DB::Result::Problem->fixed_states()->{$problem->{state}}; # Open problems are either unknown, older, or new push @{$open->{$council}{$type}}, $problem if $problem->{state} eq 'confirmed'; } diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm index 6fa854cb2..8fd835265 100644 --- a/perllib/FixMyStreet/Map/Tilma/Original.pm +++ b/perllib/FixMyStreet/Map/Tilma/Original.pm @@ -102,6 +102,7 @@ sub map_pins { my $n = tile_to_os($y); my ( $lat, $lon ) = Utils::convert_en_to_latlon( $e, $n ); + my ( $around_map, $around_map_list, $nearby, $dist ) = FixMyStreet::Map::map_features( $c, $lat, $lon, $interval ); @@ -111,7 +112,7 @@ sub map_pins { _ll_to_en( $_->latitude, $_->longitude ); my $px = os_to_px($easting, $sx); my $py = os_to_px($northing, $sy, 1); - my $col = $_->state eq 'fixed' ? 'green' : 'red'; + my $col = exists FixMyStreet::DB::Result::Problem->fixed_states()->{$_->state} ? 'green' : 'red'; $pins .= display_pin($c, $px, $py, $col, $_->id, $_->title); } @@ -121,7 +122,7 @@ sub map_pins { _ll_to_en( $p->latitude, $p->longitude ); my $px = os_to_px($easting, $sx); my $py = os_to_px($northing, $sy, 1); - my $col = $p->state eq 'fixed' ? 'green' : 'red'; + my $col = exists FixMyStreet::DB::Result::Problem->fixed_states()->{$p->state} ? 'green' : 'red'; $pins .= display_pin($c, $px, $py, $col, $p->id, $p->title); } diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t index e56734bfc..af99a058e 100644 --- a/t/app/controller/questionnaire.t +++ b/t/app/controller/questionnaire.t @@ -204,7 +204,12 @@ foreach my $test ( } my $result; - $result = 'fixed' if $test->{fields}{been_fixed} eq 'Yes'; + $result = 'fixed - user' + if $test->{fields}{been_fixed} eq 'Yes' + && $test->{problem_state} ne 'fixed'; + $result = 'fixed' + if $test->{fields}{been_fixed} eq 'Yes' + && $test->{problem_state} eq 'fixed'; $result = 'confirmed' if $test->{fields}{been_fixed} eq 'No'; $result = 'unknown' if $test->{fields}{been_fixed} eq 'Unknown'; @@ -214,7 +219,7 @@ foreach my $test ( # Check the right HTML page has been returned $mech->content_like( qr/<title>[^<]*Questionnaire/m ); $mech->content_contains( 'glad to hear it’s been fixed' ) - if $result eq 'fixed'; + if $result =~ /fixed/; $mech->content_contains( 'get some more information about the status of your problem' ) if $result eq 'unknown'; $mech->content_contains( "sorry to hear that" ) diff --git a/t/map/tilma/original.t b/t/map/tilma/original.t new file mode 100644 index 000000000..bfc8c4327 --- /dev/null +++ b/t/map/tilma/original.t @@ -0,0 +1,105 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; +use FixMyStreet::App; +use FixMyStreet::Map; +use FixMyStreet::TestMech; +use DateTime; + +my $mech = FixMyStreet::TestMech->new; + +FixMyStreet::Map::set_map_class(); +my $r = Catalyst::Request->new( { base => URI->new('/'), uri => URI->new('http://fixmystreet.com/test') } ); + +my $c = FixMyStreet::App->new( { + request => $r, +}); + +$mech->delete_user('test@example.com'); +my $user = + FixMyStreet::App->model('DB::User') + ->find_or_create( { email => 'test@example.com', name => 'Test User' } ); +ok $user, "created test user"; + +my $dt = DateTime->now(); + + +my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( + { + postcode => 'SW1A 1AA', + council => '2504', + areas => ',105255,11806,11828,2247,2504,', + category => 'Other', + title => 'Test 2', + detail => 'Test 2 Detail', + used_map => 't', + name => 'Test User', + anonymous => 'f', + state => 'fixed', + confirmed => $dt->ymd . ' ' . $dt->hms, + lang => 'en-gb', + service => '', + cobrand => 'default', + cobrand_data => '', + send_questionnaire => 't', + latitude => '49.7668057243776', + longitude => '-7.55715980363992', + user_id => $user->id, + } +); + +for my $test ( + { + state => 'fixed', + colour => 'G', + }, + { + state => 'fixed - user', + colour => 'G', + }, + { + state => 'fixed - council', + colour => 'G', + }, + { + state => 'confirmed', + colour => 'R', + }, + { + state => 'investigating', + colour => 'R', + }, + { + state => 'planned', + colour => 'R', + }, + { + state => 'in progress', + colour => 'R', + }, +) { + subtest "pin colour for state $test->{state}" => sub { + $report->state($test->{state}); + $report->update; + + my ( $pins, $around_map_list, $nearby, $dist ) = + FixMyStreet::Map::map_pins( $c, 0, 0, 0, 0 ); + + ok $pins; + ok $around_map_list; + ok $nearby; + ok $dist; + + my $id = $report->id; + my $colour = $test->{colour}; + + like $pins, qr#<a [^>]* /report/$id [^>]*>[^>]*/i/pin$colour#x, 'pin colour'; + }; +} + +$mech->delete_user( $user ); + + +done_testing(); |