aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/admin.t4
-rw-r--r--t/app/controller/report_new.t41
-rw-r--r--t/app/model/alert_type.t4
3 files changed, 35 insertions, 14 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t
index beeb6c9c1..d8a1c24a1 100644
--- a/t/app/controller/admin.t
+++ b/t/app/controller/admin.t
@@ -79,6 +79,8 @@ my $alert = FixMyStreet::App->model('DB::Alert')->find_or_create(
subtest 'check summary counts' => sub {
my $problems = FixMyStreet::App->model('DB::Problem')->search( { state => { -in => [qw/confirmed fixed closed investigating planned/, 'in progress', 'fixed - user', 'fixed - council'] } } );
+ ok $mech->host('www.fixmystreet.com');
+
my $problem_count = $problems->count;
$problems->update( { cobrand => '' } );
@@ -947,7 +949,7 @@ subtest 'hiding comment marked as fixed reopens report' => sub {
$update->mark_fixed( 1 );
$update->update;
- $report->state('fixed');
+ $report->state('fixed - user');
$report->update;
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 15237e041..076813868 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -80,7 +80,7 @@ foreach my $test (
],
},
{
- msg => 'may_show_name defaults to true',
+ msg => 'may_show_name is remembered',
pc => 'SW1A 1AA',
fields => {
title => '',
@@ -95,7 +95,7 @@ foreach my $test (
password_register => '',
remember_me => undef,
},
- changes => { may_show_name => '1' },
+ changes => {},
errors => [
'Please enter a subject',
'Please enter some details',
@@ -313,15 +313,24 @@ foreach my $test (
};
}
+my $first_user;
foreach my $test (
{
- desc => 'does not have an account',
- user => 0,
+ desc => 'does not have an account, does not set a password',
+ user => 0, password => 0,
},
{
- desc => 'does have an account and is not signed in; does not sign in',
- user => 1,
- }
+ desc => 'does not have an account, sets a password',
+ user => 0, password => 1,
+ },
+ {
+ desc => 'does have an account and is not signed in; does not sign in, does not set a password',
+ user => 1, password => 0,
+ },
+ {
+ desc => 'does have an account and is not signed in; does not sign in, sets a password',
+ user => 1, password => 1,
+ },
) {
subtest "test report creation for a user who " . $test->{desc} => sub {
$mech->log_out_ok;
@@ -336,9 +345,13 @@ foreach my $test (
$user->name( 'Old Name' );
$user->password( 'old_password' );
$user->update;
- } else {
+ } elsif (!$first_user) {
ok !FixMyStreet::App->model('DB::User')->find( { email => $test_email } ),
"test user does not exist";
+ $first_user = 1;
+ } else {
+ # Not first pass, so will exist, but want no user to start, so delete it.
+ $mech->delete_user($test_email);
}
# submit initial pc form
@@ -362,7 +375,7 @@ foreach my $test (
email => 'test-1@example.com',
phone => '07903 123 456',
category => 'Street lighting',
- password_register => 'secret',
+ password_register => $test->{password} ? 'secret' : '',
}
},
"submit good details"
@@ -410,7 +423,13 @@ foreach my $test (
$mech->get_ok( '/report/' . $report->id );
is $report->name, 'Joe Bloggs', 'name updated correctly';
- ok $report->user->check_password('secret'), 'password updated correctly';
+ if ($test->{password}) {
+ ok $report->user->check_password('secret'), 'password updated correctly';
+ } elsif ($test->{user}) {
+ ok $report->user->check_password('old_password'), 'password unchanged, as no new one given';
+ } else {
+ is $report->user->password, '', 'password still not set, as none given';
+ }
# check that the reporter has an alert
my $alert = FixMyStreet::App->model('DB::Alert')->find( {
@@ -425,7 +444,7 @@ foreach my $test (
# cleanup
$mech->delete_user($user)
- if $test->{user};
+ if $test->{user} && $test->{password};
};
}
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index 6767d43fc..ab129b4e7 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -174,11 +174,11 @@ for my $test (
},
{
postcode => 'Buckingham Gate',
- expected_postcode => 'Buckingham Gate',
+ expected_postcode => 'Buckingham\s+Gate',
},
{
postcode => 'Buckingham gate',
- expected_postcode => 'Buckingham gate',
+ expected_postcode => 'Buckingham\s+gate',
},
) {
subtest "correct text for postcode $test->{postcode}" => sub {