aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/app/controller/questionnaire.t9
-rw-r--r--t/app/controller/report_display.t24
-rw-r--r--t/app/model/problem.t140
-rw-r--r--t/app/model/questionnaire.t106
-rw-r--r--t/map/tilma/original.t108
5 files changed, 385 insertions, 2 deletions
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&rsquo;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/app/controller/report_display.t b/t/app/controller/report_display.t
index 1f857a387..5c66200c8 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -235,6 +235,30 @@ for my $test (
banner_text => 'This problem has been fixed.',
fixed => 1
},
+ {
+ description => 'user fixed report',
+ date => DateTime->now,
+ state => 'fixed - user',
+ banner_id => 'fixed',
+ banner_text => 'This problem has been fixed.',
+ fixed => 1
+ },
+ {
+ description => 'council fixed report',
+ date => DateTime->now,
+ state => 'fixed - council',
+ banner_id => 'fixed',
+ banner_text => 'This problem has been fixed.',
+ fixed => 1
+ },
+ {
+ description => 'closed report',
+ date => DateTime->now,
+ state => 'closed',
+ banner_id => '',
+ banner_text => '',
+ fixed => 0
+ },
) {
subtest "banner for $test->{description}" => sub {
$report->confirmed( $test->{date}->ymd . ' ' . $test->{date}->hms );
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index 1b8804fce..e7c9d79bb 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -152,4 +152,144 @@ for my $test (
};
}
+for my $test (
+ {
+ state => 'unconfirmed',
+ is_open => 0,
+ },
+ {
+ state => 'confirmed',
+ is_open => 1,
+ },
+ {
+ state => 'investigating',
+ is_open => 1,
+ },
+ {
+ state => 'planned',
+ is_open => 1,
+ },
+ {
+ state => 'in progress',
+ is_open => 1,
+ },
+ {
+ state => 'fixed',
+ is_open => 0,
+ },
+ {
+ state => 'fixed - council',
+ is_open => 0,
+ },
+ {
+ state => 'fixed - user',
+ is_open => 0,
+ },
+ {
+ state => 'closed',
+ is_open => 0,
+ },
+) {
+ subtest $test->{state} . ' is open/closed' => sub {
+ $problem->state( $test->{state} );
+ is $problem->is_open, $test->{is_open}, 'is_open';
+ };
+}
+
+for my $test (
+ {
+ state => 'unconfirmed',
+ is_fixed => 0,
+ },
+ {
+ state => 'confirmed',
+ is_fixed => 0,
+ },
+ {
+ state => 'investigating',
+ is_fixed => 0,
+ },
+ {
+ state => 'planned',
+ is_fixed => 0,
+ },
+ {
+ state => 'in progress',
+ is_fixed => 0,
+ },
+ {
+ state => 'fixed',
+ is_fixed => 1,
+ },
+ {
+ state => 'fixed - council',
+ is_fixed => 1,
+ },
+ {
+ state => 'fixed - user',
+ is_fixed => 1,
+ },
+ {
+ state => 'closed',
+ is_fixed => 0,
+ },
+) {
+ subtest $test->{state} . ' is fixed/open' => sub {
+ $problem->state( $test->{state} );
+ is $problem->is_fixed, $test->{is_fixed}, 'is_fixed';
+ };
+}
+
+for my $test (
+ {
+ state => 'partial',
+ is_visible => 0,
+ },
+ {
+ state => 'hidden',
+ is_visible => 0,
+ },
+ {
+ state => 'unconfirmed',
+ is_visible => 0,
+ },
+ {
+ state => 'confirmed',
+ is_visible => 1,
+ },
+ {
+ state => 'investigating',
+ is_visible => 1,
+ },
+ {
+ state => 'planned',
+ is_visible => 1,
+ },
+ {
+ state => 'in progress',
+ is_visible => 1,
+ },
+ {
+ state => 'fixed',
+ is_visible => 1,
+ },
+ {
+ state => 'fixed - council',
+ is_visible => 1,
+ },
+ {
+ state => 'fixed - user',
+ is_visible => 1,
+ },
+ {
+ state => 'closed',
+ is_visible => 1,
+ },
+) {
+ subtest $test->{state} . ' is fixed/open' => sub {
+ $problem->state( $test->{state} );
+ is $problem->is_visible, $test->{is_visible}, 'is_visible';
+ };
+}
+
done_testing();
diff --git a/t/app/model/questionnaire.t b/t/app/model/questionnaire.t
new file mode 100644
index 000000000..60b52043a
--- /dev/null
+++ b/t/app/model/questionnaire.t
@@ -0,0 +1,106 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use FixMyStreet;
+use FixMyStreet::TestMech;
+
+my $user = FixMyStreet::App->model('DB::User')->find_or_create( { email => 'test@example.com' } );
+
+my $problem = FixMyStreet::App->model('DB::Problem')->create(
+ {
+ postcode => 'EH99 1SP',
+ latitude => 1,
+ longitude => 1,
+ areas => 1,
+ title => 'to be sent',
+ detail => 'detail',
+ used_map => 1,
+ user_id => 1,
+ name => 'A Name',
+ state => 'confirmed',
+ service => '',
+ cobrand => 'default',
+ cobrand_data => '',
+ confirmed => \"ms_current_timestamp() - '5 weeks'::interval",
+ whensent => \"ms_current_timestamp() - '5 weeks'::interval",
+ user => $user,
+ anonymous => 0,
+ }
+);
+
+diag $problem->id;
+
+my $mech = FixMyStreet::TestMech->new;
+
+for my $test (
+ {
+ state => 'unconfirmed',
+ send_email => 0,
+ },
+ {
+ state => 'partial',
+ send_email => 0,
+ },
+ {
+ state => 'hidden',
+ send_email => 0,
+ },
+ {
+ state => 'confirmed',
+ send_email => 1,
+ },
+ {
+ state => 'investigating',
+ send_email => 1,
+ },
+ {
+ state => 'planned',
+ send_email => 1,
+ },
+ {
+ state => 'in progress',
+ send_email => 1,
+ },
+ {
+ state => 'fixed',
+ send_email => 1,
+ },
+ {
+ state => 'fixed - council',
+ send_email => 1,
+ },
+ {
+ state => 'fixed - user',
+ send_email => 1,
+ },
+ {
+ state => 'closed',
+ send_email => 1,
+ },
+) {
+ subtest "correct questionnaire behviour for state $test->{state}" => sub {
+ $problem->discard_changes;
+ $problem->state( $test->{state} );
+ $problem->send_questionnaire( 1 );
+ $problem->update;
+
+ $problem->questionnaires->delete;
+
+ $mech->email_count_is(0);
+
+ FixMyStreet::App->model('DB::Questionnaire')
+ ->send_questionnaires( { site => 'fixmystreet' } );
+
+ $mech->email_count_is( $test->{send_email} );
+
+ $mech->clear_emails_ok();
+ }
+}
+
+$mech->delete_user( $user );
+
+done_testing();
diff --git a/t/map/tilma/original.t b/t/map/tilma/original.t
new file mode 100644
index 000000000..b953a32b2
--- /dev/null
+++ b/t/map/tilma/original.t
@@ -0,0 +1,108 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+use FixMyStreet::App;
+use FixMyStreet::Map;
+use FixMyStreet::TestMech;
+use DateTime;
+use mySociety::Locale;
+
+my $mech = FixMyStreet::TestMech->new;
+
+mySociety::Locale::gettext_domain('FixMyStreet');
+
+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();